MigrateUrlAliasTestBase.php

Same filename in other branches
  1. 9 core/modules/path/tests/src/Kernel/Migrate/d7/MigrateUrlAliasTestBase.php
  2. 10 core/modules/path/tests/src/Kernel/Migrate/d7/MigrateUrlAliasTestBase.php
  3. 11.x core/modules/path/tests/src/Kernel/Migrate/d7/MigrateUrlAliasTestBase.php

Namespace

Drupal\Tests\path\Kernel\Migrate\d7

File

core/modules/path/tests/src/Kernel/Migrate/d7/MigrateUrlAliasTestBase.php

View source
<?php

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

use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\Tests\Traits\Core\PathAliasTestTrait;

/**
 * Tests URL alias migration.
 *
 * @group path
 */
abstract class MigrateUrlAliasTestBase extends MigrateDrupal7TestBase {
    use PathAliasTestTrait;
    
    /**
     * {@inheritdoc}
     */
    public static $modules = [
        'language',
        'menu_ui',
        'node',
        'path',
        'path_alias',
        '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() {
        $path_alias = $this->loadPathAliasByConditions([
            'path' => '/taxonomy/term/4',
            'alias' => '/term33',
            'langcode' => 'und',
        ]);
        $this->assertIdentical('/taxonomy/term/4', $path_alias->getPath());
        $this->assertIdentical('/term33', $path_alias->getAlias());
        $this->assertIdentical('und', $path_alias->language()
            ->getId());
        // Alias with no slash.
        $path_alias = $this->loadPathAliasByConditions([
            'alias' => '/source-noslash',
        ]);
        $this->assertSame('/admin', $path_alias->getPath());
        $this->assertSame('und', $path_alias->language()
            ->getId());
    }

}

Classes

Title Deprecated Summary
MigrateUrlAliasTestBase Tests URL alias migration.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.