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 5519e0b7bde..2173a8ae6e0 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 24e53927e35..b55d0757944 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 45a89aaf758..3436736c7f3 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 aa1472642ff..6c7b92dc9ee 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 @@ class MigrateBlockNoBlockContentTest extends MigrateDrupal7TestBase { $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 bde49c62660..2b65a98f582 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 bda3ec22889..00e9bf79b2b 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 @@ class PathAliasMenuLinkContentTest extends KernelTestBase { 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 5c6c6fcdc3a..00000000000 --- a/core/modules/path_alias/tests/src/Kernel/EntityAliasTest.php +++ /dev/null @@ -1,49 +0,0 @@ -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 d43a531b593..d72000a3681 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 @@ class RssFieldsTest extends ViewsKernelTestBase { $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 9280387ff8d..ee8865d995c 100644 --- a/core/modules/views/tests/src/Kernel/PluginInstanceTest.php +++ b/core/modules/views/tests/src/Kernel/PluginInstanceTest.php @@ -12,13 +12,6 @@ use Drupal\views\Plugin\views\PluginBase; */ 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 6d2ed55fed2..5d8c23f2283 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 950df9d163c..8cc6f175580 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 5ba0c7bb4d8..51110a29ccf 100644 --- a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php +++ b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php @@ -120,10 +120,6 @@ class ResolvedLibraryDefinitionsFilesMatchTest extends KernelTestBase { // @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 2ac1d89c71c..8c153bd9225 100644 --- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php +++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php @@ -40,7 +40,6 @@ class ModuleConfigureRouteTest extends KernelTestBase { 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 3f1856a8d13..05f1d69fcf9 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 @@ class ContentNegotiationRoutingTest extends KernelTestBase { $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 aee2729a73d..1c0cbc1eebf 100644 --- a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php +++ b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php @@ -5,6 +5,7 @@ namespace Drupal\KernelTests\Core\Routing; 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 @@ class RouteProviderTest extends KernelTestBase { $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 30b0e5cd503..d4361352f7f 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 9108fa049af..46b4d880189 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -591,6 +591,16 @@ abstract class KernelTestBase extends TestCase implements ServiceProviderInterfa ->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')