Move into nested docroot

This commit is contained in:
Rob Davies 2017-02-13 15:31:17 +00:00
parent 83a0d3a149
commit c8b70abde9
13405 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,137 @@
<?php
namespace Drupal\Tests\path\Kernel\Migrate\d6;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\Core\Database\Database;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* URL alias migration.
*
* @group migrate_drupal_6
*/
class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['language', 'content_translation', 'path'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installConfig(['node']);
$this->installSchema('node', ['node_access']);
$this->migrateUsers(FALSE);
$this->migrateFields();
$this->executeMigrations([
'language',
'd6_node_settings',
'd6_node',
'd6_node_translation',
'd6_url_alias',
]);
}
/**
* Assert a path.
*
* @param string $pid
* The path id.
* @param array $conditions
* The path conditions.
* @param array $path
* The path.
*/
private function assertPath($pid, $conditions, $path) {
$this->assertTrue($path, "Path alias for " . $conditions['source'] . " successfully loaded.");
$this->assertIdentical($conditions['alias'], $path['alias']);
$this->assertIdentical($conditions['langcode'], $path['langcode']);
$this->assertIdentical($conditions['source'], $path['source']);
}
/**
* Test the url alias migration.
*/
public function testUrlAlias() {
$id_map = $this->getMigration('d6_url_alias')->getIdMap();
// Test that the field exists.
$conditions = array(
'source' => '/node/1',
'alias' => '/alias-one',
'langcode' => 'af',
);
$path = \Drupal::service('path.alias_storage')->load($conditions);
$this->assertPath('1', $conditions, $path);
$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->assertPath('2', $conditions, $path);
// 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 = $this->getMigration('d6_url_alias');
$this->executeMigration($migration);
$path = \Drupal::service('path.alias_storage')->load(array('pid' => $path['pid']));
$conditions['alias'] = '/new-url-alias';
$this->assertPath('2', $conditions, $path);
$conditions = array(
'source' => '/node/3',
'alias' => '/alias-three',
'langcode' => 'und',
);
$path = \Drupal::service('path.alias_storage')->load($conditions);
$this->assertPath('3', $conditions, $path);
}
/**
* Test the URL alias migration with translated nodes.
*/
public function testUrlAliasWithTranslatedNodes() {
$alias_storage = $this->container->get('path.alias_storage');
// Alias for the 'The Real McCoy' node in English.
$path = $alias_storage->load(['alias' => '/the-real-mccoy']);
$this->assertSame('/node/10', $path['source']);
$this->assertSame('en', $path['langcode']);
// Alias for the 'The Real McCoy' French translation,
// which should now point to node/10 instead of node/11.
$path = $alias_storage->load(['alias' => '/le-vrai-mccoy']);
$this->assertSame('/node/10', $path['source']);
$this->assertSame('fr', $path['langcode']);
// Alias for the 'Abantu zulu' node in Zulu.
$path = $alias_storage->load(['alias' => '/abantu-zulu']);
$this->assertSame('/node/12', $path['source']);
$this->assertSame('zu', $path['langcode']);
// Alias for the 'Abantu zulu' English translation,
// which should now point to node/12 instead of node/13.
$path = $alias_storage->load(['alias' => '/the-zulu-people']);
$this->assertSame('/node/12', $path['source']);
$this->assertSame('en', $path['langcode']);
}
}

View file

@ -0,0 +1,41 @@
<?php
namespace Drupal\Tests\path\Kernel\Migrate\d7;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
* Tests URL alias migration.
*
* @group path
*/
class MigrateUrlAliasTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['path'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d7_url_alias');
}
/**
* Test the URL alias migration.
*/
public function testUrlAlias() {
$path = \Drupal::service('path.alias_storage')->load([
'source' => '/taxonomy/term/4',
'alias' => '/term33',
'langcode' => 'und',
]);
$this->assertIdentical('/taxonomy/term/4', $path['source']);
$this->assertIdentical('/term33', $path['alias']);
$this->assertIdentical('und', $path['langcode']);
}
}

View file

@ -0,0 +1,58 @@
<?php
namespace Drupal\Tests\path\Kernel;
use Drupal\content_translation_test\Entity\EntityTestTranslatableUISkip;
use Drupal\KernelTests\KernelTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
/**
* Tests path alias deletion when there is no canonical link template.
*
* @group path
*/
class PathNoCanonicalLinkTest extends KernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('path', 'content_translation_test', 'language', 'entity_test', 'user', 'system');
protected function setUp() {
parent::setUp();
$this->installEntitySchema('entity_test');
$this->installEntitySchema('entity_test_mul');
\Drupal::service('router.builder')->rebuild();
// Adding german language.
ConfigurableLanguage::create(['id' => 'de'])->save();
$this->config('language.types')->setData([
'configurable' => ['language_interface'],
'negotiation' => ['language_interface' => ['enabled' => ['language-url' => 0]]],
])->save();
}
/**
* Tests for no canonical link templates.
*/
public function testNoCanonicalLinkTemplate() {
$entity_type = EntityTestTranslatableUISkip::create([
'name' => 'name english',
'language' => 'en'
]);
$entity_type->save();
$entity_type->addTranslation('de', ['name' => 'name german']);
$entity_type->save();
$this->assertEqual(count($entity_type->getTranslationLanguages()), 2);
$entity_type->removeTranslation('de');
$entity_type->save();
$this->assertEqual(count($entity_type->getTranslationLanguages()), 1);
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace Drupal\Tests\path\Kernel\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests the d6_url_alias source plugin.
*
* @covers \Drupal\path\Plugin\migrate\source\d6\UrlAlias
* @group path
*/
class UrlAliasTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['migrate_drupal', 'path'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['url_alias'] = [
[
'pid' => 1,
'src' => 'node/1',
'dst' => 'test-article',
'language' => 'en',
],
[
'pid' => 2,
'src' => 'node/2',
'dst' => 'another-alias',
'language' => 'en',
],
];
// The expected results.
$tests[0]['expected_data'] = $tests[0]['source_data']['url_alias'];
return $tests;
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace Drupal\Tests\path\Kernel\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests the d7_url_alias source plugin.
*
* @covers \Drupal\path\Plugin\migrate\source\d7\UrlAlias
* @group path
*/
class UrlAliasTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['migrate_drupal', 'path'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['url_alias'] = [
[
'pid' => 1,
'source' => 'node/1',
'alias' => 'test-article',
'language' => 'en',
],
[
'pid' => 2,
'source' => 'node/2',
'alias' => 'another-alias',
'language' => 'en',
],
];
// The expected results.
$tests[0]['expected_data'] = $tests[0]['source_data']['url_alias'];
return $tests;
}
}

View file

@ -0,0 +1,35 @@
<?php
namespace Drupal\Tests\path\Unit\Field;
use Drupal\Tests\Core\Field\BaseFieldDefinitionTestBase;
/**
* @coversDefaultClass \Drupal\Core\Field\BaseFieldDefinition
* @group path
*/
class PathFieldDefinitionTest extends BaseFieldDefinitionTestBase {
/**
* {@inheritdoc}
*/
protected function getPluginId() {
return 'path';
}
/**
* {@inheritdoc}
*/
protected function getModuleAndPath() {
return array('path', dirname(dirname(dirname(dirname(__DIR__)))));
}
/**
* @covers ::getColumns
* @covers ::getSchema
*/
public function testGetColumns() {
$this->assertSame(array(), $this->definition->getColumns());
}
}