You are here

public function MigrateUrlAliasTest::testUrlAliasWithTranslatedNodes in Drupal 8

Same name in this branch
  1. 8 core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php \Drupal\Tests\path\Kernel\Migrate\d6\MigrateUrlAliasTest::testUrlAliasWithTranslatedNodes()
  2. 8 core/modules/path/tests/src/Kernel/Migrate/d7/MigrateUrlAliasTest.php \Drupal\Tests\path\Kernel\Migrate\d7\MigrateUrlAliasTest::testUrlAliasWithTranslatedNodes()

Test the URL alias migration with translated nodes.

File

core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php, line 130

Class

MigrateUrlAliasTest
URL alias migration.

Namespace

Drupal\Tests\path\Kernel\Migrate\d6

Code

public function testUrlAliasWithTranslatedNodes() {

  // Alias for the 'The Real McCoy' node in English.
  $path_alias = $this
    ->loadPathAliasByConditions([
    'alias' => '/the-real-mccoy',
  ]);
  $this
    ->assertSame('/node/10', $path_alias
    ->getPath());
  $this
    ->assertSame('en', $path_alias
    ->get('langcode')->value);

  // Alias for the 'The Real McCoy' French translation,
  // which should now point to node/10 instead of node/11.
  $path_alias = $this
    ->loadPathAliasByConditions([
    'alias' => '/le-vrai-mccoy',
  ]);
  $this
    ->assertSame('/node/10', $path_alias
    ->getPath());
  $this
    ->assertSame('fr', $path_alias
    ->get('langcode')->value);

  // Alias for the 'Abantu zulu' node in Zulu.
  $path_alias = $this
    ->loadPathAliasByConditions([
    'alias' => '/abantu-zulu',
  ]);
  $this
    ->assertSame('/node/12', $path_alias
    ->getPath());
  $this
    ->assertSame('zu', $path_alias
    ->get('langcode')->value);

  // Alias for the 'Abantu zulu' English translation,
  // which should now point to node/12 instead of node/13.
  $path_alias = $this
    ->loadPathAliasByConditions([
    'alias' => '/the-zulu-people',
  ]);
  $this
    ->assertSame('/node/12', $path_alias
    ->getPath());
  $this
    ->assertSame('en', $path_alias
    ->get('langcode')->value);
}