diff --git a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php index 5519e0b7bdefe4fd6256f9a962a2a43a01713add..2173a8ae6e077b5d6eb271114e46c7bed27a2dc8 100644 --- a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php @@ -34,7 +34,6 @@ class MigrateBlockContentTranslationTest extends MigrateDrupal6TestBase { protected function setUp(): void { parent::setUp(); $this->installEntitySchema('block_content'); - $this->installEntitySchema('path_alias'); $this->installConfig(['block']); $this->installConfig(['block_content']); $this->container->get('theme_installer')->install(['stark']); diff --git a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php index 24e53927e359b116ab8bc94e76af8238b8959dac..b55d0757944fa9e29982618ca7b36f202847b0af 100644 --- a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php @@ -32,7 +32,6 @@ class MigrateBlockTest extends MigrateDrupal6TestBase { */ protected function setUp(): void { parent::setUp(); - $this->installEntitySchema('path_alias'); // Install the themes used for this test. $this->installEntitySchema('block_content'); diff --git a/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockContentTranslationTest.php b/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockContentTranslationTest.php index 45a89aaf758b70a0aafe2be933d4e6ea314f3be2..3436736c7f38cff415b079622739e9de18066e1b 100644 --- a/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockContentTranslationTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockContentTranslationTest.php @@ -37,7 +37,6 @@ class MigrateBlockContentTranslationTest extends MigrateDrupal7TestBase { protected function setUp(): void { parent::setUp(); $this->installEntitySchema('block_content'); - $this->installEntitySchema('path_alias'); $this->installConfig(['block']); $this->installConfig(['block_content']); $this->container->get('theme_installer')->install(['stark']); diff --git a/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockNoBlockContentTest.php b/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockNoBlockContentTest.php index aa1472642fff5e6f487c6c93fa49029e50a4b629..6c7b92dc9ee1daaa27e865948364f262a94f037d 100644 --- a/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockNoBlockContentTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockNoBlockContentTest.php @@ -37,7 +37,6 @@ protected function setUp(): void { $this->container->get('theme_installer')->install(['olivero', 'claro']); $this->installConfig(static::$modules); - $this->installEntitySchema('path_alias'); // Set Olivero and Claro as the default public and admin theme. $config = $this->config('system.theme'); diff --git a/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php b/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php index bde49c62660f5294de9e09522bd93928b2329486..2b65a98f582ec575e36af0be28356e650c9d3089 100644 --- a/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php @@ -34,7 +34,6 @@ class MigrateBlockTest extends MigrateDrupal7TestBase { */ protected function setUp(): void { parent::setUp(); - $this->installEntitySchema('path_alias'); // Install the themes used for this test. $this->installEntitySchema('block_content'); diff --git a/core/modules/menu_link_content/tests/src/Kernel/PathAliasMenuLinkContentTest.php b/core/modules/menu_link_content/tests/src/Kernel/PathAliasMenuLinkContentTest.php index bda3ec228899b3ed0db516b2f2e97d9e36337e74..00e9bf79b2b3a0616450cd8eb123737c4cfd0366 100644 --- a/core/modules/menu_link_content/tests/src/Kernel/PathAliasMenuLinkContentTest.php +++ b/core/modules/menu_link_content/tests/src/Kernel/PathAliasMenuLinkContentTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\menu_link_content\Kernel; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Menu\MenuTreeParameters; use Drupal\menu_link_content\Entity\MenuLinkContent; use Drupal\KernelTests\KernelTestBase; @@ -44,6 +45,17 @@ protected function setUp(): void { module_set_weight('menu_link_content', 1); } + /** + * {@inheritdoc} + */ + public function register(ContainerBuilder $container) { + parent::register($container); + + $definition = $container->getDefinition('path_alias.path_processor'); + $definition + ->addTag('path_processor_inbound', ['priority' => 100]); + } + /** * Tests the path aliasing changing. */ diff --git a/core/modules/path_alias/tests/src/Kernel/EntityAliasTest.php b/core/modules/path_alias/tests/src/Kernel/EntityAliasTest.php deleted file mode 100644 index 5c6c6fcdc3a12ee15b7028404446b3ce32cfcd13..0000000000000000000000000000000000000000 --- a/core/modules/path_alias/tests/src/Kernel/EntityAliasTest.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php - -declare(strict_types = 1); - -namespace Drupal\Tests\path_alias\Kernel; - -use Drupal\entity_test\Entity\EntityTest; -use Drupal\KernelTests\KernelTestBase; -use Drupal\Tests\Traits\Core\PathAliasTestTrait; - -/** - * Tests path alias on entities. - * - * @group path_alias - */ -class EntityAliasTest extends KernelTestBase { - - use PathAliasTestTrait; - - /** - * {@inheritdoc} - */ - protected static $modules = [ - 'path_alias', - 'entity_test', - 'user', - ]; - - /** - * {@inheritdoc} - */ - protected function setUp(): void { - parent::setUp(); - $this->installEntitySchema('entity_test'); - $this->installEntitySchema('path_alias'); - $this->installEntitySchema('user'); - } - - /** - * Tests transform. - */ - public function testEntityAlias(): void { - EntityTest::create(['id' => 1])->save(); - $this->createPathAlias('/entity_test/1', '/entity-alias'); - $entity = EntityTest::load(1); - $this->assertSame('/entity-alias', $entity->toUrl()->toString()); - } - -} diff --git a/core/modules/views/tests/src/Kernel/Plugin/RssFieldsTest.php b/core/modules/views/tests/src/Kernel/Plugin/RssFieldsTest.php index d43a531b593d79d91f0b8643cffaf0d72d0daf4e..d72000a36818e7ed8908b2902ca72534d2dbdf96 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/RssFieldsTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/RssFieldsTest.php @@ -37,6 +37,7 @@ protected function setUp($import_test_views = TRUE): void { $this->installConfig(['node', 'filter']); $this->installEntitySchema('user'); $this->installEntitySchema('node'); + $this->installEntitySchema('path_alias'); $this->createContentType(['type' => 'article']); } diff --git a/core/modules/views/tests/src/Kernel/PluginInstanceTest.php b/core/modules/views/tests/src/Kernel/PluginInstanceTest.php index 9280387ff8d2c886d0a0cb2dd0135636efe30a80..ee8865d995cca490e791a98fabf8785c9e573899 100644 --- a/core/modules/views/tests/src/Kernel/PluginInstanceTest.php +++ b/core/modules/views/tests/src/Kernel/PluginInstanceTest.php @@ -12,13 +12,6 @@ */ class PluginInstanceTest extends ViewsKernelTestBase { - /** - * {@inheritdoc} - */ - protected static $modules = [ - 'path_alias', - ]; - /** * All views plugin types. * diff --git a/core/modules/views/tests/src/Kernel/ViewsKernelTestBase.php b/core/modules/views/tests/src/Kernel/ViewsKernelTestBase.php index 6d2ed55fed2e531f74a09902726ae3af5585d917..5d8c23f228387dc1876ea6572e940e66a39bfa6b 100644 --- a/core/modules/views/tests/src/Kernel/ViewsKernelTestBase.php +++ b/core/modules/views/tests/src/Kernel/ViewsKernelTestBase.php @@ -28,6 +28,7 @@ abstract class ViewsKernelTestBase extends KernelTestBase { * {@inheritdoc} */ protected static $modules = [ + 'path_alias', 'system', 'views', 'views_test_config', diff --git a/core/modules/workspaces/tests/src/Kernel/WorkspaceViewsKernelTest.php b/core/modules/workspaces/tests/src/Kernel/WorkspaceViewsKernelTest.php index 950df9d163c5d0492a31f85b99e18cccd77d4312..8cc6f175580004ac35127e005d22e0eea8f7cbc0 100644 --- a/core/modules/workspaces/tests/src/Kernel/WorkspaceViewsKernelTest.php +++ b/core/modules/workspaces/tests/src/Kernel/WorkspaceViewsKernelTest.php @@ -20,7 +20,7 @@ class WorkspaceViewsKernelTest extends ViewsKernelTestBase { * * @var array */ - protected static $modules = ['views_ui', 'workspaces', 'path_alias']; + protected static $modules = ['views_ui', 'workspaces']; /** * Tests creating a view of workspace entities. diff --git a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php index 5ba0c7bb4d8f3899bf1be22b1c1cb052c887f033..51110a29ccfe1b0014c00a408190f2a97d8c6692 100644 --- a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php +++ b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php @@ -120,10 +120,6 @@ protected function setUp(): void { // @todo Remove this in https://www.drupal.org/node/3039217. $this->installEntitySchema('user'); - // Install the 'path_alias' entity schema because the path alias path - // processor requires it. - $this->installEntitySchema('path_alias'); - // Remove demo_umami_content module as its install hook creates content // that relies on the presence of entity tables and various other elements // not present in a kernel test. diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php index 2ac1d89c71c5fac6b36d6966ea7cfe504ac2b884..8c153bd9225a35fb74d9dabba4da3dd679effc2b 100644 --- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php +++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php @@ -40,7 +40,6 @@ protected function setUp(): void { parent::setUp(); $this->routeProvider = \Drupal::service('router.route_provider'); $this->moduleInfo = \Drupal::service('extension.list.module')->getList(); - $this->installEntitySchema('path_alias'); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php b/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php index 3f1856a8d1394513280d2e29816870c8c8b213b0..05f1d69fcf99d3df358244376b59b1526f362345 100644 --- a/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php +++ b/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php @@ -2,6 +2,7 @@ namespace Drupal\KernelTests\Core\Routing; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\Traits\Core\PathAliasTestTrait; use Symfony\Component\HttpFoundation\Request; @@ -30,6 +31,20 @@ protected function setUp(): void { $this->installEntitySchema('path_alias'); } + /** + * {@inheritdoc} + */ + public function register(ContainerBuilder $container) { + parent::register($container); + + // \Drupal\KernelTests\KernelTestBase::register() removes the alias path + // processor. + if ($container->hasDefinition('path_alias.path_processor')) { + $definition = $container->getDefinition('path_alias.path_processor'); + $definition->addTag('path_processor_inbound', ['priority' => 100])->addTag('path_processor_outbound', ['priority' => 300]); + } + } + /** * Tests the content negotiation aspect of routing. */ diff --git a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php index aee2729a73d4fbe304b683977010ed9004a37222..1c0cbc1eebfaeb892dfa0debbab1acb1f9da1692 100644 --- a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php +++ b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php @@ -5,6 +5,7 @@ use ColinODell\PsrTestLogger\TestLogger; use Drupal\Core\Cache\MemoryBackend; use Drupal\Core\Database\Database; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\KeyValueStore\KeyValueMemoryFactory; use Drupal\Core\Path\CurrentPathStack; use Drupal\Core\Routing\MatcherDumper; @@ -105,6 +106,19 @@ protected function setUp(): void { $this->logger = new TestLogger(); } + /** + * {@inheritdoc} + */ + public function register(ContainerBuilder $container) { + parent::register($container); + + // Read the incoming path alias for these tests. + if ($container->hasDefinition('path_alias.path_processor')) { + $definition = $container->getDefinition('path_alias.path_processor'); + $definition->addTag('path_processor_inbound'); + } + } + /** * {@inheritdoc} */ diff --git a/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php index 30b0e5cd503e7fc50f716a92bec480a722c47b15..d4361352f7f5c41fffc8b402579020167e3ceaee 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php @@ -32,7 +32,7 @@ class Stable9LibraryOverrideTest extends StableLibraryOverrideTestBase { /** * {@inheritdoc} */ - protected static $modules = ['system', 'user']; + protected static $modules = ['system', 'user', 'path_alias']; /** * {@inheritdoc} diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php index 9108fa049afbb5ea1062500bc4b126c95c08ad08..46b4d88018995b039576272e2ce8fb068244cd92 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -591,6 +591,16 @@ public function register(ContainerBuilder $container) { ->addTag('event_subscriber'); } + if ($container->hasDefinition('path_alias.path_processor')) { + // The alias-based processor requires the path_alias entity schema to be + // installed, so we prevent it from being registered to the path processor + // manager. We do this by removing the tags that the compiler pass looks + // for. This means that the URL generator can safely be used within tests. + $container->getDefinition('path_alias.path_processor') + ->clearTag('path_processor_inbound') + ->clearTag('path_processor_outbound'); + } + // Relax the password hashing cost in tests to avoid performance issues. if ($container->hasDefinition('password')) { $container->getDefinition('password')