251abbf47acc05e710e36e9575e71390187692b5
[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    * Tests getDefinitions() and getDefinition() with a derivativeDecorator.
14    */
15   public function testDerivativeDecorator() {
16     // Ensure that getDefinitions() returns the expected definitions.
17     $this->assertEqual($this->mockBlockManager->getDefinitions(), $this->mockBlockExpectedDefinitions);
18
19     // Ensure that getDefinition() returns the expected definition.
20     foreach ($this->mockBlockExpectedDefinitions as $id => $definition) {
21       $this->assertEqual($this->mockBlockManager->getDefinition($id), $definition);
22     }
23
24     // Ensure that NULL is returned as the definition of a non-existing base
25     // plugin, a non-existing derivative plugin, or a base plugin that may not
26     // be used without deriving.
27     $this->assertIdentical($this->mockBlockManager->getDefinition('non_existing', FALSE), NULL, 'NULL returned as the definition of a non-existing base plugin.');
28     $this->assertIdentical($this->mockBlockManager->getDefinition('menu:non_existing', FALSE), NULL, 'NULL returned as the definition of a non-existing derivative plugin.');
29     $this->assertIdentical($this->mockBlockManager->getDefinition('menu', FALSE), NULL, 'NULL returned as the definition of a base plugin that may not be used without deriving.');
30   }
31
32 }