Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes

This commit is contained in:
Pantheon Automation 2016-04-20 09:56:34 -07:00 committed by Greg Anderson
parent b11a755ba8
commit c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions

View file

@ -0,0 +1,29 @@
id: taxonomy_term_stub_test
label: Taxonomy term stub
migration_tags:
- Import and rollback test
source:
plugin: embedded_data
data_rows:
-
id: 1
vocab: 1
name: music
parent: 2
ids:
id:
type: integer
process:
tid: id
vid: vocab
name: name
weight: weight
parent:
plugin: migration
migration: taxonomy_term_stub_test
source: parent
destination:
plugin: entity:taxonomy_term
migration_dependencies:
required:
- vocabularies

View file

@ -0,0 +1,9 @@
name: 'Taxonomy Migrate stub test'
type: module
description: 'Provides a migration plugin for stub testing.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- taxonomy
- migrate

View file

@ -0,0 +1,40 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Upgrade variables to taxonomy.settings.yml.
*
* @group migrate_drupal_6
*/
class MigrateTaxonomyConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* {@inheritdoc}
*/
public static $modules = array('taxonomy');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('taxonomy_settings');
}
/**
* Tests migration of taxonomy variables to taxonomy.settings.yml.
*/
public function testTaxonomySettings() {
$config = $this->config('taxonomy.settings');
$this->assertIdentical(100, $config->get('terms_per_page_admin'));
$this->assertIdentical(FALSE, $config->get('override_selector'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'taxonomy.settings', $config->get());
}
}

View file

@ -0,0 +1,85 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate;
use Drupal\migrate\MigrateExecutable;
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
use Drupal\migrate_drupal\Tests\StubTestTrait;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
/**
* Test stub creation for taxonomy terms.
*
* @group taxonomy
*/
class MigrateTaxonomyTermStubTest extends MigrateDrupalTestBase {
use StubTestTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'text', 'taxonomy_term_stub_test'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('taxonomy_term');
}
/**
* Tests creation of taxonomy term stubs.
*/
public function testStub() {
Vocabulary::create([
'vid' => 'test_vocabulary',
'name' => 'Test vocabulary',
])->save();
$this->performStubTest('taxonomy_term');
}
/**
* Tests creation of stubs when weight is mapped.
*/
public function testStubWithWeightMapping() {
// Create a vocabulary via migration for the terms to reference.
$vocabulary_data_rows = [
['id' => '1', 'name' => 'tags'],
];
$ids = ['id' => ['type' => 'integer']];
$definition = [
'migration_tags' => ['Stub test'],
'source' => [
'plugin' => 'embedded_data',
'data_rows' => $vocabulary_data_rows,
'ids' => $ids,
],
'process' => [
'vid' => 'id',
'name' => 'name',
],
'destination' => ['plugin' => 'entity:taxonomy_vocabulary'],
];
$vocabulary_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$vocabulary_executable = new MigrateExecutable($vocabulary_migration, $this);
$vocabulary_executable->import();
// We have a term referencing an unmigrated parent, forcing a stub to be
// created.
$migration = $this->getMigration('taxonomy_term_stub_test');
$term_executable = new MigrateExecutable($migration, $this);
$term_executable->import();
$this->assertTrue($migration->getIdMap()->getRowBySource(['2']), 'Stub row exists in the ID map table');
// Load the referenced term, which should exist as a stub.
/** @var \Drupal\Core\Entity\ContentEntityBase $stub_entity */
$stub_entity = Term::load(2);
$this->assertTrue($stub_entity, 'Stub successfully created');
if ($stub_entity) {
$this->assertIdentical(count($stub_entity->validate()), 0, 'Stub is a valid entity');
}
}
}

View file

