You are here

protected function QueryResultAssertionTrait::assertErrors in GraphQL 8.3

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

Assert a query result with certain errors.

Parameters

string $query: The query string.

array $variables: The query variables.

mixed $expected: The expected error messages.

\Drupal\Core\Cache\CacheableMetadata $metadata: The expected cache metadata object.

2 calls to QueryResultAssertionTrait::assertErrors()
SecureFieldTest::testInsecureField in tests/src/Kernel/Framework/SecureFieldTest.php
Test if an insecure field is accessible.
TestFrameworkTest::testErrorAssertion in tests/src/Kernel/Framework/TestFrameworkTest.php
Test result error assertions.

File

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

Class

QueryResultAssertionTrait
Trait for easier assertion on GraphQL query results.

Namespace

Drupal\Tests\graphql\Traits

Code

protected function assertErrors($query, $variables, $expected, CacheableMetadata $metadata) {
  $result = $this
    ->graphQlProcessor()
    ->processQuery($this
    ->getDefaultSchema(), OperationParams::create([
    'query' => $query,
    'variables' => $variables,
  ]));
  $this
    ->assertResultErrors($result, $expected);
  $this
    ->assertResultMetadata($result, $metadata);
}