You are here

protected function ThunderGqlsTestBase::runAndTestQuery in Thunder 6.2.x

Execute query and compare to expected response.

Parameters

string $schema: The schema to test.

Throws

\GuzzleHttp\Exception\GuzzleException

2 calls to ThunderGqlsTestBase::runAndTestQuery()
JsonLdSchemaTest::testSchema in modules/thunder_gqls/tests/src/Functional/JsonLdSchemaTest.php
Tests the jsonld extension.
SchemaTest::testSchema in modules/thunder_gqls/tests/src/Functional/SchemaTest.php
Tests the article schema.

File

modules/thunder_gqls/tests/src/Functional/ThunderGqlsTestBase.php, line 141

Class

ThunderGqlsTestBase
The base class for all functional Thunder GraphQl schema tests.

Namespace

Drupal\Tests\thunder_gqls\Functional

Code

protected function runAndTestQuery(string $schema) : void {
  $query = $this
    ->getQueryFromFile($schema);
  $variables = $this
    ->getVariablesFromFile($schema);
  $response = $this
    ->query($query, $variables);
  $this
    ->assertEquals(200, $response
    ->getStatusCode(), 'Response not 200');
  $responseData = json_decode($response
    ->getBody(), TRUE)['data'];
  $expectedData = json_decode($this
    ->getExpectedResponseFromFile($schema), TRUE)['data'];
  $this
    ->assertEqualsCanonicalizing($expectedData, $responseData);
}