3 namespace Drupal\KernelTests\Core\Plugin;
6 * Tests that plugins implementing PluginInspectionInterface are inspectable.
10 class InspectionTest extends PluginTestBase {
13 * Ensure the test plugins correctly implement getPluginId() and getPluginDefinition().
15 public function testInspection() {
16 foreach (['user_login'] as $id) {
17 $plugin = $this->testPluginManager->createInstance($id);
18 $expected_definition = $this->testPluginExpectedDefinitions[$id];
19 $this->assertIdentical($plugin->getPluginId(), $id);
20 $this->assertIdentical($this->testPluginManager->getDefinition($id), $expected_definition);
21 $this->assertIdentical($plugin->getPluginDefinition(), $expected_definition);
23 // Skip the 'menu' derived blocks, because MockMenuBlock does not implement
24 // PluginInspectionInterface. The others do by extending PluginBase.
25 foreach (['user_login', 'layout'] as $id) {
26 $plugin = $this->mockBlockManager->createInstance($id);
27 $expected_definition = $this->mockBlockExpectedDefinitions[$id];
28 $this->assertIdentical($plugin->getPluginId(), $id);
29 $this->assertIdentical($this->castSafeStrings($this->mockBlockManager->getDefinition($id)), $expected_definition);
30 $this->assertIdentical($this->castSafeStrings($plugin->getPluginDefinition()), $expected_definition);
32 // Test a plugin manager that provides defaults.
33 foreach (['test_block1', 'test_block2'] as $id) {
34 $plugin = $this->defaultsTestPluginManager->createInstance($id);
35 $expected_definition = $this->defaultsTestPluginExpectedDefinitions[$id];
36 $this->assertIdentical($plugin->getPluginId(), $id);
37 $this->assertIdentical($this->defaultsTestPluginManager->getDefinition($id), $expected_definition);
38 $this->assertIdentical($this->castSafeStrings($plugin->getPluginDefinition()), $expected_definition);