@ -0,0 +1,92 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\taxonomy\Entity\Term;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Upgrade taxonomy terms.
*
* @group migrate_drupal_6
*/
class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('taxonomy');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('taxonomy_term');
$this->executeMigrations(['d6_taxonomy_vocabulary', 'd6_taxonomy_term']);
}
/**
* Tests the Drupal 6 taxonomy term to Drupal 8 migration.
*/
public function testTaxonomyTerms() {
$expected_results = array(
'1' => array(
'source_vid' => 1,
'vid' => 'vocabulary_1_i_0_',
'weight' => 0,
'parent' => array(0),
),
'2' => array(
'source_vid' => 2,
'vid' => 'vocabulary_2_i_1_',
'weight' => 3,
'parent' => array(0),
),
'3' => array(
'source_vid' => 2,
'vid' => 'vocabulary_2_i_1_',
'weight' => 4,
'parent' => array(2),
),
'4' => array(
'source_vid' => 3,
'vid' => 'vocabulary_3_i_2_',
'weight' => 6,
'parent' => array(0),
),
'5' => array(
'source_vid' => 3,
'vid' => 'vocabulary_3_i_2_',
'weight' => 7,
'parent' => array(4),
),
'6' => array(
'source_vid' => 3,
'vid' => 'vocabulary_3_i_2_',
'weight' => 8,
'parent' => array(4, 5),
),
);
$terms = Term::loadMultiple(array_keys($expected_results));
foreach ($expected_results as $tid => $values) {
/** @var 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);
if ($values['parent'] === array(0)) {
$this->assertNull($term->parent->target_id);
}
else {
$parents = array();
foreach (\Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid) as $parent) {
$parents[] = (int) $parent->id();
}
$this->assertIdentical($parents, $values['parent']);
}
}
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Migrate taxonomy vocabularies to taxonomy.vocabulary.*.yml.
*
* @group migrate_drupal_6
*/
class MigrateTaxonomyVocabularyTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('taxonomy');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_taxonomy_vocabulary');
}
/**
* Tests the Drupal 6 taxonomy vocabularies to Drupal 8 migration.
*/
public function testTaxonomyVocabulary() {
for ($i = 0; $i < 3; $i++) {
$j = $i + 1;
$vocabulary = Vocabulary::load("vocabulary_{$j}_i_{$i}_");
$this->assertIdentical($this->getMigration('d6_taxonomy_vocabulary')->getIdMap()->lookupDestinationID(array($j)), array($vocabulary->id()));
$this->assertIdentical("vocabulary $j (i=$i)", $vocabulary->label());
$this->assertIdentical("description of vocabulary $j (i=$i)", $vocabulary->getDescription());
$this->assertIdentical($i, $vocabulary->getHierarchy());
$this->assertIdentical(4 + $i, $vocabulary->get('weight'));
}
$vocabulary = Vocabulary::load('vocabulary_name_much_longer_than');
$this->assertIdentical('vocabulary name much longer than thirty two characters', $vocabulary->label());
$this->assertIdentical('description of vocabulary name much longer than thirty two characters', $vocabulary->getDescription());
$this->assertIdentical(3, $vocabulary->getHierarchy());
$this->assertIdentical(7, $vocabulary->get('weight'));
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Upgrade taxonomy term node associations.
*
* @group migrate_drupal_6
*/
class MigrateTermNodeRevisionTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installSchema('node', ['node_access']);
$this->migrateContent(TRUE);
$this->migrateTaxonomy();
$this->executeMigrations(['d6_term_node', 'd6_term_node_revision']);
}
/**
* Tests the Drupal 6 term-node revision association to Drupal 8 migration.
*/
public function testTermRevisionNode() {
$node = \Drupal::entityManager()->getStorage('node')->loadRevision(2);
$this->assertIdentical(2, count($node->vocabulary_3_i_2_));
$this->assertIdentical('4', $node->vocabulary_3_i_2_[0]->target_id);
$this->assertIdentical('5', $node->vocabulary_3_i_2_[1]->target_id);
}
}

View file

