protected function QueryResultAssertionTrait::assertResults in GraphQL 8.4
Same name and namespace in other branches
- 8.3 tests/src/Traits/QueryResultAssertionTrait.php \Drupal\Tests\graphql\Traits\QueryResultAssertionTrait::assertResults()
Assert a result for a graphql query and variables.
Parameters
string $query: The query string.
array $variables: The query variables.
array $expected: The expected result.
\Drupal\Core\Cache\CacheableMetadata|null $metadata: The expected cache metadata object.
25 calls to QueryResultAssertionTrait::assertResults()
- BufferedFieldTest::testBatchedFields in tests/
src/ Kernel/ Framework/ BufferedFieldTest.php - Test if the schema is created properly.
- EntityBufferTest::testEntityBuffer in tests/
src/ Kernel/ EntityBufferTest.php - Tests the entity buffer.
- EntityDefinitionTest::testBaseFieldFilter in tests/
src/ Kernel/ DataProducer/ EntityDefinitionTest.php - Tests that filtering base field definitions works.
- EntityDefinitionTest::testConfiguredFieldFilter in tests/
src/ Kernel/ DataProducer/ EntityDefinitionTest.php - Tests that filtering configured field definitions works.
- EntityDefinitionTest::testEntityDefinition in tests/
src/ Kernel/ DataProducer/ EntityDefinitionTest.php - Tests that retrieving an entity definition works.
File
- tests/
src/ Traits/ QueryResultAssertionTrait.php, line 90
Class
- QueryResultAssertionTrait
- Trait for easier assertion on GraphQL query results.
Namespace
Drupal\Tests\graphql\TraitsCode
protected function assertResults($query, array $variables, array $expected, CacheableMetadata $metadata = NULL) : 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, []);
$this
->assertResultData($result, $expected);
$this
->assertResultMetadata($result, $metadata ?: $this
->defaultCacheMetaData());
self::assertTrue($context
->isEmpty(), "Metadata was leaked during operation execution: {$context->serialize()}");
}