Skip to content

Commit

Permalink
Merge pull request #202 from creative-commoners/pulls/7/phpunit11
Browse files Browse the repository at this point in the history
DEP Use PHPUnit 11
  • Loading branch information
GuySartorelli authored Sep 18, 2024
2 parents 24d9828 + 93160fa commit e0cae29
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
9 changes: 4 additions & 5 deletions tests/php/Publisher/FilesystemPublisherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand All @@ -341,7 +340,7 @@ public function testPathToURL($expected, $path): void
);
}

public function providePathsToURL()
public static function providePathsToURL()
{
return [
['http://example.com', 'index.html'],
Expand Down
29 changes: 10 additions & 19 deletions tests/php/Service/UrlBundleServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -93,15 +86,15 @@ 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],
[DeleteStaticCacheJob::class],
];
}

public function urlsPerJobCases(): array
public static function urlsPerJobCases(): array
{
return [
[
Expand All @@ -115,7 +108,7 @@ public function urlsPerJobCases(): array
];
}

public function chunkCases(): array
public static function chunkCases(): array
{
return [
[
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down

0 comments on commit e0cae29

Please sign in to comment.