diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php index aebb473..db4a052 100644 --- a/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php +++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php @@ -35,6 +35,7 @@ public function __construct() { // A simple plugin: the user login block. $this->discovery->setDefinition('user_login', array( + 'id' => 'user_login', 'label' => t('User login'), 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserLoginBlock', )); @@ -46,11 +47,13 @@ public function __construct() { // MockMenuBlockDeriver class ensures that only derivatives, and not the // base plugin, are available to the system. $this->discovery->setDefinition('menu', array( + 'id' => 'menu', 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock', 'deriver' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlockDeriver', )); // A plugin defining itself as a derivative. $this->discovery->setDefinition('menu:foo', array( + 'id' => 'menu', 'label' => t('Base label'), 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock', )); @@ -62,6 +65,7 @@ public function __construct() { // MockLayoutBlockDeriver class ensures that both the base plugin and the // derivatives are available to the system. $this->discovery->setDefinition('layout', array( + 'id' => 'layout', 'label' => t('Layout'), 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlock', 'deriver' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlockDeriver', @@ -70,6 +74,7 @@ public function __construct() { // A block plugin that requires context to function. This block requires a // user object in order to return the user name from the getTitle() method. $this->discovery->setDefinition('user_name', array( + 'id' => 'user_name', 'label' => t('User name'), 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserNameBlock', 'context' => array( @@ -79,6 +84,7 @@ public function __construct() { // An optional context version of the previous block plugin. $this->discovery->setDefinition('user_name_optional', array( + 'id' => 'user_name_optional', 'label' => t('User name optional'), 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserNameBlock', 'context' => array( @@ -88,12 +94,14 @@ public function __construct() { // A block plugin that requires a typed data string context to function. $this->discovery->setDefinition('string_context', array( + 'id' => 'string_context', 'label' => t('String typed data'), 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\TypedDataStringBlock', )); // A complex context plugin that requires both a user and node for context. $this->discovery->setDefinition('complex_context', array( + 'id' => 'complex_context', 'label' => t('Complex context'), 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockComplexContextBlock', 'context' => array( diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/PluginTestBase.php b/core/tests/Drupal/KernelTests/Core/Plugin/PluginTestBase.php index 3d651b1..dd5528b 100644 --- a/core/tests/Drupal/KernelTests/Core/Plugin/PluginTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Plugin/PluginTestBase.php @@ -58,31 +58,38 @@ protected function setUp() { ); $this->mockBlockExpectedDefinitions = array( 'user_login' => array( + 'id' => 'user_login', 'label' => 'User login', 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserLoginBlock', ), 'menu:main_menu' => array( + 'id' => 'menu', 'label' => 'Main menu', 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock', ), 'menu:navigation' => array( + 'id' => 'menu', 'label' => 'Navigation', 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock', ), 'menu:foo' => array( + 'id' => 'menu', 'label' => 'Base label', 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock', 'setting' => 'default', ), 'layout' => array( + 'id' => 'layout', 'label' => 'Layout', 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlock', ), 'layout:foo' => array( + 'id' => 'layout', 'label' => 'Layout Foo', 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlock', ), 'user_name' => array( + 'id' => 'user_name', 'label' => 'User name', 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserNameBlock', 'context' => array( @@ -90,6 +97,7 @@ protected function setUp() { ), ), 'user_name_optional' => array( + 'id' => 'user_name_optional', 'label' => 'User name optional', 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserNameBlock', 'context' => array( @@ -97,10 +105,12 @@ protected function setUp() { ), ), 'string_context' => array( + 'id' => 'string_context', 'label' => 'String typed data', 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\TypedDataStringBlock', ), 'complex_context' => array( + 'id' => 'complex_context', 'label' => 'Complex context', 'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockComplexContextBlock', 'context' => array( diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php index 07ba435..1e96458 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php @@ -94,6 +94,7 @@ public function testGetDerivativeFetcherWithAnnotationObjects() { public function testGetDeriverClassWithClassedDefinitions() { $definitions = array(); $definition = $this->prophesize(DerivablePluginDefinitionInterface::class); + $definition->id()->willReturn('non_container_aware_discovery'); $definition->getDeriver()->willReturn(TestDerivativeDiscoveryWithObject::class); $definitions['non_container_aware_discovery'] = $definition->reveal();