Skip to content

Commit

Permalink
DEP Use PHPUnit 11
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Sep 9, 2024
1 parent f267237 commit 0f7b4be
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion tests/php/Caching/ProxyCacheAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected function getMockCacheInterface()
{
$methods = ['get', 'set', 'has', 'delete', 'getMultiple', 'setMultiple', 'clear', 'deleteMultiple'];
$mock = $this->getMockBuilder(CacheInterface::class)
->setMethods($methods)
->onlyMethods($methods)
->getMock();

return $mock;
Expand Down
2 changes: 1 addition & 1 deletion tests/php/GridFieldArchiveActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function testGetArchiveAction()
protected function createGridField()
{
$mock = $this->getMockBuilder(Controller::class)
->setMethods(['Link'])
->onlyMethods(['Link'])
->getMock();
$mock->method('Link')->will($this->returnValue('Test'));
$form = new Form(
Expand Down
7 changes: 4 additions & 3 deletions tests/php/ReadingModeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use InvalidArgumentException;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Versioned\ReadingMode;
use PHPUnit\Framework\Attributes\DataProvider;

class ReadingModeTest extends SapphireTest
{
Expand Down Expand Up @@ -88,7 +89,7 @@ public function testFromQueryString($readingMode, $dataQuery, $queryStringArray,
* - query string (string)
* @return array
*/
public function provideReadingModes()
public static function provideReadingModes()
{
return [
// Draft
Expand Down Expand Up @@ -147,16 +148,16 @@ public function provideReadingModes()
}

/**
* @dataProvider provideTestInvalidStage
* @param string $stage
*/
#[DataProvider('provideTestInvalidStage')]
public function testInvalidStage($stage)
{
$this->expectException(\InvalidArgumentException::class);
ReadingMode::validateStage($stage);
}

public function provideTestInvalidStage()
public static function provideTestInvalidStage()
{
return [
[''],
Expand Down
7 changes: 3 additions & 4 deletions tests/php/RecursiveStagesServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use SilverStripe\Versioned\Tests\RecursiveStagesServiceTest\GroupObject;
use SilverStripe\Versioned\Tests\RecursiveStagesServiceTest\PrimaryObject;
use SilverStripe\Versioned\Versioned;
use PHPUnit\Framework\Attributes\DataProvider;

class RecursiveStagesServiceTest extends SapphireTest
{
Expand Down Expand Up @@ -51,9 +52,7 @@ public function testStageDiffersRecursiveWithInvalidObject(): void
});
}

/**
* @dataProvider objectsProvider
*/
#[DataProvider('objectsProvider')]
public function testStageDiffersRecursive(string $class, string $identifier, bool $delete, bool $expected): void
{
Versioned::withVersionedMode(function () use ($class, $identifier, $delete, $expected): void {
Expand Down Expand Up @@ -81,7 +80,7 @@ public function testStageDiffersRecursive(string $class, string $identifier, boo
});
}

public function objectsProvider(): array
public static function objectsProvider(): array
{
return [
'primary object (versioned, update)' => [
Expand Down
11 changes: 4 additions & 7 deletions tests/php/VersionedNumberCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverStripe\Versioned\Versioned;
use SilverStripe\Versioned\Tests\VersionedTest\TestObject;
use ReflectionMethod;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* @internal Only test the right values are returned, not that the cache is actually used.
Expand Down Expand Up @@ -68,7 +69,7 @@ protected function setUp(): void
TestObject::singleton()->flushCache();
}

public function cacheDataProvider()
public static function cacheDataProvider()
{
return [
[Versioned::DRAFT, 'publishedID', false, 'draftVersion'],
Expand All @@ -81,9 +82,7 @@ public function cacheDataProvider()
}


/**
* @dataProvider cacheDataProvider
*/
#[DataProvider('cacheDataProvider')]
public function testVersionNumberCache($stage, $ID, $cache, $expected)
{
$actual = Versioned::get_versionnumber_by_stage(TestObject::class, $stage, VersionedNumberCacheTest::${$ID}, $cache);
Expand All @@ -96,9 +95,7 @@ public function testVersionNumberCache($stage, $ID, $cache, $expected)
}
}

/**
* @dataProvider cacheDataProvider
*/
#[DataProvider('cacheDataProvider')]
public function testPrepopulatedVersionNumberCache($stage, $ID, $cache, $expected)
{
$owner = TestObject::singleton();
Expand Down

0 comments on commit 0f7b4be

Please sign in to comment.