5 * Contains \Drupal\Tests\redirect\Kernel\Migrate\d7\PathRedirectTest.
8 namespace Drupal\Tests\redirect\Kernel\Migrate\d7;
10 use Drupal\redirect\Entity\Redirect;
11 use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
15 * Tests the d7_path_redirect source plugin.
19 class PathRedirectTest extends MigrateDrupalTestBase {
24 public static $modules = array('redirect', 'link');
29 protected function setUp() {
31 $this->installEntitySchema('redirect');
32 $this->loadFixture(__DIR__ . '/../../../../fixtures/drupal7.php');
34 $this->executeMigration('d7_path_redirect');
38 * Asserts various aspects of a redirect entity.
41 * The entity ID in the form ENTITY_TYPE.BUNDLE.FIELD_NAME.
42 * @param string $source_url
43 * The expected source url.
44 * @param string $redirect_url
45 * The expected redirect url.
46 * @param string $status_code
47 * The expected status code.
49 protected function assertEntity($id, $source_url, $redirect_url, $status_code) {
50 /** @var Redirect $redirect */
51 $redirect = Redirect::load($id);
52 $this->assertSame($this->getMigration('d7_path_redirect')
54 ->lookupDestinationID([$id]), [$redirect->id()]);
55 $this->assertSame($source_url, $redirect->getSourceUrl());
56 $this->assertSame($redirect_url, $redirect->getRedirectUrl()
58 $this->assertSame($status_code, $redirect->getStatusCode());
62 * Tests the Drupal 7 path redirect to Drupal 8 migration.
64 public function testPathRedirect() {
65 $this->assertEntity(5, '/test/source/url', 'base:test/redirect/url', '301');
66 $this->assertEntity(7, '/test/source/url2', 'http://test/external/redirect/url?foo=bar&biz=buz', '307');