core/lib/Drupal/Core/Block/BlockBase.php | 2 +- .../test/ExtendNonInstalledClassOperation.php | 18 ------------------ .../plugin_test/fruit/ExtendingNonInstalledClass.php | 14 ++++++++++++++ .../Plugin/Discovery/AnnotatedClassDiscoveryTest.php | 7 +++++++ .../CustomDirectoryAnnotatedClassDiscoveryTest.php | 7 +++++++ .../Tests/Core/Plugin/DefaultPluginManagerTest.php | 19 +++++++++++++++++++ 6 files changed, 48 insertions(+), 19 deletions(-) diff --git a/core/lib/Drupal/Core/Block/BlockBase.php b/core/lib/Drupal/Core/Block/BlockBase.php index 3e33e14..e21926a 100644 --- a/core/lib/Drupal/Core/Block/BlockBase.php +++ b/core/lib/Drupal/Core/Block/BlockBase.php @@ -280,7 +280,7 @@ public function getFormClass($operation) { if (isset($this->getPluginDefinition()['forms'][$operation])) { return $this->getPluginDefinition()['forms'][$operation]; } - elseif ($operation == 'configure' && $this instanceof PluginFormInterface) { + elseif ($operation === 'configure' && $this instanceof PluginFormInterface) { return static::class; } } diff --git a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/ExtendNonInstalledClassOperation.php b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/ExtendNonInstalledClassOperation.php deleted file mode 100644 index 9e476c6..0000000 --- a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/ExtendNonInstalledClassOperation.php +++ /dev/null @@ -1,18 +0,0 @@ - 'Drupal\plugin_test_extended\Plugin\plugin_test\fruit\BigApple', 'provider' => 'plugin_test_extended', ), + 'extending_non_installed_class' => array( + 'id' => 'extending_non_installed_class', + 'label' => 'A plugin whose class is extending from a non-installed module class', + 'color' => 'pink', + 'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\ExtendingNonInstalledClass', + 'provider' => 'plugin_test', + ), ); $base_directory = \Drupal::root() . '/core/modules/system/tests/modules/plugin_test/src'; diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php index 3d5d8c2..a9fbf79 100644 --- a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php @@ -71,6 +71,13 @@ protected function setUp() { 'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Orange', 'provider' => 'plugin_test', ), + 'extending_non_installed_class' => array( + 'id' => 'extending_non_installed_class', + 'label' => 'A plugin whose class is extending from a non-installed module class', + 'color' => 'pink', + 'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\ExtendingNonInstalledClass', + 'provider' => 'plugin_test', + ), ); $base_directory = \Drupal::root() . '/core/modules/system/tests/modules/plugin_test/src'; diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php index c0423bc..ffdac5a 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php @@ -60,6 +60,25 @@ protected function setUp() { $this->namespaces['Drupal\plugin_test'] = $this->root . '/core/modules/system/tests/modules/plugin_test/src'; } + /** + * Tests the plugin manager with a plugin that extends a non-installed class. + */ + public function testDefaultPluginManagerWithPluginExtendingNonInstalledClass() { + $definitions = array(); + $definitions['extending_non_installed_class'] = array( + 'id' => 'extending_non_installed_class', + 'label' => 'A plugin whose class is extending from a non-installed module class', + 'color' => 'pink', + 'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\ExtendingNonInstalledClass', + 'provider' => 'plugin_test', + ); + + $module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); + $plugin_manager = new TestPluginManager($this->namespaces, $definitions, $module_handler, 'test_alter_hook', '\Drupal\plugin_test\Plugin\plugin_test\fruit\FruitInterface'); + $plugin_manager->getDefinition('plugin_test', FALSE); + $this->assertTrue(TRUE, 'No PHP fatal error occurred when retrieving the definitions of a module with plugins that depend on a non-installed module class should not cause a PHP fatal.'); + } + /** * Tests the plugin manager with a disabled module. */