function UnitTestCase::getContainerWithCacheTagsInvalidator

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::getContainerWithCacheTagsInvalidator()
  2. 10 core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::getContainerWithCacheTagsInvalidator()
  3. 11.x 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 257

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')
        ->will($this->returnValue($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.