class PluginAlterTest in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Render/Element/PluginAlterTest.php \Drupal\KernelTests\Core\Render\Element\PluginAlterTest
- 9 core/tests/Drupal/KernelTests/Core/Render/Element/PluginAlterTest.php \Drupal\KernelTests\Core\Render\Element\PluginAlterTest
@group Render
Hierarchy
- class \Drupal\KernelTests\Core\Render\Element\PluginAlterTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of PluginAlterTest
File
- core/
tests/ Drupal/ KernelTests/ Core/ Render/ Element/ PluginAlterTest.php, line 10
Namespace
Drupal\KernelTests\Core\Render\ElementView source
class PluginAlterTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'element_info_test',
];
/**
* Tests hook_element_plugin_alter().
*/
public function testPluginAlter() {
$info_manager = $this->container
->get('plugin.manager.element_info');
$this
->assertArrayHasKey('weight', $info_manager
->getDefinitions());
// @see element_info_test_element_plugin_alter()
$this->container
->get('state')
->set('hook_element_plugin_alter:remove_weight', TRUE);
// The definition will be cached.
$this
->assertArrayHasKey('weight', $info_manager
->getDefinitions());
// Clearing the caches removes the definition.
$info_manager
->clearCachedDefinitions();
$this
->assertArrayNotHasKey('weight', $info_manager
->getDefinitions());
}
}