Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -1,8 +1,9 @@
id: taxonomy_term.full
label: 'Taxonomy term page'
langcode: en
status: true
cache: true
targetEntityType: taxonomy_term
dependencies:
module:
- taxonomy
id: taxonomy_term.full
label: 'Taxonomy term page'
targetEntityType: taxonomy_term
cache: true

View file

@ -105,7 +105,7 @@ display:
title_enable: false
title: All
title_enable: true
title: '%1'
title: '{{ arguments.tid }}'
default_argument_type: fixed
default_argument_options:
argument: ''
@ -231,7 +231,7 @@ display:
admin_label: ''
empty: true
tokenize: true
target: '!1'
target: '{{ raw_arguments.tid }}'
view_mode: full
bypass_access: false
plugin_id: entity
@ -246,8 +246,11 @@ display:
contexts:
- 'languages:language_interface'
- url
- url.query_args
- 'user.node_grants:view'
cacheable: false
- user.permissions
max-age: -1
tags: { }
feed_1:
id: feed_1
display_title: Feed
@ -283,7 +286,9 @@ display:
- 'languages:language_interface'
- url
- 'user.node_grants:view'
cacheable: false
- user.permissions
max-age: -1
tags: { }
page_1:
id: page_1
display_title: Page
@ -299,5 +304,8 @@ display:
contexts:
- 'languages:language_interface'
- url
- url.query_args
- 'user.node_grants:view'
cacheable: false
- user.permissions
max-age: -1
tags: { }

View file

@ -1,9 +1,9 @@
id: d6_taxonomy_term
label: Drupal 6 taxonomy terms
label: Taxonomy terms
migration_tags:
- Drupal 6
source:
plugin: d6_taxonomy_term
plugin: taxonomy_term
process:
tid: tid
vid:
@ -14,13 +14,9 @@ process:
description: description
weight: weight
parent:
-
plugin: skip_on_empty
method: process
source: parent
-
plugin: migration
migration: d6_taxonomy_term
plugin: migration
migration: d6_taxonomy_term
source: parent
changed: timestamp
destination:
plugin: entity:taxonomy_term

View file

@ -1,5 +1,5 @@
id: d6_taxonomy_vocabulary
label: Drupal 6 taxonomy vocabularies
label: Taxonomy vocabularies
migration_tags:
- Drupal 6
source:

View file

@ -1,20 +1,15 @@
id: d6_term_node
label: Drupal 6 term/node relationships
label: Term/node relationships
migration_tags:
- Drupal 6
builder:
plugin: d6_term_node
load:
plugin: d6_term_node
source:
plugin: d6_term_node
process:
nid: nid
type: type
# The actual field name is dynamic and will be added by the load plugin.
# The actual field name is dynamic and will be added by the builder.
destination:
plugin: entity:node
migration_dependencies:

View file

@ -1,21 +1,15 @@
id: d6_term_node_revision
label: Drupal 6 term/node relationship revisions
label: Term/node relationship revisions
migration_tags:
- Drupal 6
builder:
plugin: d6_term_node
load:
plugin: d6_term_node
bundle_migration: d6_vocabulary_field
source:
plugin: d6_term_node_revision
process:
vid: vid
type: type
# The actual field name is dynamic and will be added by the load plugin.
# The actual field name is dynamic and will be added by the builder.
destination:
plugin: entity_revision:node
migration_dependencies:

View file

@ -1,5 +1,5 @@
id: d6_vocabulary_entity_display
label: Drupal 6 vocabulary display configuration
label: Vocabulary display configuration
migration_tags:
- Drupal 6
source:
@ -11,7 +11,6 @@ source:
label: hidden
type: entity_reference_label
weight: 20
process:
entity_type: 'constants/entity_type'
view_mode: 'constants/view_mode'

View file

@ -1,5 +1,5 @@
id: d6_vocabulary_entity_form_display
label: Drupal 6 vocabulary form display configuration
label: Vocabulary form display configuration
migration_tags:
- Drupal 6
source:

View file

@ -1,5 +1,5 @@
id: d6_vocabulary_field
label: Drupal 6 vocabulary field configuration
label: Vocabulary field configuration
migration_tags:
- Drupal 6
source:

View file

@ -1,5 +1,5 @@
id: d6_vocabulary_field_instance
label: Drupal 6 vocabulary field instance configuration
label: Vocabulary field instance configuration
migration_tags:
- Drupal 6
source:
@ -20,7 +20,7 @@ process:
plugin: skip_on_empty
method: row
'settings/handler': 'constants/selection_handler'
'settings/handler_settings/target_bundles/0': @field_name
'settings/handler_settings/target_bundles/0': '@field_name'
'settings/handler_settings/auto_create': 'constants/auto_create'
destination:
plugin: entity:field_config

View file

@ -0,0 +1,25 @@
id: d7_taxonomy_term
label: Taxonomy terms
migration_tags:
- Drupal 7
source:
plugin: taxonomy_term
process:
tid: tid
vid:
plugin: migration
migration: d7_taxonomy_vocabulary
source: vid
name: name
description: description
weight: weight
parent:
plugin: migration
migration: d7_taxonomy_term
source: parent
changed: timestamp
destination:
plugin: entity:taxonomy_term
migration_dependencies:
required:
- d7_taxonomy_vocabulary

View file

@ -0,0 +1,15 @@
id: d7_taxonomy_vocabulary
label: Taxonomy vocabularies
migration_tags:
- Drupal 7
source:
plugin: d7_taxonomy_vocabulary
process:
vid: machine_name
label: name
name: name
description: description
hierarchy: hierarchy
weight: weight
destination:
plugin: entity:taxonomy_vocabulary

View file

@ -1,7 +1,8 @@
id: d6_taxonomy_settings
label: Drupal 6 taxonomy configuration
id: taxonomy_settings
label: Taxonomy configuration
migration_tags:
- Drupal 6
- Drupal 7
source:
plugin: variable
variables:

View file

@ -187,13 +187,6 @@ class Term extends ContentEntityBase implements TermInterface {
return $fields;
}
/**
* {@inheritdoc}
*/
public function getChangedTime() {
return $this->get('changed')->value;
}
/**
* {@inheritdoc}
*/

View file

@ -122,48 +122,6 @@ class Vocabulary extends ConfigEntityBundleBase implements VocabularyInterface {
return $this->description;
}
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
parent::postSave($storage, $update);
if ($update && $this->getOriginalId() != $this->id() && !$this->isSyncing()) {
// Reflect machine name changes in the definitions of existing 'taxonomy'
// fields.
$field_ids = array();
$field_map = \Drupal::entityManager()->getFieldMapByFieldType('entity_reference');
foreach ($field_map as $entity_type => $field_storages) {
foreach ($field_storages as $field_storage => $info) {
$field_ids[] = $entity_type . '.' . $field_storage;
}
}
$field_storages = \Drupal::entityManager()->getStorage('field_storage_config')->loadMultiple($field_ids);
$taxonomy_fields = array_filter($field_storages, function ($field_storage) {
return $field_storage->getType() == 'entity_reference' && $field_storage->getSetting('target_type') == 'taxonomy_term';
});
foreach ($taxonomy_fields as $field_storage) {
$update_storage = FALSE;
$allowed_values = $field_storage->getSetting('allowed_values');
foreach ($allowed_values as &$value) {
if ($value['vocabulary'] == $this->getOriginalId()) {
$value['vocabulary'] = $this->id();
$update_storage = TRUE;
}
}
$field_storage->setSetting('allowed_values', $allowed_values);
if ($update_storage) {
$field_storage->save();
}
}
}
$storage->resetCache($update ? array($this->getOriginalId()) : array());
}
/**
* {@inheritdoc}
*/

View file

