MigrateUrlAliasTest.php 1.8 KB
Newer Older
1 2
<?php

3
namespace Drupal\Tests\path\Kernel\Migrate\d7;
4 5 6 7 8 9

/**
 * Tests URL alias migration.
 *
 * @group path
 */
10
class MigrateUrlAliasTest extends MigrateUrlAliasTestBase {
11 12

  /**
13
   * {@inheritdoc}
14
   */
15
  public static $modules = [
16
    'path_alias',
17
    'content_translation',
18
    'migrate_drupal_multilingual',
19
  ];
20 21 22 23 24 25

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
26 27 28 29
    $this->executeMigrations([
      'd7_node_translation',
      'd7_url_alias',
    ]);
30 31
  }

32 33 34 35 36
  /**
   * Test the URL alias migration with translated nodes.
   */
  public function testUrlAliasWithTranslatedNodes() {
    // Alias for the 'The thing about Deep Space 9' node in English.
37 38 39
    $path_alias = $this->loadPathAliasByConditions(['alias' => '/deep-space-9']);
    $this->assertSame('/node/2', $path_alias->getPath());
    $this->assertSame('en', $path_alias->get('langcode')->value);
40 41 42

    // Alias for the 'The thing about Deep Space 9' Icelandic translation,
    // which should now point to node/2 instead of node/3.
43 44 45
    $path_alias = $this->loadPathAliasByConditions(['alias' => '/deep-space-9-is']);
    $this->assertSame('/node/2', $path_alias->getPath());
    $this->assertSame('is', $path_alias->get('langcode')->value);
46 47

    // Alias for the 'The thing about Firefly' node in Icelandic.
48 49 50
    $path_alias = $this->loadPathAliasByConditions(['alias' => '/firefly-is']);
    $this->assertSame('/node/4', $path_alias->getPath());
    $this->assertSame('is', $path_alias->get('langcode')->value);
51 52 53

    // Alias for the 'The thing about Firefly' English translation,
    // which should now point to node/4 instead of node/5.
54 55 56
    $path_alias = $this->loadPathAliasByConditions(['alias' => '/firefly']);
    $this->assertSame('/node/4', $path_alias->getPath());
    $this->assertSame('en', $path_alias->get('langcode')->value);
57 58
  }

59
}