Skip to content

Commit 83b00a6

Browse files
committed
B2B:2037:[AWS S3] [Integration Tests]: Investigate Test Failures in MediaGallerySynchronization & MediaGallerySynchronizationMetadata modules
- Added static fixes and other issues
1 parent df9654b commit 83b00a6

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

app/code/Magento/MediaGalleryMetadata/Model/Jpeg/ReadFile.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ public function execute(string $path): FileInterface
112112

113113
if ($marker != self::MARKER_IMAGE_FILE_START) {
114114
$this->driver->fileClose($resource);
115-
116115
throw new ValidatorException(__('Not a JPEG image'));
117116
}
118117

@@ -151,7 +150,6 @@ private function readMarker($resource): string
151150

152151
if ($data[0] != self::MARKER_PREFIX) {
153152
$this->driver->fileClose($resource);
154-
155153
throw new LocalizedException(__('File is corrupted'));
156154
}
157155

@@ -172,7 +170,7 @@ private function readCompressedImage($resource): string
172170
$compressedImage .= $this->read($resource, self::ONE_MEGABYTE);
173171
} while (!$this->driver->endOfFile($resource));
174172

175-
$endOfImageMarkerPosition = strpos($compressedImage, self::MARKER_PREFIX.self::MARKER_IMAGE_END);
173+
$endOfImageMarkerPosition = strpos($compressedImage, self::MARKER_PREFIX . self::MARKER_IMAGE_END);
176174

177175
if ($endOfImageMarkerPosition !== false) {
178176
$compressedImage = substr($compressedImage, 0, $endOfImageMarkerPosition);

app/code/Magento/MediaGallerySynchronization/Test/Integration/Model/SynchronizeFilesTest.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020

2121
/**
2222
* Test for SynchronizeFiles.
23-
*
24-
* @internal
25-
* @coversNothing
2623
*/
2724
class SynchronizeFilesTest extends TestCase
2825
{
@@ -54,18 +51,17 @@ protected function setUp(): void
5451
$this->synchronizeFiles = Bootstrap::getObjectManager()->get(SynchronizeFilesInterface::class);
5552
$this->getAssetsByPath = Bootstrap::getObjectManager()->get(GetAssetsByPathsInterface::class);
5653
$this->mediaDirectory = Bootstrap::getObjectManager()->get(Filesystem::class)
57-
->getDirectoryWrite(
58-
DirectoryList::MEDIA
59-
)
60-
;
54+
->getDirectoryWrite(DirectoryList::MEDIA);
6155
$this->driver = $this->mediaDirectory->getDriver();
6256
}
6357

6458
/**
65-
* Test for SynchronizeFiles::execute.
59+
* Test for SynchronizeFiles::execute
6660
*
6761
* @dataProvider filesProvider
68-
*
62+
* @param string $file
63+
* @param string $title
64+
* @param string $source
6965
* @throws FileSystemException
7066
* @throws LocalizedException
7167
*/
@@ -84,13 +80,14 @@ public function testExecute(
8480
$this->synchronizeFiles->execute([$file]);
8581

8682
$loadedAsset = $this->getAssetsByPath->execute([$file])[0];
83+
8784
$this->assertEquals($title, pathinfo($loadedAsset->getTitle(), PATHINFO_FILENAME));
8885
$this->assertEquals($source, $loadedAsset->getSource());
8986
$this->driver->deleteFile($modifiableFilePath);
9087
}
9188

9289
/**
93-
* Data provider for testExecute.
90+
* Data provider for testExecute
9491
*
9592
* @return array[]
9693
*/
@@ -100,8 +97,8 @@ public function filesProvider(): array
10097
[
10198
'/magento.jpg',
10299
'magento',
103-
'Local',
104-
],
100+
'Local'
101+
]
105102
];
106103
}
107104
}

dev/tests/integration/testsuite/Magento/MediaGallerySynchronizationMetadata/Model/SynchronizeFilesTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public function testExecute(
9191

9292
$loadedAssets = $this->getAssetsByPath->execute([$file])[0];
9393
$loadedKeywords = $this->getKeywords($loadedAssets) ?: null;
94+
9495
$this->assertEquals($title, pathinfo($loadedAssets->getTitle(), PATHINFO_FILENAME));
9596
$this->assertEquals($description, $loadedAssets->getDescription());
9697
$this->assertEquals($keywords, $loadedKeywords);

0 commit comments

Comments
 (0)