diff --git a/composer.json b/composer.json index d5d0b149..03dee62d 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 497bdba4..8dcc5fba 100644 --- a/tests/php/FileSubsitesTest.php +++ b/tests/php/FileSubsitesTest.php @@ -10,6 +10,7 @@ use SilverStripe\Subsites\Model\Subsite; use SilverStripe\Security\Member; use ReflectionMethod; +use PHPUnit\Framework\Attributes\DataProvider; class FileSubsitesTest extends BaseSubsiteTest { @@ -74,9 +75,7 @@ public function testWritingSubsiteID() $this->assertEquals($folder->SubsiteID, $file->SubsiteID); } - /** - * @dataProvider provideTestCanEdit - */ + #[DataProvider('provideTestCanEdit')] public function testCanEdit( string $fileKey, string $memberKey, @@ -91,7 +90,7 @@ public function testCanEdit( $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 7f0fd7e0..67eea1b8 100644 --- a/tests/php/Service/ThemeResolverTest.php +++ b/tests/php/Service/ThemeResolverTest.php @@ -7,6 +7,7 @@ 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 @@ public function testSubsiteWithCustomThemeDoesNotCascadeUpTheList() $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 @@ public function testCustomThemeDefinitionsAreRespected($themeOptions, $siteTheme $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 b7e59562..adb65115 100644 --- a/tests/php/SiteTreeSubsitesTest.php +++ b/tests/php/SiteTreeSubsitesTest.php @@ -26,6 +26,7 @@ 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 @@ public function testBasicSanity() $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 @@ public function errorPageLocationsProvider() ]; } - /** - * @dataProvider errorPageLocationsProvider - */ + #[DataProvider('errorPageLocationsProvider')] public function testErrorPageLocations($subsiteFixtureName, $expectedFilename) { $static_path = Config::inst()->get(ErrorPage::class, 'static_filepath'); @@ -382,8 +381,8 @@ public function testValidateURLSegment() /** * @param bool $withChildren * @param int $expectedChildren - * @dataProvider duplicateToSubsiteProvider */ + #[DataProvider('duplicateToSubsiteProvider')] public function testDuplicateToSubsite($withChildren, $expectedChildren) { /** @var SiteTree $page */ @@ -408,7 +407,7 @@ public function testDuplicateToSubsite($withChildren, $expectedChildren) /** * @return array[] */ - public function duplicateToSubsiteProvider() + public static function duplicateToSubsiteProvider() { return [ [true, 1], @@ -437,7 +436,7 @@ public function testThemeResolverIsUsedForSettingThemeList() SiteTree::singleton()->extend('contentcontrollerInit', $controller); } - public function provideAlternateAbsoluteLink() + public static function provideAlternateAbsoluteLink() { return [ ['home', null, 'http://localhost'], @@ -452,11 +451,11 @@ public function provideAlternateAbsoluteLink() } /** - * @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 74ec6cbe..228c0b49 100644 --- a/tests/php/SubsiteTest.php +++ b/tests/php/SubsiteTest.php @@ -13,6 +13,7 @@ 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 @@ public function testDefaultDomain() * @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 @@ public function testDomainProtocol($class, $identifier, $currentIsSecure, $expec $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 2505d6cd..c1679e9d 100644 --- a/tests/php/WildcardDomainFieldTest.php +++ b/tests/php/WildcardDomainFieldTest.php @@ -4,6 +4,7 @@ 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 @@ public function testValidDomains($domain) /** * Check that valid domains are accepted * - * @dataProvider invalidDomains * @param $domain */ + #[DataProvider('invalidDomains')] public function testInvalidDomains($domain) { $field = new WildcardDomainField('DomainField'); @@ -38,16 +39,16 @@ public function testInvalidDomains($domain) /** * 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 @@ public function validDomains() ]; } - public function invalidDomains() + public static function invalidDomains() { return [ ['-mysite'], @@ -77,7 +78,7 @@ public function invalidDomains() ]; } - public function validWildcards() + public static function validWildcards() { return [ ['*.mysite.com'],