@@ -247,6 +247,9 @@ public function testResizeFromThemesMediaStorageDatabase()
247
247
$ this ->databaseMock ->expects ($ this ->any ())
248
248
->method ('checkDbUsage ' )
249
249
->will ($ this ->returnValue (true ));
250
+ $ this ->databaseMock ->expects ($ this ->any ())
251
+ ->method ('fileExists ' )
252
+ ->will ($ this ->returnValue (false ));
250
253
251
254
$ this ->productImageMock ->expects ($ this ->any ())
252
255
->method ('getCountUsedProductImages ' )
@@ -287,6 +290,9 @@ public function testResizeFromImageNameMediaStorageDatabase()
287
290
$ this ->databaseMock ->expects ($ this ->any ())
288
291
->method ('checkDbUsage ' )
289
292
->will ($ this ->returnValue (true ));
293
+ $ this ->databaseMock ->expects ($ this ->any ())
294
+ ->method ('fileExists ' )
295
+ ->will ($ this ->returnValue (false ));
290
296
291
297
$ this ->mediaDirectoryMock ->expects ($ this ->any ())
292
298
->method ('isFile ' )
@@ -316,4 +322,65 @@ public function testResizeFromImageNameMediaStorageDatabase()
316
322
317
323
$ this ->service ->resizeFromImageName ($ this ->testfilename );
318
324
}
325
+
326
+ public function testSkipResizingAlreadyResizedImageOnDisk ()
327
+ {
328
+ $ this ->databaseMock ->expects ($ this ->any ())
329
+ ->method ('checkDbUsage ' )
330
+ ->will ($ this ->returnValue (false ));
331
+
332
+ $ this ->mediaDirectoryMock ->expects ($ this ->any ())
333
+ ->method ('isFile ' )
334
+ ->will ($ this ->returnValue (true ));
335
+
336
+ $ this ->themeCollectionMock ->expects ($ this ->any ())
337
+ ->method ('loadRegisteredThemes ' )
338
+ ->willReturn (
339
+ [ new DataObject (['id ' => '0 ' ]) ]
340
+ );
341
+ $ this ->themeCustomizationConfigMock ->expects ($ this ->any ())
342
+ ->method ('getStoresByThemes ' )
343
+ ->willReturn (
344
+ ['0 ' => []]
345
+ );
346
+
347
+ $ this ->imageFactoryMock ->expects ($ this ->never ())
348
+ ->method ('create ' );
349
+
350
+ $ this ->service ->resizeFromImageName ($ this ->testfilename );
351
+ }
352
+
353
+ public function testSkipResizingAlreadyResizedImageInDatabase ()
354
+ {
355
+ $ this ->databaseMock ->expects ($ this ->any ())
356
+ ->method ('checkDbUsage ' )
357
+ ->will ($ this ->returnValue (true ));
358
+ $ this ->databaseMock ->expects ($ this ->any ())
359
+ ->method ('fileExists ' )
360
+ ->will ($ this ->returnValue (true ));
361
+
362
+ $ this ->mediaDirectoryMock ->expects ($ this ->any ())
363
+ ->method ('isFile ' )
364
+ ->with ($ this ->testfilepath )
365
+ ->willReturnOnConsecutiveCalls (
366
+ $ this ->returnValue (false ),
367
+ $ this ->returnValue (true )
368
+ );
369
+
370
+ $ this ->themeCollectionMock ->expects ($ this ->any ())
371
+ ->method ('loadRegisteredThemes ' )
372
+ ->willReturn (
373
+ [ new DataObject (['id ' => '0 ' ]) ]
374
+ );
375
+ $ this ->themeCustomizationConfigMock ->expects ($ this ->any ())
376
+ ->method ('getStoresByThemes ' )
377
+ ->willReturn (
378
+ ['0 ' => []]
379
+ );
380
+
381
+ $ this ->databaseMock ->expects ($ this ->never ())
382
+ ->method ('saveFile ' );
383
+
384
+ $ this ->service ->resizeFromImageName ($ this ->testfilename );
385
+ }
319
386
}
0 commit comments