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 ef4cbfe commit d236d1a
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 66 deletions.
5 changes: 3 additions & 2 deletions tests/Auth/HandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use SilverStripe\GraphQL\Tests\Fake\BrutalAuthenticatorFake;
use SilverStripe\GraphQL\Tests\Fake\FalsyAuthenticatorFake;
use SilverStripe\GraphQL\Tests\Fake\PushoverAuthenticatorFake;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* @package silverstripe-graphql
Expand Down Expand Up @@ -80,8 +81,8 @@ public function testExceptionThrownWhenAuthenticatorDoesNotImplementAuthenticato
*
* @param array $authenticators
* @param string $expected
* @dataProvider prioritisedAuthenticatorProvider
*/
#[DataProvider('prioritisedAuthenticatorProvider')]
public function testAuthenticatorsCanBePrioritised($authenticators, $expected)
{
Handler::config()->set('authenticators', $authenticators);
Expand All @@ -92,7 +93,7 @@ public function testAuthenticatorsCanBePrioritised($authenticators, $expected)
/**
* @return array
*/
public function prioritisedAuthenticatorProvider()
public static function prioritisedAuthenticatorProvider()
{
return [
[
Expand Down
7 changes: 3 additions & 4 deletions tests/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
use SilverStripe\Dev\SapphireTest;
use SilverStripe\GraphQL\Controller;
use SilverStripe\ORM\DB;
use PHPUnit\Framework\Attributes\DataProvider;

class ControllerTest extends SapphireTest
{
protected $usesDatabase = false;

public function providePrepareBacktrace()
public static function providePrepareBacktrace()
{
$querySource = <<<'GRAPHQL'
query ReadFiles($filter: FakeInputType!) {
Expand Down Expand Up @@ -152,9 +153,7 @@ public function providePrepareBacktrace()
];
}

/**
* @dataProvider providePrepareBacktrace
*/
#[DataProvider('providePrepareBacktrace')]
public function testPrepareBacktrace(array $trace, array $expected)
{
$controller = new Controller(__FUNCTION__);
Expand Down
5 changes: 3 additions & 2 deletions tests/Modules/AssetAdmin/ReadFileUsageQueryCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use SilverStripe\Dev\SapphireTest;
use Silverstripe\Assets\Dev\TestAssetStore;
use SilverStripe\GraphQL\Schema\Schema;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* Most of the search functionality is covered in {@link FileFilterInputTypeCreatorTest}
Expand Down Expand Up @@ -38,7 +39,7 @@ protected function tearDown(): void
parent::tearDown();
}

public function fileUsageDataProvider()
public static function fileUsageDataProvider()
{
return [
[File::class, 'rootfile', 2, 'rootfile file is used twice'],
Expand All @@ -50,12 +51,12 @@ public function fileUsageDataProvider()
}

/**
* @dataProvider fileUsageDataProvider
* @param string $class
* @param string $fixture
* @param int|false $expectedCount
* @param $message
*/
#[DataProvider('fileUsageDataProvider')]
public function testUsageCount(string $class, string $fixture, $expectedCount, $message)
{
$id = $this->idFromFixture($class, $fixture);
Expand Down
5 changes: 3 additions & 2 deletions tests/Modules/CMS/LinkablePluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use SilverStripe\GraphQL\Schema\Field\ModelQuery;
use SilverStripe\GraphQL\Schema\Schema;
use SilverStripe\GraphQL\Schema\SchemaConfig;
use PHPUnit\Framework\Attributes\DataProvider;

class LinkablePluginTest extends SapphireTest
{
Expand All @@ -24,8 +25,8 @@ protected function setUp(): void

/**
* @param bool $list
* @dataProvider provideApply
*/
#[DataProvider('provideApply')]
public function testApply(bool $list)
{
$query = new ModelQuery(
Expand Down Expand Up @@ -102,7 +103,7 @@ public function testResolver()
}


public function provideApply()
public static function provideApply()
{
return [
[true],
Expand Down
2 changes: 1 addition & 1 deletion tests/PersistedQuery/HTTPProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testSchemaMapping()
public function testHTTPRequests()
{
$mock = $this->getMockBuilder(HTTPClient::class)
->setMethods(['getURL'])
->onlyMethods(['getURL'])
->getMock();
$mock->expects($this->once())
->method('getURL')
Expand Down
7 changes: 3 additions & 4 deletions tests/Schema/AbstractTypeRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use ReflectionObject;
use stdClass;
use SilverStripe\Control\Session;
use PHPUnit\Framework\Attributes\DataProvider;

class AbstractTypeRegistryTest extends SapphireTest
{
Expand Down Expand Up @@ -50,9 +51,7 @@ public function testRebuildOnMissingPath()
);
}

/**
* @dataProvider provideRebuildOnMissing
*/
#[DataProvider('provideRebuildOnMissing')]
public function testRebuildOnMissing(
bool $controller,
bool $autobuild,
Expand Down Expand Up @@ -93,7 +92,7 @@ public function testRebuildOnMissing(
$this->assertSame($expected, $canRebuildOnMissingMethod->invoke($registry));
}

public function provideRebuildOnMissing(): array
public static function provideRebuildOnMissing(): array
{
// controller = current controller is a GraphQLController
// autobuild = if autobuild is enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testApply()
public function testResolve()
{
$fake = $this->getMockBuilder(DBDate::class)
->setMethods(['Nice'])
->onlyMethods(['Nice'])
->getMock();
$fake->expects($this->once())
->method('Nice');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testApply()
public function testResolve()
{
$fake = $this->getMockBuilder(DBDatetime::class)
->setMethods(['Time'])
->onlyMethods(['Time'])
->getMock();
$fake->expects($this->once())
->method('Time');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DBFieldArgsTest extends SapphireTest
public function testBaseFormatResolver()
{
$fake = $this->getMockBuilder(DBText::class)
->setMethods(['FirstSentence'])
->onlyMethods(['FirstSentence'])
->getMock();
$fake->expects($this->once())
->method('FirstSentence');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testApply()
public function testResolve()
{
$fake = $this->getMockBuilder(DBHTMLText::class)
->setMethods(['setProcessShortcodes'])
->onlyMethods(['setProcessShortcodes'])
->getMock();
$fake->expects($this->exactly(4))
->method('setProcessShortcodes')
Expand Down
4 changes: 2 additions & 2 deletions tests/Schema/DataObject/Plugin/DBFieldArgs/DBTextArgsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testApply()
public function testResolve()
{
$fake = $this->getMockBuilder(DBText::class)
->setMethods(['FirstParagraph'])
->onlyMethods(['FirstParagraph'])
->getMock();
$fake->expects($this->once())
->method('FirstParagraph');
Expand All @@ -44,7 +44,7 @@ public function testResolve()
DBTextArgs::resolve($fake, ['format' => 'FirstParagraph', 'limit' => 5], []);

$fake = $this->getMockBuilder(DBText::class)
->setMethods(['LimitSentences'])
->onlyMethods(['LimitSentences'])
->getMock();
$fake->expects($this->once())
->method('LimitSentences')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testApply()
public function testResolve()
{
$fake = $this->getMockBuilder(DBTime::class)
->setMethods(['Nice'])
->onlyMethods(['Nice'])
->getMock();
$fake->expects($this->once())
->method('Nice');
Expand Down
7 changes: 3 additions & 4 deletions tests/Schema/DataObject/Plugin/FiltersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use SilverStripe\GraphQL\Schema\DataObject\Plugin\QueryFilter\Filters\NotEqualFilter;
use SilverStripe\GraphQL\Schema\DataObject\Plugin\QueryFilter\Filters\StartsWithFilter;
use SilverStripe\ORM\ArrayList;
use PHPUnit\Framework\Attributes\DataProvider;

class FiltersTest extends SapphireTest
{
Expand All @@ -25,9 +26,7 @@ class FiltersTest extends SapphireTest
'null' => null
];

/**
* @dataProvider filterArgumentsProvider
*/
#[DataProvider('filterArgumentsProvider')]
public function testFilterArguments(FieldFilterInterface $filter, string $identifier, array $params): void
{
$this->assertEquals($identifier, $filter->getIdentifier());
Expand All @@ -40,7 +39,7 @@ public function testFilterArguments(FieldFilterInterface $filter, string $identi
}
}

public function filterArgumentsProvider(): array
public static function filterArgumentsProvider(): array
{
return [
[
Expand Down
5 changes: 3 additions & 2 deletions tests/Schema/DataObject/Plugin/InheritanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use SilverStripe\GraphQL\Tests\Schema\DataObject\FakeInterfaceBuilder;
use SilverStripe\GraphQL\Tests\Schema\DataObject\TestSchema;
use SilverStripe\ORM\DataObject;
use PHPUnit\Framework\Attributes\DataProvider;

class InheritanceTest extends SapphireTest
{
Expand Down Expand Up @@ -62,8 +63,8 @@ class InheritanceTest extends SapphireTest
* @param false $unions
* @throws \ReflectionException
* @throws SchemaBuilderException
* @dataProvider provideUnionOption
*/
#[DataProvider('provideUnionOption')]
public function testInheritance($unions = false)
{
$schema = new TestSchema();
Expand Down Expand Up @@ -168,7 +169,7 @@ private function assertCalls(array $expected, array $actual)
$this->assertEmpty(array_diff($compare ?? [], $expected), 'Actual calls exceed the expected calls');
}

public function provideUnionOption()
public static function provideUnionOption()
{
return [
[true],
Expand Down
Loading

0 comments on commit d236d1a

Please sign in to comment.