Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Plugin / InspectionTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Plugin;
4
5 /**
6  * Tests that plugins implementing PluginInspectionInterface are inspectable.
7  *
8  * @group Plugin
9  */
10 class InspectionTest extends PluginTestBase {
11
12   /**
13    * {@inheritdoc}
14    */
15   public static $modules = ['node', 'user'];
16
17   /**
18    * Ensure the test plugins correctly implement getPluginId() and getPluginDefinition().
19    */
20   public function testInspection() {
21     foreach (['user_login'] as $id) {
22       $plugin = $this->testPluginManager->createInstance($id);
23       $expected_definition = $this->testPluginExpectedDefinitions[$id];
24       $this->assertIdentical($plugin->getPluginId(), $id);
25       $this->assertIdentical($this->testPluginManager->getDefinition($id), $expected_definition);
26       $this->assertIdentical($plugin->getPluginDefinition(), $expected_definition);
27     }
28     // Skip the 'menu' derived blocks, because MockMenuBlock does not implement
29     // PluginInspectionInterface. The others do by extending PluginBase.
30     foreach (['user_login', 'layout'] as $id) {
31       $plugin = $this->mockBlockManager->createInstance($id);
32       $expected_definition = $this->mockBlockExpectedDefinitions[$id];
33       $this->assertIdentical($plugin->getPluginId(), $id);
34       $this->assertIdentical($this->castSafeStrings($this->mockBlockManager->getDefinition($id)), $expected_definition);
35       $this->assertIdentical($this->castSafeStrings($plugin->getPluginDefinition()), $expected_definition);
36     }
37     // Test a plugin manager that provides defaults.
38     foreach (['test_block1', 'test_block2'] as $id) {
39       $plugin = $this->defaultsTestPluginManager->createInstance($id);
40       $expected_definition = $this->defaultsTestPluginExpectedDefinitions[$id];
41       $this->assertIdentical($plugin->getPluginId(), $id);
42       $this->assertIdentical($this->defaultsTestPluginManager->getDefinition($id), $expected_definition);
43       $this->assertIdentical($this->castSafeStrings($plugin->getPluginDefinition()), $expected_definition);
44     }
45   }
46
47 }