@@ -163,17 +163,13 @@ public function testGetImagesJson()
163
163
$ this ->galleryMock ->expects ($ this ->once ())->method ('getImages ' )->willReturn ($ images );
164
164
$ this ->fileSystemMock ->expects ($ this ->once ())->method ('getDirectoryRead ' )->willReturn ($ this ->readMock );
165
165
166
- $ this ->mediaConfigMock ->expects ( $ this -> any ())-> method ('getMediaUrl ' )->willReturnMap ($ url );
167
- $ this ->mediaConfigMock ->expects ( $ this -> any ())-> method ('getMediaPath ' )->willReturnMap ($ mediaPath );
168
- $ this ->readMock ->expects ( $ this -> any ())-> method ('stat ' )->willReturnMap ($ sizeMap );
166
+ $ this ->mediaConfigMock ->method ('getMediaUrl ' )->willReturnMap ($ url );
167
+ $ this ->mediaConfigMock ->method ('getMediaPath ' )->willReturnMap ($ mediaPath );
168
+ $ this ->readMock ->method ('stat ' )->willReturnMap ($ sizeMap );
169
169
$ this ->jsonEncoderMock ->expects ($ this ->once ())->method ('encode ' )->willReturnCallback ('json_encode ' );
170
170
171
- $ this ->readMock ->expects ($ this ->any ())
172
- ->method ('isFile ' )
173
- ->willReturn (true );
174
- $ this ->databaseMock ->expects ($ this ->any ())
175
- ->method ('checkDbUsage ' )
176
- ->willReturn (false );
171
+ $ this ->readMock ->method ('isFile ' )->willReturn (true );
172
+ $ this ->databaseMock ->method ('checkDbUsage ' )->willReturn (false );
177
173
178
174
$ this ->assertSame (json_encode ($ imagesResult ), $ this ->content ->getImagesJson ());
179
175
}
@@ -239,26 +235,26 @@ public function testGetImagesJsonWithException()
239
235
240
236
$ this ->content ->setElement ($ this ->galleryMock );
241
237
$ this ->galleryMock ->expects ($ this ->once ())->method ('getImages ' )->willReturn ($ images );
242
- $ this ->fileSystemMock ->expects ( $ this -> any ())-> method ('getDirectoryRead ' )->willReturn ($ this ->readMock );
243
- $ this ->mediaConfigMock ->expects ( $ this -> any ())-> method ('getMediaUrl ' );
244
- $ this ->mediaConfigMock ->expects ( $ this -> any ())-> method ('getMediaPath ' );
238
+ $ this ->fileSystemMock ->method ('getDirectoryRead ' )->willReturn ($ this ->readMock );
239
+ $ this ->mediaConfigMock ->method ('getMediaUrl ' );
240
+ $ this ->mediaConfigMock ->method ('getMediaPath ' );
245
241
246
- $ this ->readMock -> expects ( $ this -> any ())
242
+ $ this ->readMock
247
243
->method ('isFile ' )
248
244
->willReturn (true );
249
- $ this ->databaseMock -> expects ( $ this -> any ())
245
+ $ this ->databaseMock
250
246
->method ('checkDbUsage ' )
251
247
->willReturn (false );
252
248
253
- $ this ->readMock ->expects ( $ this -> any ())-> method ('stat ' )->willReturnOnConsecutiveCalls (
249
+ $ this ->readMock ->method ('stat ' )->willReturnOnConsecutiveCalls (
254
250
$ this ->throwException (
255
251
new FileSystemException (new Phrase ('test ' ))
256
252
),
257
253
$ this ->throwException (
258
254
new FileSystemException (new Phrase ('test ' ))
259
255
)
260
256
);
261
- $ this ->imageHelper ->expects ( $ this -> any ())-> method ('getDefaultPlaceholderUrl ' )->willReturn ($ placeholderUrl );
257
+ $ this ->imageHelper ->method ('getDefaultPlaceholderUrl ' )->willReturn ($ placeholderUrl );
262
258
$ this ->jsonEncoderMock ->expects ($ this ->once ())->method ('encode ' )->willReturnCallback ('json_encode ' );
263
259
264
260
$ this ->assertSame (json_encode ($ imagesResult ), $ this ->content ->getImagesJson ());
@@ -396,7 +392,7 @@ private function getMediaAttribute(string $label, string $attributeCode)
396
392
$ mediaAttribute = $ this ->getMockBuilder (Attribute::class)
397
393
->disableOriginalConstructor ()
398
394
->getMock ();
399
- $ mediaAttribute-> expects ( $ this -> any ())
395
+ $ mediaAttribute
400
396
->method ('getAttributeCode ' )
401
397
->willReturn ($ attributeCode );
402
398
$ mediaAttribute ->expects ($ this ->once ())
@@ -436,21 +432,23 @@ public function testGetImagesJsonMediaStorageMode()
436
432
$ this ->fileSystemMock ->expects ($ this ->once ())
437
433
->method ('getDirectoryRead ' )
438
434
->willReturn ($ this ->readMock );
439
- $ this ->mediaConfigMock -> expects ( $ this -> any ())
435
+ $ this ->mediaConfigMock
440
436
->method ('getMediaPath ' )
441
437
->willReturnMap ($ mediaPath );
442
438
443
- $ this ->readMock -> expects ( $ this -> any ())
439
+ $ this ->readMock
444
440
->method ('isFile ' )
445
441
->willReturn (false );
446
- $ this ->databaseMock -> expects ( $ this -> any ())
442
+ $ this ->databaseMock
447
443
->method ('checkDbUsage ' )
448
444
->willReturn (true );
449
445
450
446
$ this ->databaseMock ->expects ($ this ->once ())
451
447
->method ('saveFileToFilesystem ' )
452
448
->with ('catalog/product/image_1.jpg ' );
453
449
450
+ $ this ->readMock ->method ('stat ' )->willReturn (['size ' => 123 ]);
451
+
454
452
$ this ->content ->getImagesJson ();
455
453
}
456
454
}
0 commit comments