diff --git a/composer.json b/composer.json index d5d0b14..03dee62 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "silverstripe/versioned": "^3" }, "require-dev": { - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^11.3", "squizlabs/php_codesniffer": "^3", "silverstripe/standards": "^1", "phpstan/extension-installer": "^1.3" diff --git a/tests/php/FileSubsitesTest.php b/tests/php/FileSubsitesTest.php index 497bdba..8dcc5fb 100644 --- a/tests/php/FileSubsitesTest.php +++ b/tests/php/FileSubsitesTest.php @@ -10,6 +10,7 @@ use SilverStripe\Subsites\Extensions\FileSubsites; use SilverStripe\Subsites\Model\Subsite; use SilverStripe\Security\Member; use ReflectionMethod; +use PHPUnit\Framework\Attributes\DataProvider; class FileSubsitesTest extends BaseSubsiteTest { @@ -74,9 +75,7 @@ class FileSubsitesTest extends BaseSubsiteTest $this->assertEquals($folder->SubsiteID, $file->SubsiteID); } - /** - * @dataProvider provideTestCanEdit - */ + #[DataProvider('provideTestCanEdit')] public function testCanEdit( string $fileKey, string $memberKey, @@ -91,7 +90,7 @@ class FileSubsitesTest extends BaseSubsiteTest $this->assertSame($expected, $file->canEdit($member)); } - public function provideTestCanEdit(): array + public static function provideTestCanEdit(): array { $ret = []; $data = [ diff --git a/tests/php/Service/ThemeResolverTest.php b/tests/php/Service/ThemeResolverTest.php index 7f0fd7e..67eea1b 100644 --- a/tests/php/Service/ThemeResolverTest.php +++ b/tests/php/Service/ThemeResolverTest.php @@ -7,6 +7,7 @@ use SilverStripe\Dev\SapphireTest; use SilverStripe\Subsites\Model\Subsite; use SilverStripe\Subsites\Service\ThemeResolver; use SilverStripe\View\SSViewer; +use PHPUnit\Framework\Attributes\DataProvider; class ThemeResolverTest extends SapphireTest { @@ -64,9 +65,7 @@ class ThemeResolverTest extends SapphireTest $this->assertSame($expected, $resolver->getThemeList($subsite)); } - /** - * @dataProvider customThemeDefinitionsAreRespectedProvider - */ + #[DataProvider('customThemeDefinitionsAreRespectedProvider')] public function testCustomThemeDefinitionsAreRespected($themeOptions, $siteTheme, $expected) { Config::modify()->set(ThemeResolver::class, 'theme_options', $themeOptions); @@ -79,7 +78,7 @@ class ThemeResolverTest extends SapphireTest $this->assertSame($expected, $resolver->getThemeList($subsite)); } - public function customThemeDefinitionsAreRespectedProvider() + public static function customThemeDefinitionsAreRespectedProvider() { return [ // Simple diff --git a/tests/php/SiteTreeSubsitesTest.php b/tests/php/SiteTreeSubsitesTest.php index b7e5956..adb6511 100644 --- a/tests/php/SiteTreeSubsitesTest.php +++ b/tests/php/SiteTreeSubsitesTest.php @@ -26,6 +26,7 @@ use SilverStripe\Subsites\Tests\SiteTreeSubsitesTest\TestErrorPage; use SilverStripe\Versioned\Versioned; use SilverStripe\View\SSViewer; use TractorCow\Fluent\Extension\FluentSiteTreeExtension; +use PHPUnit\Framework\Attributes\DataProvider; class SiteTreeSubsitesTest extends BaseSubsiteTest { @@ -94,7 +95,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest $this->assertInstanceOf(FieldList::class, singleton(SubsitesVirtualPage::class)->getCMSFields()); } - public function errorPageLocationsProvider() + public static function errorPageLocationsProvider() { return [ ['domaintest1', '/error-500-one.example.org.html'], @@ -102,9 +103,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest ]; } - /** - * @dataProvider errorPageLocationsProvider - */ + #[DataProvider('errorPageLocationsProvider')] public function testErrorPageLocations($subsiteFixtureName, $expectedFilename) { $static_path = Config::inst()->get(ErrorPage::class, 'static_filepath'); @@ -382,8 +381,8 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest /** * @param bool $withChildren * @param int $expectedChildren - * @dataProvider duplicateToSubsiteProvider */ + #[DataProvider('duplicateToSubsiteProvider')] public function testDuplicateToSubsite($withChildren, $expectedChildren) { /** @var SiteTree $page */ @@ -408,7 +407,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest /** * @return array[] */ - public function duplicateToSubsiteProvider() + public static function duplicateToSubsiteProvider() { return [ [true, 1], @@ -437,7 +436,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest SiteTree::singleton()->extend('contentcontrollerInit', $controller); } - public function provideAlternateAbsoluteLink() + public static function provideAlternateAbsoluteLink() { return [ ['home', null, 'http://localhost'], @@ -452,11 +451,11 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest } /** - * @dataProvider provideAlternateAbsoluteLink * @param string $pageFixtureName * @param string|null $action * @param string $expectedAbsoluteLink */ + #[DataProvider('provideAlternateAbsoluteLink')] public function testAlternateAbsoluteLink($pageFixtureName, $action, $expectedAbsoluteLink) { // Setting a control value, in case base url is set for the installation under test diff --git a/tests/php/SubsiteTest.php b/tests/php/SubsiteTest.php index 74ec6cb..228c0b4 100644 --- a/tests/php/SubsiteTest.php +++ b/tests/php/SubsiteTest.php @@ -13,6 +13,7 @@ use SilverStripe\Subsites\Model\Subsite; use SilverStripe\Subsites\Model\SubsiteDomain; use SilverStripe\Subsites\State\SubsiteState; use UnexpectedValueException; +use PHPUnit\Framework\Attributes\DataProvider; class SubsiteTest extends BaseSubsiteTest { @@ -317,8 +318,8 @@ class SubsiteTest extends BaseSubsiteTest * @param string $identifier Fixture identifier * @param bool $currentIsSecure Whether the current base URL should be secure * @param string $expected The expected base URL for the subsite or subsite domain - * @dataProvider domainProtocolProvider */ + #[DataProvider('domainProtocolProvider')] public function testDomainProtocol($class, $identifier, $currentIsSecure, $expected) { /** @var Subsite|SubsiteDomain $model */ @@ -328,7 +329,7 @@ class SubsiteTest extends BaseSubsiteTest $this->assertSame($this->normaliseTrailingSlash($expected), $model->absoluteBaseURL()); } - public function domainProtocolProvider() + public static function domainProtocolProvider() { return [ [Subsite::class, 'domaintest2', false, 'http://two.mysite.com'], diff --git a/tests/php/WildcardDomainFieldTest.php b/tests/php/WildcardDomainFieldTest.php index 2505d6c..c1679e9 100644 --- a/tests/php/WildcardDomainFieldTest.php +++ b/tests/php/WildcardDomainFieldTest.php @@ -4,6 +4,7 @@ namespace SilverStripe\Subsites\Tests; use SilverStripe\Dev\SapphireTest; use SilverStripe\Subsites\Forms\WildcardDomainField; +use PHPUnit\Framework\Attributes\DataProvider; /** * Tests {@see WildcardDomainField} @@ -14,9 +15,9 @@ class WildcardDomainFieldTest extends SapphireTest /** * Check that valid domains are accepted * - * @dataProvider validDomains * @param $domain */ + #[DataProvider('validDomains')] public function testValidDomains($domain) { $field = new WildcardDomainField('DomainField'); @@ -26,9 +27,9 @@ class WildcardDomainFieldTest extends SapphireTest /** * Check that valid domains are accepted * - * @dataProvider invalidDomains * @param $domain */ + #[DataProvider('invalidDomains')] public function testInvalidDomains($domain) { $field = new WildcardDomainField('DomainField'); @@ -38,16 +39,16 @@ class WildcardDomainFieldTest extends SapphireTest /** * Check that valid domains are accepted * - * @dataProvider validWildcards * @param $domain */ + #[DataProvider('validWildcards')] public function testValidWildcards($domain) { $field = new WildcardDomainField('DomainField'); $this->assertTrue($field->checkHostname($domain), "Validate that {$domain} is a valid domain wildcard"); } - public function validDomains() + public static function validDomains() { return [ ['www.mysite.com'], @@ -60,7 +61,7 @@ class WildcardDomainFieldTest extends SapphireTest ]; } - public function invalidDomains() + public static function invalidDomains() { return [ ['-mysite'], @@ -77,7 +78,7 @@ class WildcardDomainFieldTest extends SapphireTest ]; } - public function validWildcards() + public static function validWildcards() { return [ ['*.mysite.com'],