upgrades core to 8.4.2

This commit is contained in:
Bachir Soussi Chiadmi
2017-11-14 16:09:54 +01:00
parent bd60eff9b3
commit c2b4e25be4
3504 changed files with 140306 additions and 38684 deletions
@@ -15,6 +15,12 @@ process:
field: vid
length: 32
migrated: true
-
# This plugin checks if the vocabulary being migrated is the one used by
# Forum. If so, we use the machine name that Forum expects. Otherwise, we
# leave it unchanged.
plugin: forum_vocabulary
machine_name: forums
label: name
name: name
description: description
@@ -11,6 +11,7 @@ source:
label: hidden
type: entity_reference_label
weight: 20
field_prefix: field_
process:
entity_type: 'constants/entity_type'
view_mode: 'constants/view_mode'
@@ -23,10 +24,32 @@ process:
-
plugin: skip_on_empty
method: row
# This value is only used in the 'field_name' process pipeline below.
raw_field_name:
-
plugin: migration_lookup
migration: d6_taxonomy_vocabulary
source: vid
-
plugin: skip_on_empty
method: row
field_name:
plugin: migration_lookup
migration: d6_taxonomy_vocabulary
source: vid
# Prepend field_ to avoid conflicts with base fields, and make sure the
# result is no longer than 32 characters.
-
plugin: concat
source:
- constants/field_prefix
- '@raw_field_name'
-
plugin: substr
length: 32
-
# This plugin checks if the vocabulary being migrated is the one used by
# Forum. If so, we use the machine name that Forum expects. Otherwise, we
# leave it unchanged.
plugin: forum_vocabulary
machine_name: taxonomy_forums
destination:
plugin: component_entity_display
migration_dependencies:
@@ -9,6 +9,7 @@ source:
form_mode: default
options:
weight: 20
field_prefix: field_
process:
entity_type: 'constants/entity_type'
form_mode: 'constants/form_mode'
@@ -27,10 +28,32 @@ process:
-
plugin: skip_on_empty
method: row
# This value is only used in the 'field_name' process pipeline below.
raw_field_name:
-
plugin: migration_lookup
migration: d6_taxonomy_vocabulary
source: vid
-
plugin: skip_on_empty
method: row
field_name:
plugin: migration_lookup
migration: d6_taxonomy_vocabulary
source: vid
# Prepend field_ to avoid conflicts with base fields, and make sure the
# result is no longer than 32 characters.
-
plugin: concat
source:
- constants/field_prefix
- '@raw_field_name'
-
plugin: substr
length: 32
-
# This plugin checks if the vocabulary being migrated is the one used by
# Forum. If so, we use the machine name that Forum expects. Otherwise, we
# leave it unchanged.
plugin: forum_vocabulary
machine_name: taxonomy_forums
destination:
plugin: component_entity_form_display
migration_dependencies:
@@ -8,10 +8,12 @@ source:
entity_type: node
type: entity_reference
target_entity_type: taxonomy_term
field_prefix: field_
process:
entity_type: 'constants/entity_type'
type: 'constants/type'
field_name:
# This value is only used in the 'field_name' process pipeline below.
raw_field_name:
-
plugin: migration_lookup
migration: d6_taxonomy_vocabulary
@@ -19,6 +21,23 @@ process:
-
plugin: skip_on_empty
method: row
field_name:
# Prepend field_ to avoid conflicts with base fields, and make sure the
# result is no longer than 32 characters.
-
plugin: concat
source:
- constants/field_prefix
- '@raw_field_name'
-
plugin: substr
length: 32
-
# This plugin checks if the vocabulary being migrated is the one used by
# Forum. If so, we use the machine name that Forum expects. Otherwise, we
# leave it unchanged.
plugin: forum_vocabulary
machine_name: taxonomy_forums
'settings/target_type': 'constants/target_entity_type'
cardinality: cardinality
destination:
@@ -8,6 +8,7 @@ source:
entity_type: node
auto_create: true
selection_handler: 'default:taxonomy_term'
field_prefix: field_
process:
entity_type: 'constants/entity_type'
bundle:
@@ -18,7 +19,8 @@ process:
-
plugin: skip_on_empty
method: row
field_name:
# This value is only used in the 'field_name' process pipeline below.
raw_field_name:
-
plugin: migration_lookup
migration: d6_taxonomy_vocabulary
@@ -26,6 +28,23 @@ process:
-
plugin: skip_on_empty
method: row
field_name:
# Prepend field_ to avoid conflicts with base fields, and make sure the
# result is no longer than 32 characters.
-
plugin: concat
source:
- constants/field_prefix
- '@raw_field_name'
-
plugin: substr
length: 32
-
# This plugin checks if the vocabulary being migrated is the one used by
# Forum. If so, we use the machine name that Forum expects. Otherwise, we
# leave it unchanged.
plugin: forum_vocabulary
machine_name: taxonomy_forums
label: name
'settings/handler': 'constants/selection_handler'
'settings/handler_settings/target_bundles/0': '@field_name'
@@ -30,6 +30,7 @@ process:
plugin: default_value
default_value: 0
source: '@parent_id'
forum_container: is_container
changed: timestamp
destination:
plugin: entity:taxonomy_term
@@ -6,15 +6,19 @@ source:
plugin: d7_taxonomy_vocabulary
process:
vid:
-
plugin: machine_name
source: name
-
plugin: make_unique_entity_field
source: machine_name
entity_type: taxonomy_vocabulary
field: vid
length: 32
migrated: true
-
# This plugin checks if the vocabulary being migrated is the one used by
# Forum. If so, we use the machine name that Forum expects. Otherwise, we
# leave it unchanged.
plugin: forum_vocabulary
machine_name: forums
label: name
name: name
description: description
@@ -8,6 +8,7 @@ source:
variables:
- taxonomy_override_selector
- taxonomy_terms_per_page_admin
source_module: taxonomy
process:
override_selector: taxonomy_override_selector
terms_per_page_admin: taxonomy_terms_per_page_admin
+3 -1
View File
@@ -46,6 +46,7 @@ use Drupal\taxonomy\TermInterface;
* "canonical" = "/taxonomy/term/{taxonomy_term}",
* "delete-form" = "/taxonomy/term/{taxonomy_term}/delete",
* "edit-form" = "/taxonomy/term/{taxonomy_term}/edit",
* "create" = "/taxonomy/term",
* },
* permission_granularity = "bundle"
* )
@@ -229,7 +230,8 @@ class Term extends ContentEntityBase implements TermInterface {
* {@inheritdoc}
*/
public function getVocabularyId() {
return $this->get('vid')->target_id;
@trigger_error('The ' . __METHOD__ . ' method is deprecated since version 8.4.0 and will be removed before 9.0.0. Use ' . __CLASS__ . '::bundle() instead to get the vocabulary ID.', E_USER_DEPRECATED);
return $this->bundle();
}
/**
@@ -227,7 +227,7 @@ class OverviewTerms extends FormBase {
];
}
$form['terms'][$key]['term'] = [
'#prefix' => !empty($indentation) ? drupal_render($indentation) : '',
'#prefix' => !empty($indentation) ? \Drupal::service('renderer')->render($indentation) : '',
'#type' => 'link',
'#title' => $term->getName(),
'#url' => $term->urlInfo(),
@@ -3,7 +3,6 @@
namespace Drupal\taxonomy\Plugin\EntityReferenceSelection;
use Drupal\Component\Utility\Html;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
use Drupal\Core\Form\FormStateInterface;
use Drupal\taxonomy\Entity\Vocabulary;
@@ -24,8 +23,13 @@ class TermSelection extends DefaultSelection {
/**
* {@inheritdoc}
*/
public function entityQueryAlter(SelectInterface $query) {
// @todo: How to set access, as vocabulary is now config?
public function defaultConfiguration() {
return [
'sort' => [
'field' => 'name',
'direction' => 'asc',
]
] + parent::defaultConfiguration();
}
/**
@@ -49,15 +53,13 @@ class TermSelection extends DefaultSelection {
*/
public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
if ($match || $limit) {
$this->configuration['handler_settings']['sort'] = ['field' => 'name', 'direction' => 'asc'];
return parent::getReferenceableEntities($match, $match_operator, $limit);
}
$options = [];
$bundles = $this->entityManager->getBundleInfo('taxonomy_term');
$handler_settings = $this->configuration['handler_settings'];
$bundle_names = !empty($handler_settings['target_bundles']) ? $handler_settings['target_bundles'] : array_keys($bundles);
$bundle_names = $this->getConfiguration()['target_bundles'] ?: array_keys($bundles);
foreach ($bundle_names as $bundle) {
if ($vocabulary = Vocabulary::load($bundle)) {
@@ -2,6 +2,8 @@
namespace Drupal\taxonomy\Plugin\migrate\cckfield;
@trigger_error('TaxonomyTermReference is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\taxonomy\Plugin\migrate\field\TaxonomyTermReference instead.', E_USER_DEPRECATED);
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
@@ -13,16 +15,14 @@ use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
* },
* core = {6,7}
* )
*
* @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use
* \Drupal\taxonomy\Plugin\migrate\field\TaxonomyTermReference instead.
*
* @see https://www.drupal.org/node/2751897
*/
class TaxonomyTermReference extends CckFieldPluginBase {
/**
* {@inheritdoc}
*/
public function getFieldFormatterMap() {
return [];
}
/**
* {@inheritdoc}
*/
@@ -0,0 +1,33 @@
<?php
namespace Drupal\taxonomy\Plugin\migrate\field;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
/**
* @MigrateField(
* id = "taxonomy_term_reference",
* type_map = {
* "taxonomy_term_reference" = "entity_reference"
* },
* core = {6,7}
* )
*/
class TaxonomyTermReference extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
$process = [
'plugin' => 'iterator',
'source' => $field_name,
'process' => [
'target_id' => 'tid',
],
];
$migration->setProcessOfProperty($field_name, $process);
}
}
@@ -0,0 +1,46 @@
<?php
namespace Drupal\taxonomy\Plugin\migrate\process;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
/**
* Checks if the vocabulary being migrated is the one used for forums.
*
* Drupal 8 Forum is expecting specific machine names for its field and
* vocabulary names. This process plugin forces a given machine name to the
* field or vocabulary that is being migrated.
*
* The 'forum_vocabulary' source property is evaluated in the
* d6_taxonomy_vocabulary or d7_taxonomy_vocabulary source plugins and is set to
* true if the vocabulary vid being migrated is the same as the one in the
* 'forum_nav_vocabulary' variable on the source site.
*
* Example:
*
* @code
* process:
* field_name:
* plugin: forum_vocabulary
* machine_name: taxonomy_forums
* @endcode
*
* @MigrateProcessPlugin(
* id = "forum_vocabulary"
* )
*/
class ForumVocabulary extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if ($row->getSourceProperty('forum_vocabulary') && !empty($this->configuration['machine_name'])) {
$value = $this->configuration['machine_name'];
}
return $value;
}
}
@@ -12,7 +12,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
*
* @MigrateSource(
* id = "taxonomy_term",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*
* @deprecated in Drupal 8.3.0, intended to be removed in Drupal 9.0.0.
@@ -12,7 +12,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
*
* @MigrateSource(
* id = "d6_taxonomy_term",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*/
class Term extends DrupalSqlBase {
@@ -10,7 +10,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
*
* @MigrateSource(
* id = "d6_term_node",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*/
class TermNode extends DrupalSqlBase {
@@ -6,7 +6,8 @@ namespace Drupal\taxonomy\Plugin\migrate\source\d6;
* Source returning tids from the term_node table for the non-current revision.
*
* @MigrateSource(
* id = "d6_term_node_revision"
* id = "d6_term_node_revision",
* source_module = "taxonomy"
* )
*/
class TermNodeRevision extends TermNode {
@@ -11,7 +11,7 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
*
* @MigrateSource(
* id = "d6_taxonomy_vocabulary",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*/
class Vocabulary extends DrupalSqlBase {
@@ -69,6 +69,14 @@ class Vocabulary extends DrupalSqlBase {
->fetchCol();
$row->setSourceProperty('node_types', $node_types);
$row->setSourceProperty('cardinality', ($row->getSourceProperty('tags') == 1 || $row->getSourceProperty('multiple') == 1) ? FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED : 1);
// If the vocabulary being migrated is the one defined in the
// 'forum_nav_vocabulary' variable, set the 'forum_vocabulary' source
// property to true so we know this is the vocabulary used by Forum.
if ($this->variableGet('forum_nav_vocabulary', 0) == $row->getSourceProperty('vid')) {
$row->setSourceProperty('forum_vocabulary', TRUE);
}
return parent::prepareRow($row);
}
@@ -7,7 +7,7 @@ namespace Drupal\taxonomy\Plugin\migrate\source\d6;
*
* @MigrateSource(
* id = "d6_taxonomy_vocabulary_per_type",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*/
class VocabularyPerType extends Vocabulary {
@@ -9,7 +9,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
*
* @MigrateSource(
* id = "d6_taxonomy_vocabulary_translation",
* source_provider = "taxonomy"
* source_module = "i18ntaxonomy"
* )
*/
class VocabularyTranslation extends DrupalSqlBase {
@@ -12,7 +12,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
*
* @MigrateSource(
* id = "d7_taxonomy_term",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*/
class Term extends FieldableEntity {
@@ -70,6 +70,11 @@ class Term extends FieldableEntity {
->fetchCol();
$row->setSourceProperty('parent', $parents);
// Determine if this is a forum container.
$forum_container_tids = $this->variableGet('forum_containers', []);
$current_tid = $row->getSourceProperty('tid');
$row->setSourceProperty('is_container', in_array($current_tid, $forum_container_tids));
return parent::prepareRow($row);
}
@@ -2,6 +2,7 @@
namespace Drupal\taxonomy\Plugin\migrate\source\d7;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
@@ -9,7 +10,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
*
* @MigrateSource(
* id = "d7_taxonomy_vocabulary",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*/
class Vocabulary extends DrupalSqlBase {
@@ -46,6 +47,20 @@ class Vocabulary extends DrupalSqlBase {
];
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
// If the vocabulary being migrated is the one defined in the
// 'forum_nav_vocabulary' variable, set the 'forum_vocabulary' source
// property to true so we know this is the vocabulary used by Forum.
if ($this->variableGet('forum_nav_vocabulary', 0) == $row->getSourceProperty('vid')) {
$row->setSourceProperty('forum_vocabulary', TRUE);
}
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
@@ -2,6 +2,7 @@
namespace Drupal\taxonomy\Plugin\views\argument;
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
@@ -106,7 +107,7 @@ class IndexTidDepth extends ArgumentPluginBase implements ContainerFactoryPlugin
// Now build the subqueries.
$subquery = db_select('taxonomy_index', 'tn');
$subquery->addField('tn', 'nid');
$where = db_or()->condition('tn.tid', $tids, $operator);
$where = (new Condition('OR'))->condition('tn.tid', $tids, $operator);
$last = "tn";
if ($this->options['depth'] > 0) {
@@ -17,9 +17,9 @@ use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
*/
class IndexTidDepthModifier extends ArgumentPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) { }
public function buildOptionsForm(&$form, FormStateInterface $form_state) {}
public function query($group_by = FALSE) { }
public function query($group_by = FALSE) {}
public function preQuery() {
// We don't know our argument yet, but it's based upon our position:
@@ -116,7 +116,7 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
];
$form['node'] = [
'#type' => 'checkbox',
'#title' => $this->t('Load default filter from node page, that\'s good for related taxonomy blocks'),
'#title' => $this->t("Load default filter from node page, that's good for related taxonomy blocks"),
'#default_value' => $this->options['node'],
];
@@ -194,7 +194,7 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
$taxonomy_terms = $node->{$field->getName()}->referencedEntities();
/** @var \Drupal\taxonomy\TermInterface $taxonomy_term */
foreach ($taxonomy_terms as $taxonomy_term) {
$taxonomy[$taxonomy_term->id()] = $taxonomy_term->getVocabularyId();
$taxonomy[$taxonomy_term->id()] = $taxonomy_term->bundle();
}
}
}
@@ -145,8 +145,8 @@ class TaxonomyIndexTid extends PrerenderList {
foreach ($data as $tid => $term) {
$this->items[$node_nid][$tid]['name'] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
$this->items[$node_nid][$tid]['tid'] = $tid;
$this->items[$node_nid][$tid]['vocabulary_vid'] = $term->getVocabularyId();
$this->items[$node_nid][$tid]['vocabulary'] = $vocabularies[$term->getVocabularyId()]->label();
$this->items[$node_nid][$tid]['vocabulary_vid'] = $term->bundle();
$this->items[$node_nid][$tid]['vocabulary'] = $vocabularies[$term->bundle()]->label();
if (!empty($this->options['link_to_taxonomy'])) {
$this->items[$node_nid][$tid]['make_link'] = TRUE;
@@ -82,7 +82,9 @@ class TaxonomyIndexTid extends ManyToOne {
}
}
public function hasExtraOptions() { return TRUE; }
public function hasExtraOptions() {
return TRUE;
}
/**
* {@inheritdoc}
@@ -2,6 +2,7 @@
namespace Drupal\taxonomy\Plugin\views\filter;
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Form\FormStateInterface;
/**
@@ -54,7 +55,7 @@ class TaxonomyIndexTidDepth extends TaxonomyIndexTid {
$operator = '=';
}
else {
$operator = 'IN';# " IN (" . implode(', ', array_fill(0, sizeof($this->value), '%d')) . ")";
$operator = 'IN';
}
// The normal use of ensureMyTable() here breaks Views.
@@ -72,7 +73,7 @@ class TaxonomyIndexTidDepth extends TaxonomyIndexTid {
// Now build the subqueries.
$subquery = db_select('taxonomy_index', 'tn');
$subquery->addField('tn', 'nid');
$where = db_or()->condition('tn.tid', $this->value, $operator);
$where = (new Condition('OR'))->condition('tn.tid', $this->value, $operator);
$last = "tn";
if ($this->options['depth'] > 0) {
+1 -1
View File
@@ -85,7 +85,7 @@ class TermForm extends ContentEntityForm {
'#value' => $term->id(),
];
return parent::form($form, $form_state, $term);
return parent::form($form, $form_state);
}
/**
@@ -87,6 +87,9 @@ interface TermInterface extends ContentEntityInterface, EntityChangedInterface {
*
* @return string
* The id of the vocabulary.
*
* @deprecated Scheduled for removal before Drupal 9.0.0. Use
* TermInterface::bundle() instead.
*/
public function getVocabularyId();
@@ -52,7 +52,7 @@ interface TermStorageInterface extends ContentEntityStorageInterface {
* Finds all children of a term ID.
*
* @param int $tid
* Term ID to retrieve parents for.
* Term ID to retrieve children for.
* @param string $vid
* An optional vocabulary ID to restrict the child search.
*
@@ -65,7 +65,7 @@ class TaxonomyTermIndentationTest extends TaxonomyTestBase {
'terms[tid:' . $term2->id() . ':0][weight]' => 1,
];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid' ) . '/overview', $edit, t('Save'));
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid') . '/overview', $edit, t('Save'));
// All terms back at the root level, no indentation should be present.
$this->assertNoPattern('|<div class="js-indentation indentation">&nbsp;</div>|');
@@ -78,10 +78,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 = [
+52
View File
@@ -0,0 +1,52 @@
/**
* @file
* Taxonomy behaviors.
*/
(function ($, Drupal) {
/**
* Move a block in the blocks table from one region to another.
*
* This behavior is dependent on the tableDrag behavior, since it uses the
* objects initialized in that behavior to update the row.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches the drag behavior to a applicable table element.
*/
Drupal.behaviors.termDrag = {
attach(context, settings) {
const backStep = settings.taxonomy.backStep;
const forwardStep = settings.taxonomy.forwardStep;
// Get the blocks tableDrag object.
const tableDrag = Drupal.tableDrag.taxonomy;
const $table = $('#taxonomy');
const rows = $table.find('tr').length;
// When a row is swapped, keep previous and next page classes set.
tableDrag.row.prototype.onSwap = function (swappedRow) {
$table.find('tr.taxonomy-term-preview').removeClass('taxonomy-term-preview');
$table.find('tr.taxonomy-term-divider-top').removeClass('taxonomy-term-divider-top');
$table.find('tr.taxonomy-term-divider-bottom').removeClass('taxonomy-term-divider-bottom');
const tableBody = $table[0].tBodies[0];
if (backStep) {
for (let n = 0; n < backStep; n++) {
$(tableBody.rows[n]).addClass('taxonomy-term-preview');
}
$(tableBody.rows[backStep - 1]).addClass('taxonomy-term-divider-top');
$(tableBody.rows[backStep]).addClass('taxonomy-term-divider-bottom');
}
if (forwardStep) {
for (let k = rows - forwardStep - 1; k < rows - 1; k++) {
$(tableBody.rows[k]).addClass('taxonomy-term-preview');
}
$(tableBody.rows[rows - forwardStep - 2]).addClass('taxonomy-term-divider-top');
$(tableBody.rows[rows - forwardStep - 1]).addClass('taxonomy-term-divider-bottom');
}
};
},
};
}(jQuery, Drupal));
+3 -3
View File
@@ -9,8 +9,8 @@ dependencies:
- text
configure: entity.taxonomy_vocabulary.collection
# 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
+8 -22
View File
@@ -1,33 +1,20 @@
/**
* @file
* Taxonomy behaviors.
*/
* DO NOT EDIT THIS FILE.
* See the following change record for more information,
* https://www.drupal.org/node/2815083
* @preserve
**/
(function ($, Drupal) {
'use strict';
/**
* Move a block in the blocks table from one region to another.
*
* This behavior is dependent on the tableDrag behavior, since it uses the
* objects initialized in that behavior to update the row.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches the drag behavior to a applicable table element.
*/
Drupal.behaviors.termDrag = {
attach: function (context, settings) {
attach: function attach(context, settings) {
var backStep = settings.taxonomy.backStep;
var forwardStep = settings.taxonomy.forwardStep;
// Get the blocks tableDrag object.
var tableDrag = Drupal.tableDrag.taxonomy;
var $table = $('#taxonomy');
var rows = $table.find('tr').length;
// When a row is swapped, keep previous and next page classes set.
tableDrag.row.prototype.onSwap = function (swappedRow) {
$table.find('tr.taxonomy-term-preview').removeClass('taxonomy-term-preview');
$table.find('tr.taxonomy-term-divider-top').removeClass('taxonomy-term-divider-top');
@@ -52,5 +39,4 @@
};
}
};
})(jQuery, Drupal);
})(jQuery, Drupal);
+7 -1
View File
@@ -22,6 +22,8 @@ use Drupal\taxonomy\VocabularyInterface;
*
* @deprecated in Drupal 8.2.x and will be removed before 9.0.0. Use
* \Drupal\taxonomy\VocabularyInterface::HIERARCHY_DISABLED instead.
*
* @see https://www.drupal.org/node/2807795
*/
const TAXONOMY_HIERARCHY_DISABLED = 0;
@@ -30,6 +32,8 @@ const TAXONOMY_HIERARCHY_DISABLED = 0;
*
* @deprecated in Drupal 8.2.x and will be removed before 9.0.0. Use
* \Drupal\taxonomy\VocabularyInterface::HIERARCHY_SINGLE instead.
*
* @see https://www.drupal.org/node/2807795
*/
const TAXONOMY_HIERARCHY_SINGLE = 1;
@@ -38,6 +42,8 @@ const TAXONOMY_HIERARCHY_SINGLE = 1;
*
* @deprecated in Drupal 8.2.x and will be removed before 9.0.0. Use
* \Drupal\taxonomy\VocabularyInterface::HIERARCHY_MULTIPLE instead.
*
* @see https://www.drupal.org/node/2807795
*/
const TAXONOMY_HIERARCHY_MULTIPLE = 2;
@@ -61,7 +67,7 @@ function taxonomy_help($route_name, RouteMatchInterface $route_match) {
$output .= '<dt>' . t('Classifying entity content') . '</dt>';
$output .= '<dd>' . t('A user with the <em>Administer fields</em> permission for a certain entity type may add <em>Taxonomy term</em> reference fields to the entity type, which will allow entities to be classified using taxonomy terms. See the <a href=":entity_reference">Entity Reference help</a> for more information about reference fields. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them.', [':field_ui' => $field_ui_url, ':field' => \Drupal::url('help.page', ['name' => 'field']), ':entity_reference' => \Drupal::url('help.page', ['name' => 'entity_reference'])]) . '</dd>';
$output .= '<dt>' . t('Adding new terms during content creation') . '</dt>';
$output .= '<dd>' . t('Allowing users to add new terms gradually builds a vocabulary as content is added and edited. Users can add new terms if either of the two <em>Autocomplete</em> widgets is chosen for the Taxonomy term reference field in the <em>Manage form display</em> page for the field. You will also need to enable the <em>Create referenced entities if they don\'t already exist</em> option, and restrict the field to one vocabulary.') . '</dd>';
$output .= '<dd>' . t("Allowing users to add new terms gradually builds a vocabulary as content is added and edited. Users can add new terms if either of the two <em>Autocomplete</em> widgets is chosen for the Taxonomy term reference field in the <em>Manage form display</em> page for the field. You will also need to enable the <em>Create referenced entities if they don't already exist</em> option, and restrict the field to one vocabulary.") . '</dd>';
$output .= '<dt>' . t('Configuring displays and form displays') . '</dt>';
$output .= '<dd>' . t('See the <a href=":entity_reference">Entity Reference help</a> page for the field widgets and formatters that can be configured for any reference field on the <em>Manage display</em> and <em>Manage form display</em> pages. Taxonomy additionally provides an <em>RSS category</em> formatter that displays nothing when the entity item is displayed as HTML, but displays an RSS category instead of a list when the entity item is displayed in an RSS feed.', [':entity_reference' => \Drupal::url('help.page', ['name' => 'entity_reference'])]) . '</li>';
$output .= '</ul>';
@@ -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
@@ -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
@@ -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
@@ -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);
}
/**
@@ -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));
}
/**
@@ -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));
}
/**
@@ -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);
}
@@ -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());
}
}
@@ -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());
}
}