Problem/Motivation
In #2336597: Convert path aliases to full featured entities we added a BC layer to kernel tests that removes path_processor_inbound and path_processor_outbound tags from the path_alias.path_processor definition. This is a great source of confusion when writing kernel tests that rely on path aliases.
Steps to reproduce
Write a kernel test as per the MR that boils down to this:
EntityTest::create(['id' => 1])->save();
$this->createPathAlias('/entity_test/1', '/entity-alias');
$entity = EntityTest::load(1);
$this->assertSame('/entity-alias', $entity->toUrl()->toString());
Watch it fail.
Remove this from KernelTestBase::register
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');
}
Watch it pass.
Proposed resolution
Remove code that disabled path processing, ensure tests that use path alias install its schema.