public function ResultCacheTest::testCacheableResult in GraphQL 8.4
Same name and namespace in other branches
- 8.3 tests/src/Kernel/Framework/ResultCacheTest.php \Drupal\Tests\graphql\Kernel\Framework\ResultCacheTest::testCacheableResult()
Check basic result caching.
File
- tests/
src/ Kernel/ Framework/ ResultCacheTest.php, line 41
Class
- ResultCacheTest
- Test query result caching.
Namespace
Drupal\Tests\graphql\Kernel\FrameworkCode
public function testCacheableResult() : void {
$dummy = $this
->getMockBuilder(Server::class)
->disableOriginalConstructor()
->setMethods([
'id',
])
->getMock();
$dummy
->expects($this
->once())
->method('id')
->willReturn('test');
$this
->mockResolver('Query', 'root', function () use ($dummy) {
return $dummy
->id();
});
// The first request that is supposed to be cached.
$this
->query('{ root }');
// This should *not* invoke the processor a second time.
$this
->query('{ root }');
}