public function WidgetPluginManagerTest::testWidgetDefinitionAlter in Drupal 9
Same name and namespace in other branches
- 8 core/modules/field/tests/src/Kernel/WidgetPluginManagerTest.php \Drupal\Tests\field\Kernel\WidgetPluginManagerTest::testWidgetDefinitionAlter()
Tests that the widget definitions alter hook works.
File
- core/
modules/ field/ tests/ src/ Kernel/ WidgetPluginManagerTest.php, line 17
Class
- WidgetPluginManagerTest
- Tests the field widget manager.
Namespace
Drupal\Tests\field\KernelCode
public function testWidgetDefinitionAlter() {
$widget_definition = \Drupal::service('plugin.manager.field.widget')
->getDefinition('test_field_widget_multiple');
// Test if hook_field_widget_info_alter is being called.
$this
->assertContains('test_field', $widget_definition['field_types'], "The 'test_field_widget_multiple' widget is enabled for the 'test_field' field type in field_test_field_widget_info_alter().");
}