Skip to content

Commit 5a3c55e

Browse files
committed
Merge remote-tracking branch 'origin/B2B-2036' into B2B-2053
2 parents 21c26fc + 6a2843a commit 5a3c55e

File tree

5 files changed

+31
-26
lines changed

5 files changed

+31
-26
lines changed

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3MediaGalleryDeleteFolderTest.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<argument name="filePath">media/.thumbswysiwyg/{{AdminMediaGalleryFolderData.name}}/{{AdminMediaGalleryFolder2Data.name}}/{{ImageUpload.file}}</argument>
6868
</helper>
6969
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertDirectoryDoesNotExist" stepKey="assertLocalBaseImageDirectoryDoesNotExist">
70-
<argument name="path">pub/media/wysiwyg/{{AdminMediaGalleryFolderData.name}}</argument>
70+
<argument name="path">pub/media/.renditions/wysiwyg/{{AdminMediaGalleryFolderData.name}}</argument>
7171
</helper>
7272
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileExists" stepKey="assertLocalThumbnailImageExists">
7373
<argument name="filePath">pub/media/.thumbswysiwyg/{{AdminMediaGalleryFolderData.name}}/{{AdminMediaGalleryFolder2Data.name}}/{{ImageUpload.file}}</argument>
@@ -105,7 +105,7 @@
105105
<argument name="filePath">media/.thumbswysiwyg/{{AdminMediaGalleryFolderData.name}}/{{AdminMediaGalleryFolder2Data.name}}/{{ImageUpload.file}}</argument>
106106
</helper>
107107
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileExists" stepKey="assertLocalBaseImageExists2">
108-
<argument name="filePath">pub/media/wysiwyg/{{AdminMediaGalleryFolderData.name}}/{{AdminMediaGalleryFolder2Data.name}}/{{ImageUpload.file}}</argument>
108+
<argument name="filePath">pub/media/.renditions/wysiwyg/{{AdminMediaGalleryFolderData.name}}/{{AdminMediaGalleryFolder2Data.name}}/{{ImageUpload.file}}</argument>
109109
</helper>
110110
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileExists" stepKey="assertLocalThumbnailImageExists2">
111111
<argument name="filePath">pub/media/.thumbswysiwyg/{{AdminMediaGalleryFolderData.name}}/{{AdminMediaGalleryFolder2Data.name}}/{{ImageUpload.file}}</argument>
@@ -139,10 +139,10 @@
139139
<argument name="filePath">media/.thumbswysiwyg/{{AdminMediaGalleryFolderData.name}}/{{AdminMediaGalleryFolder2Data.name}}/{{ImageUpload.file}}</argument>
140140
</helper>
141141
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertDirectoryExists" stepKey="assertLocal1stCreatedBaseFolderExists">
142-
<argument name="path">pub/media/wysiwyg/{{AdminMediaGalleryFolderData.name}}</argument>
142+
<argument name="path">pub/media/.renditions/wysiwyg/{{AdminMediaGalleryFolderData.name}}</argument>
143143
</helper>
144144
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertDirectoryDoesNotExist" stepKey="assertLocal2ndCreatedBaseFolderDoesNotExist">
145-
<argument name="path">pub/media/wysiwyg/{{AdminMediaGalleryFolderData.name}}/{{AdminMediaGalleryFolder2Data.name}}</argument>
145+
<argument name="path">pub/media/.renditions/wysiwyg/{{AdminMediaGalleryFolderData.name}}/{{AdminMediaGalleryFolder2Data.name}}</argument>
146146
</helper>
147147
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileExists" stepKey="assertLocalThumbnailImageExists3">
148148
<argument name="filePath">pub/media/.thumbswysiwyg/{{AdminMediaGalleryFolderData.name}}/{{AdminMediaGalleryFolder2Data.name}}/{{ImageUpload.file}}</argument>

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3MediaGalleryDeleteImageTest.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<argument name="filePath">media/.thumbswysiwyg/{{AdminMediaGalleryFolderData.name}}/{{ImageUpload.file}}</argument>
6464
</helper>
6565
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertDirectoryDoesNotExist" stepKey="assertLocalBaseImageDirectoryDoesNotExist">
66-
<argument name="path">pub/media/wysiwyg/{{AdminMediaGalleryFolderData.name}}</argument>
66+
<argument name="path">pub/media/.renditions/wysiwyg/{{AdminMediaGalleryFolderData.name}}</argument>
6767
</helper>
6868
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileExists" stepKey="assertLocalThumbnailImageExists">
6969
<argument name="filePath">pub/media/.thumbswysiwyg/{{AdminMediaGalleryFolderData.name}}/{{ImageUpload.file}}</argument>
@@ -98,7 +98,7 @@
9898
<argument name="filePath">media/.thumbswysiwyg/{{AdminMediaGalleryFolderData.name}}/{{ImageUpload.file}}</argument>
9999
</helper>
100100
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileExists" stepKey="assertLocalBaseImageExists2">
101-
<argument name="filePath">pub/media/wysiwyg/{{AdminMediaGalleryFolderData.name}}/{{ImageUpload.file}}</argument>
101+
<argument name="filePath">pub/media/.renditions/wysiwyg/{{AdminMediaGalleryFolderData.name}}/{{ImageUpload.file}}</argument>
102102
</helper>
103103
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileExists" stepKey="assertLocalThumbnailImageExists2">
104104
<argument name="filePath">pub/media/.thumbswysiwyg/{{AdminMediaGalleryFolderData.name}}/{{ImageUpload.file}}</argument>
@@ -134,10 +134,10 @@
134134
<argument name="filePath">media/.thumbswysiwyg/{{AdminMediaGalleryFolderData.name}}/{{ImageUpload.file}}</argument>
135135
</helper>
136136
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertDirectoryExists" stepKey="assertLocalCreatedBaseFolderExists">
137-
<argument name="path">pub/media/wysiwyg/{{AdminMediaGalleryFolderData.name}}</argument>
137+
<argument name="path">pub/media/.renditions/wysiwyg/{{AdminMediaGalleryFolderData.name}}</argument>
138138
</helper>
139139
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileDoesNotExist" stepKey="assertLocalBaseImageDoesNotExist">
140-
<argument name="filePath">pub/media/wysiwyg/{{AdminMediaGalleryFolderData.name}}/{{ImageUpload.file}}</argument>
140+
<argument name="filePath">pub/media/.renditions/wysiwyg/{{AdminMediaGalleryFolderData.name}}/{{ImageUpload.file}}</argument>
141141
</helper>
142142
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertDirectoryExists" stepKey="assertLocalThumbnailDirectoryExists">
143143
<argument name="path">pub/media/.thumbswysiwyg/{{AdminMediaGalleryFolderData.name}}</argument>

