You are here

public function DisabledResultCacheTest::testDisabledCache in GraphQL 8.4

Same name and namespace in other branches
  1. 8.3 tests/src/Kernel/Framework/DisabledResultCacheTest.php \Drupal\Tests\graphql\Kernel\Framework\DisabledResultCacheTest::testDisabledCache()

Test if disabling the result cache has the desired effect.

File

tests/src/Kernel/Framework/DisabledResultCacheTest.php, line 45

Class

DisabledResultCacheTest
Test disabled result cache.

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

public function testDisabledCache() : void {
  $this
    ->createTestServer('test', '/graphql/uncached', [
    'caching' => FALSE,
  ]);
  $object = $this
    ->getMockBuilder(Server::class)
    ->disableOriginalConstructor()
    ->setMethods([
    'id',
  ])
    ->getMock();
  $object
    ->expects($this
    ->exactly(2))
    ->method('id')
    ->willReturn('test');
  $this
    ->mockResolver('Query', 'root', function () use ($object) {
    return $object
      ->id();
  });

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

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