Update to Drupal 8.2.5. For more information, see https://www.drupal.org/project/drupal/releases/8.2.5
This commit is contained in:
parent
8544b60b39
commit
db56c09587
86 changed files with 2413 additions and 488 deletions
|
|
@ -13,7 +13,16 @@ use Drupal\taxonomy\TermInterface;
|
|||
*/
|
||||
class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase {
|
||||
|
||||
public static $modules = array('taxonomy', 'text');
|
||||
public static $modules = [
|
||||
'comment',
|
||||
'datetime',
|
||||
'image',
|
||||
'link',
|
||||
'node',
|
||||
'taxonomy',
|
||||
'telephone',
|
||||
'text',
|
||||
];
|
||||
|
||||
/**
|
||||
* The cached taxonomy tree items, keyed by vid and tid.
|
||||
|
|
@ -28,7 +37,16 @@ class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('taxonomy_term');
|
||||
$this->executeMigrations(['d7_taxonomy_vocabulary', 'd7_taxonomy_term']);
|
||||
$this->installConfig(static::$modules);
|
||||
|
||||
$this->executeMigrations([
|
||||
'd7_node_type',
|
||||
'd7_comment_type',
|
||||
'd7_field',
|
||||
'd7_taxonomy_vocabulary',
|
||||
'd7_field_instance',
|
||||
'd7_taxonomy_term'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -48,8 +66,12 @@ class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase {
|
|||
* The weight the migrated entity should have.
|
||||
* @param array $expected_parents
|
||||
* The parent terms the migrated entity should have.
|
||||
* @param int $expected_field_integer_value
|
||||
* The value the migrated entity field should have.
|
||||
* @param int $expected_term_reference_tid
|
||||
* The term reference id the migrated entity field should have.
|
||||
*/
|
||||
protected function assertEntity($id, $expected_label, $expected_vid, $expected_description = '', $expected_format = NULL, $expected_weight = 0, $expected_parents = []) {
|
||||
protected function assertEntity($id, $expected_label, $expected_vid, $expected_description = '', $expected_format = NULL, $expected_weight = 0, $expected_parents = [], $expected_field_integer_value = NULL, $expected_term_reference_tid = NULL) {
|
||||
/** @var \Drupal\taxonomy\TermInterface $entity */
|
||||
$entity = Term::load($id);
|
||||
$this->assertTrue($entity instanceof TermInterface);
|
||||
|
|
@ -60,6 +82,14 @@ class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase {
|
|||
$this->assertEqual($expected_weight, $entity->getWeight());
|
||||
$this->assertIdentical($expected_parents, $this->getParentIDs($id));
|
||||
$this->assertHierarchy($expected_vid, $id, $expected_parents);
|
||||
if (!is_null($expected_field_integer_value)) {
|
||||
$this->assertTrue($entity->hasField('field_integer'));
|
||||
$this->assertEquals($expected_field_integer_value, $entity->field_integer->value);
|
||||
}
|
||||
if (!is_null($expected_term_reference_tid)) {
|
||||
$this->assertTrue($entity->hasField('field_integer'));
|
||||
$this->assertEquals($expected_term_reference_tid, $entity->field_term_reference->target_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -67,9 +97,9 @@ class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase {
|
|||
*/
|
||||
public function testTaxonomyTerms() {
|
||||
$this->assertEntity(1, 'General discussion', 'forums', '', NULL, 2);
|
||||
$this->assertEntity(2, 'Term1', 'test_vocabulary', 'The first term.', 'filtered_html');
|
||||
$this->assertEntity(2, 'Term1', 'test_vocabulary', 'The first term.', 'filtered_html', 0, [], NULL, 3);
|
||||
$this->assertEntity(3, 'Term2', 'test_vocabulary', 'The second term.', 'filtered_html');
|
||||
$this->assertEntity(4, 'Term3', 'test_vocabulary', 'The third term.', 'full_html', 0, [3]);
|
||||
$this->assertEntity(4, 'Term3', 'test_vocabulary', 'The third term.', 'full_html', 0, [3], 6);
|
||||
$this->assertEntity(5, 'Custom Forum', 'forums', 'Where the cool kids are.', NULL, 3);
|
||||
$this->assertEntity(6, 'Games', 'forums', '', NULL, 4);
|
||||
$this->assertEntity(7, 'Minecraft', 'forums', '', NULL, 1, [6]);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source;
|
||||
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
* Tests the taxonomy term source with vocabulary filter.
|
||||
*
|
||||
* @covers \Drupal\taxonomy\Plugin\migrate\source\Term
|
||||
* @covers \Drupal\taxonomy\Plugin\migrate\source\d6\Term
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TermSourceWithVocabularyFilterTest extends TermTest {
|
||||
|
|
@ -47,7 +47,7 @@ class TermSourceWithVocabularyFilterTest extends TermTest {
|
|||
|
||||
// Set up source plugin configuration.
|
||||
$tests[0]['configuration'] = [
|
||||
'vocabulary' => [5],
|
||||
'bundle' => [5],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source;
|
||||
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests taxonomy term source plugin.
|
||||
*
|
||||
* @covers \Drupal\taxonomy\Plugin\migrate\source\Term
|
||||
* @covers \Drupal\taxonomy\Plugin\migrate\source\d6\Term
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TermTest extends MigrateSqlSourceTestBase {
|
||||
|
|
@ -67,6 +67,13 @@ class TermTest extends MigrateSqlSourceTestBase {
|
|||
'description' => 'description value 6',
|
||||
'weight' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 7,
|
||||
'vid' => 3,
|
||||
'name' => 'name value 7',
|
||||
'description' => 'description value 7',
|
||||
'weight' => 0,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['term_hierarchy'] = [
|
||||
[
|
||||
|
|
@ -97,6 +104,10 @@ class TermTest extends MigrateSqlSourceTestBase {
|
|||
'tid' => 6,
|
||||
'parent' => 2,
|
||||
],
|
||||
[
|
||||
'tid' => 7,
|
||||
'parent' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
|
|
@ -149,8 +160,58 @@ class TermTest extends MigrateSqlSourceTestBase {
|
|||
'weight' => 0,
|
||||
'parent' => [3, 2],
|
||||
],
|
||||
[
|
||||
'tid' => 7,
|
||||
'vid' => 3,
|
||||
'name' => 'name value 7',
|
||||
'description' => 'description value 7',
|
||||
'weight' => 0,
|
||||
'parent' => [0],
|
||||
],
|
||||
];
|
||||
|
||||
$tests[0]['expected_count'] = NULL;
|
||||
// Empty configuration will return terms for all vocabularies.
|
||||
$tests[0]['configuration'] = [];
|
||||
|
||||
// Change configuration to get one vocabulary, 5.
|
||||
$tests[1]['source_data'] = $tests[0]['source_data'];
|
||||
$tests[1]['expected_data'] = [
|
||||
[
|
||||
'tid' => 1,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 1',
|
||||
'description' => 'description value 1',
|
||||
'weight' => 0,
|
||||
'parent' => [0],
|
||||
],
|
||||
[
|
||||
'tid' => 4,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 4',
|
||||
'description' => 'description value 4',
|
||||
'weight' => 1,
|
||||
'parent' => [1],
|
||||
],
|
||||
];
|
||||
$tests[1]['expected_count'] = NULL;
|
||||
$tests[1]['configuration']['bundle'] = ['5'];
|
||||
|
||||
// Same as previous test, but with configuration vocabulary as a string
|
||||
// instead of an array.
|
||||
$tests[2]['source_data'] = $tests[0]['source_data'];
|
||||
$tests[2]['expected_data'] = $tests[1]['expected_data'];
|
||||
$tests[2]['expected_count'] = NULL;
|
||||
$tests[2]['configuration']['bundle'] = '5';
|
||||
|
||||
// Change configuration to get two vocabularies, 5 and 6.
|
||||
$tests[3]['source_data'] = $tests[0]['source_data'];
|
||||
$tests[3]['expected_data'] = $tests[0]['expected_data'];
|
||||
// Remove the last element because it is for vid 3.
|
||||
array_pop($tests[3]['expected_data']);
|
||||
$tests[3]['expected_count'] = NULL;
|
||||
$tests[3]['configuration']['bundle'] = ['5', '6'];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d7;
|
||||
|
||||
/**
|
||||
* Tests the taxonomy term source with vocabulary filter.
|
||||
*
|
||||
* @covers \Drupal\taxonomy\Plugin\migrate\source\d7\Term
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TermSourceWithVocabularyFilterTest extends TermTest {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
// Get the source data from parent.
|
||||
$tests = parent::providerSource();
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'tid' => 1,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 1',
|
||||
'description' => 'description value 1',
|
||||
'weight' => 0,
|
||||
'parent' => [0],
|
||||
],
|
||||
[
|
||||
'tid' => 4,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 4',
|
||||
'description' => 'description value 4',
|
||||
'weight' => 1,
|
||||
'parent' => [1],
|
||||
],
|
||||
];
|
||||
|
||||
// We know there are two rows with machine_name == 'tags'.
|
||||
$tests[0]['expected_count'] = 2;
|
||||
|
||||
// Set up source plugin configuration.
|
||||
$tests[0]['configuration'] = [
|
||||
'bundle' => ['tags'],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,258 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests taxonomy term source plugin.
|
||||
*
|
||||
* @covers \Drupal\taxonomy\Plugin\migrate\source\d7\Term
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TermTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['taxonomy_term_data'] = [
|
||||
[
|
||||
'tid' => 1,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 1',
|
||||
'description' => 'description value 1',
|
||||
'weight' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 2,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 2',
|
||||
'description' => 'description value 2',
|
||||
'weight' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 3,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 3',
|
||||
'description' => 'description value 3',
|
||||
'weight' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 4,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 4',
|
||||
'description' => 'description value 4',
|
||||
'weight' => 1,
|
||||
],
|
||||
[
|
||||
'tid' => 5,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 5',
|
||||
'description' => 'description value 5',
|
||||
'weight' => 1,
|
||||
],
|
||||
[
|
||||
'tid' => 6,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 6',
|
||||
'description' => 'description value 6',
|
||||
'weight' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 7,
|
||||
'vid' => 3,
|
||||
'name' => 'name value 7',
|
||||
'description' => 'description value 7',
|
||||
'weight' => 0,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['taxonomy_term_hierarchy'] = [
|
||||
[
|
||||
'tid' => 1,
|
||||
'parent' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 2,
|
||||
'parent' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 3,
|
||||
'parent' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 4,
|
||||
'parent' => 1,
|
||||
],
|
||||
[
|
||||
'tid' => 5,
|
||||
'parent' => 2,
|
||||
],
|
||||
[
|
||||
'tid' => 6,
|
||||
'parent' => 3,
|
||||
],
|
||||
[
|
||||
'tid' => 6,
|
||||
'parent' => 2,
|
||||
],
|
||||
[
|
||||
'tid' => 7,
|
||||
'parent' => 0,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['taxonomy_vocabulary'] = [
|
||||
[
|
||||
'vid' => 5,
|
||||
'machine_name' => 'tags',
|
||||
],
|
||||
[
|
||||
'vid' => 6,
|
||||
'machine_name' => 'categories',
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['field_config_instance'] = [
|
||||
[
|
||||
'field_name' => 'field_term_field',
|
||||
'entity_type' => 'taxonomy_term',
|
||||
'bundle' => 'tags',
|
||||
'deleted' => 0,
|
||||
],
|
||||
[
|
||||
'field_name' => 'field_term_field',
|
||||
'entity_type' => 'taxonomy_term',
|
||||
'bundle' => 'categories',
|
||||
'deleted' => 0,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['field_data_field_term_field'] = [
|
||||
[
|
||||
'entity_type' => 'taxonomy_term',
|
||||
'bundle' => 'tags',
|
||||
'deleted' => 0,
|
||||
'entity_id' => 1,
|
||||
'delta' => 0,
|
||||
],
|
||||
[
|
||||
'entity_type' => 'taxonomy_term',
|
||||
'bundle' => 'categories',
|
||||
'deleted' => 0,
|
||||
'entity_id' => 1,
|
||||
'delta' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'tid' => 1,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 1',
|
||||
'description' => 'description value 1',
|
||||
'weight' => 0,
|
||||
'parent' => [0],
|
||||
],
|
||||
[
|
||||
'tid' => 2,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 2',
|
||||
'description' => 'description value 2',
|
||||
'weight' => 0,
|
||||
'parent' => [0],
|
||||
],
|
||||
[
|
||||
'tid' => 3,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 3',
|
||||
'description' => 'description value 3',
|
||||
'weight' => 0,
|
||||
'parent' => [0],
|
||||
],
|
||||
[
|
||||
'tid' => 4,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 4',
|
||||
'description' => 'description value 4',
|
||||
'weight' => 1,
|
||||
'parent' => [1],
|
||||
],
|
||||
[
|
||||
'tid' => 5,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 5',
|
||||
'description' => 'description value 5',
|
||||
'weight' => 1,
|
||||
'parent' => [2],
|
||||
],
|
||||
[
|
||||
'tid' => 6,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 6',
|
||||
'description' => 'description value 6',
|
||||
'weight' => 0,
|
||||
'parent' => [3, 2],
|
||||
],
|
||||
[
|
||||
'tid' => 7,
|
||||
'vid' => 3,
|
||||
'name' => 'name value 7',
|
||||
'description' => 'description value 7',
|
||||
'weight' => 0,
|
||||
'parent' => [0],
|
||||
],
|
||||
];
|
||||
|
||||
$tests[0]['expected_count'] = NULL;
|
||||
// Empty configuration will return terms for all vocabularies.
|
||||
$tests[0]['configuration'] = [];
|
||||
|
||||
// Change configuration to get one vocabulary, "tags".
|
||||
$tests[1]['source_data'] = $tests[0]['source_data'];
|
||||
$tests[1]['expected_data'] = [
|
||||
[
|
||||
'tid' => 1,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 1',
|
||||
'description' => 'description value 1',
|
||||
'weight' => 0,
|
||||
'parent' => [0],
|
||||
],
|
||||
[
|
||||
'tid' => 4,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 4',
|
||||
'description' => 'description value 4',
|
||||
'weight' => 1,
|
||||
'parent' => [1],
|
||||
],
|
||||
];
|
||||
$tests[1]['expected_count'] = NULL;
|
||||
$tests[1]['configuration']['bundle'] = ['tags'];
|
||||
|
||||
// Same as previous test, but with configuration vocabulary as a string
|
||||
// instead of an array.
|
||||
$tests[2]['source_data'] = $tests[0]['source_data'];
|
||||
$tests[2]['expected_data'] = $tests[1]['expected_data'];
|
||||
$tests[2]['expected_count'] = NULL;
|
||||
$tests[2]['configuration']['bundle'] = 'tags';
|
||||
|
||||
// Change configuration to get two vocabularies, "tags" and "categories".
|
||||
$tests[3]['source_data'] = $tests[0]['source_data'];
|
||||
$tests[3]['expected_data'] = $tests[0]['expected_data'];
|
||||
// Remove the last element because it is for vid 3.
|
||||
array_pop($tests[3]['expected_data']);
|
||||
$tests[3]['expected_count'] = NULL;
|
||||
$tests[3]['configuration']['bundle'] = ['tags', 'categories'];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue