You are here

public function DefaultPluginManagerTest::testCacheClearWithTags in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php \Drupal\Tests\Core\Plugin\DefaultPluginManagerTest::testCacheClearWithTags()

Tests the plugin manager cache clear with tags.

File

core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php, line 215
Contains \Drupal\Tests\Core\Plugin\DefaultPluginManagerTest.

Class

DefaultPluginManagerTest
Tests the DefaultPluginManager.

Namespace

Drupal\Tests\Core\Plugin

Code

public function testCacheClearWithTags() {
  $cid = $this
    ->randomMachineName();
  $cache_backend = $this
    ->getMock('Drupal\\Core\\Cache\\CacheBackendInterface');
  $cache_tags_invalidator = $this
    ->getMock('Drupal\\Core\\Cache\\CacheTagsInvalidatorInterface');
  $cache_tags_invalidator
    ->expects($this
    ->once())
    ->method('invalidateTags')
    ->with(array(
    'tag',
  ));
  $cache_backend
    ->expects($this
    ->never())
    ->method('deleteMultiple');
  $this
    ->getContainerWithCacheTagsInvalidator($cache_tags_invalidator);
  $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, NULL, NULL, '\\Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\FruitInterface');
  $plugin_manager
    ->setCacheBackend($cache_backend, $cid, array(
    'tag',
  ));
  $plugin_manager
    ->clearCachedDefinitions();
}