You are here

public function ResultTest::testPersistedQuery in GraphQL 8.3

Test a persisted query result.

File

tests/src/Kernel/Framework/ResultTest.php, line 44

Class

ResultTest
Test the whole query result pipeline.

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

public function testPersistedQuery() {
  $queryProvider = $this
    ->prophesize(QueryProviderInterface::class);
  $this->container
    ->set('graphql.query_provider', $queryProvider
    ->reveal());
  $queryProvider
    ->getQuery('a', Argument::any())
    ->willReturn('query { root }');
  $result = $this
    ->persistedQuery('a');
  $this
    ->assertSame(200, $result
    ->getStatusCode());
  $this
    ->assertSame([
    'data' => [
      'root' => 'test',
    ],
  ], json_decode($result
    ->getContent(), TRUE));
}