Skip to content

Commit

Permalink
MNT Upgrade to phpunit 11
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jan 14, 2025
1 parent 184125f commit 4fc30fd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 33 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"composer/semver": "^3.4"
},
"require-dev": {
"phpunit/phpunit": "^9.6"
"phpunit/phpunit": "^11.3"
}
}
19 changes: 7 additions & 12 deletions tests/BranchLogicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down Expand Up @@ -219,9 +220,7 @@ public function provideGetCmsMajor(): array
];
}

/**
* @dataProvider provideGetCmsMajor
*/
#[DataProvider('provideGetCmsMajor')]
public function testGetCmsMajor(
string $githubRepository,
string $branch,
Expand All @@ -238,7 +237,7 @@ public function testGetCmsMajor(
$this->assertSame($expected, $cmsMajor);
}

public function provideGetBranchesForMergeUp(): array
public static function provideGetBranchesForMergeUp(): array
{
return [
'no branches' => [
Expand Down Expand Up @@ -778,9 +777,7 @@ public function provideGetBranchesForMergeUp(): array
];
}

/**
* @dataProvider provideGetBranchesForMergeUp
*/
#[DataProvider('provideGetBranchesForMergeUp')]
public function testGetBranchesForMergeUp(
string $githubRepository,
string $defaultBranch,
Expand All @@ -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' => [
Expand Down Expand Up @@ -844,9 +841,7 @@ public function provideGetBranchesForMergeUpExceptions(): array
];
}

/**
* @dataProvider provideGetBranchesForMergeUpExceptions
*/
#[DataProvider('provideGetBranchesForMergeUpExceptions')]
public function testGetBranchesForMergeUpExceptions(
string $githubRepository,
string $defaultBranch,
Expand Down
33 changes: 13 additions & 20 deletions tests/MetaDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down Expand Up @@ -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);
Expand All @@ -65,7 +64,7 @@ public function testGetMetaDataForRepositoryInvalid(): void
MetaData::getMetaDataForRepository('');
}

public function provideGetMetaDataByPackagistName(): array
public static function provideGetMetaDataByPackagistName(): array
{
return [
'missing repo' => [
Expand All @@ -87,9 +86,7 @@ public function provideGetMetaDataByPackagistName(): array
];
}

/**
* @dataProvider provideGetMetaDataByPackagistName
*/
#[DataProvider('provideGetMetaDataByPackagistName')]
public function testGetMetaDataByPackagistName(string $repoName, bool $resultEmpty): void
{
$repoData = MetaData::getMetaDataByPackagistName($repoName);
Expand All @@ -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();
Expand All @@ -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' => [
Expand All @@ -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);
Expand Down

0 comments on commit 4fc30fd

Please sign in to comment.