Skip to content

Commit

Permalink
Upgrade phpunit to fit the shop
Browse files Browse the repository at this point in the history
Some deprecations are still there and cannot be removed easily without heavy refactorings of old stuff

Signed-off-by: Anton Fedurtsya <[email protected]>
  • Loading branch information
Sieg committed Jan 9, 2024
1 parent 3c691ae commit 84c4a96
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"require-dev": {
"squizlabs/php_codesniffer": "3.*",
"phpstan/phpstan": "^1.8.11",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^10.4",
"oxid-esales/oxideshop-ce": "dev-b-7.1.x",
"mikey179/vfsstream": "~1.6.8"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testGenerateThumbnail(
}


public function getThumbnailDataProvider()
public static function getThumbnailDataProvider()
{
return [
'cropped_thumbnail_of_size_800x800_when_bigger_source_size_landscape' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Media/Repository/MediaRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testGetMediaByIdNotFound(): void
$sut->getMediaById('someWrongId');
}

public function getFolderMediaDataProvider(): \Generator
public static function getFolderMediaDataProvider(): \Generator
{
yield "first page in folder" => [
'folder' => 'someFolder',
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Service/MediaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function testFolder()
$this->assertEquals('Folder1', $sut->imageResource->getFolderName());
}

public function getUploadMediaDataProvider()
public static function getUploadMediaDataProvider()
{
return [
[
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Image/DataTransfer/ImageSizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testIsEmpty(int $width, int $height, bool $expected): void
$this->assertSame($expected, $sut->isEmpty());
}

public function isEmptyDataProvider(): array
public static function isEmptyDataProvider(): array
{
return [
[0, 0, true],
Expand All @@ -56,7 +56,7 @@ public function testGetInFormat(
$this->assertSame($expectedResult, $sut->getInFormat($format, $emptyFormat));
}

public function getInFormatDataProvider(): array
public static function getInFormatDataProvider(): array
{
return [
[123, 321, '%dx%d', '', '123x321'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Image/Service/ImageResourceRefactoredTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testCalculateMediaThumbnailUrl(string $fileName, string $fileTyp
$this->assertSame($expected, $sut->calculateMediaThumbnailUrl(fileName: $fileName, fileType: $fileType));
}

public function mediaThumbnailUrlDataProvider(): \Generator
public static function mediaThumbnailUrlDataProvider(): \Generator
{
yield 'image' => [
'fileName' => 'someFilename.gif',
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Image/Service/ImageResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public function testGetThumbnailUrl($sFile, ?ImageSizeInterface $imageSize = nul
$this->assertEquals($expected ? ('https://test.com/out/pictures/ddmedia/' . $expected) : $expected, $result);
}

public function getImagePathDataProvider(): array
public static function getImagePathDataProvider(): array
{
return [
[
Expand All @@ -293,7 +293,7 @@ public function getImagePathDataProvider(): array
];
}

public function getThumbnailPathDataProvider(): array
public static function getThumbnailPathDataProvider(): array
{
return [
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Media/DataType/MediaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testIsDirectory(string $fileType, bool $expectedResult): void
$this->assertSame($expectedResult, $sut->isDirectory());
}

public function isDirectoryDataProvider(): \Generator
public static function isDirectoryDataProvider(): \Generator
{
yield "some gif image filetype" => ['fileType' => 'image/gif', 'expectedResult' => false];
yield "some jpeg image filetype" => ['fileType' => 'image/jpeg', 'expectedResult' => false];
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Service/FileSystemServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testEnsureDirectorySuccessful(string $pathExample): void
$this->assertTrue(is_dir($path));
}

public function ensureDirectorySuccessCasesDataProvider(): \Generator
public static function ensureDirectorySuccessCasesDataProvider(): \Generator
{
yield ['pathExample' => 'someDirectory'];
yield ['pathExample' => 'someDirectory/withSubDirectory'];
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Service/NamingServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testSanitizeFilename($filename, $expectedResult): void
$this->assertSame($expectedResult, $sut->sanitizeFilename($filename));
}

public function sanitizeFilenameDataProvider(): \Generator
public static function sanitizeFilenameDataProvider(): \Generator
{
yield "no extension" => ['filename' => 'somexc', 'expectedResult' => 'someyb'];
yield "extension should not be changed" => ['filename' => 'somexc.xcabc', 'expectedResult' => 'someyb.xcabc'];
Expand All @@ -67,7 +67,7 @@ public function testGetUniqueFilename(string $filename, string $expectation): vo
$this->assertSame($expectation, $sut->getUniqueFilename($filename));
}

public function getUniqueFilenameDataProvider(): \Generator
public static function getUniqueFilenameDataProvider(): \Generator
{
yield 'not existing file no directory' => [
'filename' => 'vfs://root/someSimpleFile.ext',
Expand Down Expand Up @@ -127,7 +127,7 @@ public function testValidateGoodFilename(string $goodFilename): void
$this->assertTrue($sut->validateFileName($goodFilename));
}

public function validationGoodFileNamesDataProvider(): \Generator
public static function validationGoodFileNamesDataProvider(): \Generator
{
yield ['fileName' => 'example.txt'];
}
Expand All @@ -141,7 +141,7 @@ public function testValidateBadFilename(string $badFilename): void
$sut->validateFileName($badFilename);
}

public function validationBadFileNamesDataProvider(): \Generator
public static function validationBadFileNamesDataProvider(): \Generator
{
yield ['fileName' => 'someFileNameWithoutExtension'];
yield ['fileName' => ''];
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Transput/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testGetStringRequestParameter(
}
}

public function requestOnlyStringDataProvider(): array
public static function requestOnlyStringDataProvider(): array
{
$defaultValue = 'someDefault';
return [
Expand Down Expand Up @@ -71,7 +71,7 @@ public function testGetBoolRequestParameter($requestValue, $expectedValue): void
$this->assertSame($expectedValue, $sut->getBoolRequestParameter($paramName));
}

public function requestBoolDataProvider(): array
public static function requestBoolDataProvider(): array
{
return [
[null, false],
Expand Down Expand Up @@ -99,7 +99,7 @@ public function testGetIntRequestParameter($requestValue, $expectedValue): void
$this->assertSame($expectedValue, $sut->getIntRequestParameter($paramName));
}

public function getIntDataProvider(): array
public static function getIntDataProvider(): array
{
return [
'null' => [null, 0],
Expand Down
21 changes: 9 additions & 12 deletions tests/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="true"
backupStaticAttributes="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
beStrictAboutTestsThatDoNotTestAnything="false"
verbose="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true" processUncoveredFiles="false">
<include>
<directory suffix=".php">../src</directory>
</include>
</coverage>
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
requireCoverageMetadata="false">
<testsuites>
<testsuite name="Unit">
<directory>Unit/</directory>
Expand All @@ -27,4 +19,9 @@
<directory>Integration/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">../src</directory>
</include>
</source>
</phpunit>

0 comments on commit 84c4a96

Please sign in to comment.