app/code/Magento/MediaGalleryRenditions/Model/GenerateRenditions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
use Magento\MediaGalleryRenditionsApi\Api\GetRenditionPathInterface;
2020
use Psr\Log\LoggerInterface;
2121

22+
/**
23+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
24+
*/
2225
class GenerateRenditions implements GenerateRenditionsInterface
2326
{
2427
private const IMAGE_FILE_NAME_PATTERN = '#\.(jpg|jpeg|gif|png)$# i';
@@ -205,7 +208,7 @@ private function createResizedRendition(string $absolutePath, string $absoluteRe
205208
*/
206209
private function shouldFileBeResized(string $absolutePath): bool
207210
{
208-
[$width, $height] = getimagesize($absolutePath);
211+
[$width, $height] = getimagesizefromstring($this->getMediaDirectory()->readFile($absolutePath));
209212
return $width > $this->config->getWidth() || $height > $this->config->getHeight();
210213
}
211214

app/code/Magento/MediaGalleryRenditions/Test/Integration/Model/GenerateRenditionsTest.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function setup(): void
6363
$this->mediaDirectory = $this->objectManager->get(Filesystem::class)
6464
->getDirectoryWrite(DirectoryList::MEDIA);
6565
$this->mediaDirectory->create(self::TEST_DIR);
66-
$this->driver = $this->objectManager->get(DriverInterface::class);
66+
$this->driver = $this->mediaDirectory->getDriver();
6767
$this->renditionSizeConfig = $this->objectManager->get(Config::class);
6868
$config = $this->objectManager->get(ScopeConfigInterface::class);
6969
$this->origConfigValue = $config->getValue(
@@ -114,10 +114,9 @@ public static function tearDownAfterClass(): void
114114
public function testExecute(string $path, string $renditionPath): void
115115
{
116116
$this->copyImage($path);
117-
$this->generateRenditions->execute([self::TEST_DIR . '/' . $path]);
118-
$expectedRenditionPath = $this->mediaDirectory->getAbsolutePath($renditionPath);
119-
list($imageWidth, $imageHeight) = getimagesize($expectedRenditionPath);
120-
$this->assertFileExists($expectedRenditionPath);
117+
$this->generateRenditions->execute([self::TEST_DIR . DIRECTORY_SEPARATOR . $path]);
118+
list($imageWidth, $imageHeight) = getimagesizefromstring($this->mediaDirectory->readFile($renditionPath));
119+
$this->assertTrue($this->mediaDirectory->isExist($renditionPath));
121120
$this->assertLessThanOrEqual(
122121
$this->renditionSizeConfig->getWidth(),
123122
$imageWidth,
@@ -131,16 +130,18 @@ public function testExecute(string $path, string $renditionPath): void
131130
}
132131

133132
/**
134-
* @param array $paths
133+
* Copies file from the integration test directory to the media directory
134+
*
135+
* @param string $path
135136
* @throws FileSystemException
136137
*/
137138
private function copyImage(string $path): void
138139
{
139-
$imagePath = realpath(__DIR__ . '/../../_files' . $path);
140-
$modifiableFilePath = $this->mediaDirectory->getAbsolutePath(self::TEST_DIR . $path );
141-
$this->driver->copy(
142-
$imagePath,
143-
$modifiableFilePath
140+
$imagePath = realpath(__DIR__ . '/../../_files/' . $path);
141+
$modifiableFilePath = $this->mediaDirectory->getAbsolutePath(self::TEST_DIR . DIRECTORY_SEPARATOR . $path);
142+
$this->driver->filePutContents(
143+
$modifiableFilePath,
144+
file_get_contents($imagePath)
144145
);
145146
}
146147

@@ -151,11 +152,11 @@ public function renditionsImageProvider(): array
151152
{
152153
return [
153154
'rendition_image_not_generated' => [
154-
'paths' => '/magento_medium_image.jpg',
155+
'path' => 'magento_medium_image.jpg',
155156
'renditionPath' => ".renditions/" . self::TEST_DIR . "/magento_medium_image.jpg"
156157
],
157158
'rendition_image_generated' => [
158-
'paths' => '/magento_large_image.jpg',
159+
'path' => 'magento_large_image.jpg',
159160
'renditionPath' => ".renditions/" . self::TEST_DIR . "/magento_large_image.jpg"
160161
]
161162
];

app/code/Magento/MediaGalleryRenditions/Test/Integration/Model/GetRenditionPathTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected function setup(): void
3939
$this->getRenditionPath = Bootstrap::getObjectManager()->get(GetRenditionPathInterface::class);
4040
$this->mediaDirectory = Bootstrap::getObjectManager()->get(Filesystem::class)
4141
->getDirectoryWrite(DirectoryList::MEDIA);
42-
$this->driver = Bootstrap::getObjectManager()->get(DriverInterface::class);
42+
$this->driver = $this->mediaDirectory->getDriver();
4343
}
4444

4545
/**
@@ -51,9 +51,10 @@ public function testExecute(string $path, string $expectedRenditionPath): void
5151
{
5252
$imagePath = realpath(__DIR__ . '/../../_files' . $path);
5353
$modifiableFilePath = $this->mediaDirectory->getAbsolutePath($path);
54-
$this->driver->copy(
55-
$imagePath,
56-
$modifiableFilePath
54+
$this->mediaDirectory->create(dirname($path));
55+
$this->driver->filePutContents(
56+
$modifiableFilePath,
57+
file_get_contents($imagePath)
5758
);
5859
$this->assertEquals($expectedRenditionPath, $this->getRenditionPath->execute($path));
5960
}

0 commit comments

Comments
 (0)