From f8222fbb351e9848e038ed1ef16adcc95e706ce2 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 11 Sep 2024 19:17:24 +1200 Subject: [PATCH] DEP Use PHPUnit 11 --- tests/Auth/HandlerTest.php | 8 +-- tests/ControllerTest.php | 7 +- tests/Middleware/CSRFMiddlewareTest.php | 2 +- ...Test.php => MiddlewareProcessTestBase.php} | 2 +- .../ReadFileUsageQueryCreatorTest.php | 5 +- tests/Modules/CMS/LinkablePluginTest.php | 5 +- tests/PersistedQuery/HTTPProviderTest.php | 2 +- tests/Schema/AbstractTypeRegistryTest.php | 7 +- .../Plugin/DBFieldArgs/DBDateArgsTest.php | 2 +- .../Plugin/DBFieldArgs/DBDatetimeArgsTest.php | 2 +- .../Plugin/DBFieldArgs/DBFieldArgsTest.php | 2 +- .../Plugin/DBFieldArgs/DBHTMLTextArgsTest.php | 15 ++++- .../Plugin/DBFieldArgs/DBTextArgsTest.php | 4 +- .../Plugin/DBFieldArgs/DBTimeArgsTest.php | 2 +- .../Schema/DataObject/Plugin/FiltersTest.php | 32 ++++----- .../DataObject/Plugin/InheritanceTest.php | 5 +- tests/Schema/IntegrationTest.php | 65 +++++++------------ tests/Schema/SchemaTest.php | 8 +-- 18 files changed, 85 insertions(+), 90 deletions(-) rename tests/Middleware/{BaseMiddlewareProcessTest.php => MiddlewareProcessTestBase.php} (94%) diff --git a/tests/Auth/HandlerTest.php b/tests/Auth/HandlerTest.php index 7a62b10e3..f6da7fd68 100644 --- a/tests/Auth/HandlerTest.php +++ b/tests/Auth/HandlerTest.php @@ -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 @@ -65,7 +66,6 @@ public function testGetAuthenticator() /** * Test that an exception is thrown if an authenticator is configured that doesn't implement the interface - * */ public function testExceptionThrownWhenAuthenticatorDoesNotImplementAuthenticatorInterface() { @@ -80,8 +80,8 @@ public function testExceptionThrownWhenAuthenticatorDoesNotImplementAuthenticato * * @param array $authenticators * @param string $expected - * @dataProvider prioritisedAuthenticatorProvider */ + #[DataProvider('prioritisedAuthenticatorProvider')] public function testAuthenticatorsCanBePrioritised($authenticators, $expected) { Handler::config()->set('authenticators', $authenticators); @@ -92,7 +92,7 @@ public function testAuthenticatorsCanBePrioritised($authenticators, $expected) /** * @return array */ - public function prioritisedAuthenticatorProvider() + public static function prioritisedAuthenticatorProvider() { return [ [ @@ -128,7 +128,6 @@ public function prioritisedAuthenticatorProvider() /** * Ensure that an failed authentication attempt throws an exception - * */ public function testFailedAuthenticationThrowsException() { @@ -142,7 +141,6 @@ public function testFailedAuthenticationThrowsException() * Ensure that when a falsy value is returned from an authenticator (when it should throw * an exception on failure) that a sensible default message is used in a ValidationException * instead. - * */ public function testFailedAuthenticationWithFalsyReturnValueThrowsDefaultException() { diff --git a/tests/ControllerTest.php b/tests/ControllerTest.php index 45c864184..4ab06107c 100644 --- a/tests/ControllerTest.php +++ b/tests/ControllerTest.php @@ -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!) { @@ -152,9 +153,7 @@ public function providePrepareBacktrace() ]; } - /** - * @dataProvider providePrepareBacktrace - */ + #[DataProvider('providePrepareBacktrace')] public function testPrepareBacktrace(array $trace, array $expected) { $controller = new Controller(__FUNCTION__); diff --git a/tests/Middleware/CSRFMiddlewareTest.php b/tests/Middleware/CSRFMiddlewareTest.php index 61487bbc3..3eddd7199 100644 --- a/tests/Middleware/CSRFMiddlewareTest.php +++ b/tests/Middleware/CSRFMiddlewareTest.php @@ -6,7 +6,7 @@ use SilverStripe\GraphQL\Middleware\CSRFMiddleware; use SilverStripe\Security\SecurityToken; -class CSRFMiddlewareTest extends BaseMiddlewareProcessTest +class CSRFMiddlewareTest extends MiddlewareProcessTestBase { private bool $securityTokenWasEnabled = false; diff --git a/tests/Middleware/BaseMiddlewareProcessTest.php b/tests/Middleware/MiddlewareProcessTestBase.php similarity index 94% rename from tests/Middleware/BaseMiddlewareProcessTest.php rename to tests/Middleware/MiddlewareProcessTestBase.php index b89bc1180..d7ee42ef3 100644 --- a/tests/Middleware/BaseMiddlewareProcessTest.php +++ b/tests/Middleware/MiddlewareProcessTestBase.php @@ -9,7 +9,7 @@ use SilverStripe\GraphQL\Middleware\QueryMiddleware; use SilverStripe\GraphQL\Schema\Schema as SchemaSchema; -abstract class BaseMiddlewareProcessTest extends SapphireTest +abstract class MiddlewareProcessTestBase extends SapphireTest { /** * @var callable diff --git a/tests/Modules/AssetAdmin/ReadFileUsageQueryCreatorTest.php b/tests/Modules/AssetAdmin/ReadFileUsageQueryCreatorTest.php index 620467a45..4828f76ba 100644 --- a/tests/Modules/AssetAdmin/ReadFileUsageQueryCreatorTest.php +++ b/tests/Modules/AssetAdmin/ReadFileUsageQueryCreatorTest.php @@ -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} @@ -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'], @@ -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); diff --git a/tests/Modules/CMS/LinkablePluginTest.php b/tests/Modules/CMS/LinkablePluginTest.php index 70b00032b..e9269fd3d 100644 --- a/tests/Modules/CMS/LinkablePluginTest.php +++ b/tests/Modules/CMS/LinkablePluginTest.php @@ -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 { @@ -24,8 +25,8 @@ protected function setUp(): void /** * @param bool $list - * @dataProvider provideApply */ + #[DataProvider('provideApply')] public function testApply(bool $list) { $query = new ModelQuery( @@ -102,7 +103,7 @@ public function testResolver() } - public function provideApply() + public static function provideApply() { return [ [true], diff --git a/tests/PersistedQuery/HTTPProviderTest.php b/tests/PersistedQuery/HTTPProviderTest.php index bdc93b7aa..f4a560648 100644 --- a/tests/PersistedQuery/HTTPProviderTest.php +++ b/tests/PersistedQuery/HTTPProviderTest.php @@ -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') diff --git a/tests/Schema/AbstractTypeRegistryTest.php b/tests/Schema/AbstractTypeRegistryTest.php index 8fca02d4f..39f8930ae 100644 --- a/tests/Schema/AbstractTypeRegistryTest.php +++ b/tests/Schema/AbstractTypeRegistryTest.php @@ -11,6 +11,7 @@ use ReflectionObject; use stdClass; use SilverStripe\Control\Session; +use PHPUnit\Framework\Attributes\DataProvider; class AbstractTypeRegistryTest extends SapphireTest { @@ -50,9 +51,7 @@ public function testRebuildOnMissingPath() ); } - /** - * @dataProvider provideRebuildOnMissing - */ + #[DataProvider('provideRebuildOnMissing')] public function testRebuildOnMissing( bool $controller, bool $autobuild, @@ -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 diff --git a/tests/Schema/DataObject/Plugin/DBFieldArgs/DBDateArgsTest.php b/tests/Schema/DataObject/Plugin/DBFieldArgs/DBDateArgsTest.php index b0b1ae78f..ebd1012ea 100644 --- a/tests/Schema/DataObject/Plugin/DBFieldArgs/DBDateArgsTest.php +++ b/tests/Schema/DataObject/Plugin/DBFieldArgs/DBDateArgsTest.php @@ -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'); diff --git a/tests/Schema/DataObject/Plugin/DBFieldArgs/DBDatetimeArgsTest.php b/tests/Schema/DataObject/Plugin/DBFieldArgs/DBDatetimeArgsTest.php index 80a9350bf..9131e286e 100644 --- a/tests/Schema/DataObject/Plugin/DBFieldArgs/DBDatetimeArgsTest.php +++ b/tests/Schema/DataObject/Plugin/DBFieldArgs/DBDatetimeArgsTest.php @@ -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'); diff --git a/tests/Schema/DataObject/Plugin/DBFieldArgs/DBFieldArgsTest.php b/tests/Schema/DataObject/Plugin/DBFieldArgs/DBFieldArgsTest.php index f7fea6367..8a6101b2a 100644 --- a/tests/Schema/DataObject/Plugin/DBFieldArgs/DBFieldArgsTest.php +++ b/tests/Schema/DataObject/Plugin/DBFieldArgs/DBFieldArgsTest.php @@ -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'); diff --git a/tests/Schema/DataObject/Plugin/DBFieldArgs/DBHTMLTextArgsTest.php b/tests/Schema/DataObject/Plugin/DBFieldArgs/DBHTMLTextArgsTest.php index 8f06380ef..3b8d22878 100644 --- a/tests/Schema/DataObject/Plugin/DBFieldArgs/DBHTMLTextArgsTest.php +++ b/tests/Schema/DataObject/Plugin/DBFieldArgs/DBHTMLTextArgsTest.php @@ -33,11 +33,20 @@ public function testApply() public function testResolve() { $fake = $this->getMockBuilder(DBHTMLText::class) - ->setMethods(['setProcessShortcodes']) + ->onlyMethods(['setProcessShortcodes']) ->getMock(); - $fake->expects($this->exactly(4)) + $matcher = $this->exactly(4); + $fake->expects($matcher) ->method('setProcessShortcodes') - ->withConsecutive([true], [false], [false], [true]); + ->willReturnCallback(function (bool $process) use ($fake, $matcher) { + match ($matcher->numberOfInvocations()) { + 1 => $this->assertSame(true, $process), + 2 => $this->assertSame(false, $process), + 3 => $this->assertSame(false, $process), + 4 => $this->assertSame(true, $process), + }; + return $fake; + }); $trueConfig = new SchemaConfig(); $trueConfig->set('modelConfig.DataObject', ['parseShortcodes' => true]); diff --git a/tests/Schema/DataObject/Plugin/DBFieldArgs/DBTextArgsTest.php b/tests/Schema/DataObject/Plugin/DBFieldArgs/DBTextArgsTest.php index 173caa3bb..c8a252777 100644 --- a/tests/Schema/DataObject/Plugin/DBFieldArgs/DBTextArgsTest.php +++ b/tests/Schema/DataObject/Plugin/DBFieldArgs/DBTextArgsTest.php @@ -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'); @@ -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') diff --git a/tests/Schema/DataObject/Plugin/DBFieldArgs/DBTimeArgsTest.php b/tests/Schema/DataObject/Plugin/DBFieldArgs/DBTimeArgsTest.php index 26e0880d8..a3337f597 100644 --- a/tests/Schema/DataObject/Plugin/DBFieldArgs/DBTimeArgsTest.php +++ b/tests/Schema/DataObject/Plugin/DBFieldArgs/DBTimeArgsTest.php @@ -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'); diff --git a/tests/Schema/DataObject/Plugin/FiltersTest.php b/tests/Schema/DataObject/Plugin/FiltersTest.php index 177354271..a98cc8b0c 100644 --- a/tests/Schema/DataObject/Plugin/FiltersTest.php +++ b/tests/Schema/DataObject/Plugin/FiltersTest.php @@ -15,19 +15,21 @@ 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 { - private array $values = [ + /** + * @internal + */ + private static array $values = [ 'string' => 'test', 'array' => ['a', 'b'], 'number' => 42, 'null' => null ]; - /** - * @dataProvider filterArgumentsProvider - */ + #[DataProvider('filterArgumentsProvider')] public function testFilterArguments(FieldFilterInterface $filter, string $identifier, array $params): void { $this->assertEquals($identifier, $filter->getIdentifier()); @@ -40,58 +42,58 @@ public function testFilterArguments(FieldFilterInterface $filter, string $identi } } - public function filterArgumentsProvider(): array + public static function filterArgumentsProvider(): array { return [ [ new ContainsFilter(), 'contains', - array_slice($this->values, 0, 2, true) + array_slice(FiltersTest::$values, 0, 2, true) ], [ new EndsWithFilter(), 'endswith', - array_slice($this->values, 0, 2, true) + array_slice(FiltersTest::$values, 0, 2, true) ], [ new EqualToFilter(), 'eq', - $this->values + FiltersTest::$values ], [ new GreaterThanFilter(), 'gt', - $this->values + FiltersTest::$values ], [ new GreaterThanOrEqualFilter(), 'gte', - $this->values + FiltersTest::$values ], [ new InFilter(), 'in', - $this->values['array'] + FiltersTest::$values['array'] ], [ new LessThanFilter(), 'lt', - $this->values + FiltersTest::$values ], [ new LessThanOrEqualFilter(), 'lte', - $this->values + FiltersTest::$values ], [ new NotEqualFilter(), 'ne', - $this->values + FiltersTest::$values ], [ new StartsWithFilter(), 'startswith', - array_slice($this->values, 0, 2, true) + array_slice(FiltersTest::$values, 0, 2, true) ] ]; } diff --git a/tests/Schema/DataObject/Plugin/InheritanceTest.php b/tests/Schema/DataObject/Plugin/InheritanceTest.php index 5e0a2e35d..43e171db7 100644 --- a/tests/Schema/DataObject/Plugin/InheritanceTest.php +++ b/tests/Schema/DataObject/Plugin/InheritanceTest.php @@ -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 { @@ -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(); @@ -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], diff --git a/tests/Schema/IntegrationTest.php b/tests/Schema/IntegrationTest.php index 70a5df582..ad4767a4c 100644 --- a/tests/Schema/IntegrationTest.php +++ b/tests/Schema/IntegrationTest.php @@ -44,6 +44,7 @@ use GraphQL\Validator\Rules\QueryDepth; use GraphQL\Validator\ValidationContext; use ReflectionClass; +use PHPUnit\Framework\Attributes\DataProvider; class IntegrationTest extends SapphireTest { @@ -418,7 +419,7 @@ public function testNestedFieldDefinitions() $this->assertMissingField($result, 'title'); } - public function provideFilterAndSort(): array + public static function provideFilterAndSort(): array { return [ [ @@ -508,9 +509,7 @@ public function provideFilterAndSort(): array ]; } - /** - * @dataProvider provideFilterAndSort - */ + #[DataProvider('provideFilterAndSort')] public function testFilterAndSort(string $query, string $testAgainst, string $placeholderRecord, string $expected): void { $dir = '_' . __FUNCTION__; @@ -671,7 +670,7 @@ public function testFieldAliases() $this->assertResult('readOneDataObjectFake.author', null, $result); } - public function provideFilterAndSortOnlyRead(): array + public static function provideFilterAndSortOnlyRead(): array { return [ 'read with sort' => [ @@ -797,9 +796,7 @@ public function provideFilterAndSortOnlyRead(): array ]; } - /** - * @dataProvider provideFilterAndSortOnlyRead - */ + #[DataProvider('provideFilterAndSortOnlyRead')] public function testFilterAndSortOnlyRead(string $fixture, string $query, array $expected) { $author = Member::create(['FirstName' => 'tester1']); @@ -847,7 +844,7 @@ public function testFilterAndSortOnlyRead(string $fixture, string $query, array $this->assertResults($expected, $records); } - public function provideFilterAndSortWithArgsOnlyRead(): array + public static function provideFilterAndSortWithArgsOnlyRead(): array { return [ 'read with sort - with sort arg' => [ @@ -900,9 +897,7 @@ public function provideFilterAndSortWithArgsOnlyRead(): array ]; } - /** - * @dataProvider provideFilterAndSortWithArgsOnlyRead - */ + #[DataProvider('provideFilterAndSortWithArgsOnlyRead')] public function testFilterAndSortWithArgsOnlyRead(string $fixture, string $query, array $args, array $expected) { $author = Member::create(['FirstName' => 'tester1']); @@ -1157,9 +1152,9 @@ public function testCanViewPagination() /** * @throws SchemaBuilderException * @throws SchemaNotFoundException - * @dataProvider provideObfuscationState * @param bool $shouldObfuscateTypes */ + #[DataProvider('provideObfuscationState')] public function testQueriesAndMutations($shouldObfuscateTypes) { FakeProductPage::get()->removeAll(); @@ -1502,7 +1497,7 @@ public function testBulkLoadNamespaceAndFilepath() /** * @return array */ - public function provideObfuscationState(): array + public static function provideObfuscationState(): array { return [ [false], [true] ]; } @@ -1577,9 +1572,7 @@ public function testHtaccess(): void ); } - /** - * @dataProvider provideDefaultDepthLimit - */ + #[DataProvider('provideDefaultDepthLimit')] public function testDefaultDepthLimit(int $queryDepth, int $limit) { // This global rule should be ignored. @@ -1593,14 +1586,12 @@ public function testDefaultDepthLimit(int $queryDepth, int $limit) } } - public function provideDefaultDepthLimit() + public static function provideDefaultDepthLimit() { - return $this->createProviderForComplexityOrDepth(15); + return IntegrationTest::createProviderForComplexityOrDepth(15); } - /** - * @dataProvider provideCustomDepthLimit - */ + #[DataProvider('provideCustomDepthLimit')] public function testCustomDepthLimit(int $queryDepth, int $limit) { // This global rule should be ignored. @@ -1614,14 +1605,12 @@ public function testCustomDepthLimit(int $queryDepth, int $limit) } } - public function provideCustomDepthLimit() + public static function provideCustomDepthLimit() { - return $this->createProviderForComplexityOrDepth(25); + return IntegrationTest::createProviderForComplexityOrDepth(25); } - /** - * @dataProvider provideCustomComplexityLimit - */ + #[DataProvider('provideCustomComplexityLimit')] public function testCustomComplexityLimit(int $queryComplexity, int $limit) { // This global rule should be ignored. @@ -1635,37 +1624,33 @@ public function testCustomComplexityLimit(int $queryComplexity, int $limit) } } - public function provideCustomComplexityLimit() + public static function provideCustomComplexityLimit() { - return $this->createProviderForComplexityOrDepth(10); + return IntegrationTest::createProviderForComplexityOrDepth(10); } - /** - * @dataProvider provideDefaultNodeLimit - */ + #[DataProvider('provideDefaultNodeLimit')] public function testDefaultNodeLimit(int $numNodes, int $limit) { $schema = $this->createSchema(new TestSchemaBuilder(['_' . __FUNCTION__])); $this->runNodeLimitTest($numNodes, $limit, $schema); } - public function provideDefaultNodeLimit() + public static function provideDefaultNodeLimit() { - return $this->createProviderForComplexityOrDepth(500); + return IntegrationTest::createProviderForComplexityOrDepth(500); } - /** - * @dataProvider provideCustomNodeLimit - */ + #[DataProvider('provideCustomNodeLimit')] public function testCustomNodeLimit(int $numNodes, int $limit) { $schema = $this->createSchema(new TestSchemaBuilder(['_' . __FUNCTION__])); $this->runNodeLimitTest($numNodes, $limit, $schema); } - public function provideCustomNodeLimit() + public static function provideCustomNodeLimit() { - return $this->createProviderForComplexityOrDepth(200); + return IntegrationTest::createProviderForComplexityOrDepth(200); } public function testGlobalRuleNotRemoved() @@ -1694,7 +1679,7 @@ private function removeDocumentValidatorRule(string $ruleName): void $reflectionValidator->setStaticPropertyValue('rules', $rules); } - private function createProviderForComplexityOrDepth(int $limit): array + private static function createProviderForComplexityOrDepth(int $limit): array { return [ 'far less than limit' => [1, $limit], diff --git a/tests/Schema/SchemaTest.php b/tests/Schema/SchemaTest.php index ca304a4e0..8ca2d078f 100644 --- a/tests/Schema/SchemaTest.php +++ b/tests/Schema/SchemaTest.php @@ -46,7 +46,7 @@ public function testApplyConfig() { $mock = $this->getMockBuilder(Schema::class) ->setConstructorArgs(['test', $this->createSchemaContext()]) - ->setMethods(['addType', 'addInterface', 'addUnion', 'addModel', 'addEnum', 'addScalar']) + ->onlyMethods(['addType', 'addInterface', 'addUnion', 'addModel', 'addEnum', 'addScalar']) ->getMock(); $mock ->expects($this->exactly(3)) @@ -148,7 +148,7 @@ public function testTypes() $schema->addType($type = Type::create('MyType')); $mock = $this->getMockBuilder(Type::class) ->setConstructorArgs(['DupeType']) - ->setMethods(['mergeWith']) + ->onlyMethods(['mergeWith']) ->getMock(); $mock->expects($this->once()) ->method('mergeWith') @@ -192,7 +192,7 @@ public function testInterfaces() $schema->addInterface($int = InterfaceType::create('MyType')); $mock = $this->getMockBuilder(InterfaceType::class) ->setConstructorArgs(['DupeType']) - ->setMethods(['mergeWith']) + ->onlyMethods(['mergeWith']) ->getMock(); $mock->expects($this->once()) ->method('mergeWith') @@ -213,7 +213,7 @@ public function testUnions() $schema->addUnion($int = UnionType::create('MyType')); $mock = $this->getMockBuilder(UnionType::class) ->setConstructorArgs(['DupeType']) - ->setMethods(['mergeWith']) + ->onlyMethods(['mergeWith']) ->getMock(); $mock->expects($this->once()) ->method('mergeWith')