Commit c2874bbc authored by webchick's avatar webchick

Issue #1817180 by zuuperman, tstoeckler, amateescu: Fixed Tests:...

Issue #1817180 by zuuperman, tstoeckler, amateescu: Fixed Tests: hook_widget_info_alter() is not called anymore.
parent 38168470
......@@ -9,6 +9,7 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\field\Plugin\Type\Widget\WidgetLegacyDiscoveryDecorator;
......@@ -44,7 +45,7 @@ class WidgetPluginManager extends PluginManagerBase {
* Constructs a WidgetPluginManager object.
*/
public function __construct() {
$this->baseDiscovery = new WidgetLegacyDiscoveryDecorator(new AnnotatedClassDiscovery('field', 'widget'));
$this->baseDiscovery = new AlterDecorator(new WidgetLegacyDiscoveryDecorator(new AnnotatedClassDiscovery('field', 'widget')), 'field_widget_info');
$this->discovery = new CacheDecorator($this->baseDiscovery, $this->cache_id, $this->cache_bin);
$this->factory = new WidgetFactory($this);
......
......@@ -328,4 +328,16 @@ function testSettingsInfo() {
$this->assertIdentical(field_info_formatter_settings($type), $info['settings'], format_string("field_info_formatter_settings returns %type's formatter settings", array('%type' => $type)));
}
}
/**
* Test that the widget definition functions work.
*/
function testWidgetDefinition() {
$widget_definition = field_info_widget_types('test_field_widget_multiple');
// Test if hook_field_widget_info_alter is beïng 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().");
}
}
......@@ -47,6 +47,13 @@ function field_test_field_info() {
);
}
/**
* Implements hook_field_widget_info_alter().
*/
function field_test_field_widget_info_alter(&$info) {
$info['test_field_widget_multiple']['field_types'][] = 'test_field';
}
/**
* Implements hook_field_update_forbid().
*/
......
......@@ -14,13 +14,14 @@
/**
* Plugin implementation of the 'test_field_widget_multiple' widget.
*
* The 'field_types' entry is left empty, and is populated through hook_field_widget_info_alter().
*
* @see field_test_field_widget_info_alter()
*
* @Plugin(
* id = "test_field_widget_multiple",
* module = "field_test",
* label = @Translation("Test widget - multiple"),
* field_types = {
* "test_field"
* },
* settings = {
* "test_widget_setting_multiple" = "dummy test string"
* },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment