mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Merge pull request #598 from creative-commoners/pulls/4/phpunit11
DEP Use PHPUnit 11
This commit is contained in:
commit
f58a8630e5
@ -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"
|
||||
|
@ -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 = [
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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'],
|
||||
|
@ -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'],
|
||||
|
Loading…
Reference in New Issue
Block a user