summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2016-12-19 09:33:59 +0000
committerAlex Pott2016-12-19 09:33:59 +0000
commit08febd9a9f1cf45eddb2ccebeb1d24155454c868 (patch)
tree106eff2ecd568ce5e1ace7142b06ba16504c655d
parent714799324429f301188a1ff9113907728d4c1e18 (diff)
Issue #2823955 by Jo Fitzgerald, benjy, quietone, claudiu.cristea, mikeryan: No need to specify operator for Vocabulary filter in Term source
-rw-r--r--core/modules/taxonomy/src/Plugin/migrate/source/Term.php2
-rw-r--r--core/modules/taxonomy/src/Plugin/migrate/source/d6/Term.php2
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d6/TermTest.php61
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d7/TermTest.php61
4 files changed, 124 insertions, 2 deletions
diff --git a/core/modules/taxonomy/src/Plugin/migrate/source/Term.php b/core/modules/taxonomy/src/Plugin/migrate/source/Term.php
index 14dda1f..ce468a2 100644
--- a/core/modules/taxonomy/src/Plugin/migrate/source/Term.php
+++ b/core/modules/taxonomy/src/Plugin/migrate/source/Term.php
@@ -54,7 +54,7 @@ class Term extends DrupalSqlBase {
->orderBy('td.tid');
if (isset($this->configuration['vocabulary'])) {
- $query->condition('td.vid', $this->configuration['vocabulary'], 'IN');
+ $query->condition('td.vid', (array) $this->configuration['vocabulary'], 'IN');
}
return $query;
diff --git a/core/modules/taxonomy/src/Plugin/migrate/source/d6/Term.php b/core/modules/taxonomy/src/Plugin/migrate/source/d6/Term.php
index 0418277..b8a603d 100644
--- a/core/modules/taxonomy/src/Plugin/migrate/source/d6/Term.php
+++ b/core/modules/taxonomy/src/Plugin/migrate/source/d6/Term.php
@@ -27,7 +27,7 @@ class Term extends DrupalSqlBase {
->orderBy('td.tid');
if (isset($this->configuration['bundle'])) {
- $query->condition('td.vid', $this->configuration['bundle'], 'IN');
+ $query->condition('td.vid', (array) $this->configuration['bundle'], 'IN');
}
return $query;
diff --git a/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d6/TermTest.php b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d6/TermTest.php
index 29e23b8..d1ac238 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d6/TermTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d6/TermTest.php
@@ -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;
}
diff --git a/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d7/TermTest.php b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d7/TermTest.php
index e20e4c0..be905d9 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d7/TermTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d7/TermTest.php
@@ -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']['taxonomy_term_hierarchy'] = [
[
@@ -97,6 +104,10 @@ class TermTest extends MigrateSqlSourceTestBase {
'tid' => 6,
'parent' => 2,
],
+ [
+ 'tid' => 7,
+ 'parent' => 0,
+ ],
];
$tests[0]['source_data']['taxonomy_vocabulary'] = [
[
@@ -189,8 +200,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, "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;
}