composer update

This commit is contained in:
Oliver Davies 2019-01-24 08:00:03 +00:00
parent f6abc3dce2
commit 71dfaca858
1753 changed files with 45274 additions and 14619 deletions

View file

@ -104,7 +104,14 @@ class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
$this->assertArrayHasKey($tid, $tree_terms, "Term $tid exists in vocabulary tree");
$tree_term = $tree_terms[$tid];
$this->assertEquals($values['parent'], $tree_term->parents, "Term $tid has correct parents in vocabulary tree");
// PostgreSQL, MySQL and SQLite may not return the parent terms in the
// same order so sort before testing.
$expected_parents = $values['parent'];
sort($expected_parents);
$actual_parents = $tree_term->parents;
sort($actual_parents);
$this->assertEquals($expected_parents, $actual_parents, "Term $tid has correct parents in vocabulary tree");
}
}

View file

@ -0,0 +1,142 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\TermInterface;
/**
* Tests migration of localized translated taxonomy terms.
*
* @group migrate_drupal_6
*/
class MigrateTermLocalizedTranslationTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'content_translation',
'language',
'menu_ui',
'node',
'taxonomy',
// Required for translation migrations.
'migrate_drupal_multilingual',
];
/**
* The cached taxonomy tree items, keyed by vid and tid.
*
* @var array
*/
protected $treeData = [];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('taxonomy_term');
$this->installConfig(static::$modules);
$this->executeMigrations([
'language',
'd6_node_type',
'd6_field',
'd6_taxonomy_vocabulary',
'd6_field_instance',
'd6_taxonomy_term',
'd6_taxonomy_term_localized_translation',
]);
}
/**
* Validates a migrated term contains the expected values.
*
* @param int $id
* Entity ID to load and check.
* @param string $expected_language
* The language code for this term.
* @param string $expected_label
* The label the migrated entity should have.
* @param string $expected_vid
* The parent vocabulary the migrated entity should have.
* @param string $expected_description
* The description the migrated entity should have.
* @param string $expected_format
* The format the migrated entity should have.
* @param int $expected_weight
* 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_language, $expected_label, $expected_vid, $expected_description = '', $expected_format = NULL, $expected_weight = 0, array $expected_parents = [], $expected_field_integer_value = NULL, $expected_term_reference_tid = NULL) {
/** @var \Drupal\taxonomy\TermInterface $entity */
$entity = Term::load($id);
$this->assertInstanceOf(TermInterface::class, $entity);
$this->assertSame($expected_language, $entity->language()->getId());
$this->assertSame($expected_label, $entity->label());
$this->assertSame($expected_vid, $entity->bundle());
$this->assertSame($expected_description, $entity->getDescription());
$this->assertSame($expected_format, $entity->getFormat());
$this->assertSame($expected_weight, $entity->getWeight());
$this->assertHierarchy($expected_vid, $id, $expected_parents);
}
/**
* Asserts that a term is present in the tree storage, with the right parents.
*
* @param string $vid
* Vocabulary ID.
* @param int $tid
* ID of the term to check.
* @param array $parent_ids
* The expected parent term IDs.
*/
protected function assertHierarchy($vid, $tid, array $parent_ids) {
if (!isset($this->treeData[$vid])) {
$tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);
$this->treeData[$vid] = [];
foreach ($tree as $item) {
$this->treeData[$vid][$item->tid] = $item;
}
}
$this->assertArrayHasKey($tid, $this->treeData[$vid], "Term $tid exists in taxonomy tree");
$term = $this->treeData[$vid][$tid];
$this->assertEquals($parent_ids, array_filter($term->parents), "Term $tid has correct parents in taxonomy tree");
}
/**
* Tests the Drupal 6 i18n localized taxonomy term to Drupal 8 migration.
*/
public function testTranslatedLocalizedTaxonomyTerms() {
$this->assertEntity(14, 'en', 'Talos IV', 'vocabulary_name_much_longer_than', 'The home of Captain Christopher Pike.', NULL, '0', []);
$this->assertEntity(15, 'en', 'Vulcan', 'vocabulary_name_much_longer_than', NULL, NULL, '0', []);
/** @var \Drupal\taxonomy\TermInterface $entity */
$entity = Term::load(14);
$this->assertTrue($entity->hasTranslation('fr'));
$translation = $entity->getTranslation('fr');
$this->assertSame('fr - Talos IV', $translation->label());
$this->assertSame('fr - The home of Captain Christopher Pike.', $translation->getDescription());
$this->assertTrue($entity->hasTranslation('zu'));
$translation = $entity->getTranslation('zu');
$this->assertSame('Talos IV', $translation->label());
$this->assertSame('zu - The home of Captain Christopher Pike.', $translation->getDescription());
$entity = Term::load(15);
$this->assertFalse($entity->hasTranslation('fr'));
$this->assertTrue($entity->hasTranslation('zu'));
$translation = $entity->getTranslation('zu');
$this->assertSame('zu - Vulcan', $translation->label());
$this->assertSame('', $translation->getDescription());
}
}

