upgrades core to 8.4.2
This commit is contained in:
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- taxonomy
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
+3
-3
@@ -8,8 +8,8 @@ dependencies:
|
||||
- taxonomy
|
||||
- migrate
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- taxonomy
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
+3
-3
@@ -8,8 +8,8 @@ dependencies:
|
||||
- taxonomy
|
||||
- views
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
+3
-3
@@ -6,8 +6,8 @@ package: Testing
|
||||
dependencies:
|
||||
- taxonomy
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Drupal\Tests\taxonomy\Functional;
|
||||
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use \Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
|
||||
/**
|
||||
* Posts an article with a taxonomy term and a date prior to 1970.
|
||||
@@ -60,7 +60,7 @@ class LegacyTest extends TaxonomyTestBase {
|
||||
$edit['created[0][value][time]'] = $date->format('H:i:s');
|
||||
$edit['body[0][value]'] = $this->randomMachineName();
|
||||
$edit['field_tags[target_id]'] = $this->randomMachineName();
|
||||
$this->drupalPostForm('node/add/article', $edit, t('Save and publish'));
|
||||
$this->drupalPostForm('node/add/article', $edit, t('Save'));
|
||||
// Checks that the node has been saved.
|
||||
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
|
||||
$this->assertEqual($node->getCreatedTime(), $date->getTimestamp(), 'Legacy node was saved with the right date.');
|
||||
|
||||
@@ -73,10 +73,6 @@ trait TaxonomyTranslationTestTrait {
|
||||
|
||||
/**
|
||||
* Adds term reference field for the article content type.
|
||||
*
|
||||
* @param bool $translatable
|
||||
* (optional) If TRUE, create a translatable term reference field. Defaults
|
||||
* to FALSE.
|
||||
*/
|
||||
protected function setUpTermReferenceField() {
|
||||
$handler_settings = [
|
||||
|
||||
@@ -74,10 +74,12 @@ class TermTranslationFieldViewTest extends TaxonomyTestBase {
|
||||
$node = Node::create([
|
||||
'title' => $this->randomMachineName(),
|
||||
'type' => 'article',
|
||||
'description' => [[
|
||||
'value' => $this->randomMachineName(),
|
||||
'format' => 'basic_html'
|
||||
]],
|
||||
'description' => [
|
||||
[
|
||||
'value' => $this->randomMachineName(),
|
||||
'format' => 'basic_html',
|
||||
],
|
||||
],
|
||||
$this->termFieldName => [['target_id' => $this->term->id()]],
|
||||
'langcode' => $this->baseLangcode,
|
||||
]);
|
||||
|
||||
@@ -57,7 +57,7 @@ class TaxonomyFieldAllTermsTest extends TaxonomyTestBase {
|
||||
$this->assertText('The taxonomy term name for the term: ' . $this->term1->getName());
|
||||
|
||||
// The machine name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary_vid }}
|
||||
$this->assertText('The machine name for the vocabulary the term belongs to: ' . $this->term1->getVocabularyId());
|
||||
$this->assertText('The machine name for the vocabulary the term belongs to: ' . $this->term1->bundle());
|
||||
|
||||
// The name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary }}
|
||||
$vocabulary = Vocabulary::load($this->term1->bundle());
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Drupal\Tests\taxonomy\Functional\Views;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\user\Entity\Role;
|
||||
use Drupal\user\RoleInterface;
|
||||
use Drupal\views\Views;
|
||||
@@ -124,6 +125,12 @@ class TaxonomyTermViewTest extends TaxonomyTestBase {
|
||||
// query anymore.
|
||||
// @see \Drupal\views\Plugin\views\filter\LanguageFilter::query()
|
||||
$node->delete();
|
||||
|
||||
// We also have to remove the nodes created by the parent ::setUp() method
|
||||
// if we want to be able to uninstall the Content Translation module.
|
||||
foreach (Node::loadMultiple() as $node) {
|
||||
$node->delete();
|
||||
}
|
||||
\Drupal::service('module_installer')->uninstall(['content_translation', 'language']);
|
||||
|
||||
$view = Views::getView('taxonomy_term');
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Functional;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
@@ -77,7 +78,7 @@ class VocabularyUiTest extends TaxonomyTestBase {
|
||||
$this->drupalPostForm('admin/structure/taxonomy/add', $edit, t('Save'));
|
||||
|
||||
$site_name = $this->config('system.site')->get('name');
|
||||
$this->assertTitle(t('Don\'t Panic | @site-name', ['@site-name' => $site_name]), 'The page title contains the escaped character.');
|
||||
$this->assertTitle(t("Don't Panic | @site-name", ['@site-name' => $site_name]), 'The page title contains the escaped character.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,8 +89,8 @@ class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
|
||||
$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->assertIdentical($values['vid'], $term->vid->target_id);
|
||||
$this->assertIdentical((string) $values['weight'], $term->weight->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);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
|
||||
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");
|
||||
|
||||
@@ -32,17 +32,17 @@ class MigrateTaxonomyVocabularyTest extends MigrateDrupal6TestBase {
|
||||
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([$j]), [$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'));
|
||||
$this->assertSame($this->getMigration('d6_taxonomy_vocabulary')->getIdMap()->lookupDestinationID([$j]), [$vocabulary->id()]);
|
||||
$this->assertSame("vocabulary $j (i=$i)", $vocabulary->label());
|
||||
$this->assertSame("description of vocabulary $j (i=$i)", $vocabulary->getDescription());
|
||||
$this->assertSame($i, $vocabulary->getHierarchy());
|
||||
$this->assertSame(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'));
|
||||
$this->assertSame('vocabulary name much longer than thirty two characters', $vocabulary->label());
|
||||
$this->assertSame('description of vocabulary name much longer than thirty two characters', $vocabulary->getDescription());
|
||||
$this->assertSame(3, $vocabulary->getHierarchy());
|
||||
$this->assertSame(7, $vocabulary->get('weight'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ class MigrateTermNodeRevisionTest extends MigrateDrupal6TestBase {
|
||||
*/
|
||||
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);
|
||||
$this->assertSame(2, count($node->field_vocabulary_3_i_2_));
|
||||
$this->assertSame('4', $node->field_vocabulary_3_i_2_[0]->target_id);
|
||||
$this->assertSame('5', $node->field_vocabulary_3_i_2_[1]->target_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,12 +40,12 @@ class MigrateTermNodeTest extends MigrateDrupal6TestBase {
|
||||
|
||||
$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);
|
||||
$this->assertSame(1, count($node->field_vocabulary_1_i_0_));
|
||||
$this->assertSame('1', $node->field_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);
|
||||
$this->assertSame(2, count($node->field_vocabulary_2_i_1_));
|
||||
$this->assertSame('2', $node->field_vocabulary_2_i_1_[0]->target_id);
|
||||
$this->assertSame('3', $node->field_vocabulary_2_i_1_[1]->target_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+9
-4
@@ -41,11 +41,16 @@ class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
|
||||
$this->executeMigration('d6_vocabulary_entity_display');
|
||||
|
||||
// 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']);
|
||||
$component = EntityViewDisplay::load('node.page.default')->getComponent('field_tags');
|
||||
$this->assertSame('entity_reference_label', $component['type']);
|
||||
$this->assertSame(20, $component['weight']);
|
||||
// Test the Id map.
|
||||
$this->assertIdentical(['node', 'article', 'default', 'tags'], $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationID([4, 'article']));
|
||||
$this->assertSame(['node', 'article', 'default', 'field_tags'], $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationID([4, 'article']));
|
||||
|
||||
// Tests that a vocabulary named like a D8 base field will be migrated and
|
||||
// prefixed with 'field_' to avoid conflicts.
|
||||
$field_type = EntityViewDisplay::load('node.sponsor.default')->getComponent('field_type');
|
||||
$this->assertTrue(is_array($field_type));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+11
-6
@@ -41,16 +41,21 @@ class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupal6TestBase {
|
||||
$this->executeMigration('d6_vocabulary_entity_form_display');
|
||||
|
||||
// Test that the field exists.
|
||||
$component = EntityFormDisplay::load('node.page.default')->getComponent('tags');
|
||||
$this->assertIdentical('options_select', $component['type']);
|
||||
$this->assertIdentical(20, $component['weight']);
|
||||
$component = EntityFormDisplay::load('node.page.default')->getComponent('field_tags');
|
||||
$this->assertSame('options_select', $component['type']);
|
||||
$this->assertSame(20, $component['weight']);
|
||||
// Test the Id map.
|
||||
$this->assertIdentical(['node', 'article', 'default', 'tags'], $this->getMigration('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID([4, 'article']));
|
||||
$this->assertSame(['node', 'article', 'default', 'field_tags'], $this->getMigration('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID([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');
|
||||
$this->assertSame($entity_form_display->getComponent('field_vocabulary_1_i_0_')['type'], 'options_select');
|
||||
$this->assertSame($entity_form_display->getComponent('field_vocabulary_2_i_1_')['type'], 'entity_reference_autocomplete_tags');
|
||||
|
||||
// Tests that a vocabulary named like a D8 base field will be migrated and
|
||||
// prefixed with 'field_' to avoid conflicts.
|
||||
$field_type = EntityFormDisplay::load('node.sponsor.default')->getComponent('field_type');
|
||||
$this->assertTrue(is_array($field_type));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+16
-11
@@ -40,30 +40,35 @@ class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
|
||||
$this->executeMigration('d6_vocabulary_field_instance');
|
||||
|
||||
// Test that the field exists.
|
||||
$field_id = 'node.article.tags';
|
||||
$field_id = 'node.article.field_tags';
|
||||
$field = FieldConfig::load($field_id);
|
||||
$this->assertIdentical($field_id, $field->id(), 'Field instance exists on article bundle.');
|
||||
$this->assertIdentical('Tags', $field->label());
|
||||
$this->assertSame($field_id, $field->id(), 'Field instance exists on article bundle.');
|
||||
$this->assertSame('Tags', $field->label());
|
||||
$this->assertTrue($field->isRequired(), 'Field is required');
|
||||
|
||||
// Test the page bundle as well.
|
||||
$field_id = 'node.page.tags';
|
||||
$field_id = 'node.page.field_tags';
|
||||
$field = FieldConfig::load($field_id);
|
||||
$this->assertIdentical($field_id, $field->id(), 'Field instance exists on page bundle.');
|
||||
$this->assertIdentical('Tags', $field->label());
|
||||
$this->assertSame($field_id, $field->id(), 'Field instance exists on page bundle.');
|
||||
$this->assertSame('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->assertSame('default:taxonomy_term', $settings['handler'], 'The handler plugin ID is correct.');
|
||||
$this->assertSame(['field_tags'], $settings['handler_settings']['target_bundles'], 'The target_bundles handler setting is correct.');
|
||||
$this->assertSame(TRUE, $settings['handler_settings']['auto_create'], 'The "auto_create" setting is correct.');
|
||||
|
||||
$this->assertIdentical(['node', 'article', 'tags'], $this->getMigration('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationID([4, 'article']));
|
||||
$this->assertSame(['node', 'article', 'field_tags'], $this->getMigration('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationID([4, 'article']));
|
||||
|
||||
// Test the the field vocabulary_1_i_0_.
|
||||
$field_id = 'node.story.vocabulary_1_i_0_';
|
||||
$field_id = 'node.story.field_vocabulary_1_i_0_';
|
||||
$field = FieldConfig::load($field_id);
|
||||
$this->assertFalse($field->isRequired(), 'Field is not required');
|
||||
|
||||
// Tests that a vocabulary named like a D8 base field will be migrated and
|
||||
// prefixed with 'field_' to avoid conflicts.
|
||||
$field_type = FieldConfig::load('node.sponsor.field_type');
|
||||
$this->assertInstanceOf(FieldConfig::class, $field_type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,16 +30,21 @@ class MigrateVocabularyFieldTest extends MigrateDrupal6TestBase {
|
||||
*/
|
||||
public function testVocabularyField() {
|
||||
// Test that the field exists.
|
||||
$field_storage_id = 'node.tags';
|
||||
$field_storage_id = 'node.field_tags';
|
||||
/** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
|
||||
$field_storage = FieldStorageConfig::load($field_storage_id);
|
||||
$this->assertIdentical($field_storage_id, $field_storage->id());
|
||||
$this->assertSame($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->assertSame('taxonomy_term', $settings['target_type'], "Target type is correct.");
|
||||
$this->assertSame(1, $field_storage->getCardinality(), "Field cardinality in 1.");
|
||||
|
||||
$this->assertIdentical(['node', 'tags'], $this->getMigration('d6_vocabulary_field')->getIdMap()->lookupDestinationID([4]), "Test IdMap");
|
||||
$this->assertSame(['node', 'field_tags'], $this->getMigration('d6_vocabulary_field')->getIdMap()->lookupDestinationID([4]), "Test IdMap");
|
||||
|
||||
// Tests that a vocabulary named like a D8 base field will be migrated and
|
||||
// prefixed with 'field_' to avoid conflicts.
|
||||
$field_type = FieldStorageConfig::load('node.field_type');
|
||||
$this->assertInstanceOf(FieldStorageConfig::class, $field_type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase {
|
||||
public static $modules = [
|
||||
'comment',
|
||||
'datetime',
|
||||
'forum',
|
||||
'image',
|
||||
'link',
|
||||
'menu_ui',
|
||||
@@ -71,17 +72,19 @@ class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase {
|
||||
* The value the migrated entity field should have.
|
||||
* @param int $expected_term_reference_tid
|
||||
* The term reference id the migrated entity field should have.
|
||||
* @param bool $expected_container_flag
|
||||
* The term should be a container entity.
|
||||
*/
|
||||
protected function assertEntity($id, $expected_label, $expected_vid, $expected_description = '', $expected_format = NULL, $expected_weight = 0, $expected_parents = [], $expected_field_integer_value = NULL, $expected_term_reference_tid = NULL) {
|
||||
protected function assertEntity($id, $expected_label, $expected_vid, $expected_description = '', $expected_format = NULL, $expected_weight = 0, $expected_parents = [], $expected_field_integer_value = NULL, $expected_term_reference_tid = NULL, $expected_container_flag = 0) {
|
||||
/** @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->assertInstanceOf(TermInterface::class, $entity);
|
||||
$this->assertEquals($expected_label, $entity->label());
|
||||
$this->assertEquals($expected_vid, $entity->bundle());
|
||||
$this->assertEquals($expected_description, $entity->getDescription());
|
||||
$this->assertEquals($expected_format, $entity->getFormat());
|
||||
$this->assertEqual($expected_weight, $entity->getWeight());
|
||||
$this->assertIdentical($expected_parents, $this->getParentIDs($id));
|
||||
$this->assertEquals($expected_weight, $entity->getWeight());
|
||||
$this->assertEquals($expected_parents, $this->getParentIDs($id));
|
||||
$this->assertHierarchy($expected_vid, $id, $expected_parents);
|
||||
if (!is_null($expected_field_integer_value)) {
|
||||
$this->assertTrue($entity->hasField('field_integer'));
|
||||
@@ -91,6 +94,9 @@ class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase {
|
||||
$this->assertTrue($entity->hasField('field_integer'));
|
||||
$this->assertEquals($expected_term_reference_tid, $entity->field_term_reference->target_id);
|
||||
}
|
||||
if ($entity->hasField('forum_container')) {
|
||||
$this->assertEquals($expected_container_flag, $entity->forum_container->value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,9 +108,17 @@ class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase {
|
||||
$this->assertEntity(3, 'Term2', 'test_vocabulary', 'The second term.', 'filtered_html');
|
||||
$this->assertEntity(4, 'Term3', 'test_vocabulary', 'The third term.', 'full_html', 0, [3], 6);
|
||||
$this->assertEntity(5, 'Custom Forum', 'forums', 'Where the cool kids are.', NULL, 3);
|
||||
$this->assertEntity(6, 'Games', 'forums', '', NULL, 4);
|
||||
$this->assertEntity(6, 'Games', 'forums', '', NULL, 4, [], NULL, NULL, 1);
|
||||
$this->assertEntity(7, 'Minecraft', 'forums', '', NULL, 1, [6]);
|
||||
$this->assertEntity(8, 'Half Life 3', 'forums', '', NULL, 0, [6]);
|
||||
|
||||
// Verify that we still can create forum containers after the migration.
|
||||
$term = Term::create(['vid' => 'forums', 'name' => 'Forum Container', 'forum_container' => 1]);
|
||||
$term->save();
|
||||
|
||||
// Reset the forums tree data so this new term is included in the tree.
|
||||
unset($this->treeData['forums']);
|
||||
$this->assertEntity(19, 'Forum Container', 'forums', '', NULL, 0, [], NULL, NULL, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,9 +55,9 @@ class MigrateTaxonomyVocabularyTest extends MigrateDrupal7TestBase {
|
||||
*/
|
||||
public function testTaxonomyVocabulary() {
|
||||
$this->assertEntity('tags', 'Tags', 'Use tags to group articles on similar topics into categories.', VocabularyInterface::HIERARCHY_DISABLED, 0);
|
||||
$this->assertEntity('forums', 'Forums', 'Forum navigation vocabulary', VocabularyInterface::HIERARCHY_SINGLE, -10);
|
||||
$this->assertEntity('forums', 'Sujet de discussion', 'Forum navigation vocabulary', VocabularyInterface::HIERARCHY_SINGLE, -10);
|
||||
$this->assertEntity('test_vocabulary', 'Test Vocabulary', 'This is the vocabulary description', VocabularyInterface::HIERARCHY_SINGLE, 0);
|
||||
$this->assertEntity('vocabulary_name_much_longer_than', 'vocabulary name much longer than thirty two characters', 'description of vocabulary name much longer than thirty two characters', VocabularyInterface::HIERARCHY_SINGLE, 0);
|
||||
$this->assertEntity('vocabulary_name_much_longer_than', 'vocabulary name clearly different than machine name and much longer than thirty two characters', 'description of vocabulary name much longer than thirty two characters', VocabularyInterface::HIERARCHY_SINGLE, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
<?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 pending revisions.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class PendingRevisionTest 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 pending revisions.
|
||||
*/
|
||||
public function testTaxonomyIndexWithPendingRevision() {
|
||||
\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 pending 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 pending 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');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,6 +31,7 @@ class TermTest extends MigrateSqlSourceTestBase {
|
||||
'name' => 'name value 1',
|
||||
'description' => 'description value 1',
|
||||
'weight' => 0,
|
||||
'is_container' => FALSE,
|
||||
],
|
||||
[
|
||||
'tid' => 2,
|
||||
@@ -38,6 +39,7 @@ class TermTest extends MigrateSqlSourceTestBase {
|
||||
'name' => 'name value 2',
|
||||
'description' => 'description value 2',
|
||||
'weight' => 0,
|
||||
'is_container' => TRUE,
|
||||
],
|
||||
[
|
||||
'tid' => 3,
|
||||
@@ -45,6 +47,7 @@ class TermTest extends MigrateSqlSourceTestBase {
|
||||
'name' => 'name value 3',
|
||||
'description' => 'description value 3',
|
||||
'weight' => 0,
|
||||
'is_container' => FALSE,
|
||||
],
|
||||
[
|
||||
'tid' => 4,
|
||||
@@ -52,6 +55,7 @@ class TermTest extends MigrateSqlSourceTestBase {
|
||||
'name' => 'name value 4',
|
||||
'description' => 'description value 4',
|
||||
'weight' => 1,
|
||||
'is_container' => FALSE,
|
||||
],
|
||||
[
|
||||
'tid' => 5,
|
||||
@@ -59,6 +63,7 @@ class TermTest extends MigrateSqlSourceTestBase {
|
||||
'name' => 'name value 5',
|
||||
'description' => 'description value 5',
|
||||
'weight' => 1,
|
||||
'is_container' => FALSE,
|
||||
],
|
||||
[
|
||||
'tid' => 6,
|
||||
@@ -66,6 +71,7 @@ class TermTest extends MigrateSqlSourceTestBase {
|
||||
'name' => 'name value 6',
|
||||
'description' => 'description value 6',
|
||||
'weight' => 0,
|
||||
'is_container' => TRUE,
|
||||
],
|
||||
[
|
||||
'tid' => 7,
|
||||
@@ -73,6 +79,7 @@ class TermTest extends MigrateSqlSourceTestBase {
|
||||
'name' => 'name value 7',
|
||||
'description' => 'description value 7',
|
||||
'weight' => 0,
|
||||
'is_container' => TRUE,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['taxonomy_term_hierarchy'] = [
|
||||
@@ -149,6 +156,12 @@ class TermTest extends MigrateSqlSourceTestBase {
|
||||
'delta' => 0,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['variable'] = [
|
||||
[
|
||||
'name' => 'forum_containers',
|
||||
'value' => 'a:3:{i:0;s:1:"5";i:1;s:1:"6";i:2;s:1:"7";}',
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
|
||||
@@ -18,7 +18,7 @@ class TermKernelTest extends KernelTestBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [ 'filter', 'taxonomy', 'text', 'user' ];
|
||||
public static $modules = ['filter', 'taxonomy', 'text', 'user'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
||||
@@ -25,7 +25,9 @@ class TaxonomyLocalTasksTest extends LocalTaskIntegrationTestBase {
|
||||
$tasks = [
|
||||
0 => ['entity.taxonomy_term.canonical', 'entity.taxonomy_term.edit_form'],
|
||||
];
|
||||
if ($subtask) $tasks[] = $subtask;
|
||||
if ($subtask) {
|
||||
$tasks[] = $subtask;
|
||||
}
|
||||
$this->assertLocalTasks($route, $tasks);
|
||||
}
|
||||
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Plugin\migrate\cckfield;
|
||||
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\taxonomy\Plugin\migrate\cckfield\TaxonomyTermReference;
|
||||
use Prophecy\Argument;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\taxonomy\Plugin\migrate\cckfield\TaxonomyTermReference
|
||||
* @group taxonomy
|
||||
* @group legacy
|
||||
*/
|
||||
class TaxonomyTermReferenceCckTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface
|
||||
*/
|
||||
protected $plugin;
|
||||
|
||||
/**
|
||||
* @var \Drupal\migrate\Plugin\MigrationInterface
|
||||
*/
|
||||
protected $migration;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->plugin = new TaxonomyTermReference([], 'taxonomy', []);
|
||||
|
||||
$migration = $this->prophesize(MigrationInterface::class);
|
||||
|
||||
// The plugin's processCckFieldValues() method will call
|
||||
// setProcessOfProperty() and return nothing. So, in order to examine the
|
||||
// process pipeline created by the plugin, we need to ensure that
|
||||
// getProcess() always returns the last input to setProcessOfProperty().
|
||||
$migration->setProcessOfProperty(Argument::type('string'), Argument::type('array'))
|
||||
->will(function ($arguments) use ($migration) {
|
||||
$migration->getProcess()->willReturn($arguments[1]);
|
||||
});
|
||||
|
||||
$this->migration = $migration->reveal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::processCckFieldValues
|
||||
*/
|
||||
public function testProcessCckFieldValues() {
|
||||
$this->plugin->processFieldValues($this->migration, 'somefieldname', []);
|
||||
|
||||
$expected = [
|
||||
'plugin' => 'iterator',
|
||||
'source' => 'somefieldname',
|
||||
'process' => [
|
||||
'target_id' => 'tid',
|
||||
],
|
||||
];
|
||||
$this->assertSame($expected, $this->migration->getProcess());
|
||||
}
|
||||
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Plugin\migrate\field;
|
||||
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\taxonomy\Plugin\migrate\field\TaxonomyTermReference;
|
||||
use Prophecy\Argument;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\taxonomy\Plugin\migrate\field\TaxonomyTermReference
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TaxonomyTermReferenceFieldTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateFieldInterface
|
||||
*/
|
||||
protected $plugin;
|
||||
|
||||
/**
|
||||
* @var \Drupal\migrate\Plugin\MigrationInterface
|
||||
*/
|
||||
protected $migration;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->plugin = new TaxonomyTermReference([], 'taxonomy', []);
|
||||
|
||||
$migration = $this->prophesize(MigrationInterface::class);
|
||||
|
||||
// The plugin's processFieldValues() method will call
|
||||
// setProcessOfProperty() and return nothing. So, in order to examine the
|
||||
// process pipeline created by the plugin, we need to ensure that
|
||||
// getProcess() always returns the last input to setProcessOfProperty().
|
||||
$migration->setProcessOfProperty(Argument::type('string'), Argument::type('array'))
|
||||
->will(function ($arguments) use ($migration) {
|
||||
$migration->getProcess()->willReturn($arguments[1]);
|
||||
});
|
||||
|
||||
$this->migration = $migration->reveal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::processFieldValues
|
||||
*/
|
||||
public function testProcessFieldValues() {
|
||||
$this->plugin->processFieldValues($this->migration, 'somefieldname', []);
|
||||
|
||||
$expected = [
|
||||
'plugin' => 'iterator',
|
||||
'source' => 'somefieldname',
|
||||
'process' => [
|
||||
'target_id' => 'tid',
|
||||
],
|
||||
];
|
||||
$this->assertSame($expected, $this->migration->getProcess());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user