protected function QueryResultAssertionTrait::assertErrors in GraphQL 8.4
Same name and namespace in other branches
- 8.3 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.
1 call to QueryResultAssertionTrait::assertErrors()
- TestFrameworkTest::testErrorAssertion in tests/
src/ Kernel/ Framework/ TestFrameworkTest.php - Test result error assertions.
File
- tests/
src/ Traits/ QueryResultAssertionTrait.php, line 122
Class
- QueryResultAssertionTrait
- Trait for easier assertion on GraphQL query results.
Namespace
Drupal\Tests\graphql\TraitsCode
protected function assertErrors($query, array $variables, $expected, CacheableMetadata $metadata) : void {
$context = new RenderContext();
$result = $this
->getRenderer()
->executeInRenderContext($context, function () use ($query, $variables) {
return $this->server
->executeOperation(OperationParams::create([
'query' => $query,
'variables' => $variables,
]));
});
$this
->assertResultErrors($result, $expected);
$this
->assertResultMetadata($result, $metadata);
self::assertTrue($context
->isEmpty(), "Metadata was leaked during operation execution: {$context->serialize()}");
}