MigrateUrlAliasTestBase.php 1.52 KB
Newer Older
1 2 3 4 5
<?php

namespace Drupal\Tests\path\Kernel\Migrate\d7;

use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
6
use Drupal\Tests\Traits\Core\PathAliasTestTrait;
7 8 9 10 11 12 13 14

/**
 * Tests URL alias migration.
 *
 * @group path
 */
abstract class MigrateUrlAliasTestBase extends MigrateDrupal7TestBase {

15 16
  use PathAliasTestTrait;

17 18 19 20 21 22 23 24
  /**
   * {@inheritdoc}
   */
  public static $modules = [
    'language',
    'menu_ui',
    'node',
    'path',
25
    'path_alias',
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
    'text',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();

    $this->installEntitySchema('node');
    $this->installEntitySchema('path_alias');
    $this->installConfig('node');
    $this->installSchema('node', ['node_access']);

    $this->migrateUsers(FALSE);
    $this->migrateContentTypes();
    $this->executeMigrations([
      'language',
      'd7_node',
    ]);
  }

  /**
   * Test the URL alias migration.
   */
  public function testUrlAlias() {
52 53
    $path_alias = $this->loadPathAliasByConditions([
      'path' => '/taxonomy/term/4',
54 55 56
      'alias' => '/term33',
      'langcode' => 'und',
    ]);
57 58 59
    $this->assertIdentical('/taxonomy/term/4', $path_alias->getPath());
    $this->assertIdentical('/term33', $path_alias->getAlias());
    $this->assertIdentical('und', $path_alias->language()->getId());
60 61

    // Alias with no slash.
62 63 64
    $path_alias = $this->loadPathAliasByConditions(['alias' => '/source-noslash']);
    $this->assertSame('/admin', $path_alias->getPath());
    $this->assertSame('und', $path_alias->language()->getId());
65 66 67
  }

}