519d7373c5911ec433f89945e53249a81dc72b7e
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Plugin / DerivativeTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Plugin;
4
5 /**
6  * Tests that derivative plugins are correctly discovered.
7  *
8  * @group Plugin
9  */
10 class DerivativeTest extends PluginTestBase {
11
12   /**
13    * {@inheritdoc}
14    */
15   public static $modules = ['node', 'user'];
16
17   /**
18    * Tests getDefinitions() and getDefinition() with a derivativeDecorator.
19    */
20   public function testDerivativeDecorator() {
21     // Ensure that getDefinitions() returns the expected definitions.
22     $this->assertEqual($this->mockBlockManager->getDefinitions(), $this->mockBlockExpectedDefinitions);
23
24     // Ensure that getDefinition() returns the expected definition.
25     foreach ($this->mockBlockExpectedDefinitions as $id => $definition) {
26       $this->assertEqual($this->mockBlockManager->getDefinition($id), $definition);
27     }
28
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.');
35   }
36
37 }