You are here

private function QueryResultAssertionTrait::assertResultData in GraphQL 8.3

Same name and namespace in other branches
  1. 8.4 tests/src/Traits/QueryResultAssertionTrait.php \Drupal\Tests\graphql\Traits\QueryResultAssertionTrait::assertResultData()

Assert a certain result data set on a query result.

@internal

Parameters

\Drupal\graphql\GraphQL\Execution\QueryResult $result: The query result object.

mixed $expected: The expected result data set.

1 call to QueryResultAssertionTrait::assertResultData()
QueryResultAssertionTrait::assertResults in tests/src/Traits/QueryResultAssertionTrait.php
Assert a result for a graphql query and variables.

File

tests/src/Traits/QueryResultAssertionTrait.php, line 147

Class

QueryResultAssertionTrait
Trait for easier assertion on GraphQL query results.

Namespace

Drupal\Tests\graphql\Traits

Code

private function assertResultData(QueryResult $result, $expected) {
  $data = $result
    ->toArray();
  $this
    ->assertArrayHasKey('data', $data, 'No result data.');
  $this
    ->assertEquals($expected, $data['data'], 'Unexpected query result.');
}