View file

@ -81,13 +81,13 @@ class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
$field_id = 'node.story.field_vocabulary_3_i_2_';
$field = FieldConfig::load($field_id);
$this->assertFalse($field->isRequired(), 'Field is not required');
$this->assertFalse($field->isTranslatable());
$this->assertTrue($field->isTranslatable());
// Tests that a vocabulary named like a D8 base field will be migrated and
// prefixed with 'field_' to avoid conflicts.
$field_type = FieldConfig::load('node.sponsor.field_type');
$this->assertInstanceOf(FieldConfig::class, $field_type);
$this->assertFalse($field->isTranslatable());
$this->assertTrue($field->isTranslatable());
}
/**

View file

@ -0,0 +1,179 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests D6 i18n term localized source plugin.
*
* @covers \Drupal\taxonomy\Plugin\migrate\source\d6\TermLocalizedTranslation
* @group taxonomy
*/
class TermLocalizedTranslationTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['term_data'] = [
[
'tid' => 1,
'vid' => 5,
'name' => 'name value 1',
'description' => 'description value 1',
'weight' => 0,
'language' => NULL,
],
[
'tid' => 2,
'vid' => 6,
'name' => 'name value 2',
'description' => 'description value 2',
'weight' => 0,
'language' => NULL,
],
[
'tid' => 3,
'vid' => 6,
'name' => 'name value 3',
'description' => 'description value 3',
'weight' => 0,
'language' => NULL,
],
[
'tid' => 4,
'vid' => 5,
'name' => 'name value 4',
'description' => 'description value 4',
'weight' => 1,
'language' => NULL,
],
];
$tests[0]['source_data']['term_hierarchy'] = [
[
'tid' => 1,
'parent' => 0,
],
[
'tid' => 2,
'parent' => 0,
],
[
'tid' => 3,
'parent' => 0,
],
[
'tid' => 4,
'parent' => 1,
],
];
$tests[0]['source_data']['i18n_strings'] = [
[
'lid' => 6,
'objectid' => 1,
'type' => 'term',
'property' => 'name',
'objectindex' => '1',
'format' => 0,
],
[
'lid' => 7,
'objectid' => 1,
'type' => 'term',
'property' => 'description',
'objectindex' => '1',
'format' => 0,
],
[
'lid' => 8,
'objectid' => 3,
'type' => 'term',
'property' => 'name',
'objectindex' => '3',
'format' => 0,
],
];
$tests[0]['source_data']['locales_target'] = [
[
'lid' => 6,
'language' => 'fr',
'translation' => 'fr - name value 1 translation',
'plid' => 0,
'plural' => 0,
'i18n_status' => 0,
],
[
'lid' => 7,
'language' => 'fr',
'translation' => 'fr - description value 1 translation',
'plid' => 0,
'plural' => 0,
'i18n_status' => 0,
],
[
'lid' => 8,
'language' => 'zu',
'translation' => 'zu - description value 2 translation',
'plid' => 0,
'plural' => 0,
'i18n_status' => 0,
],
];
// The expected results.
$tests[0]['expected_data'] = [
[
'tid' => 1,
'vid' => 5,
'name' => 'name value 1',
'description' => 'description value 1',
'weight' => 0,
'parent' => [0],
'property' => 'name',
'language' => 'fr',
'name_translated' => 'fr - name value 1 translation',
'description_translated' => 'fr - description value 1 translation',
],
[
'tid' => 1,
'vid' => 5,
'name' => 'name value 1',
'description' => 'description value 1',
'weight' => 0,
'parent' => [0],
'property' => 'description',
'language' => 'fr',
'name_translated' => 'fr - name value 1 translation',
'description_translated' => 'fr - description value 1 translation',
],
[
'tid' => 3,
'vid' => 6,
'name' => 'name value 3',
'description' => 'description value 3',
'weight' => 0,
'parent' => [0],
'property' => 'name',
'language' => 'zu',
'name_translated' => 'zu - description value 2 translation',
'description_translated' => NULL,
],
];
$tests[0]['expected_count'] = NULL;
// Empty configuration will return terms for all vocabularies.
$tests[0]['configuration'] = [];
return $tests;
}
}