3 namespace Drupal\Tests\path\Kernel\Migrate\d7;
5 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
8 * Tests URL alias migration.
12 class MigrateUrlAliasTest extends MigrateDrupal7TestBase {
17 public static $modules = [
18 'content_translation',
29 protected function setUp() {
32 $this->installEntitySchema('node');
33 $this->installConfig('node');
34 $this->installSchema('node', ['node_access']);
36 $this->executeMigrations([
42 'd7_node_translation',
48 * Test the URL alias migration.
50 public function testUrlAlias() {
51 $alias_storage = $this->container->get('path.alias_storage');
53 $path = $alias_storage->load([
54 'source' => '/taxonomy/term/4',
58 $this->assertIdentical('/taxonomy/term/4', $path['source']);
59 $this->assertIdentical('/term33', $path['alias']);
60 $this->assertIdentical('und', $path['langcode']);
62 // Alias with no slash.
63 $path = $alias_storage->load(['alias' => '/source-noslash']);
64 $this->assertSame('/admin', $path['source']);
65 $this->assertSame('und', $path['langcode']);
69 * Test the URL alias migration with translated nodes.
71 public function testUrlAliasWithTranslatedNodes() {
72 $alias_storage = $this->container->get('path.alias_storage');
74 // Alias for the 'The thing about Deep Space 9' node in English.
75 $path = $alias_storage->load(['alias' => '/deep-space-9']);
76 $this->assertSame('/node/2', $path['source']);
77 $this->assertSame('en', $path['langcode']);
79 // Alias for the 'The thing about Deep Space 9' Icelandic translation,
80 // which should now point to node/2 instead of node/3.
81 $path = $alias_storage->load(['alias' => '/deep-space-9-is']);
82 $this->assertSame('/node/2', $path['source']);
83 $this->assertSame('is', $path['langcode']);
85 // Alias for the 'The thing about Firefly' node in Icelandic.
86 $path = $alias_storage->load(['alias' => '/firefly-is']);
87 $this->assertSame('/node/4', $path['source']);
88 $this->assertSame('is', $path['langcode']);
90 // Alias for the 'The thing about Firefly' English translation,
91 // which should now point to node/4 instead of node/5.
92 $path = $alias_storage->load(['alias' => '/firefly']);
93 $this->assertSame('/node/4', $path['source']);
94 $this->assertSame('en', $path['langcode']);