@ -207,7 +207,7 @@ class OverviewTerms extends FormBase {
$form['terms'] = array(
'#type' => 'table',
'#header' => array($this->t('Name'), $this->t('Weight'), $this->t('Operations')),
'#empty' => $this->t('No terms available. <a href="@link">Add term</a>.', array('@link' => $this->url('entity.taxonomy_term.add_form', array('taxonomy_vocabulary' => $taxonomy_vocabulary->id())))),
'#empty' => $this->t('No terms available. <a href=":link">Add term</a>.', array(':link' => $this->url('entity.taxonomy_term.add_form', array('taxonomy_vocabulary' => $taxonomy_vocabulary->id())))),
'#attributes' => array(
'id' => 'taxonomy',
),

View file

@ -7,9 +7,9 @@
namespace Drupal\taxonomy\Plugin\EntityReferenceSelection;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Html;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\SelectionBase;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
use Drupal\Core\Form\FormStateInterface;
use Drupal\taxonomy\Entity\Vocabulary;
@ -24,7 +24,7 @@ use Drupal\taxonomy\Entity\Vocabulary;
* weight = 1
* )
*/
class TermSelection extends SelectionBase {
class TermSelection extends DefaultSelection {
/**
* {@inheritdoc}
@ -73,7 +73,7 @@ class TermSelection extends SelectionBase {
if ($vocabulary = Vocabulary::load($bundle)) {
if ($terms = $this->entityManager->getStorage('taxonomy_term')->loadTree($vocabulary->id(), 0, NULL, TRUE)) {
foreach ($terms as $term) {
$options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . SafeMarkup::checkPlain($term->getName());
$options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . Html::escape($term->getName());
}
}
}

View file

@ -28,11 +28,11 @@ class EntityReferenceTaxonomyTermRssFormatter extends EntityReferenceFormatterBa
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items) {
public function viewElements(FieldItemListInterface $items, $langcode) {
$parent_entity = $items->getEntity();
$elements = array();
foreach ($this->getEntitiesToView($items) as $delta => $entity) {
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
$parent_entity->rss_elements[] = array(
'key' => 'category',
'value' => $entity->label(),

View file

@ -78,11 +78,10 @@ class TermNode extends BuilderBase implements ContainerFactoryPluginInterface {
// Only process the destination ID properties.
$process = array_intersect_key($template['process'], $migration->getDestinationPlugin()->getIds());
foreach ($migration->getSourcePlugin()->getIterator() as $source_row) {
$row = new Row($source_row, $source_row);
foreach ($migration->getSourcePlugin() as $source_row) {
// Process the row to generate the expected destination ID.
$executable->processRow($row, $process);
$map[$row->getSourceProperty('vid')] = $row->getDestinationProperty('vid');
$executable->processRow($source_row, $process);
$map[$source_row->getSourceProperty('vid')] = $source_row->getDestinationProperty('vid');
}
return $map;

View file

@ -0,0 +1,39 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Plugin\migrate\cckfield\TaxonomyTermReference.
*/
namespace Drupal\taxonomy\Plugin\migrate\cckfield;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
/**
* @PluginID("taxonomy_term_reference")
*/
class TaxonomyTermReference extends CckFieldPluginBase {
/**
* {@inheritdoc}
*/
public function getFieldFormatterMap() {
return array();
}
/**
* {@inheritdoc}
*/
public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) {
$process = array(
'plugin' => 'iterator',
'source' => $field_name,
'process' => array(
'target_id' => 'tid',
),
);
$migration->setProcessOfProperty($field_name, $process);
}
}

View file

@ -2,41 +2,62 @@
/**
* @file
* Contains \Drupal\taxonomy\Plugin\migrate\source\d6\Term.
* Contains \Drupal\taxonomy\Plugin\migrate\source\Term.
*/
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
namespace Drupal\taxonomy\Plugin\migrate\source;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 6 taxonomy terms source from database.
* Taxonomy term source from database.
*
* @todo Support term_relation, term_synonym table if possible.
*
* @MigrateSource(
* id = "d6_taxonomy_term",
* id = "taxonomy_term",
* source_provider = "taxonomy"
* )
*/
class Term extends DrupalSqlBase {
/**
* Name of the term data table.
*
* @var string
*/
protected $termDataTable;
/**
* Name of the term hierarchy table.
*
* @var string
*/
protected $termHierarchyTable;
/**
* {@inheritdoc}
*/
public function query() {
// Note the explode - this supports the (admittedly unusual) case of
// consolidating multiple vocabularies into one.
$query = $this->select('term_data', 'td')
->fields('td', array('tid', 'vid', 'name', 'description', 'weight'))
// This works, but we cannot test that, because there is no support for
// distinct() in FakeSelect, yet.
if ($this->getModuleSchemaVersion('taxonomy') >= 7000) {
$this->termDataTable = 'taxonomy_term_data';
$this->termHierarchyTable = 'taxonomy_term_hierarchy';
}
else {
$this->termDataTable = 'term_data';
$this->termHierarchyTable = 'term_hierarchy';
}
$query = $this->select($this->termDataTable, 'td')
->fields('td')
->distinct()
->orderBy('tid');
if (isset($this->configuration['vocabulary'])) {
$query->condition('vid', $this->configuration['vocabulary'], 'IN');
}
return $query;
}
@ -44,7 +65,7 @@ class Term extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
return array(
$fields = array(
'tid' => $this->t('The term ID.'),
'vid' => $this->t('Existing term VID'),
'name' => $this->t('The name of the term.'),
@ -52,6 +73,10 @@ class Term extends DrupalSqlBase {
'weight' => $this->t('Weight'),
'parent' => $this->t("The Drupal term IDs of the term's parents."),
);
if ($this->getModuleSchemaVersion('taxonomy') >= 7000) {
$fields['format'] = $this->t('Format of the term description.');
}
return $fields;
}
/**
@ -59,12 +84,13 @@ class Term extends DrupalSqlBase {
*/
public function prepareRow(Row $row) {
// Find parents for this row.
$parents = $this->select('term_hierarchy', 'th')
$parents = $this->select($this->termHierarchyTable, 'th')
->fields('th', array('parent', 'tid'))
->condition('tid', $row->getSourceProperty('tid'))
->execute()
->fetchCol();
$row->setSourceProperty('parent', $parents);
return parent::prepareRow($row);
}

View file

@ -20,7 +20,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
*/
class TermNode extends DrupalSqlBase {
/**
/**
* The join options between the node and the term node table.
*/
const JOIN = 'tn.vid = n.vid';
@ -30,7 +30,6 @@ class TermNode extends DrupalSqlBase {
*/
public function query() {
$query = $this->select('term_node', 'tn')
// @todo: working, but not is there support for distinct() in FakeSelect?
->distinct()
->fields('tn', array('nid', 'vid'))
->fields('n', array('type'));
@ -38,7 +37,6 @@ class TermNode extends DrupalSqlBase {
$query->innerJoin('term_data', 'td', 'td.tid = tn.tid AND td.vid = :vid', array(':vid' => $this->configuration['vid']));
$query->innerJoin('node', 'n', static::JOIN);
return $query;
}
/**

View file

@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 6 vocabularies source from database.
@ -17,7 +18,48 @@ use Drupal\migrate\Row;
* source_provider = "taxonomy"
* )
*/
class Vocabulary extends VocabularyBase {
class Vocabulary extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('vocabulary', 'v')
->fields('v', array(
'vid',
'name',
'description',
'help',
'relations',
'hierarchy',
'multiple',
'required',
'tags',
'module',
'weight',
));
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
return array(
'vid' => $this->t('The vocabulary ID.'),
'name' => $this->t('The name of the vocabulary.'),
'description' => $this->t('The description of the vocabulary.'),
'help' => $this->t('Help text to display for the vocabulary.'),
'relations' => $this->t('Whether or not related terms are enabled within the vocabulary. (0 = disabled, 1 = enabled)'),
'hierarchy' => $this->t('The type of hierarchy allowed within the vocabulary. (0 = disabled, 1 = single, 2 = multiple)'),
'multiple' => $this->t('Whether or not multiple terms from this vocabulary may be assigned to a node. (0 = disabled, 1 = enabled)'),
'required' => $this->t('Whether or not terms are required for nodes using this vocabulary. (0 = disabled, 1 = enabled)'),
'tags' => $this->t('Whether or not free tagging is enabled for the vocabulary. (0 = disabled, 1 = enabled)'),
'weight' => $this->t('The weight of the vocabulary in relation to other vocabularies.'),
'parents' => $this->t("The Drupal term IDs of the term's parents."),
'node_types' => $this->t('The names of the node types the vocabulary may be used with.'),
);
}
/**
* {@inheritdoc}

View file

@ -1,58 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Plugin\migrate\source\d6\VocabularyBase.
*/
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 6 vocabularies source base.
*/
abstract class VocabularyBase extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('vocabulary', 'v')
->fields('v', array(
'vid',
'name',
'description',
'help',
'relations',
'hierarchy',
'multiple',
'required',
'tags',
'module',
'weight',
));
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
return array(
'vid' => $this->t('The vocabulary ID.'),
'name' => $this->t('The name of the vocabulary.'),
'description' => $this->t('The description of the vocabulary.'),
'help' => $this->t('Help text to display for the vocabulary.'),
'relations' => $this->t('Whether or not related terms are enabled within the vocabulary. (0 = disabled, 1 = enabled)'),
'hierarchy' => $this->t('The type of hierarchy allowed within the vocabulary. (0 = disabled, 1 = single, 2 = multiple)'),
'multiple' => $this->t('Whether or not multiple terms from this vocabulary may be assigned to a node. (0 = disabled, 1 = enabled)'),
'required' => $this->t('Whether or not terms are required for nodes using this vocabulary. (0 = disabled, 1 = enabled)'),
'tags' => $this->t('Whether or not free tagging is enabled for the vocabulary. (0 = disabled, 1 = enabled)'),
'weight' => $this->t('The weight of the vocabulary in relation to other vocabularies.'),
'parents' => $this->t("The Drupal term IDs of the term's parents."),
'node_types' => $this->t('The names of the node types the vocabulary may be used with.'),
);
}
}

View file

@ -22,10 +22,8 @@ class VocabularyPerType extends Vocabulary {
*/
public function query() {
$query = parent::query();
$query->fields('nt', array(
'type',
));
$query->join('vocabulary_node_types', 'nt', 'v.vid = nt.vid');
$query->fields('nt', array('type'));
return $query;
}

View file

@ -0,0 +1,62 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Plugin\migrate\source\d7\Vocabulary.
*/
namespace Drupal\taxonomy\Plugin\migrate\source\d7;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 7 vocabularies source from database.
*
* @MigrateSource(
* id = "d7_taxonomy_vocabulary",
* source_provider = "taxonomy"
* )
*/
class Vocabulary extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('taxonomy_vocabulary', 'v')
->fields('v', array(
'vid',
'name',
'description',
'hierarchy',
'module',
'weight',
'machine_name',
));
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
return array(
'vid' => $this->t('The vocabulary ID.'),
'name' => $this->t('The name of the vocabulary.'),
'description' => $this->t('The description of the vocabulary.'),
'hierarchy' => $this->t('The type of hierarchy allowed within the vocabulary. (0 = disabled, 1 = single, 2 = multiple)'),
'module' => $this->t('Module responsible for the vocabulary.'),
'weight' => $this->t('The weight of the vocabulary in relation to other vocabularies.'),
'machine_name' => $this->t('Unique achine name of the vocabulary.')
);
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['vid']['type'] = 'integer';
return $ids;
}
}

View file

@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\taxonomy\Entity\Term;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -140,7 +139,7 @@ class IndexTidDepth extends ArgumentPluginBase implements ContainerFactoryPlugin
function title() {
$term = $this->termStorage->load($this->argument);
if (!empty($term)) {
return SafeMarkup::checkPlain($term->getName());
return $term->getName();
}
// TODO review text
return $this->t('No name');

View file

@ -10,7 +10,6 @@ namespace Drupal\taxonomy\Plugin\views\argument;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\views\Plugin\views\argument\NumericArgument;
use Drupal\Component\Utility\SafeMarkup;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@ -56,7 +55,7 @@ class Taxonomy extends NumericArgument implements ContainerFactoryPluginInterfac
if ($this->argument) {
$term = $this->termStorage->load($this->argument);
if (!empty($term)) {
return SafeMarkup::checkPlain($term->getName());
return $term->getName();
}
}
// TODO review text

View file

@ -8,7 +8,6 @@
namespace Drupal\taxonomy\Plugin\views\argument;
use Drupal\views\Plugin\views\argument\NumericArgument;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\taxonomy\VocabularyStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -63,7 +62,7 @@ class VocabularyVid extends NumericArgument {
function title() {
$vocabulary = $this->vocabularyStorage->load($this->argument);
if ($vocabulary) {
return SafeMarkup::checkPlain($vocabulary->label());
return $vocabulary->label();
}
return $this->t('No vocabulary');

View file

@ -7,10 +7,11 @@
namespace Drupal\taxonomy\Plugin\views\argument_default;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\taxonomy\TermInterface;
use Drupal\views\Plugin\CacheablePluginInterface;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
@ -28,7 +29,7 @@ use Drupal\taxonomy\VocabularyStorageInterface;
* title = @Translation("Taxonomy term ID from URL")
* )
*/
class Tid extends ArgumentDefaultPluginBase implements CacheablePluginInterface {
class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {
/**
* The route match.
@ -216,8 +217,8 @@ class Tid extends ArgumentDefaultPluginBase implements CacheablePluginInterface
/**
* {@inheritdoc}
*/
public function isCacheable() {
return TRUE;
public function getCacheMaxAge() {
return Cache::PERMANENT;
}
/**

View file

@ -11,7 +11,6 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\PrerenderList;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\taxonomy\Entity\Vocabulary;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\taxonomy\VocabularyStorageInterface;
@ -153,7 +152,7 @@ class TaxonomyIndexTid extends PrerenderList {
$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'] = SafeMarkup::checkPlain($vocabularies[$term->getVocabularyId()]->label());
$this->items[$node_nid][$tid]['vocabulary'] = $vocabularies[$term->getVocabularyId()]->label();
if (!empty($this->options['link_to_taxonomy'])) {
$this->items[$node_nid][$tid]['make_link'] = TRUE;

View file

@ -28,7 +28,8 @@ class TermName extends Field {
foreach ($items as &$item) {
// Replace spaces with hyphens.
$name = $item['raw']->get('value')->getValue();
$item['rendered']['#markup'] = str_replace(' ', '-', $name);
// @todo Add link support https://www.drupal.org/node/2567745
$item['rendered']['#context']['value'] = str_replace(' ', '-', $name);
}
}
return $items;

View file

@ -16,7 +16,6 @@ use Drupal\taxonomy\VocabularyStorageInterface;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\filter\ManyToOne;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Tags;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -154,7 +153,7 @@ class TaxonomyIndexTid extends ManyToOne {
$vocabulary = $this->vocabularyStorage->load($this->options['vid']);
if (empty($vocabulary) && $this->options['limit']) {
$form['markup'] = array(
'#markup' => '<div class="form-item">' . $this->t('An invalid vocabulary is selected. Please change it in the options.') . '</div>',
'#markup' => '<div class="js-form-item form-item">' . $this->t('An invalid vocabulary is selected. Please change it in the options.') . '</div>',
);
return;
}
@ -183,7 +182,7 @@ class TaxonomyIndexTid extends ManyToOne {
if ($tree) {
foreach ($tree as $term) {
$choice = new \stdClass();
$choice->option = array($term->id() => str_repeat('-', $term->depth) . SafeMarkup::checkPlain(\Drupal::entityManager()->getTranslationFromContext($term)->label()));
$choice->option = array($term->id() => str_repeat('-', $term->depth) . \Drupal::entityManager()->getTranslationFromContext($term)->label());
$options[] = $choice;
}
}
@ -201,7 +200,7 @@ class TaxonomyIndexTid extends ManyToOne {
}
$terms = Term::loadMultiple($query->execute());
foreach ($terms as $term) {
$options[$term->id()] = SafeMarkup::checkPlain(\Drupal::entityManager()->getTranslationFromContext($term)->label());
$options[$term->id()] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
}
}
@ -359,7 +358,7 @@ class TaxonomyIndexTid extends ManyToOne {
$this->value = array_filter($this->value);
$terms = Term::loadMultiple($this->value);
foreach ($terms as $term) {
$this->valueOptions[$term->id()] = SafeMarkup::checkPlain(\Drupal::entityManager()->getTranslationFromContext($term)->label());
$this->valueOptions[$term->id()] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
}
}
return parent::adminSummary();

View file

@ -22,7 +22,7 @@ class TermAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
switch ($operation) {
case 'view':
return AccessResult::allowedIfHasPermission($account, 'access content');

View file

@ -78,7 +78,7 @@ class TermBreadcrumbBuilder implements BreadcrumbBuilderInterface {
// This breadcrumb builder is based on a route parameter, and hence it
// depends on the 'route' cache context.
$breadcrumb->setCacheContexts(['route']);
$breadcrumb->addCacheContexts(['route']);
return $breadcrumb;
}

View file

@ -19,8 +19,8 @@ class TermViewBuilder extends EntityViewBuilder {
/**
* {@inheritdoc}
*/
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode, $langcode = NULL) {
parent::alterBuild($build, $entity, $display, $view_mode, $langcode);
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
parent::alterBuild($build, $entity, $display, $view_mode);
$build['#contextual_links']['taxonomy_term'] = array(
'route_parameters' => array('taxonomy_term' => $entity->id()),
'metadata' => array('changed' => $entity->getChangedTime()),

View file

@ -38,7 +38,7 @@ class LoadMultipleTest extends TaxonomyTestBase {
// Load the terms from the vocabulary.
$terms = entity_load_multiple_by_properties('taxonomy_term', array('vid' => $vocabulary->id()));
$count = count($terms);
$this->assertEqual($count, 5, format_string('Correct number of terms were loaded. !count terms.', array('!count' => $count)));
$this->assertEqual($count, 5, format_string('Correct number of terms were loaded. @count terms.', array('@count' => $count)));
// Load the same terms again by tid.
$terms2 = Term::loadMultiple(array_keys($terms));

View file

@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateTaxonomyConfigsTest.
* Contains \Drupal\taxonomy\Tests\Migrate\MigrateTaxonomyConfigsTest.
*/
namespace Drupal\taxonomy\Tests\Migrate\d6;
namespace Drupal\taxonomy\Tests\Migrate;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
@ -20,9 +20,7 @@ class MigrateTaxonomyConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = array('taxonomy');
@ -31,7 +29,7 @@ class MigrateTaxonomyConfigsTest extends MigrateDrupal6TestBase {
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_taxonomy_settings');
$this->executeMigration('taxonomy_settings');
}
/**

View file

@ -17,23 +17,18 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
*/
class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
static $modules = array('taxonomy', 'text');
/**
* {@inheritdoc}
*/
public static $modules = array('taxonomy');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('taxonomy_term');
$this->prepareMigrations(array(
'd6_taxonomy_vocabulary' => array(
array(array(1), array('vocabulary_1_i_0_')),
array(array(2), array('vocabulary_2_i_1_')),
array(array(3), array('vocabulary_3_i_2_')),
)));
$this->executeMigration('d6_taxonomy_term');
$this->executeMigrations(['d6_taxonomy_vocabulary', 'd6_taxonomy_term']);
}
/**

View file

@ -7,6 +7,7 @@
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\migrate\Entity\Migration;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
@ -18,9 +19,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
class MigrateTaxonomyVocabularyTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = array('taxonomy');
@ -39,7 +38,7 @@ class MigrateTaxonomyVocabularyTest extends MigrateDrupal6TestBase {
for ($i = 0; $i < 3; $i++) {
$j = $i + 1;
$vocabulary = Vocabulary::load("vocabulary_{$j}_i_{$i}_");
$this->assertIdentical(entity_load('migration', 'd6_taxonomy_vocabulary')->getIdMap()->lookupDestinationID(array($j)), array($vocabulary->id()));
$this->assertIdentical(Migration::load('d6_taxonomy_vocabulary')->getIdMap()->lookupDestinationID(array($j)), array($vocabulary->id()));
$this->assertIdentical("vocabulary $j (i=$i)", $vocabulary->label());
$this->assertIdentical("description of vocabulary $j (i=$i)", $vocabulary->getDescription());
$this->assertIdentical($i, $vocabulary->getHierarchy());

View file

@ -7,32 +7,29 @@
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade taxonomy term node associations.
*
* @group migrate_drupal_6
*/
class MigrateTermNodeRevisionTest extends MigrateTermNodeTestBase {
class MigrateTermNodeRevisionTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$id_mappings = array(
'd6_term_node:*' => array(
array(array(2), array(1)),
),
'd6_node_revision:*' => array(
array(array(2), array(2)),
),
);
$this->prepareMigrations($id_mappings);
$migrations = Migration::loadMultiple(['d6_term_node_revision:*']);
array_walk($migrations, [$this, 'executeMigration']);
$this->installSchema('node', ['node_access']);
$this->migrateContent(TRUE);
$this->migrateTaxonomy();
$this->executeMigrations(['d6_term_node:*', 'd6_term_node_revision:*']);
}
/**

View file

@ -7,8 +7,7 @@
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
use Drupal\node\Entity\Node;
/**
@ -16,33 +15,33 @@ use Drupal\node\Entity\Node;
*
* @group migrate_drupal_6
*/
class MigrateTermNodeTest extends MigrateTermNodeTestBase {
class MigrateTermNodeTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$id_mappings = array(
'd6_node:*' => array(
array(
array(0),
array(0),
),
),
);
$this->prepareMigrations($id_mappings);
$migrations = Migration::loadMultiple(['d6_term_node:*']);
array_walk($migrations, [$this, 'executeMigration']);
$this->installSchema('node', ['node_access']);
$this->migrateContent();
$this->migrateTaxonomy();
$this->executeMigrations(['d6_term_node:*']);
}
/**
* Tests the Drupal 6 term-node association to Drupal 8 migration.
*/
public function testTermNode() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$node_storage->resetCache(array(1, 2));
$nodes = Node::loadMultiple(array(1, 2));
$this->container->get('entity.manager')
->getStorage('node')
->resetCache([1, 2]);
$nodes = Node::loadMultiple([1, 2]);
$node = $nodes[1];
$this->assertIdentical(1, count($node->vocabulary_1_i_0_));
$this->assertIdentical('1', $node->vocabulary_1_i_0_[0]->target_id);

View file

@ -1,88 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateTermNodeTestBase.
*/
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\entity_reference\Tests\EntityReferenceTestTrait;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Base class for Taxonomy/Node migration tests.
*/
abstract class MigrateTermNodeTestBase extends MigrateDrupal6TestBase {
use EntityReferenceTestTrait;
/**
* {@inheritdoc}
*/
static $modules = array('node', 'taxonomy', 'text', 'filter', 'entity_reference');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installEntitySchema('taxonomy_term');
$this->installSchema('node', array('node_access'));
$vocabulary = entity_create('taxonomy_vocabulary', array(
'vid' => 'test',
));
$vocabulary->save();
$node_type = entity_create('node_type', array('type' => 'story'));
$node_type->save();
foreach (array('vocabulary_1_i_0_', 'vocabulary_2_i_1_', 'vocabulary_3_i_2_') as $name) {
$handler_settings = array(
'target_bundles' => array(
$vocabulary->id() => $vocabulary->id(),
),
'auto_create' => TRUE,
);
$this->createEntityReferenceField('node', 'story', $name, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
}
$id_mappings = array(
'd6_vocabulary_field_instance' => array(
array(array(1, 'page'), array('node', 'page', 'test')),
),
'd6_vocabulary_entity_display' => array(
array(array(1, 'page'), array('node', 'page', 'default', 'test')),
),
'd6_vocabulary_entity_form_display' => array(
array(array(1, 'page'), array('node', 'page', 'default', 'test')),
),
'd6_node' => array(
array(array(1), array(1)),
array(array(2), array(2)),
),
);
$this->prepareMigrations($id_mappings);
$vids = array(1, 2, 3);
for ($i = 1; $i <= 2; $i++) {
$node = entity_create('node', array(
'type' => 'story',
'nid' => $i,
'vid' => array_shift($vids),
'title' => $this->randomString(),
));
$node->enforceIsNew();
$node->save();
if ($i == 1) {
$node->vid->value = array_shift($vids);
$node->enforceIsNew(FALSE);
$node->setNewRevision();
$node->isDefaultRevision(FALSE);
$node->save();
}
}
}
}

View file

@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
@ -17,59 +19,16 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
* {@inheritdoc}
*/
static $modules = array('field', 'node', 'taxonomy', 'text', 'entity_reference');
public static $modules = ['field', 'taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'tags',
'type' => 'entity_reference',
'settings' => array(
'target_type' => 'taxonomy_term',
),
))->save();
foreach (array('page', 'article', 'story') as $type) {
entity_create('node_type', array('type' => $type))->save();
entity_create('field_config', array(
'label' => 'Tags',
'description' => '',
'field_name' => 'tags',
'entity_type' => 'node',
'bundle' => $type,
'required' => 1,
'settings' => array(
'handler' => 'default',
'handler_settings' => array(
'target_bundles' => array(
'tags' => 'tags',
),
'auto_create' => TRUE,
),
),
))->save();
}
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_taxonomy_vocabulary' => array(
array(array(4), array('tags')),
),
'd6_vocabulary_field_instance' => array(
array(array(4, 'page'), array('node', 'page', 'tags')),
)
);
$this->prepareMigrations($id_mappings);
$this->executeMigration('d6_vocabulary_entity_display');
$this->migrateTaxonomy();
}
/**
@ -77,11 +36,11 @@ class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
*/
public function testVocabularyEntityDisplay() {
// Test that the field exists.
$component = entity_get_display('node', 'page', 'default')->getComponent('tags');
$component = EntityViewDisplay::load('node.page.default')->getComponent('tags');
$this->assertIdentical('entity_reference_label', $component['type']);
$this->assertIdentical(20, $component['weight']);
// Test the Id map.
$this->assertIdentical(array('node', 'article', 'default', 'tags'), entity_load('migration', 'd6_vocabulary_entity_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
$this->assertIdentical(array('node', 'article', 'default', 'tags'), Migration::load('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
}
}

View file

@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
@ -17,59 +19,16 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
* {@inheritdoc}
*/
static $modules = array('node', 'taxonomy', 'field', 'text', 'entity_reference');
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'tags',
'type' => 'entity_reference',
'settings' => array(
'target_type' => 'taxonomy_term',
),
))->save();
foreach (array('page', 'article', 'story') as $type) {
entity_create('node_type', array('type' => $type))->save();
entity_create('field_config', array(
'label' => 'Tags',
'description' => '',
'field_name' => 'tags',
'entity_type' => 'node',
'bundle' => $type,
'required' => 1,
'settings' => array(
'handler' => 'default',
'handler_settings' => array(
'target_bundles' => array(
'tags' => 'tags',
),
'auto_create' => TRUE,
),
),
))->save();
}
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_taxonomy_vocabulary' => array(
array(array(4), array('tags')),
),
'd6_vocabulary_field_instance' => array(
array(array(4, 'page'), array('node', 'page', 'tags')),
)
);
$this->prepareMigrations($id_mappings);
$this->executeMigration('d6_vocabulary_entity_form_display');
$this->migrateTaxonomy();
}
/**
@ -77,11 +36,11 @@ class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupal6TestBase {
*/
public function testVocabularyEntityFormDisplay() {
// Test that the field exists.
$component = entity_get_form_display('node', 'page', 'default')->getComponent('tags');
$component = EntityFormDisplay::load('node.page.default')->getComponent('tags');
$this->assertIdentical('options_select', $component['type']);
$this->assertIdentical(20, $component['weight']);
// Test the Id map.
$this->assertIdentical(array('node', 'article', 'default', 'tags'), entity_load('migration', 'd6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
$this->assertIdentical(array('node', 'article', 'default', 'tags'), Migration::load('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
}
}

View file

@ -9,6 +9,7 @@ namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
@ -19,56 +20,16 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
* {@inheritdoc}
*/
static $modules = array('node', 'field', 'taxonomy', 'text', 'entity_reference');
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
entity_create('node_type', array('type' => 'page'))->save();
entity_create('node_type', array('type' => 'article'))->save();
entity_create('node_type', array('type' => 'story'))->save();
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_node_type' => array(
array(array('article'), array('article')),
array(array('page'), array('page')),
array(array('story'), array('story')),
),
'd6_taxonomy_vocabulary' => array(
array(array(4), array('tags')),
),
'd6_vocabulary_field' => array(
array(array(4), array('node', 'tags')),
)
);
$this->prepareMigrations($id_mappings);
// Create the vocab.
entity_create('taxonomy_vocabulary', array(
'field_name' => 'Test Vocabulary',
'description' => 'Test Vocabulary',
'vid' => 'tags',
))->save();
// Create the field storage.
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'tags',
'type' => 'entity_reference',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => array(
'target_type' => 'taxonomy_term',
),
))->save();
$this->executeMigration('d6_vocabulary_field_instance');
$this->migrateTaxonomy();
}
/**
@ -87,10 +48,10 @@ class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
$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_bundle handler setting 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'), entity_load('migration', 'd6_vocabulary_field_instance')->getIdMap()->lookupDestinationID(array(4, 'article')));
$this->assertIdentical(array('node', 'article', 'tags'), Migration::load('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationID(array(4, 'article')));
}
}

View file

@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
@ -18,33 +19,16 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
class MigrateVocabularyFieldTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
* {@inheritdoc}
*/
static $modules = array('node', 'taxonomy', 'field', 'text', 'entity_reference');
public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_taxonomy_vocabulary' => array(
array(array(4), array('tags')),
),
);
$this->prepareMigrations($id_mappings);
entity_create('taxonomy_vocabulary', array(
'name' => 'Test Vocabulary',
'description' => 'Test Vocabulary',
'vid' => 'test_vocab',
))->save();
$this->executeMigration('d6_vocabulary_field');
$this->migrateTaxonomy();
}
/**
@ -59,7 +43,7 @@ class MigrateVocabularyFieldTest extends MigrateDrupal6TestBase {
$settings = $field_storage->getSettings();
$this->assertIdentical('taxonomy_term', $settings['target_type'], "Target type is correct.");
$this->assertIdentical(array('node', 'tags'), entity_load('migration', 'd6_vocabulary_field')->getIdMap()->lookupDestinationID(array(4)), "Test IdMap");
$this->assertIdentical(array('node', 'tags'), Migration::load('d6_vocabulary_field')->getIdMap()->lookupDestinationID(array(4)), "Test IdMap");
}
}

View file

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

View file

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

View file

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

View file

@ -7,7 +7,7 @@
namespace Drupal\taxonomy\Tests;
use Drupal\entity_reference\Tests\EntityReferenceTestTrait;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\simpletest\WebTestBase;
/**

View file

@ -8,7 +8,7 @@
namespace Drupal\taxonomy\Tests;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\entity_reference\Tests\EntityReferenceTestTrait;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\language\Entity\ConfigurableLanguage;
@ -83,7 +83,7 @@ trait TaxonomyTranslationTestTrait {
* (optional) If TRUE, create a translatable term reference field. Defaults
* to FALSE.
*/
protected function setUpTermReferenceField($translatable = FALSE) {
protected function setUpTermReferenceField() {
$handler_settings = array(
'target_bundles' => array(
$this->vocabulary->id() => $this->vocabulary->id(),
@ -92,7 +92,7 @@ trait TaxonomyTranslationTestTrait {
);
$this->createEntityReferenceField('node', 'article', $this->termFieldName, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$field_storage = FieldStorageConfig::loadByName('node', $this->termFieldName);
$field_storage->setTranslatable($translatable);
$field_storage->setTranslatable(FALSE);
$field_storage->save();
entity_get_form_display('node', 'article', 'default')

View file

@ -22,7 +22,7 @@ class TermEntityReferenceTest extends TaxonomyTestBase {
*
* @var array
*/
public static $modules = array('entity_reference', 'entity_reference_test', 'entity_test');
public static $modules = ['entity_reference_test', 'entity_test'];
/**
* Tests an entity reference field restricted to a single vocabulary.

View file

@ -50,6 +50,7 @@ class TermTest extends TaxonomyTestBase {
$this->drupalPlaceBlock('local_actions_block');
$this->drupalPlaceBlock('local_tasks_block');
$this->drupalPlaceBlock('page_title_block');
$this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'bypass node access']));
$this->vocabulary = $this->createVocabulary();

View file

@ -50,7 +50,7 @@ class TermTranslationFieldViewTest extends TaxonomyTestBase {
$this->vocabulary = $this->createVocabulary();
$this->enableTranslation();
$this->setUpTerm();
$this->setUpTermReferenceField(TRUE);
$this->setUpTermReferenceField();
$this->setUpNode();
}

View file

@ -7,8 +7,6 @@
namespace Drupal\taxonomy\Tests;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Render\BubbleableMetadata;
@ -86,13 +84,13 @@ class TokenReplaceTest extends TaxonomyTestBase {
// Generate and test sanitized tokens for term1.
$tests = array();
$tests['[term:tid]'] = $term1->id();
$tests['[term:name]'] = Html::escape($term1->getName());
$tests['[term:name]'] = $term1->getName();
$tests['[term:description]'] = $term1->description->processed;
$tests['[term:url]'] = $term1->url('canonical', array('absolute' => TRUE));
$tests['[term:node-count]'] = 0;
$tests['[term:parent:name]'] = '[term:parent:name]';
$tests['[term:vocabulary:name]'] = Html::escape($this->vocabulary->label());
$tests['[term:vocabulary]'] = Html::escape($this->vocabulary->label());
$tests['[term:vocabulary:name]'] = $this->vocabulary->label();
$tests['[term:vocabulary]'] = $this->vocabulary->label();
$base_bubbleable_metadata = BubbleableMetadata::createFromObject($term1);
@ -117,14 +115,14 @@ class TokenReplaceTest extends TaxonomyTestBase {
// Generate and test sanitized tokens for term2.
$tests = array();
$tests['[term:tid]'] = $term2->id();
$tests['[term:name]'] = Html::escape($term2->getName());
$tests['[term:name]'] = $term2->getName();
$tests['[term:description]'] = $term2->description->processed;
$tests['[term:url]'] = $term2->url('canonical', array('absolute' => TRUE));
$tests['[term:node-count]'] = 1;
$tests['[term:parent:name]'] = Html::escape($term1->getName());
$tests['[term:parent:name]'] = $term1->getName();
$tests['[term:parent:url]'] = $term1->url('canonical', array('absolute' => TRUE));
$tests['[term:parent:parent:name]'] = '[term:parent:parent:name]';
$tests['[term:vocabulary:name]'] = Html::escape($this->vocabulary->label());
$tests['[term:vocabulary:name]'] = $this->vocabulary->label();
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
@ -134,22 +132,11 @@ class TokenReplaceTest extends TaxonomyTestBase {
$this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input)));
}
// Generate and test unsanitized tokens.
$tests['[term:name]'] = $term2->getName();
$tests['[term:description]'] = $term2->getDescription();
$tests['[term:parent:name]'] = $term1->getName();
$tests['[term:vocabulary:name]'] = $this->vocabulary->label();
foreach ($tests as $input => $expected) {
$output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE));
$this->assertEqual($output, $expected, format_string('Unsanitized taxonomy term token %token replaced.', array('%token' => $input)));
}
// Generate and test sanitized tokens.
$tests = array();
$tests['[vocabulary:vid]'] = $this->vocabulary->id();
$tests['[vocabulary:name]'] = Html::escape($this->vocabulary->label());
$tests['[vocabulary:description]'] = Xss::filter($this->vocabulary->getDescription());
$tests['[vocabulary:name]'] = $this->vocabulary->label();
$tests['[vocabulary:description]'] = $this->vocabulary->getDescription();
$tests['[vocabulary:node-count]'] = 1;
$tests['[vocabulary:term-count]'] = 2;
@ -160,15 +147,6 @@ class TokenReplaceTest extends TaxonomyTestBase {
$output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->getId()));
$this->assertEqual($output, $expected, format_string('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input)));
}
// Generate and test unsanitized tokens.
$tests['[vocabulary:name]'] = $this->vocabulary->label();
$tests['[vocabulary:description]'] = $this->vocabulary->getDescription();
foreach ($tests as $input => $expected) {
$output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE));
$this->assertEqual($output, $expected, format_string('Unsanitized taxonomy vocabulary token %token replaced.', array('%token' => $input)));
}
}
}

View file

@ -0,0 +1,127 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Views\ArgumentValidatorTermTest.
*/
namespace Drupal\taxonomy\Tests\Views;
use Drupal\views\Views;
/**
* Tests the plugin of the taxonomy: term argument validator.
*
* @group taxonomy
* @see Views\taxonomy\Plugin\views\argument_validator\Term
*/
class ArgumentValidatorTermTest extends TaxonomyTestBase {
/**
* Stores the taxonomy term used by this test.
*
* @var array
*/
protected $terms = [];
/**
* Stores the taxonomy names used by this test.
*
* @var array
*/
protected $names = [];
/**
* Stores the taxonomy IDs used by this test.
*
* @var array
*/
protected $ids = [];
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['taxonomy', 'taxonomy_test_views', 'views_test_config'];
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = ['test_argument_validator_term'];
protected function setUp() {
parent::setUp();
// Add three terms to the 'tags' vocabulary.
for ($i = 0; $i < 3; $i++) {
$this->terms[] = $term = $this->createTerm();
$this->names[] = $term->label();
$this->ids[] = $term->id();
}
}
/**
* Tests the term argument validator plugin.
*/
public function testArgumentValidatorTerm() {
$view = Views::getView('test_argument_validator_term');
$view->initHandlers();
// Test the single validator for term IDs.
$view->argument['tid']->validator->options['type'] = 'tid';
// Pass in a single valid term.
foreach ($this->terms as $term) {
$this->assertTrue($view->argument['tid']->setArgument($term->id()));
$this->assertEqual($view->argument['tid']->getTitle(), $term->label());
$view->argument['tid']->validated_title = NULL;
$view->argument['tid']->argument_validated = NULL;
}
// Pass in a invalid term.
$this->assertFalse($view->argument['tid']->setArgument(rand(1000, 10000)));
$this->assertEqual('', $view->argument['tid']->getTitle());
$view->argument['tid']->validated_title = NULL;
$view->argument['tid']->argument_validated = NULL;
// Test the multiple validator for term IDs.
$view->argument['tid']->validator->options['type'] = 'tids';
$view->argument['tid']->options['break_phrase'] = TRUE;
// Pass in a single term.
$this->assertTrue($view->argument['tid']->setArgument($this->terms[0]->id()));
$this->assertEqual($view->argument['tid']->getTitle(), $this->terms[0]->label());
$view->argument['tid']->validated_title = NULL;
$view->argument['tid']->argument_validated = NULL;
// Check for multiple valid terms separated by commas.
$this->assertTrue($view->argument['tid']->setArgument(implode(',', $this->ids)));
$this->assertEqual($view->argument['tid']->getTitle(), implode(', ', $this->names));
$view->argument['tid']->validated_title = NULL;
$view->argument['tid']->argument_validated = NULL;
// Check for multiple valid terms separated by plus signs.
$this->assertTrue($view->argument['tid']->setArgument(implode('+', $this->ids)));
$this->assertEqual($view->argument['tid']->getTitle(), implode(' + ', $this->names));
$view->argument['tid']->validated_title = NULL;
$view->argument['tid']->argument_validated = NULL;
// Check for a single invalid term.
$this->assertFalse($view->argument['tid']->setArgument(rand(1000, 10000)));
$this->assertEqual('', $view->argument['tid']->getTitle());
$view->argument['tid']->validated_title = NULL;
$view->argument['tid']->argument_validated = NULL;
// Check for multiple invalid terms.
$this->assertFalse($view->argument['tid']->setArgument(implode(',', [rand(1000, 10000), rand(1000, 10000)])));
$this->assertEqual('', $view->argument['tid']->getTitle());
$view->argument['tid']->validated_title = NULL;
$view->argument['tid']->argument_validated = NULL;
}
}

View file

@ -34,7 +34,7 @@ class RelationshipNodeTermDataTest extends TaxonomyTestBase {
'user',
],
];
$this->assertIdentical($expected, $view->calculateDependencies());
$this->assertIdentical($expected, $view->getDependencies());
$this->executeView($view, array($this->term1->id(), $this->term2->id()));
$expected_result = array(
array(
@ -55,7 +55,7 @@ class RelationshipNodeTermDataTest extends TaxonomyTestBase {
$view = Views::getView('test_taxonomy_node_term_data');
// Tests \Drupal\taxonomy\Plugin\views\relationship\NodeTermData::calculateDependencies().
$expected['config'][] = 'taxonomy.vocabulary.views_testing_tags';
$this->assertIdentical($expected, $view->calculateDependencies());
$this->assertIdentical($expected, $view->getDependencies());
$this->executeView($view, array($this->term1->id(), $this->term2->id()));
$this->assertIdenticalResultset($view, $expected_result, $column_map);
}

View file

@ -59,4 +59,14 @@ class TaxonomyDefaultArgumentTest extends TaxonomyTestBase {
$expected = $this->term1->id();
$this->assertEqual($expected, $view->argument['tid']->getDefaultArgument());
}
/**
* Tests escaping of page title when the taxonomy plugin provides it.
*/
public function testTermTitleEscaping() {
$this->term1->setName('<em>Markup</em>')->save();
$this->drupalGet('taxonomy_default_argument_test/'. $this->term1->id());
$this->assertEscaped($this->term1->label());
}
}

View file

@ -28,6 +28,7 @@ class TaxonomyFieldAllTermsTest extends TaxonomyTestBase {
* Tests the "all terms" field handler.
*/
public function testViewsHandlerAllTermsField() {
$this->term1->setName('<em>Markup</em>')->save();
$view = Views::getView('taxonomy_all_terms_test');
$this->executeView($view);
$this->drupalGet('taxonomy_all_terms_test');
@ -36,6 +37,7 @@ class TaxonomyFieldAllTermsTest extends TaxonomyTestBase {
$this->assertEqual(count($actual), 2, 'Correct number of taxonomy term1 links');
$this->assertEqual($actual[0]->__toString(), $this->term1->label());
$this->assertEqual($actual[1]->__toString(), $this->term1->label());
$this->assertEscaped($this->term1->label());
$actual = $this->xpath('//a[@href="' . $this->term2->url() . '"]');
$this->assertEqual(count($actual), 2, 'Correct number of taxonomy term2 links');

View file

@ -8,7 +8,7 @@
namespace Drupal\taxonomy\Tests\Views;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\entity_reference\Tests\EntityReferenceTestTrait;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\views\Tests\ViewTestData;
@ -36,7 +36,7 @@ class TaxonomyIndexTidUiTest extends UITestBase {
*
* @var array
*/
public static $modules = array('node', 'taxonomy', 'taxonomy_test_views', 'entity_reference');
public static $modules = ['node', 'taxonomy', 'taxonomy_test_views'];
/**
* A nested array of \Drupal\taxonomy\TermInterface objects.
@ -121,7 +121,7 @@ class TaxonomyIndexTidUiTest extends UITestBase {
'user',
],
];
$this->assertIdentical($expected, $view->calculateDependencies());
$this->assertIdentical($expected, $view->calculateDependencies()->getDependencies());
}
/**

View file

@ -0,0 +1,64 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyTermArgumentDepthTest.
*/
namespace Drupal\taxonomy\Tests\Views;
/**
* Tests the taxonomy term with depth argument.
*
* @group taxonomy
*/
class TaxonomyTermArgumentDepthTest extends TaxonomyTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'taxonomy_test_views', 'views', 'node'];
/**
* {@inheritdoc}
*/
public static $testViews = ['test_argument_taxonomy_index_tid_depth'];
/**
* @var \Drupal\taxonomy\TermInterface[]
*/
protected $terms = [];
/**
* @var \Drupal\views\ViewExecutable
*/
protected $view;
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
// Create a term with markup in the label.
$first = $this->createTerm(['name' => '<em>First</em>']);
// Create a node w/o any terms.
$settings = ['type' => 'article'];
// Create a node with linked to the term.
$settings['field_views_testing_tags'][0]['target_id'] = $first->id();
$this->nodes[] = $this->drupalCreateNode($settings);
$this->terms[0] = $first;
}
/**
* Tests title escaping.
*/
public function testTermWithDepthArgumentTitleEscaping() {
$this->drupalGet('test_argument_taxonomy_index_tid_depth/' . $this->terms[0]->id());
$this->assertEscaped($this->terms[0]->label());
}
}

View file

@ -9,7 +9,7 @@ namespace Drupal\taxonomy\Tests\Views;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\entity_reference\Tests\EntityReferenceTestTrait;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;

View file

@ -142,37 +142,6 @@ class VocabularyCrudTest extends TaxonomyTestBase {
$this->assertEqual($vocabulary->id(), $vocabulary2->id(), 'Vocabulary loaded successfully by name and ID.');
}
/**
* Tests that machine name changes are properly reflected.
*/
function testTaxonomyVocabularyChangeMachineName() {
// Add a field to the vocabulary.
entity_create('field_storage_config', array(
'field_name' => 'field_test',
'entity_type' => 'taxonomy_term',
'type' => 'test_field',
))->save();
entity_create('field_config', array(
'field_name' => 'field_test',
'entity_type' => 'taxonomy_term',
'bundle' => $this->vocabulary->id(),
))->save();
// Change the machine name.
$old_name = $this->vocabulary->id();
$new_name = Unicode::strtolower($this->randomMachineName());
$this->vocabulary->set('vid', $new_name);
$this->vocabulary->save();
// Check that entity bundles are properly updated.
$info = entity_get_bundles('taxonomy_term');
$this->assertFalse(isset($info[$old_name]), 'The old bundle name does not appear in entity_get_bundles().');
$this->assertTrue(isset($info[$new_name]), 'The new bundle name appears in entity_get_bundles().');
// Check that the field is still attached to the vocabulary.
$this->assertTrue(FieldConfig::loadByName('taxonomy_term', $new_name, 'field_test'), 'The bundle name was updated correctly.');
}
/**
* Test uninstall and reinstall of the taxonomy module.
*/

View file

@ -14,6 +14,12 @@ namespace Drupal\taxonomy\Tests;
*/
class VocabularyPermissionsTest extends TaxonomyTestBase {
protected function setUp() {
parent::setUp();
$this->drupalPlaceBlock('page_title_block');
}
/**
* Create, edit and delete a taxonomy term via the user interface.
*/

View file

@ -30,6 +30,7 @@ class VocabularyUiTest extends TaxonomyTestBase {
$this->drupalLogin($this->drupalCreateUser(['administer taxonomy']));
$this->vocabulary = $this->createVocabulary();
$this->drupalPlaceBlock('local_actions_block');
$this->drupalPlaceBlock('page_title_block');
}
/**

View file

@ -7,18 +7,17 @@
namespace Drupal\taxonomy;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\BundleEntityFormBase;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\taxonomy\VocabularyStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Base form for vocabulary edit forms.
*/
class VocabularyForm extends EntityForm {
class VocabularyForm extends BundleEntityFormBase {
/**
* The vocabulary storage.
@ -112,7 +111,8 @@ class VocabularyForm extends EntityForm {
'#value' => '0',
);
return parent::form($form, $form_state, $vocabulary);
$form = parent::form($form, $form_state);
return $this->protectBundleIdElement($form);
}
/**
@ -147,14 +147,14 @@ class VocabularyForm extends EntityForm {
/**
* Determines if the vocabulary already exists.
*
* @param string $id
* The vocabulary ID
* @param string $vid
* The vocabulary ID.
*
* @return bool
* TRUE if the vocabulary exists, FALSE otherwise.
*/
public function exists($id) {
$action = $this->vocabularyStorage->load($id);
public function exists($vid) {
$action = $this->vocabularyStorage->load($vid);
return !empty($action);
}

View file

@ -83,7 +83,7 @@ class VocabularyListBuilder extends DraggableListBuilder {
unset($this->weightKey);
}
$build = parent::render();
$build['table']['#empty'] = t('No vocabularies available. <a href="@link">Add vocabulary</a>.', array('@link' => \Drupal::url('entity.taxonomy_vocabulary.add_form')));
$build['table']['#empty'] = t('No vocabularies available. <a href=":link">Add vocabulary</a>.', array(':link' => \Drupal::url('entity.taxonomy_vocabulary.add_form')));
return $build;
}

View file

@ -5,7 +5,6 @@ package: Core
version: VERSION
core: 8.x
dependencies:
- entity_reference
- node
- text
configure: entity.taxonomy_vocabulary.collection

View file

@ -41,20 +41,20 @@ function taxonomy_help($route_name, RouteMatchInterface $route_match) {
$field_ui_url = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#';
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Taxonomy module allows users who have permission to create and edit content to categorize (tag) content of that type. Users who have the <em>Administer vocabularies and terms</em> <a href="!permissions" title="Taxonomy module permissions">permission</a> can add <em>vocabularies</em> that contain a set of related <em>terms</em>. The terms in a vocabulary can either be pre-set by an administrator or built gradually as content is added and edited. Terms may be organized hierarchically if desired.', array('!permissions' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-taxonomy')))) . '</p>';
$output .= '<p>' . t('For more information, see the <a href="!taxonomy">online documentation for the Taxonomy module</a>.', array('!taxonomy' => 'https://www.drupal.org/documentation/modules/taxonomy/')) . '</p>';
$output .= '<p>' . t('The Taxonomy module allows users who have permission to create and edit content to categorize (tag) content of that type. Users who have the <em>Administer vocabularies and terms</em> <a href=":permissions" title="Taxonomy module permissions">permission</a> can add <em>vocabularies</em> that contain a set of related <em>terms</em>. The terms in a vocabulary can either be pre-set by an administrator or built gradually as content is added and edited. Terms may be organized hierarchically if desired.', array(':permissions' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-taxonomy')))) . '</p>';
$output .= '<p>' . t('For more information, see the <a href=":taxonomy">online documentation for the Taxonomy module</a>.', array(':taxonomy' => 'https://www.drupal.org/documentation/modules/taxonomy/')) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing vocabularies') . '</dt>';
$output .= '<dd>' . t('Users who have the <em>Administer vocabularies and terms</em> permission can add and edit vocabularies from the <a href="!taxonomy_admin">Taxonomy administration page</a>. Vocabularies can be deleted from their <em>Edit vocabulary</em> page. Users with the <em>Taxonomy term: Administer fields</em> permission may add additional fields for terms in that vocabulary using the <a href="!field_ui">Field UI module</a>.' , array('!taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'), '!field_ui' => $field_ui_url)) . '</dd>';
$output .= '<dd>' . t('Users who have the <em>Administer vocabularies and terms</em> permission can add and edit vocabularies from the <a href=":taxonomy_admin">Taxonomy administration page</a>. Vocabularies can be deleted from their <em>Edit vocabulary</em> page. Users with the <em>Taxonomy term: Administer fields</em> permission may add additional fields for terms in that vocabulary using the <a href=":field_ui">Field UI module</a>.' , array(':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'), ':field_ui' => $field_ui_url)) . '</dd>';
$output .= '<dt>' . t('Managing terms') . '</dt>';
$output .= '<dd>' . t('Users who have the <em>Administer vocabularies and terms</em> permission or the <em>Edit terms</em> permission for a particular vocabulary can add, edit, and organize the terms in a vocabulary from a vocabulary\'s term listing page, which can be accessed by going to the <a href="!taxonomy_admin">Taxonomy administration page</a> and clicking <em>List terms</em> in the <em>Operations</em> column. Users must have the <em>Administer vocabularies and terms</em> permission or the <em>Delete terms</em> permission for a particular vocabulary to delete terms.' , array('!taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'))) . ' </dd>';
$output .= '<dd>' . t('Users who have the <em>Administer vocabularies and terms</em> permission or the <em>Edit terms</em> permission for a particular vocabulary can add, edit, and organize the terms in a vocabulary from a vocabulary\'s term listing page, which can be accessed by going to the <a href=":taxonomy_admin">Taxonomy administration page</a> and clicking <em>List terms</em> in the <em>Operations</em> column. Users must have the <em>Administer vocabularies and terms</em> permission or the <em>Delete terms</em> permission for a particular vocabulary to delete terms.' , array(':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'))) . ' </dd>';
$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.' , array('!field_ui' => $field_ui_url, '!field' => \Drupal::url('help.page', array('name' => 'field')), '!entity_reference' => \Drupal::url('help.page', array('name' => 'entity_reference')))) . '</dd>';
$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.' , array(':field_ui' => $field_ui_url, ':field' => \Drupal::url('help.page', array('name' => 'field')), ':entity_reference' => \Drupal::url('help.page', array('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 .= '<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.', array('!entity_reference' => \Drupal::url('help.page', array('name' => 'entity_reference')))) . '</li>';
$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.', array(':entity_reference' => \Drupal::url('help.page', array('name' => 'entity_reference')))) . '</li>';
$output .= '</ul>';
$output .= '</dd>';
$output .= '</dl>';
@ -501,9 +501,12 @@ function taxonomy_build_node_index($node) {
if ($status && $node->isDefaultRevision()) {
// Collect a unique list of all the term IDs from all node fields.
$tid_all = array();
$entity_reference_class = 'Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem';
foreach ($node->getFieldDefinitions() as $field) {
$field_name = $field->getName();
if (is_subclass_of($field->getItemDefinition()->getClass(), '\Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem') && $field->getSetting('target_type') == 'taxonomy_term') {
$class = $field->getItemDefinition()->getClass();
$is_entity_reference_class = ($class === $entity_reference_class) || is_subclass_of($class, $entity_reference_class);
if ($is_entity_reference_class && $field->getSetting('target_type') == 'taxonomy_term') {
foreach ($node->getTranslationLanguages() as $language) {
foreach ($node->getTranslation($language->getId())->$field_name as $item) {
if (!$item->isEmpty()) {

View file

@ -5,8 +5,6 @@
* Builds placeholder replacement tokens for taxonomy terms and vocabularies.
*/
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\taxonomy\Entity\Vocabulary;
@ -97,7 +95,6 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable
$token_service = \Drupal::token();
$replacements = array();
$sanitize = !empty($options['sanitize']);
$taxonomy_storage = \Drupal::entityManager()->getStorage('taxonomy_term');
if ($type == 'term' && !empty($data['term'])) {
$term = $data['term'];
@ -109,11 +106,13 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable
break;
case 'name':
$replacements[$original] = $sanitize ? Html::escape($term->getName()) : $term->getName();
$replacements[$original] = $term->getName();
break;
case 'description':
$replacements[$original] = $sanitize ? $term->description->processed : $term->getDescription();
// "processed" returns a \Drupal\Component\Render\MarkupInterface via
// check_markup().
$replacements[$original] = $term->description->processed;
break;
case 'url':
@ -131,14 +130,14 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable
case 'vocabulary':
$vocabulary = Vocabulary::load($term->bundle());
$bubbleable_metadata->addCacheableDependency($vocabulary);
$replacements[$original] = Html::escape($vocabulary->label());
$replacements[$original] = $vocabulary->label();
break;
case 'parent':
if ($parents = $taxonomy_storage->loadParents($term->id())) {
$parent = array_pop($parents);
$bubbleable_metadata->addCacheableDependency($parent);
$replacements[$original] = Html::escape($parent->getName());
$replacements[$original] = $parent->getName();
}
break;
}
@ -165,11 +164,13 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable
break;
case 'name':
$replacements[$original] = $sanitize ? Html::escape($vocabulary->label()) : $vocabulary->label();
$replacements[$original] = $vocabulary->label();
break;
case 'description':
$replacements[$original] = $sanitize ? Xss::filter($vocabulary->getDescription()) : $vocabulary->getDescription();
$build = ['#markup' => $vocabulary->getDescription()];
// @todo Fix in https://www.drupal.org/node/2577827
$replacements[$original] = \Drupal::service('renderer')->renderPlain($build);
break;
case 'term-count':

View file

@ -61,10 +61,10 @@ display:
offset: false
offset_label: Offset
tags:
previous: ' previous'
next: 'next '
first: first'
last: 'last »'
previous: ' Previous'
next: 'Next '
first: First'
last: 'Last »'
quantity: 9
style:
type: default
@ -165,7 +165,7 @@ display:
- url.query_args
- 'user.node_grants:view'
- user.permissions
cacheable: false
max-age: 0
page_1:
display_plugin: page
id: page_1
@ -255,4 +255,4 @@ display:
- url.query_args
- 'user.node_grants:view'
- user.permissions
cacheable: false
max-age: 0

View file

@ -60,10 +60,10 @@ display:
offset: false
offset_label: Offset
tags:
previous: ' previous'
next: 'next '
first: first'
last: 'last »'
previous: ' Previous'
next: 'Next '
first: First'
last: 'Last »'
quantity: 9
style:
type: default
@ -163,3 +163,10 @@ display:
entity_type: taxonomy_term
entity_field: tid
rendering_language: '***LANGUAGE_entity_translation***'
page_1:
display_plugin: page
id: page_1
display_title: Page
position: null
display_options:
path: taxonomy_default_argument_test

View file

@ -0,0 +1,227 @@
langcode: en
status: true
dependencies:
module:
- node
- taxonomy
- user
id: test_argument_taxonomy_index_tid_depth
label: test_argument_taxonomy_index_tid_depth
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: full
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ' Previous'
next: 'Next '
first: '« First'
last: 'Last »'
quantity: 9
style:
type: default
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
row:
type: fields
options:
inline: { }
separator: ''
hide_empty: false
default_field_elements: true
fields:
title:
id: title
table: node_field_data
field: title
entity_type: node
entity_field: title
label: ''
alter:
alter_text: false
make_link: false
absolute: false
trim: false
word_boundary: false
ellipsis: false
strip_tags: false
html: false
hide_empty: false
empty_zero: false
settings:
link_to_entity: true
plugin_id: field
relationship: none
group_type: group
admin_label: ''
exclude: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_alter_empty: true
click_sort_column: value
type: string
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
filters:
status:
value: true
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
group: 1
sorts:
created:
id: created
table: node_field_data
field: created
order: DESC
entity_type: node
entity_field: created
plugin_id: date
relationship: none
group_type: group
admin_label: ''
exposed: false
expose:
label: ''
granularity: second
header: { }
footer: { }
empty: { }
relationships: { }
arguments:
term_node_tid_depth:
id: term_node_tid_depth
table: node_field_data
field: term_node_tid_depth
relationship: none
group_type: group
admin_label: ''
default_action: ignore
exception:
value: all
title_enable: false
title: All
title_enable: true
title: '{{ arguments.term_node_tid_depth }}'
default_argument_type: fixed
default_argument_options:
argument: ''
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
items_per_page: 25
override: false
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
depth: 0
break_phrase: false
use_taxonomy_term_path: false
entity_type: node
plugin_id: taxonomy_index_tid_depth
display_extenders: { }
cache_metadata:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- 'user.node_grants:view'
- user.permissions
cacheable: false
page_1:
display_plugin: page
id: page_1
display_title: Page
position: 1
display_options:
display_extenders: { }
path: test_argument_taxonomy_index_tid_depth
cache_metadata:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- 'user.node_grants:view'
- user.permissions
cacheable: false

View file

@ -61,10 +61,10 @@ display:
offset: false
offset_label: Offset
tags:
previous: ' previous'
next: 'next '
first: first'
last: 'last »'
previous: ' Previous'
next: 'Next '
first: First'
last: 'Last »'
quantity: 9
style:
type: default

View file

@ -61,10 +61,10 @@ display:
offset: false
offset_label: Offset
tags:
previous: ' previous'
next: 'next '
first: first'
last: 'last »'
previous: ' Previous'
next: 'Next '
first: First'
last: 'Last »'
quantity: 9
style:
type: default

View file

@ -60,10 +60,10 @@ display:
offset: false
offset_label: Offset
tags:
previous: ' previous'
next: 'next '
first: first'
last: 'last »'
previous: ' Previous'
next: 'Next '
first: First'
last: 'Last »'
quantity: 9
style:
type: default

View file

@ -60,10 +60,10 @@ display:
offset: false
offset_label: Offset
tags:
previous: ' previous'
next: 'next '
first: first'
last: 'last »'
previous: ' Previous'
next: 'Next '
first: First'
last: 'Last »'
quantity: 9
style:
type: default

View file

@ -61,10 +61,10 @@ display:
offset: false
offset_label: Offset
tags:
previous: ' previous'
next: 'next '
first: first'
last: 'last »'
previous: ' Previous'
next: 'Next '
first: First'
last: 'Last »'
quantity: 9
style:
type: default
@ -199,4 +199,4 @@ display:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
cacheable: false
max-age: 0

View file

@ -60,10 +60,10 @@ display:
offset: false
offset_label: Offset
tags:
previous: ' previous'
next: 'next '
first: first'
last: 'last »'
previous: ' Previous'
next: 'Next '
first: First'
last: 'Last »'
quantity: 9
style:
type: default

View file

@ -2,13 +2,13 @@
/**
* @file
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\d6\TermSourceWithVocabularyFilterTest.
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\TermSourceWithVocabularyFilterTest.
*/
namespace Drupal\Tests\taxonomy\Unit\Migrate\d6;
namespace Drupal\Tests\taxonomy\Unit\Migrate;
/**
* Tests the Drupal 6 taxonomy term source with vocabulary filter.
* Tests the taxonomy term source with vocabulary filter.
*
* @group taxonomy
*/

View file

@ -0,0 +1,17 @@
<?php
/**
* @file
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\TermTest.
*/
namespace Drupal\Tests\taxonomy\Unit\Migrate;
/**
* Tests taxonomy term source plugin.
*
* @group taxonomy
*/
class TermTest extends TermTestBase {
}

View file

@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\d6\TermTestBase.
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\TermTestBase.
*/
namespace Drupal\Tests\taxonomy\Unit\Migrate\d6;
namespace Drupal\Tests\taxonomy\Unit\Migrate;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
@ -14,7 +14,7 @@ use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
*/
abstract class TermTestBase extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\taxonomy\Plugin\migrate\source\d6\Term';
const PLUGIN_CLASS = 'Drupal\taxonomy\Plugin\migrate\source\Term';
protected $migrationConfiguration = array(
'id' => 'test',

View file

@ -0,0 +1,105 @@
<?php
/**
* @file
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\d6\TermNodeTest.
*/
namespace Drupal\Tests\taxonomy\Unit\Migrate\d6;
use Drupal\taxonomy\Plugin\migrate\source\d6\TermNode;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests d6_term_node source plugin.
*
* @group taxonomy
*/
class TermNodeTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = TermNode::class;
protected $migrationConfiguration = array(
'id' => 'test',
'source' => array(
'plugin' => 'd6_term_node',
'vid' => 3,
),
);
protected $expectedResults = array(
array(
'nid' => 1,
'vid' => 1,
'type' => 'story',
'tid' => array(1, 4, 5),
),
);
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->databaseContents['term_node'] = array(
array(
'nid' => '1',
'vid' => '1',
'tid' => '1',
),
array(
'nid' => '1',
'vid' => '1',
'tid' => '4',
),
array(
'nid' => '1',
'vid' => '1',
'tid' => '5',
),
);
$this->databaseContents['node'] = array(
array(
'nid' => '1',
'vid' => '1',
'type' => 'story',
'language' => '',
'title' => 'Test title',
'uid' => '1',
'status' => '1',
'created' => '1388271197',
'changed' => '1420861423',
'comment' => '0',
'promote' => '0',
'moderate' => '0',
'sticky' => '0',
'tnid' => '0',
'translate' => '0',
),
);
$this->databaseContents['term_data'] = array(
array(
'tid' => '1',
'vid' => '3',
'name' => 'term 1 of vocabulary 3',
'description' => 'description of term 1 of vocabulary 3',
'weight' => '0',
),
array(
'tid' => '4',
'vid' => '3',
'name' => 'term 4 of vocabulary 3',
'description' => 'description of term 4 of vocabulary 3',
'weight' => '6',
),
array(
'tid' => '5',
'vid' => '3',
'name' => 'term 5 of vocabulary 3',
'description' => 'description of term 5 of vocabulary 3',
'weight' => '7',
),
);
parent::setUp();
}
}

View file

@ -1,17 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\d6\TermTest.
*/
namespace Drupal\Tests\taxonomy\Unit\Migrate\d6;
/**
* Tests D6 taxonomy term source plugin.
*
* @group taxonomy
*/
class TermTest extends TermTestBase {
}

View file

@ -18,9 +18,7 @@ class VocabularyTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary';
// The fake Migration configuration entity.
protected $migrationConfiguration = [
// The ID of the entity, can be any string.
'id' => 'test',
'source' => [
'plugin' => 'd6_vocabulary',

View file

@ -0,0 +1,57 @@
<?php
/**
* @file
* Contains \Drupal\Tests\taxonomy\Unit\Migrate\d7\VocabularyTest.
*/
namespace Drupal\Tests\taxonomy\Unit\Migrate\d7;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D7 vocabulary source plugin.
*
* @group taxonomy
*/
class VocabularyTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\taxonomy\Plugin\migrate\source\d7\Vocabulary';
protected $migrationConfiguration = [
'id' => 'test',
'source' => [
'plugin' => 'd7_vocabulary',
],
];
protected $expectedResults = [
[
'vid' => 1,
'name' => 'Tags',
'description' => 'Tags description.',
'hierarchy' => 0,
'module' => 'taxonomy',
'weight' => 0,
'machine_name' => 'tags',
],
[
'vid' => 2,
'name' => 'Categories',
'description' => 'Categories description.',
'hierarchy' => 1,
'module' => 'taxonomy',
'weight' => 0,
'machine_name' => 'categories',
],
];
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->databaseContents['taxonomy_vocabulary'] = $this->expectedResults;
parent::setUp();
}
}