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()); } }