You are here

public function ValidatorTest::testGetOrphanedResolversDetectsOrphanedInterfaceFieldResolvers in GraphQL 8.4

@covers ::getOrphanedResolvers

File

tests/src/Kernel/ValidatorTest.php, line 155

Class

ValidatorTest
Tests that the GraphQL validator behaves correctly.

Namespace

Drupal\Tests\graphql\Kernel

Code

public function testGetOrphanedResolversDetectsOrphanedInterfaceFieldResolvers() : void {
  $schema = <<<GQL
      type Query {
        me: Actor
      }

      interface Actor {
        name: String!
      }

      type User implements Actor {
        name: String!
      }
GQL;
  $this
    ->setUpSchema($schema);
  $this
    ->mockResolver('Query', 'me', $this->builder
    ->fromValue('Test User'));
  $this
    ->mockResolver('Actor', 'name', $this->builder
    ->fromParent());
  $this
    ->mockResolver('Actor', 'birthday', $this->builder
    ->fromValue('01-02-2021'));
  $validator = new Validator($this->schemaPluginManager);
  $orphaned_resolvers = $validator
    ->getOrphanedResolvers($this->server);
  self::assertEquals([
    'Actor' => [
      'birthday',
    ],
  ], $orphaned_resolvers);
}