@ -0,0 +1,67 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
use Drupal\node\Entity\Node;
/**
* Upgrade taxonomy term node associations.
*
* @group migrate_drupal_6
*/
class MigrateTermNodeTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installSchema('node', ['node_access']);
$this->migrateContent();
$this->migrateTaxonomy();
}
/**
* Tests the Drupal 6 term-node association to Drupal 8 migration.
*/
public function testTermNode() {
// This is a base plugin id and we want to run all derivatives.
$this->executeMigrations(['d6_term_node']);
$this->container->get('entity.manager')
->getStorage('node')
->resetCache([1, 2]);
$nodes = Node::loadMultiple([1, 2]);
$node = $nodes[1];
$this->assertIdentical(1, count($node->vocabulary_1_i_0_));
$this->assertIdentical('1', $node->vocabulary_1_i_0_[0]->target_id);
$node = $nodes[2];
$this->assertIdentical(2, count($node->vocabulary_2_i_1_));
$this->assertIdentical('2', $node->vocabulary_2_i_1_[0]->target_id);
$this->assertIdentical('3', $node->vocabulary_2_i_1_[1]->target_id);
}
/**
* Tests that term associations are ignored when they belong to nodes which
* were not migrated.
*/
public function testSkipNonExistentNode() {
// Node 2 is migrated by d6_node__story, but we need to pretend that it
// failed, so record that in the map table.
$this->mockFailure('d6_node:story', ['nid' => 2]);
// d6_term_node__2 should skip over node 2 (a.k.a. revision 3) because,
// according to the map table, it failed.
$migration = $this->getMigration('d6_term_node:2');
$this->executeMigration($migration);
$this->assertNull($migration->getIdMap()->lookupDestinationId(['vid' => 3])[0]);
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Vocabulary entity display migration.
*
* @group migrate_drupal_6
*/
class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['field', 'taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->migrateTaxonomy();
}
/**
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
*/
public function testVocabularyEntityDisplay() {
// Test that the field exists.
$component = EntityViewDisplay::load('node.page.default')->getComponent('tags');
$this->assertIdentical('entity_reference_label', $component['type']);
$this->assertIdentical(20, $component['weight']);
// Test the Id map.
$this->assertIdentical(array('node', 'article', 'default', 'tags'), $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
}
}

View file

@ -0,0 +1,45 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Vocabulary entity form display migration.
*
* @group migrate_drupal_6
*/
class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->migrateTaxonomy();
}
/**
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
*/
public function testVocabularyEntityFormDisplay() {
// Test that the field exists.
$component = EntityFormDisplay::load('node.page.default')->getComponent('tags');
$this->assertIdentical('options_select', $component['type']);
$this->assertIdentical(20, $component['weight']);
// Test the Id map.
$this->assertIdentical(array('node', 'article', 'default', 'tags'), $this->getMigration('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
// Test the term widget tags setting.
$entity_form_display = EntityFormDisplay::load('node.story.default');
$this->assertIdentical($entity_form_display->getComponent('vocabulary_1_i_0_')['type'], 'options_select');
$this->assertIdentical($entity_form_display->getComponent('vocabulary_2_i_1_')['type'], 'entity_reference_autocomplete_tags');
}
}

View file

@ -0,0 +1,59 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\field\Entity\FieldConfig;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Vocabulary field instance migration.
*
* @group migrate_drupal_6
*/
class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->migrateTaxonomy();
}
/**
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
*/
public function testVocabularyFieldInstance() {
// Test that the field exists.
$field_id = 'node.article.tags';
$field = FieldConfig::load($field_id);
$this->assertIdentical($field_id, $field->id(), 'Field instance exists on article bundle.');
$this->assertIdentical('Tags', $field->label());
$this->assertTrue($field->isRequired(), 'Field is required');
// Test the page bundle as well.
$field_id = 'node.page.tags';
$field = FieldConfig::load($field_id);
$this->assertIdentical($field_id, $field->id(), 'Field instance exists on page bundle.');
$this->assertIdentical('Tags', $field->label());
$this->assertTrue($field->isRequired(), 'Field is required');
$settings = $field->getSettings();
$this->assertIdentical('default:taxonomy_term', $settings['handler'], 'The handler plugin ID is correct.');
$this->assertIdentical(['tags'], $settings['handler_settings']['target_bundles'], 'The target_bundles handler setting is correct.');
$this->assertIdentical(TRUE, $settings['handler_settings']['auto_create'], 'The "auto_create" setting is correct.');
$this->assertIdentical(array('node', 'article', 'tags'), $this->getMigration('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationID(array(4, 'article')));
// Test the the field vocabulary_1_i_0_
$field_id = 'node.story.vocabulary_1_i_0_';
$field = FieldConfig::load($field_id);
$this->assertFalse($field->isRequired(), 'Field is not required');
}
}

View file

@ -0,0 +1,45 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Vocabulary field migration.
*
* @group migrate_drupal_6
*/
class MigrateVocabularyFieldTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->migrateTaxonomy();
}
/**
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
*/
public function testVocabularyField() {
// Test that the field exists.
$field_storage_id = 'node.tags';
/** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
$field_storage = FieldStorageConfig::load($field_storage_id);
$this->assertIdentical($field_storage_id, $field_storage->id());
$settings = $field_storage->getSettings();
$this->assertIdentical('taxonomy_term', $settings['target_type'], "Target type is correct.");
$this->assertIdentical(1, $field_storage->getCardinality(), "Field cardinality in 1.");
$this->assertIdentical(array('node', 'tags'), $this->getMigration('d6_vocabulary_field')->getIdMap()->lookupDestinationID(array(4)), "Test IdMap");
}
}

View file

@ -0,0 +1,79 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d7;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\FieldStorageConfigInterface;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface;
/**
* @group taxonomy
*/
class MigrateNodeTaxonomyTest extends MigrateDrupal7TestBase {
public static $modules = array(
'datetime',
'field',
'filter',
'image',
'link',
'node',
'taxonomy',
'telephone',
'text',
);
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installEntitySchema('taxonomy_term');
$this->installConfig(static::$modules);
$this->installSchema('node', ['node_access']);
$this->installSchema('system', ['sequences']);
$this->executeMigration('d7_node_type');
FieldStorageConfig::create(array(
'type' => 'entity_reference',
'field_name' => 'field_tags',
'entity_type' => 'node',
'settings' => array(
'target_type' => 'taxonomy_term',
),
'cardinality' => FieldStorageConfigInterface::CARDINALITY_UNLIMITED,
))->save();
FieldConfig::create(array(
'entity_type' => 'node',
'field_name' => 'field_tags',
'bundle' => 'article',
))->save();
$this->executeMigrations([
'd7_taxonomy_vocabulary',
'd7_taxonomy_term',
'd7_user_role',
'd7_user',
'd7_node:article',
]);
}
/**
* Test node migration from Drupal 7 to 8.
*/
public function testMigration() {
$node = Node::load(2);
$this->assertTrue($node instanceof NodeInterface);
$this->assertEqual(9, $node->field_tags[0]->target_id);
$this->assertEqual(14, $node->field_tags[1]->target_id);
$this->assertEqual(17, $node->field_tags[2]->target_id);
}
}

