MigrateVocabularyFieldInstanceTest.php in Zircon Profile 8.0
File
core/modules/taxonomy/src/Tests/Migrate/d6/MigrateVocabularyFieldInstanceTest.php
View source
<?php
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\field\Entity\FieldConfig;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
public static $modules = [
'taxonomy',
];
protected function setUp() {
parent::setUp();
$this
->migrateTaxonomy();
}
public function testVocabularyFieldInstance() {
$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());
$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());
$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',
), Migration::load('d6_vocabulary_field_instance')
->getIdMap()
->lookupDestinationID(array(
4,
'article',
)));
}
}