PathRedirectTest.php in Redirect 8
File
tests/src/Kernel/Migrate/d6/PathRedirectTest.php
View source
<?php
namespace Drupal\Tests\redirect\Kernel\Migrate\d6;
use Drupal\redirect\Entity\Redirect;
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
class PathRedirectTest extends MigrateDrupalTestBase {
public static $modules = [
'redirect',
'link',
'path_alias',
];
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('redirect');
$this
->loadFixture(__DIR__ . '/../../../../../tests/fixtures/drupal6.php');
$this
->executeMigrations([
'd6_path_redirect',
]);
}
public function testPathRedirect() {
$redirect = Redirect::load(5);
$this
->assertSame($this
->getMigration('d6_path_redirect')
->getIdMap()
->lookupDestinationIds([
5,
]), [
[
$redirect
->id(),
],
]);
$this
->assertSame("/test/source/url", $redirect
->getSourceUrl());
$this
->assertSame("base:test/redirect/url", $redirect
->getRedirectUrl()
->toUriString());
$redirect = Redirect::load(7);
$this
->assertSame("/test/source/url2", $redirect
->getSourceUrl());
$this
->assertSame("http://test/external/redirect/url?foo=bar&biz=buz", $redirect
->getRedirectUrl()
->toUriString());
}
}