Skip to content

Commit 67abbb3

Browse files
committed
#28081 Add missing stub key that caused Unit Test failure
1 parent 4379bd8 commit 67abbb3

File tree

1 file changed

+18
-20
lines changed
  • app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery

1 file changed

+18
-20
lines changed

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,13 @@ public function testGetImagesJson()
163163
$this->galleryMock->expects($this->once())->method('getImages')->willReturn($images);
164164
$this->fileSystemMock->expects($this->once())->method('getDirectoryRead')->willReturn($this->readMock);
165165

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);
169169
$this->jsonEncoderMock->expects($this->once())->method('encode')->willReturnCallback('json_encode');
170170

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);
177173

178174
$this->assertSame(json_encode($imagesResult), $this->content->getImagesJson());
179175
}
@@ -239,26 +235,26 @@ public function testGetImagesJsonWithException()
239235

240236
$this->content->setElement($this->galleryMock);
241237
$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');
245241

246-
$this->readMock->expects($this->any())
242+
$this->readMock
247243
->method('isFile')
248244
->willReturn(true);
249-
$this->databaseMock->expects($this->any())
245+
$this->databaseMock
250246
->method('checkDbUsage')
251247
->willReturn(false);
252248

253-
$this->readMock->expects($this->any())->method('stat')->willReturnOnConsecutiveCalls(
249+
$this->readMock->method('stat')->willReturnOnConsecutiveCalls(
254250
$this->throwException(
255251
new FileSystemException(new Phrase('test'))
256252
),
257253
$this->throwException(
258254
new FileSystemException(new Phrase('test'))
259255
)
260256
);
261-
$this->imageHelper->expects($this->any())->method('getDefaultPlaceholderUrl')->willReturn($placeholderUrl);
257+
$this->imageHelper->method('getDefaultPlaceholderUrl')->willReturn($placeholderUrl);
262258
$this->jsonEncoderMock->expects($this->once())->method('encode')->willReturnCallback('json_encode');
263259

264260
$this->assertSame(json_encode($imagesResult), $this->content->getImagesJson());
@@ -396,7 +392,7 @@ private function getMediaAttribute(string $label, string $attributeCode)
396392
$mediaAttribute = $this->getMockBuilder(Attribute::class)
397393
->disableOriginalConstructor()
398394
->getMock();
399-
$mediaAttribute->expects($this->any())
395+
$mediaAttribute
400396
->method('getAttributeCode')
401397
->willReturn($attributeCode);
402398
$mediaAttribute->expects($this->once())
@@ -436,21 +432,23 @@ public function testGetImagesJsonMediaStorageMode()
436432
$this->fileSystemMock->expects($this->once())
437433
->method('getDirectoryRead')
438434
->willReturn($this->readMock);
439-
$this->mediaConfigMock->expects($this->any())
435+
$this->mediaConfigMock
440436
->method('getMediaPath')
441437
->willReturnMap($mediaPath);
442438

443-
$this->readMock->expects($this->any())
439+
$this->readMock
444440
->method('isFile')
445441
->willReturn(false);
446-
$this->databaseMock->expects($this->any())
442+
$this->databaseMock
447443
->method('checkDbUsage')
448444
->willReturn(true);
449445

450446
$this->databaseMock->expects($this->once())
451447
->method('saveFileToFilesystem')
452448
->with('catalog/product/image_1.jpg');
453449

450+
$this->readMock->method('stat')->willReturn(['size' => 123]);
451+
454452
$this->content->getImagesJson();
455453
}
456454
}

0 commit comments

Comments
 (0)