From 4fc30fdb7500051145a769aeb762ad3339bad85f Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 15 Jan 2025 11:38:29 +1300 Subject: [PATCH] MNT Upgrade to phpunit 11 --- composer.json | 2 +- tests/BranchLogicTest.php | 19 +++++++------------ tests/MetaDataTest.php | 33 +++++++++++++-------------------- 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/composer.json b/composer.json index 33c8d43..7e3c795 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,6 @@ "composer/semver": "^3.4" }, "require-dev": { - "phpunit/phpunit": "^9.6" + "phpunit/phpunit": "^11.3" } } diff --git a/tests/BranchLogicTest.php b/tests/BranchLogicTest.php index 5675c8e..f090d87 100644 --- a/tests/BranchLogicTest.php +++ b/tests/BranchLogicTest.php @@ -7,10 +7,11 @@ use SilverStripe\SupportedModules\BranchLogic; use SilverStripe\SupportedModules\MetaData; use stdClass; +use PHPUnit\Framework\Attributes\DataProvider; class BranchLogicTest extends TestCase { - public function provideGetCmsMajor(): array + public static function provideGetCmsMajor(): array { return [ 'empty' => [ @@ -219,9 +220,7 @@ public function provideGetCmsMajor(): array ]; } - /** - * @dataProvider provideGetCmsMajor - */ + #[DataProvider('provideGetCmsMajor')] public function testGetCmsMajor( string $githubRepository, string $branch, @@ -238,7 +237,7 @@ public function testGetCmsMajor( $this->assertSame($expected, $cmsMajor); } - public function provideGetBranchesForMergeUp(): array + public static function provideGetBranchesForMergeUp(): array { return [ 'no branches' => [ @@ -778,9 +777,7 @@ public function provideGetBranchesForMergeUp(): array ]; } - /** - * @dataProvider provideGetBranchesForMergeUp - */ + #[DataProvider('provideGetBranchesForMergeUp')] public function testGetBranchesForMergeUp( string $githubRepository, string $defaultBranch, @@ -805,7 +802,7 @@ public function testGetBranchesForMergeUp( $this->assertSame($expected, $branches); } - public function provideGetBranchesForMergeUpExceptions(): array + public static function provideGetBranchesForMergeUpExceptions(): array { return [ 'Incorrect default branch for random module' => [ @@ -844,9 +841,7 @@ public function provideGetBranchesForMergeUpExceptions(): array ]; } - /** - * @dataProvider provideGetBranchesForMergeUpExceptions - */ + #[DataProvider('provideGetBranchesForMergeUpExceptions')] public function testGetBranchesForMergeUpExceptions( string $githubRepository, string $defaultBranch, diff --git a/tests/MetaDataTest.php b/tests/MetaDataTest.php index 429bc5f..7b81a94 100644 --- a/tests/MetaDataTest.php +++ b/tests/MetaDataTest.php @@ -5,10 +5,11 @@ use PHPUnit\Framework\TestCase; use RuntimeException; use SilverStripe\SupportedModules\MetaData; +use PHPUnit\Framework\Attributes\DataProvider; class MetaDataTest extends TestCase { - public function provideGetMetaDataForRepository(): array + public static function provideGetMetaDataForRepository(): array { return [ 'missing repo' => [ @@ -49,9 +50,7 @@ public function provideGetMetaDataForRepository(): array ]; } - /** - * @dataProvider provideGetMetaDataForRepository - */ + #[DataProvider('provideGetMetaDataForRepository')] public function testGetMetaDataForRepository(string $repoName, bool $allowPartialMatch, bool $resultEmpty): void { $repoData = MetaData::getMetaDataForRepository($repoName, $allowPartialMatch); @@ -65,7 +64,7 @@ public function testGetMetaDataForRepositoryInvalid(): void MetaData::getMetaDataForRepository(''); } - public function provideGetMetaDataByPackagistName(): array + public static function provideGetMetaDataByPackagistName(): array { return [ 'missing repo' => [ @@ -87,9 +86,7 @@ public function provideGetMetaDataByPackagistName(): array ]; } - /** - * @dataProvider provideGetMetaDataByPackagistName - */ + #[DataProvider('provideGetMetaDataByPackagistName')] public function testGetMetaDataByPackagistName(string $repoName, bool $resultEmpty): void { $repoData = MetaData::getMetaDataByPackagistName($repoName); @@ -103,31 +100,29 @@ public function testGetMetaDataByPackagistNameInvalid(): void MetaData::getMetaDataByPackagistName(''); } - public function provideGetMetaDataForLocksteppedRepos(): array + public static function provideGetMetaDataForLocksteppedRepos(): array { return [ 'module skeleton not lockstepped' => [ - 'packagistRef' => 'silverstripe-module/skeleton', + 'repoName' => 'silverstripe-module/skeleton', 'isLockstepped' => false, ], 'config not lockstepped' => [ - 'packagistRef' => 'silverstripe/config', + 'repoName' => 'silverstripe/config', 'isLockstepped' => false, ], 'framework lockstepped' => [ - 'packagistRef' => 'silverstripe/framework', + 'repoName' => 'silverstripe/framework', 'isLockstepped' => true, ], 'kitchen sink lockstepped' => [ - 'packagistRef' => 'silverstripe/recipe-kitchen-sink', + 'repoName' => 'silverstripe/recipe-kitchen-sink', 'isLockstepped' => true, ], ]; } - /** - * @dataProvider provideGetMetaDataForLocksteppedRepos - */ + #[DataProvider('provideGetMetaDataForLocksteppedRepos')] public function testGetMetaDataForLocksteppedRepos(string $repoName, bool $isLockstepped): void { $lockstepped = MetaData::getMetaDataForLocksteppedRepos(); @@ -140,7 +135,7 @@ public function testGetMetaDataForLocksteppedRepos(string $repoName, bool $isLoc } } - public function provideRemoveReposNotInCmsMajor(): array + public static function provideRemoveReposNotInCmsMajor(): array { return [ 'int major, no wildcard' => [ @@ -166,9 +161,7 @@ public function provideRemoveReposNotInCmsMajor(): array ]; } - /** - * @dataProvider provideRemoveReposNotInCmsMajor - */ + #[DataProvider('provideRemoveReposNotInCmsMajor')] public function testRemoveReposNotInCmsMajor(int|string $cmsMajor, bool $keepWildcardMap, bool $expectEmpty): void { $flatData = MetaData::getAllRepositoryMetaData(false);