Version 1
[yaffs-website] / web / modules / contrib / redirect / tests / src / Kernel / Migrate / d6 / PathRedirectTest.php
1 <?php
2
3 namespace Drupal\Tests\redirect\Kernel\Migrate\d6;
4
5 use Drupal\redirect\Entity\Redirect;
6 use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
7
8
9 /**
10  * Tests the d6_path_redirect source plugin.
11  *
12  * @group redirect
13  */
14 class PathRedirectTest extends MigrateDrupalTestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = array('redirect', 'link');
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUp() {
25     parent::setUp();
26     $this->installSchema('system', array('router'));
27     $this->installEntitySchema('redirect');
28     $this->loadFixture( __DIR__ . '/../../../../../tests/fixtures/drupal6.php');
29
30     $this->executeMigrations(['d6_path_redirect']);
31   }
32
33   /**
34    * Tests the Drupal 6 path redirect to Drupal 8 migration.
35    */
36   public function testPathRedirect() {
37
38     /** @var Redirect $redirect */
39     $redirect = Redirect::load(5);
40     $this->assertSame($this->getMigration('d6_path_redirect')
41       ->getIdMap()
42       ->lookupDestinationID(array(5)), array($redirect->id()));
43     $this->assertSame("/test/source/url", $redirect->getSourceUrl());
44     $this->assertSame("base:test/redirect/url", $redirect->getRedirectUrl()->toUriString());
45
46     $redirect = Redirect::load(7);
47     $this->assertSame("/test/source/url2", $redirect->getSourceUrl());
48     $this->assertSame("http://test/external/redirect/url?foo=bar&biz=buz", $redirect->getRedirectUrl()->toUriString());
49   }
50 }