You are here

public function PersistedQueriesTest::testPersistedQueries in GraphQL 8.4

Test a simple query result.

@dataProvider persistedQueriesDataProvider

File

tests/src/Kernel/Framework/PersistedQueriesTest.php, line 61

Class

PersistedQueriesTest
Tests the entire query result pipeline when using persisted queries.

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

public function testPersistedQueries(array $instanceIds, string $queryId, array $expected) : void {

  // Before adding the persisted query plugins to the server, we want to make
  // sure that there are no existing plugins already there.
  $this->server
    ->removeAllPersistedQueryInstances();
  foreach ($instanceIds as $index => $instanceId) {
    $this->{$instanceId}
      ->setWeight($index);
    $this->server
      ->addPersistedQueryInstance($this->{$instanceId});
  }
  $this->server
    ->save();
  $result = $this
    ->query($queryId, NULL, [], NULL, TRUE);
  $this
    ->assertSame(200, $result
    ->getStatusCode());
  $this
    ->assertSame($expected, json_decode($result
    ->getContent(), TRUE));
}