From c6a524e73d743d1a79055068fa1440637ecaf6d1 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 12 Sep 2024 10:26:44 +1200 Subject: [PATCH] DEP Use PHPUnit 11 --- ...rTest.php => FileConverterManagerTest.php} | 23 ++++----- .../InterventionImageFileConverterTest.php | 19 +++---- tests/php/FileFinderTest.php | 4 +- tests/php/FileNameFilterTest.php | 7 ++- tests/php/FileTest.php | 35 +++++++------ .../FileIDHelperResolutionStrategyTest.php | 41 +++++++-------- .../FilenameParsing/FileIDHelperTester.php | 50 +++++++------------ .../FilenameParsing/HashFileIDHelperTest.php | 27 +++++----- .../NaturalFileIDHelperTest.php | 16 +++--- .../php/Flysystem/FlysystemAssetStoreTest.php | 17 ++++--- tests/php/GDImageTest.php | 2 +- tests/php/ImageManipulationTest.php | 33 ++++++------ .../php/{ImageTest.php => ImageTestBase.php} | 35 +++++++------ .../php/{ImageTest.yml => ImageTestBase.yml} | 0 tests/php/ImagickImageTest.php | 2 +- tests/php/ProtectedFileControllerTest.php | 7 ++- tests/php/PublicAssetAdapterTest.php | 7 ++- tests/php/RedirectFileControllerTest.php | 35 ++++--------- .../RedirectKeepArchiveFileControllerTest.php | 15 ++---- .../Shortcodes/ImageShortcodeProviderTest.php | 9 ++-- tests/php/Storage/AssetStoreTest.php | 21 ++++---- 21 files changed, 180 insertions(+), 225 deletions(-) rename tests/php/Conversion/{FileConversionManagerTest.php => FileConverterManagerTest.php} (85%) rename tests/php/{ImageTest.php => ImageTestBase.php} (95%) rename tests/php/{ImageTest.yml => ImageTestBase.yml} (100%) diff --git a/tests/php/Conversion/FileConversionManagerTest.php b/tests/php/Conversion/FileConverterManagerTest.php similarity index 85% rename from tests/php/Conversion/FileConversionManagerTest.php rename to tests/php/Conversion/FileConverterManagerTest.php index 8ff5d0a5..e53ddb88 100644 --- a/tests/php/Conversion/FileConversionManagerTest.php +++ b/tests/php/Conversion/FileConverterManagerTest.php @@ -10,6 +10,7 @@ use SilverStripe\Assets\Tests\Conversion\FileConverterManagerTest\TestTxtToImageConverter; use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\SapphireTest; +use PHPUnit\Framework\Attributes\DataProvider; class FileConverterManagerTest extends SapphireTest { @@ -41,35 +42,33 @@ protected function setUp(): void } } - public function provideConvert(): array + public static function provideConvert(): array { return [ 'supported by image converter' => [ - 'fromFormat' => 'jpg', - 'toFormat' => 'png', + 'fromExtension' => 'jpg', + 'toExtension' => 'png', 'expectSuccess' => true, ], 'supported by txt converter' => [ - 'fromFormat' => 'txt', - 'toFormat' => 'png', + 'fromExtension' => 'txt', + 'toExtension' => 'png', 'expectSuccess' => true, ], 'unsupported 1' => [ - 'fromFormat' => 'jpg', - 'toFormat' => 'txt', + 'fromExtension' => 'jpg', + 'toExtension' => 'txt', 'expectSuccess' => false, ], 'unsupported 2' => [ - 'fromFormat' => 'txt', - 'toFormat' => 'doc', + 'fromExtension' => 'txt', + 'toExtension' => 'doc', 'expectSuccess' => false, ], ]; } - /** - * @dataProvider provideConvert - */ + #[DataProvider('provideConvert')] public function testConvert(string $fromExtension, string $toExtension, bool $expectSuccess): void { $manager = new FileConverterManager(); diff --git a/tests/php/Conversion/InterventionImageFileConverterTest.php b/tests/php/Conversion/InterventionImageFileConverterTest.php index 93bc922a..eb5a10ba 100644 --- a/tests/php/Conversion/InterventionImageFileConverterTest.php +++ b/tests/php/Conversion/InterventionImageFileConverterTest.php @@ -9,6 +9,7 @@ use SilverStripe\Assets\Folder; use SilverStripe\Assets\Image; use SilverStripe\Dev\SapphireTest; +use PHPUnit\Framework\Attributes\DataProvider; class InterventionImageFileConverterTest extends SapphireTest { @@ -34,7 +35,7 @@ protected function setUp(): void } } - public function provideSupportsConversion(): array + public static function provideSupportsConversion(): array { // We don't need to check every possible file type here. // We're just validating that the logic overall holds true. @@ -90,16 +91,14 @@ public function provideSupportsConversion(): array ]; } - /** - * @dataProvider provideSupportsConversion - */ + #[DataProvider('provideSupportsConversion')] public function testSupportsConversion(string $from, string $to, array $options, bool $expected): void { $converter = new InterventionImageFileConverter(); $this->assertSame($expected, $converter->supportsConversion($from, $to, $options)); } - public function provideConvert(): array + public static function provideConvert(): array { return [ 'no options' => [ @@ -111,9 +110,7 @@ public function provideConvert(): array ]; } - /** - * @dataProvider provideConvert - */ + #[DataProvider('provideConvert')] public function testConvert(array $options): void { $origFile = $this->objFromFixture(Image::class, 'jpg-image'); @@ -133,7 +130,7 @@ public function testConvert(array $options): void } } - public function provideConvertUnsupported(): array + public static function provideConvertUnsupported(): array { return [ 'nothing to convert from' => [ @@ -181,9 +178,7 @@ public function provideConvertUnsupported(): array ]; } - /** - * @dataProvider provideConvertUnsupported - */ + #[DataProvider('provideConvertUnsupported')] public function testConvertUnsupported(string $fixtureClass, string $fromFixture, string $to, array $options, string $exceptionMessage): void { $file = $this->objFromFixture($fixtureClass, $fromFixture); diff --git a/tests/php/FileFinderTest.php b/tests/php/FileFinderTest.php index e6250de5..93913d35 100644 --- a/tests/php/FileFinderTest.php +++ b/tests/php/FileFinderTest.php @@ -14,10 +14,10 @@ class FileFinderTest extends SapphireTest protected $base; - public function __construct() + public function __construct(string $name) { $this->base = __DIR__ . '/FileFinderTest'; - parent::__construct(); + parent::__construct($name); } public function testBasicOperation() diff --git a/tests/php/FileNameFilterTest.php b/tests/php/FileNameFilterTest.php index e5f986f6..dc595b70 100644 --- a/tests/php/FileNameFilterTest.php +++ b/tests/php/FileNameFilterTest.php @@ -5,6 +5,7 @@ use SilverStripe\Assets\FileNameFilter; use SilverStripe\Dev\SapphireTest; use SilverStripe\View\Parsers\Transliterator; +use PHPUnit\Framework\Attributes\DataProvider; class FileNameFilterTest extends SapphireTest { @@ -59,9 +60,7 @@ public function testFilterWithCustomRules() ); } - /** - * @dataProvider providerFilterWithEmptyString - */ + #[DataProvider('providerFilterWithEmptyString')] public function testFilterWithEmptyString($name) { $filter = new FileNameFilter(); @@ -80,7 +79,7 @@ public function testFilterWithEmptyString($name) ); } - public function providerFilterWithEmptyString() + public static function providerFilterWithEmptyString() { return [['ö ö ö.jpg'], ['新しいファイル.jpg']]; } diff --git a/tests/php/FileTest.php b/tests/php/FileTest.php index e696ce88..6845a14d 100644 --- a/tests/php/FileTest.php +++ b/tests/php/FileTest.php @@ -24,6 +24,7 @@ use SilverStripe\Security\Member; use SilverStripe\Security\PermissionChecker; use SilverStripe\Versioned\Versioned; +use PHPUnit\Framework\Attributes\DataProvider; /** * Tests for the File class @@ -185,7 +186,7 @@ public function testInvalidImageManipulations() $this->assertNull($broken->Pad(100, 100)); } - public function appCategoryDataProvider() + public static function appCategoryDataProvider() { return [ ['image', 'jpg'], @@ -200,9 +201,7 @@ public function appCategoryDataProvider() ]; } - /** - * @dataProvider appCategoryDataProvider - */ + #[DataProvider('appCategoryDataProvider')] public function testAppCategory($category, $extension) { // Test various categories @@ -833,10 +832,10 @@ public function testRename() } /** - * @dataProvider allowedExtensionsProvider * @param array $allowedExtensions * @param array $expected */ + #[DataProvider('allowedExtensionsProvider')] public function testGetAllowedExtensions($allowedExtensions, $expected) { Config::modify()->set(File::class, 'allowed_extensions', $allowedExtensions); @@ -846,7 +845,7 @@ public function testGetAllowedExtensions($allowedExtensions, $expected) /** * @return array[] */ - public function allowedExtensionsProvider() + public static function allowedExtensionsProvider() { return [ 'unkeyed array' => [ @@ -875,7 +874,7 @@ public function allowedExtensionsProvider() public function testCanViewReturnsExtendedResult() { /** @var File&MockObject $file */ - $file = $this->getMockBuilder(File::class)->setMethods(['extendedCan'])->getMock(); + $file = $this->getMockBuilder(File::class)->onlyMethods(['extendedCan'])->getMock(); $file->expects($this->once())->method('extendedCan')->willReturn(true); $this->assertTrue($file->canView()); } @@ -885,7 +884,7 @@ public function testCanViewDelegatesToParentWhenInheritingPermissions() $this->logOut(); /** @var File&MockObject $file */ - $file = $this->getMockBuilder(File::class)->setMethods(['extendedCan'])->getMock(); + $file = $this->getMockBuilder(File::class)->onlyMethods(['extendedCan'])->getMock(); $file->expects($this->once())->method('extendedCan')->willReturn(null); /** @var PermissionChecker&MockObject $permissionChecker */ @@ -938,7 +937,7 @@ public function testCanViewReturnsFalseForAnonymousUsersWithCanViewTypeLoggedInU $this->logOut(); /** @var File&MockObject $file */ - $file = $this->getMockBuilder(File::class)->setMethods(['extendedCan'])->getMock(); + $file = $this->getMockBuilder(File::class)->onlyMethods(['extendedCan'])->getMock(); $file->expects($this->once())->method('extendedCan')->willReturn(null); $file->CanViewType = 'LoggedInUsers'; @@ -950,7 +949,7 @@ public function testCanViewReturnsFalseForAnonymousUsersWithCanViewTypeOnlyThese $this->logOut(); /** @var File&MockObject $file */ - $file = $this->getMockBuilder(File::class)->setMethods(['extendedCan'])->getMock(); + $file = $this->getMockBuilder(File::class)->onlyMethods(['extendedCan'])->getMock(); $file->expects($this->once())->method('extendedCan')->willReturn(null); $file->CanViewType = 'OnlyTheseUsers'; @@ -960,7 +959,7 @@ public function testCanViewReturnsFalseForAnonymousUsersWithCanViewTypeOnlyThese public function testCanViewReturnsTrueForUserInGroupWithCanViewTypeOnlyTheseUsers() { /** @var File&MockObject $file */ - $file = $this->getMockBuilder(File::class)->setMethods(['extendedCan'])->getMock(); + $file = $this->getMockBuilder(File::class)->onlyMethods(['extendedCan'])->getMock(); $file->expects($this->once())->method('extendedCan')->willReturn(null); /** @var Member&MockObject $member */ @@ -976,7 +975,7 @@ public function testCanViewFallsBackToCheckingDefaultFilePermissions() $this->logOut(); /** @var File&MockObject $file */ - $file = $this->getMockBuilder(File::class)->setMethods(['extendedCan'])->getMock(); + $file = $this->getMockBuilder(File::class)->onlyMethods(['extendedCan'])->getMock(); $file->expects($this->once())->method('extendedCan')->willReturn(null); /** @var PermissionChecker&MockObject $permissionChecker */ @@ -992,7 +991,7 @@ public function testCanViewFallsBackToCheckingDefaultFilePermissions() public function testCanEditReturnsExtendedResult() { /** @var File&MockObject $file */ - $file = $this->getMockBuilder(File::class)->setMethods(['extendedCan'])->getMock(); + $file = $this->getMockBuilder(File::class)->onlyMethods(['extendedCan'])->getMock(); $file->expects($this->once())->method('extendedCan')->willReturn(true); $this->assertTrue($file->canEdit()); } @@ -1002,7 +1001,7 @@ public function testCanEditReturnsTrueForUserWithEditAllPermissions() $this->logInWithPermission(); /** @var File&MockObject $file */ - $file = $this->getMockBuilder(File::class)->setMethods(['extendedCan'])->getMock(); + $file = $this->getMockBuilder(File::class)->onlyMethods(['extendedCan'])->getMock(); $file->expects($this->once())->method('extendedCan')->willReturn(null); $this->assertTrue($file->canEdit()); } @@ -1012,7 +1011,7 @@ public function testCanEditDelegatesToParentWhenInheritingPermissions() $this->logOut(); /** @var File&MockObject $file */ - $file = $this->getMockBuilder(File::class)->setMethods(['extendedCan'])->getMock(); + $file = $this->getMockBuilder(File::class)->onlyMethods(['extendedCan'])->getMock(); $file->expects($this->once())->method('extendedCan')->willReturn(null); /** @var PermissionChecker&MockObject $permissionChecker */ @@ -1030,7 +1029,7 @@ public function testCanEditFallsBackToCheckingDefaultFilePermissions() $this->logOut(); /** @var File&MockObject $file */ - $file = $this->getMockBuilder(File::class)->setMethods(['extendedCan'])->getMock(); + $file = $this->getMockBuilder(File::class)->onlyMethods(['extendedCan'])->getMock(); $file->expects($this->once())->method('extendedCan')->willReturn(null); /** @var PermissionChecker&MockObject $permissionChecker */ @@ -1047,7 +1046,7 @@ public function testCanEditFallsBackToCheckingDefaultFilePermissions() * @return Generator * @see testHasRestrictedAccess */ - public function restrictedAccessDataProvider() + public static function restrictedAccessDataProvider() { yield ['restricted-test-r', false]; yield ['restricted-test-r1', false]; @@ -1063,11 +1062,11 @@ public function restrictedAccessDataProvider() } /** - * @dataProvider restrictedAccessDataProvider * * @param string $fixtureName * @param bool $expected */ + #[DataProvider('restrictedAccessDataProvider')] public function testHasRestrictedAccess(string $fixtureName, bool $expected) { /** @var Folder $folder */ diff --git a/tests/php/FilenameParsing/FileIDHelperResolutionStrategyTest.php b/tests/php/FilenameParsing/FileIDHelperResolutionStrategyTest.php index 154a728d..9fd9b6e9 100644 --- a/tests/php/FilenameParsing/FileIDHelperResolutionStrategyTest.php +++ b/tests/php/FilenameParsing/FileIDHelperResolutionStrategyTest.php @@ -18,6 +18,7 @@ use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\SapphireTest; use SilverStripe\Versioned\Versioned; +use PHPUnit\Framework\Attributes\DataProvider; class FileIDHelperResolutionStrategyTest extends SapphireTest { @@ -65,7 +66,7 @@ protected function tearDown(): void parent::tearDown(); } - public function fileList() + public static function fileList() { return [ ['root-file'], @@ -76,9 +77,9 @@ public function fileList() ]; } - public function fileHelperList() + public static function fileHelperList() { - $files = $this->fileList(); + $files = static::fileList(); $list = []; // We're not testing the FileIDHelper implementation here. But there's a bit of split logic based on whatever // the FileIDHelper uses the hash or not. @@ -91,8 +92,8 @@ public function fileHelperList() /** * This method checks that FileID resolve when access directly. - * @dataProvider fileHelperList */ + #[DataProvider('fileHelperList')] public function testDirectResolveFileID($fixtureID, FileIDHelper $helper) { /** @var File $fileDO */ @@ -117,8 +118,8 @@ public function testDirectResolveFileID($fixtureID, FileIDHelper $helper) /** * This method checks that FileID resolve when their file ID Scheme is a secondary resolution mechanism. - * @dataProvider fileHelperList */ + #[DataProvider('fileHelperList')] public function testSecondaryResolveFileID($fixtureID, FileIDHelper $helper) { /** @var File $fileDO */ @@ -142,8 +143,8 @@ public function testSecondaryResolveFileID($fixtureID, FileIDHelper $helper) /** * This method checks that resolve fails when there's an hash mismatch - * @dataProvider fileHelperList */ + #[DataProvider('fileHelperList')] public function testBadHashResolveFileID($fixtureID, FileIDHelper $helper) { /** @var File $fileDO */ @@ -168,8 +169,8 @@ public function testBadHashResolveFileID($fixtureID, FileIDHelper $helper) /** * This method checks that FileID resolve when access directly. - * @dataProvider fileHelperList */ + #[DataProvider('fileHelperList')] public function testDirectSoftResolveFileID($fixtureID, FileIDHelper $helper) { /** @var File $fileDO */ @@ -207,8 +208,8 @@ public function testDirectSoftResolveFileID($fixtureID, FileIDHelper $helper) /** * This method check that older url get redirect to the later ones. This is only relevant for File Scheme with * explicit hash. Natural path URL don't change even when the hash of the file does. - * @dataProvider fileList */ + #[DataProvider('fileList')] public function testSoftResolveOlderFileID($fixtureID) { /** @var File $fileDO */ @@ -243,8 +244,8 @@ public function testSoftResolveOlderFileID($fixtureID) /** * This method checks that FileID resolve when their file ID Scheme is a secondary resolution mechanism. - * @dataProvider fileHelperList */ + #[DataProvider('fileHelperList')] public function testSecondarySoftResolveFileID($fixtureID, FileIDHelper $helper) { /** @var File $fileDO */ @@ -276,8 +277,8 @@ public function testSecondarySoftResolveFileID($fixtureID, FileIDHelper $helper) /** * When a file id can be parsed, but that no file can be found, null should be return. - * @dataProvider fileList */ + #[DataProvider('fileList')] public function testResolveMissingFileID($fixtureID) { /** @var File $fileDO */ @@ -301,7 +302,7 @@ public function testResolveMissingFileID($fixtureID) $this->assertNull($redirect, 'Theres no file on our adapter for resolveFileID to find'); } - public function searchTupleStrategyVariation() + public static function searchTupleStrategyVariation() { $expected = 'expected/abcdef7890/file.txt'; @@ -348,8 +349,8 @@ public function searchTupleStrategyVariation() /** * This method checks that FileID resolve when access directly. - * @dataProvider searchTupleStrategyVariation */ + #[DataProvider('searchTupleStrategyVariation')] public function testSearchForTuple(FileIDHelperResolutionStrategy $strategy, $tuple, $expected) { /** @var FileHashingService $hasher */ @@ -466,7 +467,7 @@ public function testHashlessSearchForTuple() $this->assertEquals($hash, $respPfID->getHash(), 'hash should have been read from main file'); } - public function findVariantsStrategyVariation() + public static function findVariantsStrategyVariation() { $brokenHelper = new BrokenFileIDHelper('nonsense.txt', 'nonsense', '', 'nonsense.txt', false, ''); $mockHelper = new MockFileIDHelper( @@ -512,8 +513,8 @@ public function findVariantsStrategyVariation() /** * This method checks that FileID resolve when access directly. * @param FileIDHelperResolutionStrategy $strategy - * @dataProvider findVariantsStrategyVariation */ + #[DataProvider('findVariantsStrategyVariation')] public function testFindVariant($strategy, $tuple) { $this->fs->write('Folder/FolderFile.pdf', 'version 1'); @@ -599,7 +600,7 @@ public function testParseFileID() $this->assertEmpty($parsedFileID); } - public function listVariantwihtoutFileID() + public static function listVariantwihtoutFileID() { $content = "The quick brown fox jumps over the lazy dog."; $hash = sha1($content ?? ''); @@ -623,9 +624,7 @@ public function listVariantwihtoutFileID() ]; } - /** - * @dataProvider listVariantwihtoutFileID - */ + #[DataProvider('listVariantwihtoutFileID')] public function testGenerateVariantFileID($mainFilePath, $content, ParsedFileID $variantPfid, $expectedFileID) { /** @var FileResolutionStrategy $strategy */ @@ -640,7 +639,7 @@ public function testGenerateVariantFileID($mainFilePath, $content, ParsedFileID } } - public function listVariantParsedFiledID() + public static function listVariantParsedFiledID() { $pfid = new ParsedFileID('folder/file.txt', 'abcdef7890'); $ambigious = new ParsedFileID('decade1980/file.txt', 'abcdef7890'); @@ -678,9 +677,7 @@ public function listVariantParsedFiledID() ]; } - /** - * @dataProvider listVariantParsedFiledID - */ + #[DataProvider('listVariantParsedFiledID')] public function testStripVariant(ParsedFileID $expected, $input) { /** @var FileResolutionStrategy $strategy */ diff --git a/tests/php/FilenameParsing/FileIDHelperTester.php b/tests/php/FilenameParsing/FileIDHelperTester.php index 252e80f1..c6d20661 100644 --- a/tests/php/FilenameParsing/FileIDHelperTester.php +++ b/tests/php/FilenameParsing/FileIDHelperTester.php @@ -1,6 +1,7 @@ getHelper(); @@ -73,28 +72,23 @@ public function testBuildFileID($expected, $input) /** * `buildFileID` accepts an optional `cleanFilename` argument that disables cleaning of filename. - * @dataProvider dirtyFileIDFromDirtyTuple - * @dataProvider fileIDComponents */ + #[DataProvider('dirtyFileIDFromDirtyTuple')] + #[DataProvider('fileIDComponents')] public function testDirtyBuildFildID($expected, $input) { $help = $this->getHelper(); $this->assertEquals($expected, $help->buildFileID(new ParsedFileID(...$input), null, null, false)); } - - /** - * @dataProvider dirtyFilenames - */ + #[DataProvider('dirtyFilenames')] public function testCleanFilename($expected, $input) { $help = $this->getHelper(); $this->assertEquals($expected, $help->cleanFilename($input)); } - /** - * @dataProvider fileIDComponents - */ + #[DataProvider('fileIDComponents')] public function testParseFileID($input, $expected) { $help = $this->getHelper(); @@ -110,10 +104,7 @@ public function testParseFileID($input, $expected) $this->assertEquals($expectedVariant, $parsedFiledID->getVariant()); } - - /** - * @dataProvider brokenFileID - */ + #[DataProvider('brokenFileID')] public function testParseBrokenFileID($input) { $help = $this->getHelper(); @@ -121,10 +112,7 @@ public function testParseBrokenFileID($input) $this->assertNull($parsedFiledID); } - - /** - * @dataProvider variantOf - */ + #[DataProvider('variantOf')] public function testVariantOf($variantFileID, ParsedFileID $original, $expected) { $help = $this->getHelper(); @@ -132,9 +120,7 @@ public function testVariantOf($variantFileID, ParsedFileID $original, $expected) $this->assertEquals($expected, $isVariantOf); } - /** - * @dataProvider variantIn - */ + #[DataProvider('variantIn')] public function testLookForVariantIn(ParsedFileID $original, $expected) { $help = $this->getHelper(); diff --git a/tests/php/FilenameParsing/HashFileIDHelperTest.php b/tests/php/FilenameParsing/HashFileIDHelperTest.php index 18a2935d..84728159 100644 --- a/tests/php/FilenameParsing/HashFileIDHelperTest.php +++ b/tests/php/FilenameParsing/HashFileIDHelperTest.php @@ -7,16 +7,17 @@ use SilverStripe\Assets\FilenameParsing\HashFileIDHelper; use SilverStripe\Assets\FilenameParsing\ParsedFileID; use SilverStripe\Core\Convert; +use PHPUnit\Framework\Attributes\DataProvider; class HashFileIDHelperTest extends FileIDHelperTester { - protected function getHelper() + protected static function getHelper() { return new HashFileIDHelper(); } - public function fileIDComponents() + public static function fileIDComponents() { return [ // Common use case @@ -45,7 +46,7 @@ public function fileIDComponents() ]; } - public function dirtyFileIDComponents() + public static function dirtyFileIDComponents() { return [ // Cases that need clean up @@ -61,7 +62,7 @@ public function dirtyFileIDComponents() ]; } - public function dirtyFileIDFromDirtyTuple() + public static function dirtyFileIDFromDirtyTuple() { return [ // Cases that need clean up @@ -77,7 +78,7 @@ public function dirtyFileIDFromDirtyTuple() ]; } - function dirtyFilenames() + public static function dirtyFilenames() { return [ ['sam.jpg', 'sam.jpg'], @@ -90,7 +91,7 @@ function dirtyFilenames() ]; } - public function brokenFileID() + public static function brokenFileID() { return [ ['sam.jpg'], @@ -103,7 +104,7 @@ public function brokenFileID() ]; } - public function variantOf() + public static function variantOf() { return [ [ @@ -159,7 +160,7 @@ public function variantOf() ]; } - public function variantIn() + public static function variantIn() { return [ [new ParsedFileID('sam.jpg', 'abcdef7890'), 'abcdef7890'], @@ -177,7 +178,7 @@ public function testHashlessBuildFileID() $this->getHelper()->buildFileID('Filename.txt', ''); } - public function provideRewriteExtension() + public static function provideRewriteExtension() { $jpgToPng = 'ExtRewrite' . Convert::base64url_encode(['jpg', 'png']); @@ -193,9 +194,7 @@ public function provideRewriteExtension() ]; } - /** - * @dataProvider provideRewriteExtension - */ + #[DataProvider('provideRewriteExtension')] public function testRewriteVariantExtension($variant, $inFilename, $outFilename) { $helper = new HashFileIDHelper(); @@ -207,9 +206,7 @@ public function testRewriteVariantExtension($variant, $inFilename, $outFilename) $this->assertEquals($outFilename, $actualFilename); } - /** - * @dataProvider provideRewriteExtension - */ + #[DataProvider('provideRewriteExtension')] public function testRestoreOriginalExtension($variant, $outFilename, $inFilename) { $helper = new HashFileIDHelper(); diff --git a/tests/php/FilenameParsing/NaturalFileIDHelperTest.php b/tests/php/FilenameParsing/NaturalFileIDHelperTest.php index 075f3e0a..63aee49f 100644 --- a/tests/php/FilenameParsing/NaturalFileIDHelperTest.php +++ b/tests/php/FilenameParsing/NaturalFileIDHelperTest.php @@ -7,12 +7,12 @@ class NaturalFileIDHelperTest extends FileIDHelperTester { - protected function getHelper() + protected static function getHelper() { return new NaturalFileIDHelper(); } - public function fileIDComponents() + public static function fileIDComponents() { return [ // Common use case @@ -43,7 +43,7 @@ public function fileIDComponents() ]; } - public function dirtyFileIDComponents() + public static function dirtyFileIDComponents() { return [ ['sam.jpg', [ @@ -73,7 +73,7 @@ public function dirtyFileIDComponents() ]; } - public function dirtyFileIDFromDirtyTuple() + public static function dirtyFileIDFromDirtyTuple() { return [ ['sam__double-under-score.jpg', [ @@ -97,7 +97,7 @@ public function dirtyFileIDFromDirtyTuple() ]; } - function dirtyFilenames() + public static function dirtyFilenames() { return [ ['sam.jpg', 'sam.jpg'], @@ -110,7 +110,7 @@ function dirtyFilenames() ]; } - public function brokenFileID() + public static function brokenFileID() { return [ ['/sam.jpg'], @@ -119,7 +119,7 @@ public function brokenFileID() ]; } - public function variantOf() + public static function variantOf() { return [ [ @@ -170,7 +170,7 @@ public function variantOf() ]; } - public function variantIn() + public static function variantIn() { return [ [new ParsedFileID('sam.jpg'), ''], diff --git a/tests/php/Flysystem/FlysystemAssetStoreTest.php b/tests/php/Flysystem/FlysystemAssetStoreTest.php index 029eb415..1486d6ab 100644 --- a/tests/php/Flysystem/FlysystemAssetStoreTest.php +++ b/tests/php/Flysystem/FlysystemAssetStoreTest.php @@ -11,6 +11,7 @@ use SilverStripe\Assets\Tests\FilenameParsing\FileIDHelperResolutionStrategyTest; use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\SapphireTest; +use PHPUnit\Framework\Attributes\DataProvider; class FlysystemAssetStoreTest extends SapphireTest { @@ -45,29 +46,29 @@ protected function setUp(): void parent::setUp(); $this->publicAdapter = $this->getMockBuilder(PublicAssetAdapter::class) - ->setMethods(['getPublicUrl']) + ->onlyMethods(['getPublicUrl']) ->getMock(); $this->publicFilesystem = $this->getMockBuilder(Filesystem::class) - ->setMethods(['has', 'read', 'readStream', 'lastModified']) + ->onlyMethods(['has', 'read', 'readStream', 'lastModified']) ->setConstructorArgs([$this->publicAdapter]) ->getMock(); $this->protectedAdapter = $this->getMockBuilder(ProtectedAssetAdapter::class) - ->setMethods(['getProtectedUrl']) + ->onlyMethods(['getProtectedUrl']) ->getMock(); $this->protectedFilesystem = $this->getMockBuilder(Filesystem::class) - ->setMethods(['has', 'read', 'readStream', 'lastModified']) + ->onlyMethods(['has', 'read', 'readStream', 'lastModified']) ->setConstructorArgs([$this->protectedAdapter]) ->getMock(); $this->publicStrategy = $this->getMockBuilder(FileIDHelperResolutionStrategy::class) - ->setMethods(['searchForTuple']) + ->onlyMethods(['searchForTuple']) ->getMock(); $this->protectedStrategy = $this->getMockBuilder(FileIDHelperResolutionStrategy::class) - ->setMethods(['searchForTuple']) + ->onlyMethods(['searchForTuple']) ->getMock(); } @@ -94,8 +95,8 @@ public function testGetAsUrlDoesntGrantForPublicAssets() /** * @param boolean $grant - * @dataProvider protectedUrlGrantProvider */ + #[DataProvider('protectedUrlGrantProvider')] public function testGetAsUrlWithGrant($grant) { $this->publicFilesystem->expects($this->atLeastOnce())->method('has')->willReturn(false); @@ -120,7 +121,7 @@ public function testGetAsUrlWithGrant($grant) /** * @return array[] */ - public function protectedUrlGrantProvider() + public static function protectedUrlGrantProvider() { return [ [true], diff --git a/tests/php/GDImageTest.php b/tests/php/GDImageTest.php index 81f44fe3..8d2807c9 100644 --- a/tests/php/GDImageTest.php +++ b/tests/php/GDImageTest.php @@ -10,7 +10,7 @@ use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\SilverStripeServiceConfigurationLocator; -class GDImageTest extends ImageTest +class GDImageTest extends ImageTestBase { protected function setUp(): void { diff --git a/tests/php/ImageManipulationTest.php b/tests/php/ImageManipulationTest.php index c872f113..5e815f0a 100644 --- a/tests/php/ImageManipulationTest.php +++ b/tests/php/ImageManipulationTest.php @@ -23,13 +23,14 @@ use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\SapphireTest; use SilverStripe\View\SSViewer; +use PHPUnit\Framework\Attributes\DataProvider; /** * ImageTest is abstract and should be overridden with manipulator-specific subtests */ class ImageManipulationTest extends SapphireTest { - protected static $fixture_file = 'ImageTest.yml'; + protected static $fixture_file = 'ImageTestBase.yml'; protected function setUp(): void { @@ -285,7 +286,7 @@ public function testAttributesHTML() ); } - public function lazyLoadProvider() + public static function lazyLoadProvider() { return [ 'false (bool)' => [false, false], @@ -305,8 +306,8 @@ public function lazyLoadProvider() /** * @param $val * @param $expected - * @dataProvider lazyLoadProvider */ + #[DataProvider('lazyLoadProvider')] public function testLazyLoad($val, bool $expected) { /** @var Image $origin */ @@ -324,7 +325,7 @@ public function testLazyLoad($val, bool $expected) ); } - public function lazyLoadBadProvider() + public static function lazyLoadBadProvider() { return [ 'null' => [null], @@ -339,8 +340,8 @@ public function lazyLoadBadProvider() /** * @param $val - * @dataProvider lazyLoadBadProvider */ + #[DataProvider('lazyLoadBadProvider')] public function testBadLazyLoad($val) { /** @var Image $origin */ @@ -390,7 +391,7 @@ public function testLazyLoadIsAccessibleInExtensions() Image::remove_extension(LazyLoadAccessorExtension::class); } - public function renderProvider() + public static function renderProvider() { $alt = 'This is a image Title'; $src = '/assets/ImageTest/folder/test-image.png'; @@ -441,9 +442,7 @@ public function renderProvider() ]; } - /** - * @dataProvider renderProvider - */ + #[DataProvider('renderProvider')] public function testRender(string $template, string $expected) { /** @var Image $origin */ @@ -563,27 +562,25 @@ function (AssetStore $store, string $filename, string $hash, string $variant) { $this->assertSame('Any content will do - csv is just a text file afterall', $manipulated->getString()); } - public function provideConvert(): array + public static function provideConvert(): array { return [ 'supported conversion' => [ 'originalFileFixtureClass' => File::class, 'originalFileFixture' => 'notImage', - 'toFormat' => 'jpg', + 'toExtension' => 'jpg', 'success' => true, ], 'unsupported conversion' => [ 'originalFileFixtureClass' => File::class, 'originalFileFixture' => 'notImage', - 'toFormat' => 'pdf', + 'toExtension' => 'pdf', 'success' => false, ], ]; } - /** - * @dataProvider provideConvert - */ + #[DataProvider('provideConvert')] public function testConvert(string $originalFileFixtureClass, string $originalFileFixture, string $toExtension, bool $success): void { // Make sure we have a known set of converters for testing @@ -606,7 +603,7 @@ public function testConvert(string $originalFileFixtureClass, string $originalFi } } - public function provideConvertChainWithLazyLoad(): array + public static function provideConvertChainWithLazyLoad(): array { return [ [true], @@ -614,9 +611,7 @@ public function provideConvertChainWithLazyLoad(): array ]; } - /** - * @dataProvider provideConvertChainWithLazyLoad - */ + #[DataProvider('provideConvertChainWithLazyLoad')] public function testConvertChainWithLazyLoad(bool $lazyLoad): void { // Make sure we have a known set of converters for testing diff --git a/tests/php/ImageTest.php b/tests/php/ImageTestBase.php similarity index 95% rename from tests/php/ImageTest.php rename to tests/php/ImageTestBase.php index a9f98791..8d86b2e4 100644 --- a/tests/php/ImageTest.php +++ b/tests/php/ImageTestBase.php @@ -18,13 +18,14 @@ use SilverStripe\Core\Convert; use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\SapphireTest; +use PHPUnit\Framework\Attributes\DataProvider; /** * ImageTest is abstract and should be overridden with manipulator-specific subtests */ -abstract class ImageTest extends SapphireTest +abstract class ImageTestBase extends SapphireTest { - protected static $fixture_file = 'ImageTest.yml'; + protected static $fixture_file = 'ImageTestBase.yml'; protected function setUp(): void { @@ -332,11 +333,11 @@ public function testImageResizeValidate() } /** - * @dataProvider providerTestImageResizeInvalid * @param $width * @param $height * @param $error */ + #[DataProvider('providerTestImageResizeInvalid')] public function testImageResizeInvalid($width, $height, $error) { $this->expectException(\InvalidArgumentException::class); @@ -346,7 +347,7 @@ public function testImageResizeInvalid($width, $height, $error) $image->Pad($width, $height); } - public function providerTestImageResizeInvalid() + public static function providerTestImageResizeInvalid() { return [ ['-1', 100, 'Width must be positive'], @@ -460,7 +461,7 @@ public function testCacheErrorLoading() $container = $this->getMockAssetBackend($filename, $hash); $container ->expects($this->any())->method('getStream') - ->will($this->returnValue(null)); // Should safely trigger error in InterventionBackend::getImageResource() + ->willReturn(null); // Should safely trigger error in InterventionBackend::getImageResource() // Test backend /** @var InterventionBackend $backend */ @@ -510,7 +511,7 @@ public function testCacheErrorInvalid() $stream = fopen(__DIR__.'/ImageTest/not-image.txt', 'r'); $container ->expects($this->any())->method('getStream') - ->will($this->returnValue($stream)); + ->willReturn($stream); // Test backend /** @var InterventionBackend $backend */ @@ -545,9 +546,15 @@ public function testGetSetImageBackend() { $image = $this->objFromFixture(Image::class, 'imageWithTitle'); $this->assertInstanceOf(Image_Backend::class, $image->getImageBackend()); - - $mockBackend = $this->getMockBuilder(InterventionBackend::class)->getMock(); - $mockBackend->expects($this->any())->method('getWidth')->will($this->returnValue(99999)); + // Using anonymous class rather than PHPUnit getMockBuilder() to prevent error + // Error: Typed property MockObject_InterventionBackend_1695e44d::$__phpunit_state + // must not be accessed before initialization + $mockBackend = new class extends InterventionBackend { + public function getWidth(): int + { + return 99999; + } + }; $image->setImageBackend($mockBackend); $this->assertEquals(99999, $image->getWidth()); } @@ -560,11 +567,11 @@ public function testGetSetImageBackend() protected function getMockAssetBackend($filename, $hash) { $builder = $this->getMockBuilder(AssetContainer::class)->getMock(); - $builder->expects($this->any())->method('exists')->will($this->returnValue(true)); - $builder->expects($this->any())->method('getFilename')->will($this->returnValue($filename)); - $builder->expects($this->any())->method('getHash')->will($this->returnValue($hash)); - $builder->expects($this->any())->method('getVariant')->will($this->returnValue(null)); - $builder->expects($this->any())->method('getIsImage')->will($this->returnValue(true)); + $builder->expects($this->any())->method('exists')->willReturn(true); + $builder->expects($this->any())->method('getFilename')->willReturn($filename); + $builder->expects($this->any())->method('getHash')->willReturn($hash); + $builder->expects($this->any())->method('getVariant')->willReturn(null); + $builder->expects($this->any())->method('getIsImage')->willReturn(true); return $builder; } diff --git a/tests/php/ImageTest.yml b/tests/php/ImageTestBase.yml similarity index 100% rename from tests/php/ImageTest.yml rename to tests/php/ImageTestBase.yml diff --git a/tests/php/ImagickImageTest.php b/tests/php/ImagickImageTest.php index 1c9a50b3..45437f36 100644 --- a/tests/php/ImagickImageTest.php +++ b/tests/php/ImagickImageTest.php @@ -10,7 +10,7 @@ use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\SilverStripeServiceConfigurationLocator; -class ImagickImageTest extends ImageTest +class ImagickImageTest extends ImageTestBase { protected function setUp(): void { diff --git a/tests/php/ProtectedFileControllerTest.php b/tests/php/ProtectedFileControllerTest.php index d8f54415..46d8f12a 100644 --- a/tests/php/ProtectedFileControllerTest.php +++ b/tests/php/ProtectedFileControllerTest.php @@ -12,6 +12,7 @@ use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\FunctionalTest; use SilverStripe\Versioned\Versioned; +use PHPUnit\Framework\Attributes\DataProvider; class ProtectedFileControllerTest extends FunctionalTest { @@ -50,9 +51,7 @@ protected function tearDown(): void parent::tearDown(); } - /** - * @dataProvider getFilenames - */ + #[DataProvider('getFilenames')] public function testIsValidFilename($name, $isValid) { $controller = new ProtectedFileController(); @@ -63,7 +62,7 @@ public function testIsValidFilename($name, $isValid) ); } - public function getFilenames() + public static function getFilenames() { return [ // Valid names diff --git a/tests/php/PublicAssetAdapterTest.php b/tests/php/PublicAssetAdapterTest.php index d39cd24b..a946bef1 100644 --- a/tests/php/PublicAssetAdapterTest.php +++ b/tests/php/PublicAssetAdapterTest.php @@ -5,6 +5,7 @@ use SilverStripe\Assets\Flysystem\PublicAssetAdapter; use SilverStripe\Control\Director; use SilverStripe\Dev\SapphireTest; +use PHPUnit\Framework\Attributes\DataProvider; class PublicAssetAdapterTest extends SapphireTest { @@ -29,7 +30,7 @@ public function testInitBaseURL() ); } - public function provideGetPublicUrl(): array + public static function provideGetPublicUrl(): array { return [ 'filename' => [ @@ -47,9 +48,7 @@ public function provideGetPublicUrl(): array ]; } - /** - * @dataProvider provideGetPublicUrl - */ + #[DataProvider('provideGetPublicUrl')] public function testGetPublicUrl(string $path, string $expected) { $adapter = new PublicAssetAdapter('assets'); diff --git a/tests/php/RedirectFileControllerTest.php b/tests/php/RedirectFileControllerTest.php index 446bd645..f3366581 100644 --- a/tests/php/RedirectFileControllerTest.php +++ b/tests/php/RedirectFileControllerTest.php @@ -15,6 +15,7 @@ use SilverStripe\Control\HTTPResponse; use SilverStripe\Assets\Dev\TestAssetStore; use SilverStripe\Versioned\Versioned; +use PHPUnit\Framework\Attributes\DataProvider; class RedirectFileControllerTest extends FunctionalTest { @@ -60,7 +61,7 @@ protected function tearDown(): void parent::tearDown(); } - public function fileList() + public static function fileList() { return [ 'root file' => ['asdf'], @@ -70,9 +71,7 @@ public function fileList() ]; } - /** - * @dataProvider fileList - */ + #[DataProvider('fileList')] public function testPermanentFilenameRedirect($fixtureID) { /** @var File $file */ @@ -113,8 +112,8 @@ public function testPermanentFilenameRedirect($fixtureID) /** * This test a file publish under the hash path, will redirect natural path - * @dataProvider fileList */ + #[DataProvider('fileList')] public function testTemporaryFilenameRedirect($fixtureID) { /** @var File $file */ @@ -160,9 +159,7 @@ public function testTemporaryFilenameRedirect($fixtureID) } - /** - * @dataProvider fileList - */ + #[DataProvider('fileList')] public function testRedirectWithDraftFile($fixtureID) { $hashHelper = new HashFileIDHelper(); @@ -207,9 +204,7 @@ public function testRedirectWithDraftFile($fixtureID) ); } - /** - * @dataProvider fileList - */ + #[DataProvider('fileList')] public function testRedirectAfterPublishSecondVersion($fixtureID) { $hashHelper = new HashFileIDHelper(); @@ -255,9 +250,7 @@ public function testRedirectAfterPublishSecondVersion($fixtureID) ); } - /** - * @dataProvider fileList - */ + #[DataProvider('fileList')] public function testRedirectAfterUnpublish($fixtureID) { /** @var File $file */ @@ -303,9 +296,7 @@ public function testRedirectAfterUnpublish($fixtureID) ); } - /** - * @dataProvider fileList - */ + #[DataProvider('fileList')] public function testRedirectAfterDeleting($fixtureID) { /** @var File $file */ @@ -349,7 +340,7 @@ public function testRedirectAfterDeleting($fixtureID) ); } - public function imageList() + public static function imageList() { return [ ['', 'test', 'jpg'], @@ -359,9 +350,7 @@ public function imageList() ]; } - /** - * @dataProvider imageList - */ + #[DataProvider('imageList')] public function testVariantRedirect($folderFixture, $filename, $ext) { /** @var Image $file */ @@ -418,9 +407,7 @@ public function testVariantRedirect($folderFixture, $filename, $ext) ); } - /** - * @dataProvider fileList - */ + #[DataProvider('fileList')] public function testDraftOnlyArchivedVersion($fixtureID) { $file = $this->objFromFixture(File::class, $fixtureID); diff --git a/tests/php/RedirectKeepArchiveFileControllerTest.php b/tests/php/RedirectKeepArchiveFileControllerTest.php index 9ca3fab2..cc38fcef 100644 --- a/tests/php/RedirectKeepArchiveFileControllerTest.php +++ b/tests/php/RedirectKeepArchiveFileControllerTest.php @@ -11,6 +11,7 @@ use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\FunctionalTest; use SilverStripe\Control\HTTPResponse; +use PHPUnit\Framework\Attributes\DataProvider; /** * We rerun all the same test in `RedirectFileControllerTest` but with keep_archived_assets on @@ -24,9 +25,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @dataProvider fileList - */ + #[DataProvider('fileList')] public function testRedirectAfterUnpublish($fixtureID) { /** @var File $file */ @@ -95,9 +94,8 @@ public function testRedirectAfterUnpublish($fixtureID) /** * When keeping archives. The old files should still be there. So the protected adapter should deny you access to * them. - * - * @dataProvider fileList */ + #[DataProvider('fileList')] public function testRedirectAfterDeleting($fixtureID) { /** @var File $file */ @@ -153,9 +151,8 @@ public function testRedirectAfterDeleting($fixtureID) /** * When keeping archives. The old files should still be there. So the protected adapter should deny you access to * them. - * - * @dataProvider fileList */ + #[DataProvider('fileList')] public function testResolvedArchivedFile($fixtureID) { /** @var File $file */ @@ -208,9 +205,7 @@ public function testResolvedArchivedFile($fixtureID) ); } - /** - * @dataProvider imageList - */ + #[DataProvider('imageList')] public function testVariantRedirect($folderFixture, $filename, $ext) { parent::testVariantRedirect($folderFixture, $filename, $ext); diff --git a/tests/php/Shortcodes/ImageShortcodeProviderTest.php b/tests/php/Shortcodes/ImageShortcodeProviderTest.php index 35e6102e..6951ed0c 100644 --- a/tests/php/Shortcodes/ImageShortcodeProviderTest.php +++ b/tests/php/Shortcodes/ImageShortcodeProviderTest.php @@ -16,11 +16,12 @@ use SilverStripe\Security\InheritedPermissions; use SilverStripe\Security\Member; use DOMDocument; +use PHPUnit\Framework\Attributes\DataProvider; class ImageShortcodeProviderTest extends SapphireTest { - protected static $fixture_file = '../ImageTest.yml'; + protected static $fixture_file = '../ImageTestBase.yml'; protected function setUp(): void { @@ -471,7 +472,7 @@ public function testWhiteIsConfigurable() ); } - public function gettersAndSettersProvider(): array + public static function gettersAndSettersProvider(): array { return [ 'image without special characters' => [ @@ -499,9 +500,7 @@ public function gettersAndSettersProvider(): array ]; } - /** - * @dataProvider gettersAndSettersProvider - */ + #[DataProvider('gettersAndSettersProvider')] public function testCreateImageTag(string $expected, array $attributes) { $this->assertEquals($expected, ImageShortcodeProvider::createImageTag($attributes)); diff --git a/tests/php/Storage/AssetStoreTest.php b/tests/php/Storage/AssetStoreTest.php index fd38c2d0..53d6d006 100644 --- a/tests/php/Storage/AssetStoreTest.php +++ b/tests/php/Storage/AssetStoreTest.php @@ -18,6 +18,7 @@ use SilverStripe\Core\Config\Config; use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\SapphireTest; +use PHPUnit\Framework\Attributes\DataProvider; class AssetStoreTest extends SapphireTest { @@ -235,7 +236,7 @@ public function testConflictResolution() * * @return array */ - public function dataProviderFileIDs() + public static function dataProviderFileIDs() { return [ [ @@ -300,7 +301,7 @@ public function dataProviderFileIDs() /** * Data providers for files which need cleaning up (only when generating fileID) */ - public function dataProviderDirtyFileIDs() + public static function dataProviderDirtyFileIDs() { return [ [ @@ -317,11 +318,11 @@ public function dataProviderDirtyFileIDs() /** * Test internal file Id generation * - * @dataProvider dataProviderFileIDs - * @dataProvider dataProviderDirtyFileIDs * @param string $fileID Expected file ID * @param array $tuple Tuple that generates this file ID */ + #[DataProvider('dataProviderFileIDs')] + #[DataProvider('dataProviderDirtyFileIDs')] public function testGetFileID($fileID, $tuple) { /** @var TestAssetStore $store */ @@ -579,7 +580,7 @@ public function testStoreLocationWritingLogic() $this->assertFileExists(ASSETS_PATH . '/AssetStoreTest/explicitelyPublicStore__variant.txt'); } - public function listOfVariantsToWrite() + public static function listOfVariantsToWrite() { $content = "The quick brown fox jumps over the lazy dog."; $hash = sha1($content ?? ''); @@ -605,8 +606,8 @@ public function listOfVariantsToWrite() /** * Make sure that variants are written next to their parent file - * @dataProvider listOfVariantsToWrite */ + #[DataProvider('listOfVariantsToWrite')] public function testVariantWriteNextToFile( $fsName, $mainFilePath, @@ -629,7 +630,7 @@ public function testVariantWriteNextToFile( $this->assertTrue($fs->fileExists($expectedVariantPath)); } - public function listOfFilesToNormalise() + public static function listOfFilesToNormalise() { $public = AssetStore::VISIBILITY_PUBLIC; $protected = AssetStore::VISIBILITY_PROTECTED; @@ -692,7 +693,6 @@ public function listOfFilesToNormalise() } /** - * @dataProvider listOfFilesToNormalise * @param string $fsName * @param array $contents * @param string $filename @@ -700,6 +700,7 @@ public function listOfFilesToNormalise() * @param array $expected * @param array $notExpected */ + #[DataProvider('listOfFilesToNormalise')] public function testNormalise($fsName, array $contents, $filename, $hash, array $expected, array $notExpected = []) { /** @var FileIDHelperResolutionStrategy $protectedStrat */ @@ -728,7 +729,7 @@ public function testNormalise($fsName, array $contents, $filename, $hash, array $protectedStrat->setResolutionFileIDHelpers($originalHelpers); } - public function listOfFileIDsToNormalise() + public static function listOfFileIDsToNormalise() { $public = AssetStore::VISIBILITY_PUBLIC; $protected = AssetStore::VISIBILITY_PROTECTED; @@ -821,13 +822,13 @@ public function listOfFileIDsToNormalise() } /** - * @dataProvider listOfFileIDsToNormalise * @param string $fsName * @param array $contents * @param string $fileID * @param array $expected * @param array $notExpected */ + #[DataProvider('listOfFileIDsToNormalise')] public function testNormalisePath( $fsName, array $contents,