3 namespace Drupal\KernelTests\Core\Plugin;
6 * Tests that derivative plugins are correctly discovered.
10 class DerivativeTest extends PluginTestBase {
15 public static $modules = ['node', 'user'];
18 * Tests getDefinitions() and getDefinition() with a derivativeDecorator.
20 public function testDerivativeDecorator() {
21 // Ensure that getDefinitions() returns the expected definitions.
22 $this->assertEqual($this->mockBlockManager->getDefinitions(), $this->mockBlockExpectedDefinitions);
24 // Ensure that getDefinition() returns the expected definition.
25 foreach ($this->mockBlockExpectedDefinitions as $id => $definition) {
26 $this->assertEqual($this->mockBlockManager->getDefinition($id), $definition);
29 // Ensure that NULL is returned as the definition of a non-existing base
30 // plugin, a non-existing derivative plugin, or a base plugin that may not
31 // be used without deriving.
32 $this->assertIdentical($this->mockBlockManager->getDefinition('non_existing', FALSE), NULL, 'NULL returned as the definition of a non-existing base plugin.');
33 $this->assertIdentical($this->mockBlockManager->getDefinition('menu:non_existing', FALSE), NULL, 'NULL returned as the definition of a non-existing derivative plugin.');
34 $this->assertIdentical($this->mockBlockManager->getDefinition('menu', FALSE), NULL, 'NULL returned as the definition of a base plugin that may not be used without deriving.');