PluginAlterTest.php in Drupal 10
File
core/tests/Drupal/KernelTests/Core/Render/Element/PluginAlterTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Render\Element;
use Drupal\KernelTests\KernelTestBase;
class PluginAlterTest extends KernelTestBase {
protected static $modules = [
'element_info_test',
];
public function testPluginAlter() {
$info_manager = $this->container
->get('plugin.manager.element_info');
$this
->assertArrayHasKey('weight', $info_manager
->getDefinitions());
$this->container
->get('state')
->set('hook_element_plugin_alter:remove_weight', TRUE);
$this
->assertArrayHasKey('weight', $info_manager
->getDefinitions());
$info_manager
->clearCachedDefinitions();
$this
->assertArrayNotHasKey('weight', $info_manager
->getDefinitions());
}
}