You are here

public function ResultTest::testBatchedQueries in GraphQL 8.3

Same name and namespace in other branches
  1. 8.4 tests/src/Kernel/Framework/ResultTest.php \Drupal\Tests\graphql\Kernel\Framework\ResultTest::testBatchedQueries()

Test a batched query result.

File

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

Class

ResultTest
Test the whole query result pipeline.

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

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