/** * Tests the plugin manager cache clear with tags. */ public function testCacheClearWithTags() { $cid = $this->randomName(); $cache_backend = $this->getMockBuilder('Drupal\\Core\\Cache\\MemoryBackend')->disableOriginalConstructor()->getMock(); $cache_backend->expects($this->once())->method('deleteTags')->with(array('tag' => TRUE)); $cache_backend->expects($this->never())->method('deleteMultiple'); $this->getContainerWithCacheBins($cache_backend); $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions); $plugin_manager->setCacheBackend($cache_backend, $cid, array('tag' => TRUE)); $plugin_manager->clearCachedDefinitions(); }
/** * Tests plugins without a required interface. * * @covers ::getDefinitions */ public function testGetDefinitionsWithoutRequiredInterface() { $module_handler = $this->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface'); $module_handler->expects($this->any())->method('moduleExists')->with('plugin_test')->willReturn(FALSE); $this->expectedDefinitions['kale'] = array('id' => 'kale', 'label' => 'Kale', 'color' => 'green', 'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\Kale', 'provider' => 'plugin_test'); $this->expectedDefinitions['apple']['provider'] = 'plugin_test'; $this->expectedDefinitions['banana']['provider'] = 'plugin_test'; $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, $module_handler, NULL); $this->assertInternalType('array', $plugin_manager->getDefinitions()); }
/** * @covers ::getCacheMaxAge */ public function testGetCacheMaxAge() { $module_handler = $this->prophesize(ModuleHandlerInterface::class); $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, $module_handler->reveal(), NULL); $cache_max_age = $plugin_manager->getCacheMaxAge(); $this->assertInternalType('int', $cache_max_age); }