You are here

function WidgetPluginManagerTest::testWidgetDefinitionAlter in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/field/src/Tests/WidgetPluginManagerTest.php \Drupal\field\Tests\WidgetPluginManagerTest::testWidgetDefinitionAlter()

Tests that the widget definitions alter hook works.

File

core/modules/field/src/Tests/WidgetPluginManagerTest.php, line 22
Contains \Drupal\field\Tests\WidgetPluginManagerTest.

Class

WidgetPluginManagerTest
Tests the field widget manager.

Namespace

Drupal\field\Tests

Code

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