You are here

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

Verify that fields with uncacheable annotations are not cached.

File

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

Class

ResultCacheTest
Test query result caching.

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

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

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

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