public function ViewsCacheabilityMetadataExportTest::register in Search API 8
Registers test-specific services.
Extend this method in your test to register additional services. This method is called whenever the kernel is rebuilt.
Parameters
\Drupal\Core\DependencyInjection\ContainerBuilder $container: The service container to enhance.
Overrides KernelTestBase::register
See also
\Drupal\Tests\KernelTestBase::bootKernel()
File
- tests/
src/ Kernel/ Views/ ViewsCacheabilityMetadataExportTest.php, line 71
Class
- ViewsCacheabilityMetadataExportTest
- Tests that cacheability metadata is included when Views config is exported.
Namespace
Drupal\Tests\search_api\Kernel\ViewsCode
public function register(ContainerBuilder $container) {
parent::register($container);
// Use a mocked version of the cache contexts manager so we can use a mocked
// cache context "search_api_test_context" without triggering a validation
// error.
$cache_contexts_manager = $this
->createMock(CacheContextsManager::class);
$cache_contexts_manager
->method('assertValidTokens')
->willReturn(TRUE);
$cache_contexts_manager
->method('convertTokensToKeys')
->willReturn(new ContextCacheKeys([]));
$container
->set('cache_contexts_manager', $cache_contexts_manager);
}