88namespace Magento \AdobeStockImage \Test \Unit \Model ;
99
1010use Magento \AdobeStockImage \Model \SaveImageFile ;
11- use Magento \AdobeStockImage \Model \Storage \Delete as StorageDelete ;
1211use Magento \AdobeStockImage \Model \Storage \Save as StorageSave ;
1312use Magento \Framework \Api \AttributeInterface ;
1413use 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