DisabledResultCacheTest.php in GraphQL 8.4
File
tests/src/Kernel/Framework/DisabledResultCacheTest.php
View source
<?php
namespace Drupal\Tests\graphql\Kernel\Framework;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Tests\graphql\Kernel\GraphQLTestBase;
use Drupal\graphql\Entity\Server;
class DisabledResultCacheTest extends GraphQLTestBase {
protected function setUp() : void {
parent::setUp();
$schema = <<<GQL
type Query {
root: String
}
GQL;
$this
->setUpSchema($schema);
}
public function register(ContainerBuilder $container) : void {
parent::register($container);
$parameters = $container
->getParameter('graphql.config');
$parameters['development'] = TRUE;
$container
->setParameter('graphql.config', $parameters);
}
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();
});
$this
->query('{ root }');
$this
->query('{ root }');
}
}