You are here

public function ResultCacheTest::testCacheableResult in GraphQL 8.3

Same name and namespace in other branches
  1. 8.4 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 22

Class

ResultCacheTest
Test query result caching.

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

public function testCacheableResult() {
  $this
    ->mockField('root', [
    'id' => 'root',
    'name' => 'root',
    'type' => 'String',
  ], NULL, function ($field) {
    $field
      ->expects(static::once())
      ->method('resolveValues')
      ->willReturnCallback(function () {
      (yield 'test');
    });
  });

  // The first request that is supposed to be cached.
  $this
    ->query('{ root }');

  // This should *not* invoke the processor a second time.
  $this
    ->query('{ root }');
}