You are here

public function DefaultPluginManagerTest::testDefaultPluginManagerWithAlter in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php \Drupal\Tests\Core\Plugin\DefaultPluginManagerTest::testDefaultPluginManagerWithAlter()
  2. 10 core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php \Drupal\Tests\Core\Plugin\DefaultPluginManagerTest::testDefaultPluginManagerWithAlter()

Tests the plugin manager with no cache and altering.

File

core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php, line 159

Class

DefaultPluginManagerTest
Tests the DefaultPluginManager.

Namespace

Drupal\Tests\Core\Plugin

Code

public function testDefaultPluginManagerWithAlter() {
  $module_handler = $this
    ->getMockBuilder('Drupal\\Core\\Extension\\ModuleHandler')
    ->disableOriginalConstructor()
    ->getMock();

  // Configure the stub.
  $alter_hook_name = $this
    ->randomMachineName();
  $module_handler
    ->expects($this
    ->once())
    ->method('alter')
    ->with($this
    ->equalTo($alter_hook_name), $this
    ->equalTo($this->expectedDefinitions));
  $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, $module_handler, $alter_hook_name, '\\Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\FruitInterface');
  $this
    ->assertEquals($this->expectedDefinitions, $plugin_manager
    ->getDefinitions());
  $this
    ->assertEquals($this->expectedDefinitions['banana'], $plugin_manager
    ->getDefinition('banana'));
}