Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan, xjm: Changing plugins from annotations to attributes in contrib leads to error if plugin extends from a missing dependency
parent
6b50d024b7
commit
618aeb609d
|
@ -41,7 +41,6 @@ parameters:
|
|||
- modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/fruit/ExtendingNonInstalledClass.php
|
||||
- modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/custom_annotation/UsingNonInstalledTraitClass.php
|
||||
- modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/custom_annotation/ExtendingNonInstalledClass.php
|
||||
- tests/Drupal/Tests/Component/Plugin/Attribute/Fixtures/Plugins/PluginNamespace/AttributeDiscoveryTest2.php
|
||||
|
||||
ignoreErrors:
|
||||
# new static() is a best practice in Drupal, so we cannot fix that.
|
||||
|
|
|
@ -29,10 +29,10 @@ class AttributeClassDiscoveryCachedTest extends TestCase {
|
|||
FileCacheFactory::setPrefix('prefix');
|
||||
|
||||
// Normally the attribute classes would be autoloaded.
|
||||
include_once __DIR__ . '/Fixtures/CustomPlugin.php';
|
||||
include_once __DIR__ . '/../../../../../fixtures/plugins/CustomPlugin.php';
|
||||
|
||||
$additionalClassLoader = new ClassLoader();
|
||||
$additionalClassLoader->addPsr4("com\\example\\PluginNamespace\\", __DIR__ . "/Fixtures/Plugins/PluginNamespace");
|
||||
$additionalClassLoader->addPsr4("com\\example\\PluginNamespace\\", __DIR__ . "/../../../../../fixtures/plugins/Plugin/PluginNamespace");
|
||||
$additionalClassLoader->register(TRUE);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ class AttributeClassDiscoveryCachedTest extends TestCase {
|
|||
*/
|
||||
public function testGetDefinitions(): void {
|
||||
// Path to the classes which we'll discover and parse annotation.
|
||||
$discovery_path = __DIR__ . '/Fixtures/Plugins';
|
||||
$discovery_path = __DIR__ . "/../../../../../fixtures/plugins/Plugin";
|
||||
// File path that should be discovered within that directory.
|
||||
$file_path = $discovery_path . '/PluginNamespace/AttributeDiscoveryTest1.php';
|
||||
// Define a file path within the directory that should not be discovered.
|
||||
|
|
|
@ -8,8 +8,6 @@ use Composer\Autoload\ClassLoader;
|
|||
use Drupal\Component\Plugin\Discovery\AttributeClassDiscovery;
|
||||
use Drupal\Component\FileCache\FileCacheFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use com\example\PluginNamespace\CustomPlugin;
|
||||
use com\example\PluginNamespace\CustomPlugin2;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\Component\Plugin\Discovery\AttributeClassDiscovery
|
||||
|
@ -30,10 +28,10 @@ class AttributeClassDiscoveryTest extends TestCase {
|
|||
FileCacheFactory::setPrefix('prefix');
|
||||
|
||||
// Normally the attribute classes would be autoloaded.
|
||||
include_once __DIR__ . '/Fixtures/CustomPlugin.php';
|
||||
include_once __DIR__ . '/../../../../../fixtures/plugins/CustomPlugin.php';
|
||||
|
||||
$additionalClassLoader = new ClassLoader();
|
||||
$additionalClassLoader->addPsr4("com\\example\\PluginNamespace\\", __DIR__ . "/Fixtures/Plugins/PluginNamespace");
|
||||
$additionalClassLoader->addPsr4("com\\example\\PluginNamespace\\", __DIR__ . "/../../../../../fixtures/plugins/Plugin/PluginNamespace");
|
||||
$additionalClassLoader->register(TRUE);
|
||||
}
|
||||
|
||||
|
@ -57,7 +55,7 @@ class AttributeClassDiscoveryTest extends TestCase {
|
|||
* @covers ::prepareAttributeDefinition
|
||||
*/
|
||||
public function testGetDefinitions(): void {
|
||||
$discovery = new AttributeClassDiscovery(['com\example' => [__DIR__ . '/Fixtures/Plugins']]);
|
||||
$discovery = new AttributeClassDiscovery(['com\example' => [__DIR__ . "/../../../../../fixtures/plugins/Plugin"]]);
|
||||
$this->assertEquals([
|
||||
'discovery_test_1' => [
|
||||
'id' => 'discovery_test_1',
|
||||
|
@ -65,7 +63,7 @@ class AttributeClassDiscoveryTest extends TestCase {
|
|||
],
|
||||
], $discovery->getDefinitions());
|
||||
|
||||
$custom_annotation_discovery = new AttributeClassDiscovery(['com\example' => [__DIR__ . '/Fixtures/Plugins']], CustomPlugin::class);
|
||||
$custom_annotation_discovery = new AttributeClassDiscovery(['com\example' => [__DIR__ . "/../../../../../fixtures/plugins/Plugin"]], 'com\example\PluginNamespace\CustomPlugin');
|
||||
$this->assertEquals([
|
||||
'discovery_test_1' => [
|
||||
'id' => 'discovery_test_1',
|
||||
|
@ -74,7 +72,7 @@ class AttributeClassDiscoveryTest extends TestCase {
|
|||
],
|
||||
], $custom_annotation_discovery->getDefinitions());
|
||||
|
||||
$empty_discovery = new AttributeClassDiscovery(['com\example' => [__DIR__ . '/Fixtures/Plugins']], CustomPlugin2::class);
|
||||
$empty_discovery = new AttributeClassDiscovery(['com\example' => [__DIR__ . "/../../../../../fixtures/plugins/Plugin"]], 'com\example\PluginNamespace\CustomPlugin2');
|
||||
$this->assertEquals([], $empty_discovery->getDefinitions());
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ class AttributeBridgeDecoratorTest extends TestCase {
|
|||
*/
|
||||
public function testGetDefinitions(): void {
|
||||
// Normally the attribute classes would be autoloaded.
|
||||
include_once __DIR__ . '/../Attribute/Fixtures/CustomPlugin.php';
|
||||
include_once __DIR__ . '/../Attribute/Fixtures/Plugins/PluginNamespace/AttributeDiscoveryTest1.php';
|
||||
include_once __DIR__ . '/../../../../../fixtures/plugins/CustomPlugin.php';
|
||||
include_once __DIR__ . '/../../../../../fixtures/plugins/Plugin/PluginNamespace/AttributeDiscoveryTest1.php';
|
||||
|
||||
$definitions = [];
|
||||
$definitions['object'] = new ObjectDefinition(['id' => 'foo']);
|
||||
|
@ -51,8 +51,8 @@ class AttributeBridgeDecoratorTest extends TestCase {
|
|||
*/
|
||||
public function testOtherMethod(): void {
|
||||
// Normally the attribute classes would be autoloaded.
|
||||
include_once __DIR__ . '/../Attribute/Fixtures/CustomPlugin.php';
|
||||
include_once __DIR__ . '/../Attribute/Fixtures/Plugins/PluginNamespace/AttributeDiscoveryTest1.php';
|
||||
include_once __DIR__ . '/../../../../../fixtures/plugins/CustomPlugin.php';
|
||||
include_once __DIR__ . '/../../../../../fixtures/plugins/Plugin/PluginNamespace/AttributeDiscoveryTest1.php';
|
||||
|
||||
$discovery = $this->createMock(ExtendedDiscoveryInterface::class);
|
||||
$discovery->expects($this->exactly(2))
|
||||
|
|
Loading…
Reference in New Issue