public function MigrateUrlAliasTest::testUrlAlias in Zircon Profile 8
Same name in this branch
- 8 core/modules/path/src/Tests/Migrate/d6/MigrateUrlAliasTest.php \Drupal\path\Tests\Migrate\d6\MigrateUrlAliasTest::testUrlAlias()
- 8 core/modules/path/src/Tests/Migrate/d7/MigrateUrlAliasTest.php \Drupal\path\Tests\Migrate\d7\MigrateUrlAliasTest::testUrlAlias()
Same name and namespace in other branches
- 8.0 core/modules/path/src/Tests/Migrate/d6/MigrateUrlAliasTest.php \Drupal\path\Tests\Migrate\d6\MigrateUrlAliasTest::testUrlAlias()
Test the url alias migration.
File
- core/
modules/ path/ src/ Tests/ Migrate/ d6/ MigrateUrlAliasTest.php, line 39 - Contains \Drupal\path\Tests\Migrate\d6\MigrateUrlAliasTest.
Class
- MigrateUrlAliasTest
- URL alias migration.
Namespace
Drupal\path\Tests\Migrate\d6Code
public function testUrlAlias() {
$id_map = Migration::load('d6_url_alias')
->getIdMap();
// Test that the field exists.
$conditions = array(
'source' => '/node/1',
'alias' => '/alias-one',
'langcode' => 'en',
);
$path = \Drupal::service('path.alias_storage')
->load($conditions);
$this
->assertNotNull($path, "Path alias for node/1 successfully loaded.");
$this
->assertIdentical($id_map
->lookupDestinationID(array(
$path['pid'],
)), array(
'1',
), "Test IdMap");
$conditions = array(
'source' => '/node/2',
'alias' => '/alias-two',
'langcode' => 'en',
);
$path = \Drupal::service('path.alias_storage')
->load($conditions);
$this
->assertNotNull($path, "Path alias for node/2 successfully loaded.");
// Test that we can re-import using the UrlAlias destination.
Database::getConnection('default', 'migrate')
->update('url_alias')
->fields(array(
'dst' => 'new-url-alias',
))
->condition('src', 'node/2')
->execute();
\Drupal::database()
->update($id_map
->mapTableName())
->fields(array(
'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
))
->execute();
$migration = \Drupal::entityManager()
->getStorage('migration')
->loadUnchanged('d6_url_alias');
$this
->executeMigration($migration);
$path = \Drupal::service('path.alias_storage')
->load(array(
'pid' => $path['pid'],
));
$this
->assertIdentical('/new-url-alias', $path['alias']);
}