View file

@ -0,0 +1,81 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d7;
use Drupal\taxonomy\Entity\Term;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\taxonomy\TermInterface;
/**
* Upgrade taxonomy terms.
*
* @group taxonomy
*/
class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase {
public static $modules = array('taxonomy', 'text');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('taxonomy_term');
$this->executeMigrations(['d7_taxonomy_vocabulary', 'd7_taxonomy_term']);
}
/**
* Validate a migrated term contains the expected values.
*
* @param $id
* Entity ID to load and check.
* @param $expected_label
* The label the migrated entity should have.
* @param $expected_vid
* The parent vocabulary the migrated entity should have.
* @param string $expected_description
* The description 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.
*/
protected function assertEntity($id, $expected_label, $expected_vid, $expected_description = '', $expected_weight = 0, $expected_parents = []) {
/** @var \Drupal\taxonomy\TermInterface $entity */
$entity = Term::load($id);
$this->assertTrue($entity instanceof TermInterface);
$this->assertIdentical($expected_label, $entity->label());
$this->assertIdentical($expected_vid, $entity->getVocabularyId());
$this->assertEqual($expected_description, $entity->getDescription());
$this->assertEqual($expected_weight, $entity->getWeight());
$this->assertIdentical($expected_parents, $this->getParentIDs($id));
}
/**
* Tests the Drupal 7 taxonomy term to Drupal 8 migration.
*/
public function testTaxonomyTerms() {
$this->assertEntity(1, 'General discussion', 'forums', '', 2);
$this->assertEntity(2, 'Term1', 'test_vocabulary', 'The first term.');
$this->assertEntity(3, 'Term2', 'test_vocabulary', 'The second term.');
$this->assertEntity(4, 'Term3', 'test_vocabulary', 'The third term.', 0, [3]);
$this->assertEntity(5, 'Custom Forum', 'forums', 'Where the cool kids are.', 3);
$this->assertEntity(6, 'Games', 'forums', '', 4);
$this->assertEntity(7, 'Minecraft', 'forums', '', 1, [6]);
$this->assertEntity(8, 'Half Life 3', 'forums', '', 0, [6]);
}
/**
* Retrieves the parent term IDs for a given term.
*
* @param $tid
* ID of the term to check.
*
* @return array
* List of parent term IDs.
*/
protected function getParentIDs($tid) {
return array_keys(\Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid));
}
}

View file

