Skip to content

Commit 931a010

Browse files
Feedback changes
1 parent 0a01e2d commit 931a010

File tree

2 files changed

+28
-31
lines changed

2 files changed

+28
-31
lines changed

MediaGalleryRenditions/Test/Integration/Model/GenerateRenditionsTest.php

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -68,48 +68,46 @@ public static function tearDownAfterClass(): void
6868
*
6969
* Test for generation of rendition images.
7070
*
71-
* @param array $paths
71+
* @param string $path
7272
* @param string $renditionPath
7373
* @param bool $isRenditionsGenerated
7474
* @throws LocalizedException
7575
*/
76-
public function testExecute(array $paths, string $renditionPath, bool $isRenditionsGenerated): void
76+
public function testExecute(string $path, string $renditionPath, bool $isRenditionsGenerated): void
7777
{
78-
$this->copyImage($paths);
79-
$this->generateRenditions->execute($paths);
78+
$this->copyImage($path);
79+
$this->generateRenditions->execute([$path]);
8080
$expectedRenditionPath = $this->mediaDirectory->getAbsolutePath($renditionPath);
81-
if ($isRenditionsGenerated) {
82-
list($imageWidth, $imageHeight) = getimagesize($expectedRenditionPath);
83-
$this->assertFileExists($expectedRenditionPath);
84-
$this->assertLessThanOrEqual(
85-
$this->renditionSizeConfig->getWidth(),
86-
$imageWidth,
87-
'Generated renditions image width should be less than or equal to original image'
88-
);
89-
$this->assertLessThanOrEqual(
90-
$this->renditionSizeConfig->getHeight(),
91-
$imageHeight,
92-
'Generated renditions image height should be less than or equal to original image'
93-
);
94-
} else {
81+
if (!$isRenditionsGenerated) {
9582
$this->assertFileDoesNotExist($expectedRenditionPath);
83+
return;
9684
}
85+
list($imageWidth, $imageHeight) = getimagesize($expectedRenditionPath);
86+
$this->assertFileExists($expectedRenditionPath);
87+
$this->assertLessThanOrEqual(
88+
$this->renditionSizeConfig->getWidth(),
89+
$imageWidth,
90+
'Generated renditions image width should be less than or equal to configured value'
91+
);
92+
$this->assertLessThanOrEqual(
93+
$this->renditionSizeConfig->getHeight(),
94+
$imageHeight,
95+
'Generated renditions image height should be less than or equal to configured value'
96+
);
9797
}
9898

9999
/**
100100
* @param array $paths
101101
* @throws FileSystemException
102102
*/
103-
private function copyImage(array $paths): void
103+
private function copyImage(string $path): void
104104
{
105-
foreach ($paths as $path) {
106-
$imagePath = realpath(__DIR__ . '/../../_files' . $path);
107-
$modifiableFilePath = $this->mediaDirectory->getAbsolutePath($path);
108-
$this->driver->copy(
109-
$imagePath,
110-
$modifiableFilePath
111-
);
112-
}
105+
$imagePath = realpath(__DIR__ . '/../../_files' . $path);
106+
$modifiableFilePath = $this->mediaDirectory->getAbsolutePath($path);
107+
$this->driver->copy(
108+
$imagePath,
109+
$modifiableFilePath
110+
);
113111
}
114112

115113
/**
@@ -119,12 +117,12 @@ public function renditionsImageProvider(): array
119117
{
120118
return [
121119
'rendition_image_not_generated' => [
122-
'paths' => ['/magento_medium_image.jpg'],
120+
'paths' => '/magento_medium_image.jpg',
123121
'renditionPath' => ".renditions/magento_medium_image.jpg",
124122
'isRenditionsGenerated' => false
125123
],
126124
'rendition_image_generated' => [
127-
'paths' => ['/magento_large_image.jpg'],
125+
'paths' => '/magento_large_image.jpg',
128126
'renditionPath' => ".renditions/magento_large_image.jpg",
129127
'isRenditionsGenerated' => true
130128
]

MediaGalleryRenditions/Test/Integration/Model/GetRenditionPathTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public function testExecute(string $path, string $expectedRenditionPath): void
5555
$imagePath,
5656
$modifiableFilePath
5757
);
58-
$getRenditionPath = $this->getRenditionPath->execute($path);
59-
$this->assertEquals($expectedRenditionPath, $getRenditionPath);
58+
$this->assertEquals($expectedRenditionPath, $this->getRenditionPath->execute($path));
6059
}
6160

6261
/**

0 commit comments

Comments
 (0)