EnableCliCacheTrait.php in GraphQL 8.3
Namespace
Drupal\Tests\graphql\TraitsFile
tests/src/Traits/EnableCliCacheTrait.phpView source
<?php
namespace Drupal\Tests\graphql\Traits;
use Drupal\Core\PageCache\RequestPolicyInterface;
use Prophecy\Argument;
/**
* Trait to automatically enable CLI caching in GraphQL tests.
*/
trait EnableCliCacheTrait {
/**
* Enable caching in CLI environments.
*/
protected function enableCliCache() {
// Disable the cli deny policy because we actually want caching on cli
// when kernel testing it.
$cliPolicy = $this
->prophesize(RequestPolicyInterface::class);
$cliPolicy
->check(Argument::cetera())
->willReturn(NULL);
$this->container
->set('graphql.request_policy.deny_command_line', $cliPolicy
->reveal());
}
}
Traits
Name | Description |
---|---|
EnableCliCacheTrait | Trait to automatically enable CLI caching in GraphQL tests. |