@ -0,0 +1,62 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d7;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\taxonomy\VocabularyInterface;
/**
* Migrate taxonomy vocabularies to taxonomy.vocabulary.*.yml.
*
* @group taxonomy
*/
class MigrateTaxonomyVocabularyTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('taxonomy');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d7_taxonomy_vocabulary');
}
/**
* Validate a migrated vocabulary contains the expected values.
*
* @param $id
* Entity ID to load and check.
* @param $expected_label
* The label the migrated entity should have.
* @param $expected_description
* The description the migrated entity should have.
* @param $expected_hierarchy
* The hierarchy setting the migrated entity should have.
* @param $expected_weight
* The weight the migrated entity should have.
*/
protected function assertEntity($id, $expected_label, $expected_description, $expected_hierarchy, $expected_weight) {
/** @var \Drupal\taxonomy\VocabularyInterface $entity */
$entity = Vocabulary::load($id);
$this->assertTrue($entity instanceof VocabularyInterface);
$this->assertIdentical($expected_label, $entity->label());
$this->assertIdentical($expected_description, $entity->getDescription());
$this->assertIdentical($expected_hierarchy, $entity->getHierarchy());
$this->assertIdentical($expected_weight, $entity->get('weight'));
}
/**
* Tests the Drupal 7 taxonomy vocabularies to Drupal 8 migration.
*/
public function testTaxonomyVocabulary() {
$this->assertEntity('tags', 'Tags', 'Use tags to group articles on similar topics into categories.', TAXONOMY_HIERARCHY_DISABLED, 0);
$this->assertEntity('forums', 'Forums', 'Forum navigation vocabulary', TAXONOMY_HIERARCHY_SINGLE, -10);
$this->assertEntity('test_vocabulary', 'Test Vocabulary', 'This is the vocabulary description', TAXONOMY_HIERARCHY_SINGLE, 0);
}
}

View file

@ -0,0 +1,68 @@
<?php
namespace Drupal\Tests\taxonomy\Kernel\Views;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\views\Kernel\Handler\FieldFieldAccessTestBase;
/**
* Tests base field access in Views for the taxonomy entity.
*
* @group taxonomy
*/
class TaxonomyViewsFieldAccessTest extends FieldFieldAccessTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'text', 'entity_test'];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$this->installEntitySchema('taxonomy_term');
}
/**
* Check access for taxonomy fields.
*/
public function testTermFields() {
$vocab = Vocabulary::create([
'vid' => 'random',
'name' => 'Randomness',
]);
$vocab->save();
$term1 = Term::create([
'name' => 'Semi random',
'vid' => $vocab->id(),
]);
$term1->save();
$term2 = Term::create([
'name' => 'Majorly random',
'vid' => $vocab->id(),
]);
$term2->save();
$term3 = Term::create([
'name' => 'Not really random',
'vid' => $vocab->id(),
]);
$term3->save();
$this->assertFieldAccess('taxonomy_term', 'name', 'Majorly random');
$this->assertFieldAccess('taxonomy_term', 'name', 'Semi random');
$this->assertFieldAccess('taxonomy_term', 'name', 'Not really random');
$this->assertFieldAccess('taxonomy_term', 'tid', $term1->id());
$this->assertFieldAccess('taxonomy_term', 'tid', $term2->id());
$this->assertFieldAccess('taxonomy_term', 'tid', $term3->id());
$this->assertFieldAccess('taxonomy_term', 'uuid', $term1->uuid());
$this->assertFieldAccess('taxonomy_term', 'uuid', $term2->uuid());
$this->assertFieldAccess('taxonomy_term', 'uuid', $term3->uuid());
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\taxonomy\Unit\Menu\TaxonomyLocalTasksTest.
*/
namespace Drupal\Tests\taxonomy\Unit\Menu;
use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\TermSourceWithVocabularyFilterTest.
*/
namespace Drupal\Tests\taxonomy\Unit\Migrate;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\TermTest.
*/
namespace Drupal\Tests\taxonomy\Unit\Migrate;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\TermTestBase.
*/
namespace Drupal\Tests\taxonomy\Unit\Migrate;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\d6\TermNodeTest.
*/
namespace Drupal\Tests\taxonomy\Unit\Migrate\d6;
use Drupal\taxonomy\Plugin\migrate\source\d6\TermNode;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\d6\VocabularyTest.
*/
namespace Drupal\Tests\taxonomy\Unit\Migrate\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\d7\VocabularyTest.
*/
namespace Drupal\Tests\taxonomy\Unit\Migrate\d7;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;