From 21b53cd06b7ce2e2e14071c22321d1bff1ffeca5 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 10 Sep 2024 11:15:29 +1200 Subject: [PATCH] DEP Use PHPUnit 11 --- composer.json | 2 +- tests/php/Controller/AssetAdminOpenTest.php | 7 ++- tests/php/Controller/AssetAdminTest.php | 43 +++++++------------ tests/php/Forms/RemoteFileFormFactoryTest.php | 9 ++-- tests/php/Forms/UploadFieldTest.php | 7 ++- tests/php/Model/ThumbnailGeneratorTest.php | 7 ++- 6 files changed, 30 insertions(+), 45 deletions(-) diff --git a/composer.json b/composer.json index cf4c4d108..4e0202817 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "silverstripe/admin": "^3" }, "require-dev": { - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^11.3", "silverstripe/frameworktest": "^2", "squizlabs/php_codesniffer": "^3.7", "silverstripe/cms": "^6", diff --git a/tests/php/Controller/AssetAdminOpenTest.php b/tests/php/Controller/AssetAdminOpenTest.php index 2160e0387..e369bc6fd 100644 --- a/tests/php/Controller/AssetAdminOpenTest.php +++ b/tests/php/Controller/AssetAdminOpenTest.php @@ -9,6 +9,7 @@ use SilverStripe\Assets\Folder; use SilverStripe\Assets\File; use SilverStripe\Versioned\Versioned; +use PHPUnit\Framework\Attributes\DataProvider; class AssetAdminOpenTest extends FunctionalTest { @@ -44,7 +45,7 @@ protected function tearDown(): void parent::tearDown(); } - public function provideApiRead(): array + public static function provideApiRead(): array { return [ 'Valid' => [ @@ -138,9 +139,7 @@ public function provideApiRead(): array ]; } - /** - * @dataProvider provideApiRead - */ + #[DataProvider('provideApiRead')] public function testApiRead( string $idType, string $fail, diff --git a/tests/php/Controller/AssetAdminTest.php b/tests/php/Controller/AssetAdminTest.php index cac758ea5..00458aee5 100644 --- a/tests/php/Controller/AssetAdminTest.php +++ b/tests/php/Controller/AssetAdminTest.php @@ -20,6 +20,7 @@ use SilverStripe\Security\SecurityToken; use SilverStripe\Core\Config\Config; use SilverStripe\AssetAdmin\Tests\Controller\AssetAdminTest\FilesInUseFileExtension; +use PHPUnit\Framework\Attributes\DataProvider; /** * Tests {@see AssetAdmin} @@ -473,7 +474,7 @@ public function testGetClientConfigExtensions() }); } - public function provideApiReadDescendantCounts(): array + public static function provideApiReadDescendantCounts(): array { return [ 'Valid' => [ @@ -514,9 +515,7 @@ public function provideApiReadDescendantCounts(): array ]; } - /** - * @dataProvider provideApiReadDescendantCounts - */ + #[DataProvider('provideApiReadDescendantCounts')] public function testApiReadDescendantCounts( string $idsType, string $fail, @@ -556,7 +555,7 @@ public function testApiReadDescendantCounts( } } - public function provideApiReadLiveOwnerCounts(): array + public static function provideApiReadLiveOwnerCounts(): array { return [ 'Valid' => [ @@ -597,9 +596,7 @@ public function provideApiReadLiveOwnerCounts(): array ]; } - /** - * @dataProvider provideApiReadLiveOwnerCounts - */ + #[DataProvider('provideApiReadLiveOwnerCounts')] public function testApiReadLiveOwnerCounts( string $idsType, string $fail, @@ -651,7 +648,7 @@ public function testApiReadLiveOwnerCounts( } } - public function provideApiReadUsage(): array + public static function provideApiReadUsage(): array { return [ 'Valid' => [ @@ -682,9 +679,7 @@ public function provideApiReadUsage(): array ]; } - /** - * @dataProvider provideApiReadUsage - */ + #[DataProvider('provideApiReadUsage')] public function testApiReadUsage( string $idType, string $fail, @@ -708,7 +703,7 @@ public function testApiReadUsage( } } - public function provideApiDelete(): array + public static function provideApiDelete(): array { return [ 'Valid' => [ @@ -759,9 +754,7 @@ public function provideApiDelete(): array ]; } - /** - * @dataProvider provideApiDelete - */ + #[DataProvider('provideApiDelete')] public function testApiDelete( string $idsType, string $fail, @@ -797,7 +790,7 @@ public function testApiDelete( } } - public function provideApiMove(): array + public static function provideApiMove(): array { return [ 'Valid' => [ @@ -858,9 +851,7 @@ public function provideApiMove(): array ]; } - /** - * @dataProvider provideApiMove - */ + #[DataProvider('provideApiMove')] public function testApiMove( string $idsType, string $fail, @@ -910,7 +901,7 @@ public function testApiMove( } } - public function provideApiPublish(): array + public static function provideApiPublish(): array { return [ 'Valid' => [ @@ -961,9 +952,7 @@ public function provideApiPublish(): array ]; } - /** - * @dataProvider provideApiPublish - */ + #[DataProvider('provideApiPublish')] public function testApiPublish( string $idsType, string $fail, @@ -1013,7 +1002,7 @@ public function testApiPublish( } } - public function provideApiUnpublish(): array + public static function provideApiUnpublish(): array { return [ 'Valid' => [ @@ -1064,9 +1053,7 @@ public function provideApiUnpublish(): array ]; } - /** - * @dataProvider provideApiUnpublish - */ + #[DataProvider('provideApiUnpublish')] public function testApiUnpublish( string $idsType, string $fail, diff --git a/tests/php/Forms/RemoteFileFormFactoryTest.php b/tests/php/Forms/RemoteFileFormFactoryTest.php index 5c7df1370..f0f96a7c7 100644 --- a/tests/php/Forms/RemoteFileFormFactoryTest.php +++ b/tests/php/Forms/RemoteFileFormFactoryTest.php @@ -9,6 +9,7 @@ use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\Form; use SilverStripe\View\Embed\Embeddable; +use PHPUnit\Framework\Attributes\DataProvider; class RemoteFileFormFactoryTest extends SapphireTest { @@ -33,7 +34,7 @@ protected function setUp(): void ]); } - public function providerTestAcceptedURLs() + public static function providerTestAcceptedURLs() { return [ [ @@ -74,10 +75,10 @@ public function providerTestAcceptedURLs() } /** - * @dataProvider providerTestAcceptedURLs * @param array $config Config to merge * @param string $acceptedURL OK url */ + #[DataProvider('providerTestAcceptedURLs')] public function testAcceptedURLs($config, $acceptedURL) { foreach ($config as $key => $value) { @@ -93,7 +94,7 @@ public function testAcceptedURLs($config, $acceptedURL) $this->assertInstanceOf(Form::class, $fields); } - public function providerTestRejectedURLs() + public static function providerTestRejectedURLs() { return [ [ @@ -140,11 +141,11 @@ public function providerTestRejectedURLs() } /** - * @dataProvider providerTestRejectedURLs * @param array $config Config to merge * @param string $rejectedURL rejected url * @param string $rejectedMessage */ + #[DataProvider('providerTestRejectedURLs')] public function testRejectedURLS($config, $rejectedURL) { $this->expectException(InvalidRemoteUrlException::class); diff --git a/tests/php/Forms/UploadFieldTest.php b/tests/php/Forms/UploadFieldTest.php index 7ba65c160..a6a87ebd1 100644 --- a/tests/php/Forms/UploadFieldTest.php +++ b/tests/php/Forms/UploadFieldTest.php @@ -15,6 +15,7 @@ use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\ORM\ArrayList; +use PHPUnit\Framework\Attributes\DataProvider; class UploadFieldTest extends SapphireTest { @@ -47,7 +48,7 @@ protected function tearDown(): void parent::tearDown(); } - public function provideGetUploadMaxFileSize(): array + public static function provideGetUploadMaxFileSize(): array { return [ [ @@ -61,9 +62,7 @@ public function provideGetUploadMaxFileSize(): array ]; } - /** - * @dataProvider provideGetUploadMaxFileSize - */ + #[DataProvider('provideGetUploadMaxFileSize')] public function testGetUploadMaxFileSize(?int $adminMaxFileSize, int $expected): void { Upload_Validator::config()->set('default_max_file_size', ['*' => 100]); diff --git a/tests/php/Model/ThumbnailGeneratorTest.php b/tests/php/Model/ThumbnailGeneratorTest.php index 259e96713..c5eb033f6 100644 --- a/tests/php/Model/ThumbnailGeneratorTest.php +++ b/tests/php/Model/ThumbnailGeneratorTest.php @@ -9,6 +9,7 @@ use Silverstripe\Assets\Dev\TestAssetStore; use SilverStripe\Core\Config\Config; use SilverStripe\Dev\SapphireTest; +use PHPUnit\Framework\Attributes\DataProvider; class ThumbnailGeneratorTest extends SapphireTest { @@ -117,7 +118,7 @@ public function testGenerateLink() $this->assertEquals('/assets/906835357d/TestImage__FitMaxWzEwMCwyMDBd.png', $thumbnail); } - public function provideAnimatedThumbnail(): array + public static function provideAnimatedThumbnail(): array { return [ [true], @@ -125,9 +126,7 @@ public function provideAnimatedThumbnail(): array ]; } - /** - * @dataProvider provideAnimatedThumbnail - */ + #[DataProvider('provideAnimatedThumbnail')] public function testAnimatedThumbnail(bool $allowAnimation): void { $image = new Image();