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 2173a8ae6e077b5d6eb271114e46c7bed27a2dc8..5519e0b7bdefe4fd6256f9a962a2a43a01713add 100644 --- a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php @@ -34,6 +34,7 @@ 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 c9613a28712f3991068985897edd44d65cf86808..42f92c4ecbe2cceb581f85bb8fd1d067ec9e465d 100644 --- a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php @@ -32,6 +32,7 @@ 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 3436736c7f38cff415b079622739e9de18066e1b..45a89aaf758b70a0aafe2be933d4e6ea314f3be2 100644 --- a/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockContentTranslationTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockContentTranslationTest.php @@ -37,6 +37,7 @@ 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 6c7b92dc9ee1daaa27e865948364f262a94f037d..aa1472642fff5e6f487c6c93fa49029e50a4b629 100644 --- a/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockNoBlockContentTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockNoBlockContentTest.php @@ -37,6 +37,7 @@ 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 2b65a98f582ec575e36af0be28356e650c9d3089..bde49c62660f5294de9e09522bd93928b2329486 100644 --- a/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php @@ -34,6 +34,7 @@ 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/forum/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php b/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php index d018716c62cafd8ffdc34245e0630a6e3fffd1cb..aef056bdccc68fb49040ec2b72e8bc2c785ff736 100644 --- a/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php +++ b/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php @@ -30,6 +30,7 @@ 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/menu_link_content/tests/src/Kernel/PathAliasMenuLinkContentTest.php b/core/modules/menu_link_content/tests/src/Kernel/PathAliasMenuLinkContentTest.php index 00e9bf79b2b3a0616450cd8eb123737c4cfd0366..bda3ec228899b3ed0db516b2f2e97d9e36337e74 100644 --- a/core/modules/menu_link_content/tests/src/Kernel/PathAliasMenuLinkContentTest.php +++ b/core/modules/menu_link_content/tests/src/Kernel/PathAliasMenuLinkContentTest.php @@ -2,7 +2,6 @@ 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; @@ -45,17 +44,6 @@ 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 new file mode 100644 index 0000000000000000000000000000000000000000..5c6c6fcdc3a12ee15b7028404446b3ce32cfcd13 --- /dev/null +++ b/core/modules/path_alias/tests/src/Kernel/EntityAliasTest.php @@ -0,0 +1,49 @@ +<?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 d72000a36818e7ed8908b2902ca72534d2dbdf96..d43a531b593d79d91f0b8643cffaf0d72d0daf4e 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/RssFieldsTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/RssFieldsTest.php @@ -37,7 +37,6 @@ 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 ee8865d995cca490e791a98fabf8785c9e573899..9280387ff8d2c886d0a0cb2dd0135636efe30a80 100644 --- a/core/modules/views/tests/src/Kernel/PluginInstanceTest.php +++ b/core/modules/views/tests/src/Kernel/PluginInstanceTest.php @@ -12,6 +12,13 @@ */ 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 5d8c23f228387dc1876ea6572e940e66a39bfa6b..6d2ed55fed2e531f74a09902726ae3af5585d917 100644 --- a/core/modules/views/tests/src/Kernel/ViewsKernelTestBase.php +++ b/core/modules/views/tests/src/Kernel/ViewsKernelTestBase.php @@ -28,7 +28,6 @@ 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 8cc6f175580004ac35127e005d22e0eea8f7cbc0..950df9d163c5d0492a31f85b99e18cccd77d4312 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']; + protected static $modules = ['views_ui', 'workspaces', 'path_alias']; /** * 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 51110a29ccfe1b0014c00a408190f2a97d8c6692..5ba0c7bb4d8f3899bf1be22b1c1cb052c887f033 100644 --- a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php +++ b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php @@ -120,6 +120,10 @@ 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 8c153bd9225a35fb74d9dabba4da3dd679effc2b..2ac1d89c71c5fac6b36d6966ea7cfe504ac2b884 100644 --- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php +++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php @@ -40,6 +40,7 @@ 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 05f1d69fcf99d3df358244376b59b1526f362345..3f1856a8d1394513280d2e29816870c8c8b213b0 100644 --- a/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php +++ b/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php @@ -2,7 +2,6 @@ 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; @@ -31,20 +30,6 @@ 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 1c0cbc1eebfaeb892dfa0debbab1acb1f9da1692..aee2729a73d4fbe304b683977010ed9004a37222 100644 --- a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php +++ b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php @@ -5,7 +5,6 @@ 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; @@ -106,19 +105,6 @@ 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 d4361352f7f5c41fffc8b402579020167e3ceaee..30b0e5cd503e7fc50f716a92bec480a722c47b15 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', 'path_alias']; + protected static $modules = ['system', 'user']; /** * {@inheritdoc} diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php index 0a07f19c06431aadb581d34de1cb50c653d6134f..8b38145283910d97a3a990ef390e7a6b066f6f64 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -592,16 +592,6 @@ 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')