Skip to content

Commit 142c764

Browse files
committed
Correct unit tests
1 parent 71c6ed9 commit 142c764

File tree

2 files changed

+10
-34
lines changed

2 files changed

+10
-34
lines changed

AdobeStockImage/Model/Storage/Save.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct(
6464
* @throws FileSystemException
6565
* @throws LocalizedException
6666
*/
67-
public function execute(string $imageUrl, string $destinationPath, bool $allowOverwrite =false): void
67+
public function execute(string $imageUrl, string $destinationPath, bool $allowOverwrite = false): void
6868
{
6969
$mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
7070

AdobeStockImage/Test/Unit/Model/SaveImageFileTest.php

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace Magento\AdobeStockImage\Test\Unit\Model;
99

1010
use Magento\AdobeStockImage\Model\SaveImageFile;
11-
use Magento\AdobeStockImage\Model\Storage\Delete as StorageDelete;
1211
use Magento\AdobeStockImage\Model\Storage\Save as StorageSave;
1312
use Magento\Framework\Api\AttributeInterface;
1413
use Magento\Framework\Api\Search\Document;
@@ -27,11 +26,6 @@ class SaveImageFileTest extends TestCase
2726
*/
2827
private $storageSave;
2928

30-
/**
31-
* @var MockObject|StorageDelete
32-
*/
33-
private $storageDelete;
34-
3529
/**
3630
* @var SaveImageFile
3731
*/
@@ -43,13 +37,11 @@ class SaveImageFileTest extends TestCase
4337
protected function setUp(): void
4438
{
4539
$this->storageSave = $this->createMock(StorageSave::class);
46-
$this->storageDelete = $this->createMock(StorageDelete::class);
4740

4841
$this->saveImageFile = (new ObjectManager($this))->getObject(
4942
SaveImageFile::class,
5043
[
51-
'storageSave' => $this->storageSave,
52-
'storageDelete' => $this->storageDelete
44+
'storageSave' => $this->storageSave
5345
]
5446
);
5547
}
@@ -60,18 +52,12 @@ protected function setUp(): void
6052
* @param Document $document
6153
* @param string $url
6254
* @param string $destinationPath
63-
* @param bool $delete
6455
* @dataProvider assetProvider
6556
*/
66-
public function testExecute(Document $document, string $url, string $destinationPath, bool $delete): void
57+
public function testExecute(Document $document, string $url, string $destinationPath): void
6758
{
68-
if ($delete) {
69-
$this->storageDelete->expects($this->once())
70-
->method('execute');
71-
} else {
72-
$this->storageSave->expects($this->once())
73-
->method('execute');
74-
}
59+
$this->storageSave->expects($this->once())
60+
->method('execute');
7561

7662
$this->storageSave->expects($this->once())
7763
->method('execute')
@@ -86,24 +72,16 @@ public function testExecute(Document $document, string $url, string $destination
8672
* @param Document $document
8773
* @param string $url
8874
* @param string $destinationPath
89-
* @param bool $delete
9075
* @dataProvider assetProvider
9176
*/
9277
public function testExecuteWithException(
9378
Document $document,
9479
string $url,
95-
string $destinationPath,
96-
bool $delete
80+
string $destinationPath
9781
): void {
98-
if ($delete) {
99-
$this->storageDelete->expects($this->once())
100-
->method('execute')
101-
->willThrowException(new \Exception('Some Exception'));
102-
} else {
103-
$this->storageSave->expects($this->once())
104-
->method('execute')
105-
->willThrowException(new \Exception('Some Exception'));
106-
}
82+
$this->storageSave->expects($this->once())
83+
->method('execute')
84+
->willThrowException(new \Exception('Some Exception'));
10785

10886
$this->expectException(CouldNotSaveException::class);
10987

@@ -121,14 +99,12 @@ public function assetProvider(): array
12199
[
122100
'document' => $this->getDocument(),
123101
'url' => 'https://as2.ftcdn.net/jpg/500_FemVonDcttCeKiOXFk.jpg',
124-
'destinationPath' => 'path',
125-
'delete' => false
102+
'destinationPath' => 'path'
126103
],
127104
[
128105
'document' => $this->getDocument('filepath.jpg'),
129106
'url' => 'https://as2.ftcdn.net/jpg/500_FemVonDcttCeKiOXFk.jpg',
130107
'destinationPath' => 'path',
131-
'delete' => true
132108
],
133109
];
134110
}

0 commit comments

Comments
 (0)