diff --git a/tests/php/Publisher/FilesystemPublisherTest.php b/tests/php/Publisher/FilesystemPublisherTest.php index 73a9df27..734ba035 100644 --- a/tests/php/Publisher/FilesystemPublisherTest.php +++ b/tests/php/Publisher/FilesystemPublisherTest.php @@ -14,6 +14,7 @@ use SilverStripe\StaticPublishQueue\Publisher\FilesystemPublisher; use SilverStripe\StaticPublishQueue\Test\StaticPublisherTest\Model\StaticPublisherTestPage; use SilverStripe\View\SSViewer; +use PHPUnit\Framework\Attributes\DataProvider; /** * Tests for the {@link FilesystemPublisher} class. @@ -42,7 +43,7 @@ protected function setUp(): void Config::modify()->set(FilesystemPublisher::class, 'domain_based_caching', false); Config::modify()->set(Director::class, 'alternate_base_url', 'http://example.com/'); - $mockFSP = $this->getMockBuilder(FilesystemPublisher::class)->setMethods([ + $mockFSP = $this->getMockBuilder(FilesystemPublisher::class)->onlyMethods([ 'getHTTPApplication', ])->getMock(); @@ -326,9 +327,7 @@ public function testRedirectorPageWhenHTMLOnly(): void $this->assertFileDoesNotExist($this->fsp->getDestPath() . 'somewhere-else.php'); } - /** - * @dataProvider providePathsToURL - */ + #[DataProvider('providePathsToURL')] public function testPathToURL($expected, $path): void { $reflection = new \ReflectionClass(FilesystemPublisher::class); @@ -341,7 +340,7 @@ public function testPathToURL($expected, $path): void ); } - public function providePathsToURL() + public static function providePathsToURL() { return [ ['http://example.com', 'index.html'], diff --git a/tests/php/Service/UrlBundleServiceTest.php b/tests/php/Service/UrlBundleServiceTest.php index 0fd0b794..f2cf18cc 100644 --- a/tests/php/Service/UrlBundleServiceTest.php +++ b/tests/php/Service/UrlBundleServiceTest.php @@ -9,12 +9,11 @@ use SilverStripe\StaticPublishQueue\Job\DeleteStaticCacheJob; use SilverStripe\StaticPublishQueue\Job\GenerateStaticCacheJob; use SilverStripe\StaticPublishQueue\Service\UrlBundleService; +use PHPUnit\Framework\Attributes\DataProvider; class UrlBundleServiceTest extends SapphireTest { - /** - * @dataProvider jobClasses - */ + #[DataProvider('jobClasses')] public function testJobsFromDataDefault(string $jobClass): void { $urls = [ @@ -45,9 +44,7 @@ public function testJobsFromDataDefault(string $jobClass): void $this->assertStringContainsString($message, $messageData); } - /** - * @dataProvider jobClasses - */ + #[DataProvider('jobClasses')] public function testJobsFromDataExplicitUrlsPerJob(string $jobClass): void { Config::modify()->set($jobClass, 'urls_per_job', 1); @@ -63,9 +60,7 @@ public function testJobsFromDataExplicitUrlsPerJob(string $jobClass): void $this->assertCount(2, $jobs); } - /** - * @dataProvider urlsPerJobCases - */ + #[DataProvider('urlsPerJobCases')] public function testUrlsPerJob(string $jobClass, int $urlsPerJob): void { Config::modify()->set($jobClass, 'urls_per_job', $urlsPerJob); @@ -78,9 +73,7 @@ public function testUrlsPerJob(string $jobClass, int $urlsPerJob): void $this->assertEquals($urlsPerJob, $method->invoke($job)); } - /** - * @dataProvider chunkCases - */ + #[DataProvider('chunkCases')] public function testChunkSize(string $jobClass, int $chunkSize): void { Config::modify()->set($jobClass, 'chunk_size', $chunkSize); @@ -93,7 +86,7 @@ public function testChunkSize(string $jobClass, int $chunkSize): void $this->assertEquals($chunkSize, $method->invoke($job)); } - public function jobClasses(): array + public static function jobClasses(): array { return [ [GenerateStaticCacheJob::class], @@ -101,7 +94,7 @@ public function jobClasses(): array ]; } - public function urlsPerJobCases(): array + public static function urlsPerJobCases(): array { return [ [ @@ -115,7 +108,7 @@ public function urlsPerJobCases(): array ]; } - public function chunkCases(): array + public static function chunkCases(): array { return [ [ @@ -169,9 +162,7 @@ public function testGetUrlsDontStripStage(): void $this->assertEqualsCanonicalizing($urls, $resultUrls); } - /** - * @dataProvider provideStripStageParamUrls - */ + #[DataProvider('provideStripStageParamUrls')] public function testStripStageParam(string $url, string $expectedUrl): void { UrlBundleService::config()->set('strip_stage_param', true); @@ -183,7 +174,7 @@ public function testStripStageParam(string $url, string $expectedUrl): void $this->assertEquals($expectedUrl, $method->invoke($urlService, $url)); } - public function provideStripStageParamUrls(): array + public static function provideStripStageParamUrls(): array { return [ // Testing removal of stage=Stage, expect http to remain http