You are here

public function ResultCacheTest::testUncacheableResult 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::testUncacheableResult()

Verify that uncacheable results are not cached.

File

tests/src/Kernel/Framework/ResultCacheTest.php, line 47

Class

ResultCacheTest
Test query result caching.

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

public function testUncacheableResult() {
  $this
    ->mockField('root', [
    'id' => 'root',
    'name' => 'root',
    'type' => 'String',
  ], NULL, function ($field) {
    $callback = function () {
      (yield (new CacheableValue('test'))
        ->mergeCacheMaxAge(0));
    };
    $field
      ->expects(static::exactly(2))
      ->method('resolveValues')
      ->will($this
      ->toBoundPromise($callback, $field));
  });

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

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