public function EntityBufferTest::testEntityBuffer in GraphQL 8.4
Tests the entity buffer.
File
- tests/
src/ Kernel/ EntityBufferTest.php, line 61
Class
- EntityBufferTest
- Tests the entity buffer system that it returns the correct cache metadata.
Namespace
Drupal\Tests\graphql\KernelCode
public function testEntityBuffer() : void {
$query = <<<GQL
query {
a:node(id: "1") {
title
}
b:node(id: "2") {
title
}
c:node(id: "3") {
title
}
}
GQL;
$this
->mockResolver('Query', 'node', $this->builder
->produce('entity_load')
->map('type', $this->builder
->fromValue('node'))
->map('id', $this->builder
->fromArgument('id')));
$this
->mockResolver('Node', 'title', $this->builder
->produce('entity_label')
->map('entity', $this->builder
->fromParent()));
$metadata = $this
->defaultCacheMetaData();
$metadata
->addCacheTags([
'node:1',
'node:2',
'node:3',
]);
$this
->assertResults($query, [], [
'a' => [
'title' => 'Node 1',
],
'b' => [
'title' => 'Node 2',
],
'c' => [
'title' => 'Node 3',
],
], $metadata);
}