You are here

public function TestFrameworkTest::testErrorAssertion in GraphQL 8.4

Same name and namespace in other branches
  1. 8.3 tests/src/Kernel/Framework/TestFrameworkTest.php \Drupal\Tests\graphql\Kernel\Framework\TestFrameworkTest::testErrorAssertion()

Test result error assertions.

File

tests/src/Kernel/Framework/TestFrameworkTest.php, line 65

Class

TestFrameworkTest
Test the test framework.

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

public function testErrorAssertion() : void {
  $schema = <<<GQL
      type Query {
        wrongname: String
      }
GQL;
  $this
    ->setUpSchema($schema);
  $metadata = new CacheableMetadata();
  $metadata
    ->setCacheMaxAge(0);
  $this
    ->assertErrors('{ root }', [], [
    'Cannot query field "root" on type "Query".',
  ], $metadata);
  $this
    ->assertErrors('{ root }', [], [
    '/root.*Query/',
  ], $metadata);
}