public function ValidatorTest::testGetOrphanedResolversDetectsOrphanedObjectFieldResolvers in GraphQL 8.4
@covers ::getOrphanedResolvers
File
- tests/
src/ Kernel/ ValidatorTest.php, line 132
Class
- ValidatorTest
- Tests that the GraphQL validator behaves correctly.
Namespace
Drupal\Tests\graphql\KernelCode
public function testGetOrphanedResolversDetectsOrphanedObjectFieldResolvers() : void {
$schema = <<<GQL
type Query {
me: User
}
type User {
name: String!
}
GQL;
$this
->setUpSchema($schema);
$this
->mockResolver('Query', 'me', $this->builder
->fromValue('Test User'));
$this
->mockResolver('User', 'name', $this->builder
->fromParent());
$this
->mockResolver('User', 'birthday', $this->builder
->fromValue('01-02-2021'));
$validator = new Validator($this->schemaPluginManager);
$orphaned_resolvers = $validator
->getOrphanedResolvers($this->server);
self::assertEquals([
'User' => [
'birthday',
],
], $orphaned_resolvers);
}