Skip to content

Commit

Permalink
OXDEV-7729 Fix deprecations and notices in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Fedurtsya <[email protected]>
  • Loading branch information
Sieg committed Jan 30, 2024
1 parent 06cdd13 commit 835553c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/Service/NamingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private function findNextPossibleFilename(string $path): string

return $pathInfo['dirname']
. DIRECTORY_SEPARATOR . $newFileName
. ($pathInfo['extension'] ? '.' . $pathInfo['extension'] : '');
. (isset($pathInfo['extension']) && $pathInfo['extension'] ? '.' . $pathInfo['extension'] : '');
}

public function validateFileName(string $fileName): bool
Expand Down
10 changes: 2 additions & 8 deletions tests/Unit/Image/Service/ImageResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,8 @@ public static function getThumbnailPathDataProvider(): array
];
}

public function getThumbnailUrlProvider()
public static function getThumbnailUrlProvider()
{
$sut = $this->getSut();
$sThumbName = $this->getImageSizeAsString(
md5(self::FIXTURE_FILE) . '_thumb_',
$sut->getDefaultThumbnailSize()
);

return [
[
'sFile' => '',
Expand All @@ -324,7 +318,7 @@ public function getThumbnailUrlProvider()
[
'sFile' => self::FIXTURE_FILE,
'imageSize' => null,
'expected' => 'thumbs/' . $sThumbName,
'expected' => 'thumbs/d0b3244693f743a542dc6a84b8f5ae22_thumb_185*185.jpg',
],
[
'sFile' => '111.jpg',
Expand Down
31 changes: 13 additions & 18 deletions tests/Unit/Service/MediaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,19 +293,15 @@ public function testUploadMedia()
$sut->uploadMedia($sSourcePath, $sDestPath, $sFileSize, $sFileType);
}

public function getRenameDataProvider(): array
public static function getRenameDataProvider(): array
{
$oMedia = $this->getSut(
namingService: ContainerFactory::getInstance()->getContainer()->get(NamingServiceInterface::class),
);
$defaultThumbnailSize = 185;

$defaultThumbnailSize = $oMedia->imageResource->getDefaultThumbnailSize();

$sThumbName = $this->getImageSizeAsString(
$sThumbName = self::getImageSizeAsString(
md5(self::FIXTURE_FILE) . '_thumb_',
$defaultThumbnailSize
);
$sThumbNameNew = $this->getImageSizeAsString(
$sThumbNameNew = self::getImageSizeAsString(
md5('new.jpg') . '_thumb_',
$defaultThumbnailSize
);
Expand All @@ -315,7 +311,7 @@ public function getRenameDataProvider(): array
$structureExpected['root']['out']['pictures']['ddmedia']['new.jpg'] = 'some file';
$structureExpected['root']['out']['pictures']['ddmedia']['thumbs'][$sThumbNameNew] = 'some file';

$sThumbName = $this->getImageSizeAsString(
$sThumbName = self::getImageSizeAsString(
md5(self::FIXTURE_FILE) . '_thumb_',
$defaultThumbnailSize
);
Expand All @@ -341,19 +337,19 @@ public function getRenameDataProvider(): array
$structure2['out']['pictures']['ddmedia'][self::FIXTURE_FOLDER] = [];
$structureExpected2['root']['out']['pictures']['ddmedia']['folderNew'] = [];

$sThumbName = $this->getImageSizeAsString(
$sThumbName = self::getImageSizeAsString(
md5(self::FIXTURE_FILE) . '_thumb_',
$defaultThumbnailSize
);
$sThumbName2 = $this->getImageSizeAsString(
$sThumbName2 = self::getImageSizeAsString(
md5('new_1.jpg') . '_thumb_',
$defaultThumbnailSize
);
$sThumbName3 = $this->getImageSizeAsString(
$sThumbName3 = self::getImageSizeAsString(
md5('new_1.jpg') . '_thumb_',
$defaultThumbnailSize
);
$sThumbNameNew2 = $this->getImageSizeAsString(
$sThumbNameNew2 = self::getImageSizeAsString(
md5('new_2.jpg') . '_thumb_',
$defaultThumbnailSize
);
Expand Down Expand Up @@ -438,12 +434,11 @@ public function getRenameDataProvider(): array
];
}

public function getDeleteDataProvider()
public static function getDeleteDataProvider()
{
$oMedia = $this->getSut();
$sThumbName = $this->getImageSizeAsString(
$sThumbName = self::getImageSizeAsString(
'111_thumb_',
$oMedia->imageResource->getDefaultThumbnailSize()
185
);

// scenario 1 - file in media root
Expand Down Expand Up @@ -579,7 +574,7 @@ protected function getImageResourceStub(
);
}

private function getImageSizeAsString(string $prefix, int $imageSize, $suffix = '.jpg'): string
private static function getImageSizeAsString(string $prefix, int $imageSize, $suffix = '.jpg'): string
{
return sprintf(
'%s%d*%d%s',
Expand Down
2 changes: 1 addition & 1 deletion tests/github_actions/module-medialibrary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ codeception:
title: codeception
container:
options: '-e SELENIUM_SERVER_HOST=selenium -e BROWSER_NAME=chrome -e XDEBUG_MODE=coverage -e THEME_ID=apex'
configuration: '/var/www/vendor/oxid-esales/gdpr-optin-module/tests/codeception.yml'
configuration: '/var/www/vendor/oxid-esales/media-library-module/tests/codeception.yml'
suite: 'acceptance'
additional_options: '--coverage-xml=/var/www/codeception_coverage.xml'
logfile:
Expand Down
7 changes: 6 additions & 1 deletion tests/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
requireCoverageMetadata="false">
requireCoverageMetadata="false"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
>
<testsuites>
<testsuite name="Unit">
<directory>Unit/</directory>
Expand Down

0 comments on commit 835553c

Please sign in to comment.