function WidgetPluginManagerTest::testWidgetDefinitionAlter

Same name in other branches
  1. 9 core/modules/field/tests/src/Kernel/WidgetPluginManagerTest.php \Drupal\Tests\field\Kernel\WidgetPluginManagerTest::testWidgetDefinitionAlter()
  2. 8.9.x core/modules/field/tests/src/Kernel/WidgetPluginManagerTest.php \Drupal\Tests\field\Kernel\WidgetPluginManagerTest::testWidgetDefinitionAlter()
  3. 10 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 21

Class

WidgetPluginManagerTest
Tests the field widget manager.

Namespace

Drupal\Tests\field\Kernel

Code

public function testWidgetDefinitionAlter() : void {
    $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().");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.