Commit 0b45cbb7 authored by alexpott's avatar alexpott

Issue #2850984 by maxocub: Fix path alias migration of translated nodes [D7]

parent 0179304d
...@@ -43135,6 +43135,30 @@ ...@@ -43135,6 +43135,30 @@
'alias' => 'term33', 'alias' => 'term33',
'language' => 'und', 'language' => 'und',
)) ))
->values(array(
'pid' => '2',
'source' => 'node/2',
'alias' => 'deep-space-9',
'language' => 'en',
))
->values(array(
'pid' => '3',
'source' => 'node/3',
'alias' => 'deep-space-9-is',
'language' => 'is',
))
->values(array(
'pid' => '4',
'source' => 'node/4',
'alias' => 'firefly-is',
'language' => 'is',
))
->values(array(
'pid' => '5',
'source' => 'node/5',
'alias' => 'firefly',
'language' => 'en',
))
->execute(); ->execute();
$connection->schema()->createTable('users', array( $connection->schema()->createTable('users', array(
...@@ -18,5 +18,17 @@ process: ...@@ -18,5 +18,17 @@ process:
- constants/slash - constants/slash
- alias - alias
langcode: language langcode: language
node_translation:
-
plugin: explode
source: source
delimiter: /
-
plugin: extract
index:
- 1
-
plugin: migration
migration: d7_node_translation
destination: destination:
plugin: url_alias plugin: url_alias
...@@ -14,14 +14,33 @@ class MigrateUrlAliasTest extends MigrateDrupal7TestBase { ...@@ -14,14 +14,33 @@ class MigrateUrlAliasTest extends MigrateDrupal7TestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static $modules = ['path']; public static $modules = [
'content_translation',
'language',
'node',
'path',
'text',
];
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->executeMigration('d7_url_alias');
$this->installEntitySchema('node');
$this->installConfig('node');
$this->installSchema('node', ['node_access']);
$this->executeMigrations([
'language',
'd7_user_role',
'd7_user',
'd7_node_type',
'd7_node',
'd7_node_translation',
'd7_url_alias',
]);
} }
/** /**
...@@ -38,4 +57,33 @@ public function testUrlAlias() { ...@@ -38,4 +57,33 @@ public function testUrlAlias() {
$this->assertIdentical('und', $path['langcode']); $this->assertIdentical('und', $path['langcode']);
} }
/**
* Test the URL alias migration with translated nodes.
*/
public function testUrlAliasWithTranslatedNodes() {
$alias_storage = $this->container->get('path.alias_storage');
// Alias for the 'The thing about Deep Space 9' node in English.
$path = $alias_storage->load(['alias' => '/deep-space-9']);
$this->assertSame('/node/2', $path['source']);
$this->assertSame('en', $path['langcode']);
// Alias for the 'The thing about Deep Space 9' Icelandic translation,
// which should now point to node/2 instead of node/3.
$path = $alias_storage->load(['alias' => '/deep-space-9-is']);
$this->assertSame('/node/2', $path['source']);
$this->assertSame('is', $path['langcode']);
// Alias for the 'The thing about Firefly' node in Icelandic.
$path = $alias_storage->load(['alias' => '/firefly-is']);
$this->assertSame('/node/4', $path['source']);
$this->assertSame('is', $path['langcode']);
// Alias for the 'The thing about Firefly' English translation,
// which should now point to node/4 instead of node/5.
$path = $alias_storage->load(['alias' => '/firefly']);
$this->assertSame('/node/4', $path['source']);
$this->assertSame('en', $path['langcode']);
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment