X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ftaxonomy%2Ftests%2Fsrc%2FKernel%2FMigrate%2Fd6%2FMigrateTaxonomyTermTest.php;h=20ecb6390346241c7f29b610c7b5e4aaf8d8f840;hb=5b8bb166bfa98770daef9de5c127fc2e6ef02340;hp=125283355ee2e0362d24b9618384521b9eed4a4c;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php b/web/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php index 125283355..20ecb6390 100644 --- a/web/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php +++ b/web/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php @@ -36,18 +36,21 @@ class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase { 'vid' => 'vocabulary_1_i_0_', 'weight' => 0, 'parent' => [0], + 'language' => 'zu', ], '2' => [ 'source_vid' => 2, 'vid' => 'vocabulary_2_i_1_', 'weight' => 3, 'parent' => [0], + 'language' => 'fr', ], '3' => [ 'source_vid' => 2, 'vid' => 'vocabulary_2_i_1_', 'weight' => 4, 'parent' => [2], + 'language' => 'fr', ], '4' => [ 'source_vid' => 3, @@ -81,26 +84,34 @@ class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase { } foreach ($expected_results as $tid => $values) { - /** @var Term $term */ + /** @var \Drupal\taxonomy\Entity\Term $term */ $term = $terms[$tid]; - $this->assertIdentical("term {$tid} of vocabulary {$values['source_vid']}", $term->name->value); - $this->assertIdentical("description of term {$tid} of vocabulary {$values['source_vid']}", $term->description->value); - $this->assertIdentical($values['vid'], $term->vid->target_id); - $this->assertIdentical((string) $values['weight'], $term->weight->value); + $language = isset($values['language']) ? $values['language'] . ' - ' : ''; + $this->assertSame("{$language}term {$tid} of vocabulary {$values['source_vid']}", $term->name->value); + $this->assertSame("{$language}description of term {$tid} of vocabulary {$values['source_vid']}", $term->description->value); + $this->assertSame($values['vid'], $term->vid->target_id); + $this->assertSame((string) $values['weight'], $term->weight->value); if ($values['parent'] === [0]) { - $this->assertNull($term->parent->target_id); + $this->assertSame(0, (int) $term->parent->target_id); } else { $parents = []; foreach (\Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid) as $parent) { $parents[] = (int) $parent->id(); } - $this->assertIdentical($parents, $values['parent']); + $this->assertSame($parents, $values['parent']); } $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"); } }