Update to Drupal 8.1.5. For more information, see https://www.drupal.org/project/drupal/releases/8.1.5
This commit is contained in:
parent
13b6ca7cc2
commit
38ba7c357d
342 changed files with 7814 additions and 1534 deletions
|
@ -1,10 +0,0 @@
|
|||
id: node_template
|
||||
label: Template test - node
|
||||
migration_tags:
|
||||
- Template Test
|
||||
source:
|
||||
plugin: empty
|
||||
process:
|
||||
src: barfoo
|
||||
destination:
|
||||
plugin: entity:node
|
|
@ -1,10 +0,0 @@
|
|||
id: other_template
|
||||
label: Template with a different tag
|
||||
migration_tags:
|
||||
- Different Template Test
|
||||
source:
|
||||
plugin: empty
|
||||
process:
|
||||
src: raboof
|
||||
destination:
|
||||
plugin: entity:user
|
|
@ -1,10 +0,0 @@
|
|||
id: url_template
|
||||
label: Template test - URL
|
||||
migration_tags:
|
||||
- Template Test
|
||||
source:
|
||||
plugin: empty
|
||||
process:
|
||||
src: foobar
|
||||
destination:
|
||||
plugin: url_alias
|
|
@ -1,5 +0,0 @@
|
|||
name: 'Migration template test'
|
||||
type: module
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
155
core/modules/migrate/tests/src/Kernel/MigrateBundleTest.php
Normal file
155
core/modules/migrate/tests/src/Kernel/MigrateBundleTest.php
Normal file
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate\Kernel;
|
||||
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
|
||||
/**
|
||||
* Tests setting of bundles on content entity migrations.
|
||||
*
|
||||
* @group migrate
|
||||
*/
|
||||
class MigrateBundleTest extends MigrateTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['taxonomy', 'text'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('taxonomy_vocabulary');
|
||||
$this->installEntitySchema('taxonomy_term');
|
||||
$this->installConfig(['taxonomy']);
|
||||
// Set up two vocabularies (taxonomy bundles).
|
||||
Vocabulary::create(['vid' => 'tags', 'name' => 'Tags']);
|
||||
Vocabulary::create(['vid' => 'categories', 'name' => 'Categories']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests setting the bundle in the destination.
|
||||
*/
|
||||
public function testDestinationBundle() {
|
||||
$term_data_rows = [
|
||||
['id' => 1, 'name' => 'Category 1'],
|
||||
];
|
||||
$ids = ['id' => ['type' => 'integer']];
|
||||
$definition = [
|
||||
'id' => 'terms',
|
||||
'migration_tags' => ['Bundle test'],
|
||||
'source' => [
|
||||
'plugin' => 'embedded_data',
|
||||
'data_rows' => $term_data_rows,
|
||||
'ids' => $ids,
|
||||
],
|
||||
'process' => [
|
||||
'tid' => 'id',
|
||||
'name' => 'name',
|
||||
],
|
||||
'destination' => [
|
||||
'plugin' => 'entity:taxonomy_term',
|
||||
'default_bundle' => 'categories',
|
||||
],
|
||||
'migration_dependencies' => [],
|
||||
];
|
||||
|
||||
$term_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
|
||||
|
||||
// Import and validate the term entity was created with the correct bundle.
|
||||
$term_executable = new MigrateExecutable($term_migration, $this);
|
||||
$term_executable->import();
|
||||
/** @var Term $term */
|
||||
$term = Term::load(1);
|
||||
$this->assertEquals($term->bundle(), 'categories');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests setting the bundle in the process pipeline.
|
||||
*/
|
||||
public function testProcessBundle() {
|
||||
$term_data_rows = [
|
||||
['id' => 1, 'vocab' => 'categories', 'name' => 'Category 1'],
|
||||
['id' => 2, 'vocab' => 'tags', 'name' => 'Tag 1'],
|
||||
];
|
||||
$ids = ['id' => ['type' => 'integer']];
|
||||
$definition = [
|
||||
'id' => 'terms',
|
||||
'migration_tags' => ['Bundle test'],
|
||||
'source' => [
|
||||
'plugin' => 'embedded_data',
|
||||
'data_rows' => $term_data_rows,
|
||||
'ids' => $ids,
|
||||
],
|
||||
'process' => [
|
||||
'tid' => 'id',
|
||||
'vid' => 'vocab',
|
||||
'name' => 'name',
|
||||
],
|
||||
'destination' => [
|
||||
'plugin' => 'entity:taxonomy_term',
|
||||
],
|
||||
'migration_dependencies' => [],
|
||||
];
|
||||
|
||||
$term_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
|
||||
|
||||
// Import and validate the term entities were created with the correct bundle.
|
||||
$term_executable = new MigrateExecutable($term_migration, $this);
|
||||
$term_executable->import();
|
||||
/** @var Term $term */
|
||||
$term = Term::load(1);
|
||||
$this->assertEquals($term->bundle(), 'categories');
|
||||
$term = Term::load(2);
|
||||
$this->assertEquals($term->bundle(), 'tags');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests setting bundles both in process and destination.
|
||||
*/
|
||||
public function testMixedBundles() {
|
||||
$term_data_rows = [
|
||||
['id' => 1, 'vocab' => 'categories', 'name' => 'Category 1'],
|
||||
['id' => 2, 'name' => 'Tag 1'],
|
||||
];
|
||||
$ids = ['id' => ['type' => 'integer']];
|
||||
$definition = [
|
||||
'id' => 'terms',
|
||||
'migration_tags' => ['Bundle test'],
|
||||
'source' => [
|
||||
'plugin' => 'embedded_data',
|
||||
'data_rows' => $term_data_rows,
|
||||
'ids' => $ids,
|
||||
],
|
||||
'process' => [
|
||||
'tid' => 'id',
|
||||
'vid' => 'vocab',
|
||||
'name' => 'name',
|
||||
],
|
||||
'destination' => [
|
||||
'plugin' => 'entity:taxonomy_term',
|
||||
// When no vocab is provided, the destination bundle is applied.
|
||||
'default_bundle' => 'tags',
|
||||
],
|
||||
'migration_dependencies' => [],
|
||||
];
|
||||
|
||||
$term_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
|
||||
|
||||
// Import and validate the term entities were created with the correct bundle.
|
||||
$term_executable = new MigrateExecutable($term_migration, $this);
|
||||
$term_executable->import();
|
||||
/** @var Term $term */
|
||||
$term = Term::load(1);
|
||||
$this->assertEquals($term->bundle(), 'categories');
|
||||
$term = Term::load(2);
|
||||
$this->assertEquals($term->bundle(), 'tags');
|
||||
}
|
||||
|
||||
}
|
|
@ -27,4 +27,41 @@ class MigrationTest extends KernelTestBase {
|
|||
$this->assertEquals([], $migration->getProcessPlugins([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Migration::getMigrationDependencies()
|
||||
*
|
||||
* @covers ::getMigrationDependencies
|
||||
*/
|
||||
public function testGetMigrationDependencies() {
|
||||
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration([
|
||||
'migration_dependencies' => NULL
|
||||
]);
|
||||
$this->assertNotEmpty($migration->getMigrationDependencies(), 'Migration dependencies is not empty');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Migration::getDestinationIds()
|
||||
*
|
||||
* @covers ::getDestinationIds
|
||||
*/
|
||||
public function testGetDestinationIds() {
|
||||
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration(['destinationIds' => ['foo' => 'bar']]);
|
||||
$destination_ids = $migration->getDestinationIds();
|
||||
$this->assertNotEmpty($destination_ids, 'Destination ids are not empty');
|
||||
$this->assertEquals(['foo' => 'bar'], $destination_ids, 'Destination ids match the expected values.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Migration::getTrackLastImported()
|
||||
*
|
||||
* @covers ::getTrackLastImported
|
||||
* @covers ::isTrackLastImported
|
||||
*/
|
||||
public function testGetTrackLastImported() {
|
||||
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration([]);
|
||||
$migration->setTrackLastImported(TRUE);
|
||||
$this->assertEquals(TRUE, $migration->getTrackLastImported());
|
||||
$this->assertEquals(TRUE, $migration->isTrackLastImported());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -170,6 +170,25 @@ class MigrateSourceTest extends MigrateTestCase {
|
|||
$this->assertEquals(-1, $source->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the key can be set for the count cache.
|
||||
*
|
||||
* @covers ::count
|
||||
*/
|
||||
public function testCountCacheKey() {
|
||||
// Mock the cache to validate set() receives appropriate arguments.
|
||||
$container = new ContainerBuilder();
|
||||
$cache = $this->getMock(CacheBackendInterface::class);
|
||||
$cache->expects($this->any())->method('set')
|
||||
->with('test_key', $this->isType('int'), $this->isType('int'));
|
||||
$container->set('cache.migrate', $cache);
|
||||
\Drupal::setContainer($container);
|
||||
|
||||
// Test caching the count with a configured key works.
|
||||
$source = $this->getSource(['cache_counts' => TRUE, 'cache_key' => 'test_key']);
|
||||
$this->assertEquals(1, $source->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that we don't get a row if prepareRow() is false.
|
||||
*/
|
||||
|
|
|
@ -199,9 +199,11 @@ abstract class MigrateTestCase extends UnitTestCase {
|
|||
*/
|
||||
protected function retrievalAssertHelper($expected_value, $actual_value, $message) {
|
||||
if (is_array($expected_value)) {
|
||||
foreach ($expected_value as $k => $v) {
|
||||
$this->retrievalAssertHelper($v, $actual_value[$k], $message . '[' . $k . ']');
|
||||
// If the expected and actual values are empty, no need to array compare.
|
||||
if (empty($expected_value && $actual_value)) {
|
||||
return;
|
||||
}
|
||||
$this->assertArrayEquals($expected_value, $actual_value, $message);
|
||||
}
|
||||
else {
|
||||
$this->assertSame((string) $expected_value, (string) $actual_value, $message);
|
||||
|
|
Reference in a new issue