You are here

public function WidgetPluginManagerTest::testWidgetDefinitionAlter in Drupal 8

Same name and namespace in other branches
  1. 9 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\Kernel

Code

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