updated core
This commit is contained in:
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- taxonomy
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1509719929
|
||||
datestamp: 1515021228
|
||||
|
||||
+3
-3
@@ -8,8 +8,8 @@ dependencies:
|
||||
- taxonomy
|
||||
- migrate
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1509719929
|
||||
datestamp: 1515021228
|
||||
|
||||
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- taxonomy
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1509719929
|
||||
datestamp: 1515021228
|
||||
|
||||
+3
-3
@@ -8,8 +8,8 @@ dependencies:
|
||||
- taxonomy
|
||||
- views
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1509719929
|
||||
datestamp: 1515021228
|
||||
|
||||
+3
-3
@@ -6,8 +6,8 @@ package: Testing
|
||||
dependencies:
|
||||
- taxonomy
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1509719929
|
||||
datestamp: 1515021228
|
||||
|
||||
@@ -65,7 +65,6 @@ class ArgumentValidatorTermTest extends TaxonomyTestBase {
|
||||
$view = Views::getView('test_argument_validator_term');
|
||||
$view->initHandlers();
|
||||
|
||||
|
||||
// Test the single validator for term IDs.
|
||||
$view->argument['tid']->validator->options['type'] = 'tid';
|
||||
|
||||
@@ -83,7 +82,6 @@ class ArgumentValidatorTermTest extends TaxonomyTestBase {
|
||||
$view->argument['tid']->validated_title = NULL;
|
||||
$view->argument['tid']->argument_validated = NULL;
|
||||
|
||||
|
||||
// Test the multiple validator for term IDs.
|
||||
$view->argument['tid']->validator->options['type'] = 'tids';
|
||||
$view->argument['tid']->options['break_phrase'] = TRUE;
|
||||
|
||||
@@ -92,8 +92,7 @@ class TaxonomyTermViewTest extends TaxonomyTestBase {
|
||||
$this->assertText($node->label());
|
||||
|
||||
\Drupal::service('module_installer')->install(['language', 'content_translation']);
|
||||
$language = ConfigurableLanguage::createFromLangcode('ur');
|
||||
$language->save();
|
||||
ConfigurableLanguage::createFromLangcode('ur')->save();
|
||||
// Enable translation for the article content type and ensure the change is
|
||||
// picked up.
|
||||
\Drupal::service('content_translation.manager')->setEnabled('node', 'article', TRUE);
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Kernel;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
|
||||
/**
|
||||
* Kernel tests for taxonomy forward revisions.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class ForwardRevisionTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy', 'node', 'user', 'text', 'field', 'system'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installEntitySchema('user');
|
||||
$this->installEntitySchema('node');
|
||||
$this->installEntitySchema('taxonomy_term');
|
||||
$this->installSchema('node', 'node_access');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the taxonomy index work correctly with forward revisions.
|
||||
*/
|
||||
public function testTaxonomyIndexWithForwardRevision() {
|
||||
\Drupal::configFactory()->getEditable('taxonomy.settings')->set('maintain_index_table', TRUE)->save();
|
||||
|
||||
Vocabulary::create([
|
||||
'name' => 'test',
|
||||
'vid' => 'test',
|
||||
])->save();
|
||||
$term = Term::create([
|
||||
'name' => 'term1',
|
||||
'vid' => 'test',
|
||||
]);
|
||||
$term->save();
|
||||
$term2 = Term::create([
|
||||
'name' => 'term2',
|
||||
'vid' => 'test',
|
||||
]);
|
||||
$term2->save();
|
||||
|
||||
NodeType::create([
|
||||
'type' => 'page',
|
||||
])->save();
|
||||
|
||||
FieldStorageConfig::create([
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_tags',
|
||||
'type' => 'entity_reference',
|
||||
'settings' => [
|
||||
'target_type' => 'taxonomy_term',
|
||||
],
|
||||
])->save();
|
||||
|
||||
FieldConfig::create([
|
||||
'field_name' => 'field_tags',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
])->save();
|
||||
$node = Node::create([
|
||||
'type' => 'page',
|
||||
'title' => 'test_title',
|
||||
'field_tags' => [$term->id()],
|
||||
]);
|
||||
$node->save();
|
||||
|
||||
$taxonomy_index = $this->getTaxonomyIndex();
|
||||
$this->assertEquals($term->id(), $taxonomy_index[$node->id()]->tid);
|
||||
|
||||
// Normal new revision.
|
||||
$node->setNewRevision(TRUE);
|
||||
$node->isDefaultRevision(TRUE);
|
||||
$node->field_tags->target_id = $term2->id();
|
||||
$node->save();
|
||||
|
||||
$taxonomy_index = $this->getTaxonomyIndex();
|
||||
$this->assertEquals($term2->id(), $taxonomy_index[$node->id()]->tid);
|
||||
|
||||
// Check that saving a forward (non-default) revision does not affect the
|
||||
// taxonomy index.
|
||||
$node->setNewRevision(TRUE);
|
||||
$node->isDefaultRevision(FALSE);
|
||||
$node->field_tags->target_id = $term->id();
|
||||
$node->save();
|
||||
|
||||
$taxonomy_index = $this->getTaxonomyIndex();
|
||||
$this->assertEquals($term2->id(), $taxonomy_index[$node->id()]->tid);
|
||||
|
||||
// Check that making the previously created forward-revision the default
|
||||
// revision updates the taxonomy index correctly.
|
||||
$node->isDefaultRevision(TRUE);
|
||||
$node->save();
|
||||
|
||||
$taxonomy_index = $this->getTaxonomyIndex();
|
||||
$this->assertEquals($term->id(), $taxonomy_index[$node->id()]->tid);
|
||||
}
|
||||
|
||||
protected function getTaxonomyIndex() {
|
||||
return \Drupal::database()->select('taxonomy_index')
|
||||
->fields('taxonomy_index')
|
||||
->execute()
|
||||
->fetchAllAssoc('nid');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
|
||||
}
|
||||
|
||||
foreach ($expected_results as $tid => $values) {
|
||||
/** @var Term $term */
|
||||
/** @var \Drupal\taxonomy\Entity\Term $term */
|
||||
$term = $terms[$tid];
|
||||
$language = isset($values['language']) ? $values['language'] . ' - ' : '';
|
||||
$this->assertSame("{$language}term {$tid} of vocabulary {$values['source_vid']}", $term->name->value);
|
||||
|
||||
-124
@@ -1,124 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
use Drupal\taxonomy\TermInterface;
|
||||
|
||||
/**
|
||||
* Test migration of translated taxonomy terms.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateTaxonomyTermTranslationTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'language',
|
||||
'menu_ui',
|
||||
'node',
|
||||
'taxonomy',
|
||||
];
|
||||
|
||||
/**
|
||||
* 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([
|
||||
'd6_node_type',
|
||||
'd6_field',
|
||||
'd6_taxonomy_vocabulary',
|
||||
'd6_field_instance',
|
||||
'd6_taxonomy_term',
|
||||
'd6_taxonomy_term_translation',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate 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, $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->getVocabularyId());
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert 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 taxonomy term to Drupal 8 migration.
|
||||
*/
|
||||
public function testTranslatedTaxonomyTerms() {
|
||||
$this->assertEntity(1, 'zu', 'zu - term 1 of vocabulary 1', 'vocabulary_1_i_0_', 'zu - description of term 1 of vocabulary 1', NULL, '0', []);
|
||||
$this->assertEntity(2, 'fr', 'fr - term 2 of vocabulary 2', 'vocabulary_2_i_1_', 'fr - description of term 2 of vocabulary 2', NULL, '3', []);
|
||||
$this->assertEntity(3, 'fr', 'fr - term 3 of vocabulary 2', 'vocabulary_2_i_1_', 'fr - description of term 3 of vocabulary 2', NULL, '4', ['2']);
|
||||
$this->assertEntity(4, 'en', 'term 4 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 4 of vocabulary 3', NULL, '6', []);
|
||||
$this->assertEntity(5, 'en', 'term 5 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 5 of vocabulary 3', NULL, '7', ['4']);
|
||||
$this->assertEntity(6, 'en', 'term 6 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 6 of vocabulary 3', NULL, '8', ['4', '5']);
|
||||
$this->assertEntity(7, 'fr', 'fr - term 2 of vocabulary 1', 'vocabulary_1_i_0_', 'fr - desc of term 2 vocab 1', NULL, '0', []);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Migrate;
|
||||
|
||||
/**
|
||||
* Tests the taxonomy term source with vocabulary filter.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TermSourceWithVocabularyFilterTest extends TermTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->migrationConfiguration['source']['vocabulary'] = array(5);
|
||||
parent::setUp();
|
||||
$this->expectedResults = array_values(array_filter($this->expectedResults, function($result) {
|
||||
return $result['vid'] == 5;
|
||||
}));
|
||||
// We know there are two rows with vid == 5.
|
||||
$this->expectedCount = 2;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Migrate;
|
||||
|
||||
/**
|
||||
* Tests taxonomy term source plugin.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TermTest extends TermTestBase {
|
||||
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Migrate;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Base class for taxonomy term source unit tests.
|
||||
*/
|
||||
abstract class TermTestBase extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\taxonomy\Plugin\migrate\source\Term';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'highWaterProperty' => array('field' => 'test'),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_taxonomy_term',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'tid' => 1,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 1',
|
||||
'description' => 'description value 1',
|
||||
'weight' => 0,
|
||||
'parent' => array(0),
|
||||
),
|
||||
array(
|
||||
'tid' => 2,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 2',
|
||||
'description' => 'description value 2',
|
||||
'weight' => 0,
|
||||
'parent' => array(0),
|
||||
),
|
||||
array(
|
||||
'tid' => 3,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 3',
|
||||
'description' => 'description value 3',
|
||||
'weight' => 0,
|
||||
'parent' => array(0),
|
||||
),
|
||||
array(
|
||||
'tid' => 4,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 4',
|
||||
'description' => 'description value 4',
|
||||
'weight' => 1,
|
||||
'parent' => array(1),
|
||||
),
|
||||
array(
|
||||
'tid' => 5,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 5',
|
||||
'description' => 'description value 5',
|
||||
'weight' => 1,
|
||||
'parent' => array(2),
|
||||
),
|
||||
array(
|
||||
'tid' => 6,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 6',
|
||||
'description' => 'description value 6',
|
||||
'weight' => 0,
|
||||
'parent' => array(3, 2),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
foreach ($row['parent'] as $parent) {
|
||||
$this->databaseContents['term_hierarchy'][] = array(
|
||||
'tid' => $row['tid'],
|
||||
'parent' => $parent,
|
||||
);
|
||||
}
|
||||
unset($row['parent']);
|
||||
$this->databaseContents['term_data'][$k] = $row;
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Migrate\d6;
|
||||
|
||||
use Drupal\taxonomy\Plugin\migrate\source\d6\TermNode;
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests d6_term_node source plugin.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TermNodeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = TermNode::class;
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_term_node',
|
||||
'vid' => 3,
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'type' => 'story',
|
||||
'tid' => array(1, 4, 5),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['term_node'] = array(
|
||||
array(
|
||||
'nid' => '1',
|
||||
'vid' => '1',
|
||||
'tid' => '1',
|
||||
),
|
||||
array(
|
||||
'nid' => '1',
|
||||
'vid' => '1',
|
||||
'tid' => '4',
|
||||
),
|
||||
array(
|
||||
'nid' => '1',
|
||||
'vid' => '1',
|
||||
'tid' => '5',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['node'] = array(
|
||||
array(
|
||||
'nid' => '1',
|
||||
'vid' => '1',
|
||||
'type' => 'story',
|
||||
'language' => '',
|
||||
'title' => 'Test title',
|
||||
'uid' => '1',
|
||||
'status' => '1',
|
||||
'created' => '1388271197',
|
||||
'changed' => '1420861423',
|
||||
'comment' => '0',
|
||||
'promote' => '0',
|
||||
'moderate' => '0',
|
||||
'sticky' => '0',
|
||||
'tnid' => '0',
|
||||
'translate' => '0',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['term_data'] = array(
|
||||
array(
|
||||
'tid' => '1',
|
||||
'vid' => '3',
|
||||
'name' => 'term 1 of vocabulary 3',
|
||||
'description' => 'description of term 1 of vocabulary 3',
|
||||
'weight' => '0',
|
||||
),
|
||||
array(
|
||||
'tid' => '4',
|
||||
'vid' => '3',
|
||||
'name' => 'term 4 of vocabulary 3',
|
||||
'description' => 'description of term 4 of vocabulary 3',
|
||||
'weight' => '6',
|
||||
),
|
||||
array(
|
||||
'tid' => '5',
|
||||
'vid' => '3',
|
||||
'name' => 'term 5 of vocabulary 3',
|
||||
'description' => 'description of term 5 of vocabulary 3',
|
||||
'weight' => '7',
|
||||
),
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Migrate\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
|
||||
/**
|
||||
* Tests D6 vocabulary source plugin.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class VocabularyTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary';
|
||||
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => [
|
||||
'plugin' => 'd6_vocabulary',
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'vid' => 1,
|
||||
'name' => 'Tags',
|
||||
'description' => 'Tags description.',
|
||||
'help' => 1,
|
||||
'relations' => 0,
|
||||
'hierarchy' => 0,
|
||||
'multiple' => 0,
|
||||
'required' => 0,
|
||||
'tags' => 1,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'node_types' => ['page', 'article'],
|
||||
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
|
||||
],
|
||||
[
|
||||
'vid' => 2,
|
||||
'name' => 'Categories',
|
||||
'description' => 'Categories description.',
|
||||
'help' => 1,
|
||||
'relations' => 1,
|
||||
'hierarchy' => 1,
|
||||
'multiple' => 0,
|
||||
'required' => 1,
|
||||
'tags' => 0,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'node_types' => ['article'],
|
||||
'cardinality' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as &$row) {
|
||||
foreach ($row['node_types'] as $type) {
|
||||
$this->databaseContents['vocabulary_node_types'][] = [
|
||||
'type' => $type,
|
||||
'vid' => $row['vid'],
|
||||
];
|
||||
}
|
||||
unset($row['node_types']);
|
||||
}
|
||||
$this->databaseContents['vocabulary'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Migrate\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D7 vocabulary source plugin.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class VocabularyTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\taxonomy\Plugin\migrate\source\d7\Vocabulary';
|
||||
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => [
|
||||
'plugin' => 'd7_vocabulary',
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'vid' => 1,
|
||||
'name' => 'Tags',
|
||||
'description' => 'Tags description.',
|
||||
'hierarchy' => 0,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'machine_name' => 'tags',
|
||||
],
|
||||
[
|
||||
'vid' => 2,
|
||||
'name' => 'Categories',
|
||||
'description' => 'Categories description.',
|
||||
'hierarchy' => 1,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'machine_name' => 'categories',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['taxonomy_vocabulary'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -51,7 +51,7 @@ class TaxonomyTermReferenceCckTest extends UnitTestCase {
|
||||
$this->plugin->processFieldValues($this->migration, 'somefieldname', []);
|
||||
|
||||
$expected = [
|
||||
'plugin' => 'iterator',
|
||||
'plugin' => 'sub_process',
|
||||
'source' => 'somefieldname',
|
||||
'process' => [
|
||||
'target_id' => 'tid',
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ class TaxonomyTermReferenceFieldTest extends UnitTestCase {
|
||||
$this->plugin->processFieldValues($this->migration, 'somefieldname', []);
|
||||
|
||||
$expected = [
|
||||
'plugin' => 'iterator',
|
||||
'plugin' => 'sub_process',
|
||||
'source' => 'somefieldname',
|
||||
'process' => [
|
||||
'target_id' => 'tid',
|
||||
|
||||
Reference in New Issue
Block a user