class InspectionTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Plugin/InspectionTest.php \Drupal\KernelTests\Core\Plugin\InspectionTest
- 10 core/tests/Drupal/KernelTests/Core/Plugin/InspectionTest.php \Drupal\KernelTests\Core\Plugin\InspectionTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Plugin/InspectionTest.php \Drupal\KernelTests\Core\Plugin\InspectionTest
Tests that plugins implementing PluginInspectionInterface can be inspected.
@group Plugin
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Plugin\PluginTestBase implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\Core\Plugin\InspectionTest implements \Drupal\KernelTests\Core\Plugin\PluginTestBase
- class \Drupal\KernelTests\Core\Plugin\PluginTestBase implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of InspectionTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ InspectionTest.php, line 10
Namespace
Drupal\KernelTests\Core\PluginView source
class InspectionTest extends PluginTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
'user',
];
/**
* Ensure the test plugins correctly implement getPluginId() and getPluginDefinition().
*/
public function testInspection() {
foreach ([
'user_login',
] as $id) {
$plugin = $this->testPluginManager
->createInstance($id);
$expected_definition = $this->testPluginExpectedDefinitions[$id];
$this->assertSame($id, $plugin->getPluginId());
$this->assertSame($expected_definition, $this->testPluginManager
->getDefinition($id));
$this->assertSame($expected_definition, $plugin->getPluginDefinition());
}
// Skip the 'menu' derived blocks, because MockMenuBlock does not implement
// PluginInspectionInterface. The others do by extending PluginBase.
foreach ([
'user_login',
'layout',
] as $id) {
$plugin = $this->mockBlockManager
->createInstance($id);
$expected_definition = $this->mockBlockExpectedDefinitions[$id];
$this->assertSame($id, $plugin->getPluginId());
$this->assertEquals($expected_definition, $this->mockBlockManager
->getDefinition($id));
$this->assertEquals($expected_definition, $plugin->getPluginDefinition());
}
// Test a plugin manager that provides defaults.
foreach ([
'test_block1',
'test_block2',
] as $id) {
$plugin = $this->defaultsTestPluginManager
->createInstance($id);
$expected_definition = $this->defaultsTestPluginExpectedDefinitions[$id];
$this->assertSame($id, $plugin->getPluginId());
$this->assertSame($expected_definition, $this->defaultsTestPluginManager
->getDefinition($id));
$this->assertEquals($expected_definition, $plugin->getPluginDefinition());
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.