function UnitTestCase::getContainerWithCacheTagsInvalidator

Same name in other branches
  1. 9 core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::getContainerWithCacheTagsInvalidator()
  2. 8.9.x core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::getContainerWithCacheTagsInvalidator()
  3. 10 core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::getContainerWithCacheTagsInvalidator()

Sets up a container with a cache tags invalidator.

Parameters

\Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_validator: The cache tags invalidator.

Return value

\Symfony\Component\DependencyInjection\ContainerInterface|\PHPUnit\Framework\MockObject\MockObject The container with the cache tags invalidator service.

3 calls to UnitTestCase::getContainerWithCacheTagsInvalidator()
CacheCollectorTest::setUp in core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php
DefaultPluginManagerTest::testCacheClearWithTags in core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php
Tests the plugin manager cache clear with tags.
ViewsDataTest::setUp in core/modules/views/tests/src/Unit/ViewsDataTest.php

File

core/tests/Drupal/Tests/UnitTestCase.php, line 199

Class

UnitTestCase
Provides a base class and helpers for Drupal unit tests.

Namespace

Drupal\Tests

Code

protected function getContainerWithCacheTagsInvalidator(CacheTagsInvalidatorInterface $cache_tags_validator) {
    $container = $this->createMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
    $container->expects($this->any())
        ->method('get')
        ->with('cache_tags.invalidator')
        ->willReturn($cache_tags_validator);
    \Drupal::setContainer($container);
    return $container;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.