You are here

public function TestFrameworkTest::testTypeMock in GraphQL 8.3

Test type mocking.

File

tests/src/Kernel/Framework/TestFrameworkTest.php, line 80

Class

TestFrameworkTest
Test the test framework.

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

public function testTypeMock() {
  $this
    ->mockField('value', [
    'name' => 'value',
    'parents' => [
      'Test',
    ],
    'type' => 'String',
  ], function ($value, array $args, ResolveContext $context, ResolveInfo $info) {
    (yield $value['value']);
  });
  $this
    ->mockType('test', [
    'name' => 'Test',
  ]);
  $this
    ->mockField('root', [
    'name' => 'root',
    'type' => 'Test',
  ], function ($value, array $args, ResolveContext $context, ResolveInfo $info) {
    (yield [
      'value' => 'test',
    ]);
  });
  $this
    ->assertResults('{ root { value } }', [], [
    'root' => [
      'value' => 'test',
    ],
  ], $this
    ->defaultCacheMetaData());
}