Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes
This commit is contained in:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Controller\TaxonomyController.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Controller;
|
||||
|
||||
use Drupal\Component\Utility\Xss;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Entity\Term.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Entity;
|
||||
|
||||
use Drupal\Core\Entity\ContentEntityBase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Entity\Vocabulary.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Entity;
|
||||
|
||||
use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Form\OverviewTerms.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Form;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Form\TermDeleteForm.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Form;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Form\VocabularyDeleteForm.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Form;
|
||||
|
||||
use Drupal\Core\Entity\EntityDeleteForm;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Form\VocabularyResetForm.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Form;
|
||||
|
||||
use Drupal\Core\Entity\EntityConfirmFormBase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\EntityReferenceSelection\TermSelection.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\EntityReferenceSelection;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
|
@ -39,13 +34,7 @@ class TermSelection extends DefaultSelection {
|
|||
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
|
||||
$form = parent::buildConfigurationForm($form, $form_state);
|
||||
|
||||
$form['target_bundles']['#title'] = $this->t('Vocabularies');
|
||||
// @todo: Currently allow auto-create only on taxonomy terms.
|
||||
$form['auto_create'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t("Create referenced entities if they don't already exist"),
|
||||
'#default_value' => isset($this->configuration['handler_settings']['auto_create']) ? $this->configuration['handler_settings']['auto_create'] : FALSE,
|
||||
);
|
||||
$form['target_bundles']['#title'] = $this->t('Available Vocabularies');
|
||||
|
||||
// Sorting is not possible for taxonomy terms because we use
|
||||
// \Drupal\taxonomy\TermStorageInterface::loadTree() to retrieve matches.
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\Field\FieldFormatter\EntityReferenceTaxonomyTermRssFormatter.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\migrate;
|
||||
|
||||
use Drupal\Component\Plugin\Derivative\DeriverBase;
|
||||
use Drupal\Component\Plugin\PluginManagerInterface;
|
||||
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
|
||||
use Drupal\migrate\Plugin\MigrationDeriverTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Deriver for Drupal 6 term node migrations based on vocabularies.
|
||||
*/
|
||||
class D6TermNodeDeriver extends DeriverBase implements ContainerDeriverInterface {
|
||||
use MigrationDeriverTrait;
|
||||
|
||||
/**
|
||||
* The base plugin ID this derivative is for.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $basePluginId;
|
||||
|
||||
/**
|
||||
* The migration plugin manager.
|
||||
*
|
||||
* @var \Drupal\Component\Plugin\PluginManagerInterface
|
||||
*/
|
||||
protected $migrationPluginManager;
|
||||
|
||||
/**
|
||||
* D6TermNodeDeriver constructor.
|
||||
*
|
||||
* @param string $base_plugin_id
|
||||
* The base plugin ID this derivative is for.
|
||||
* @param \Drupal\Component\Plugin\PluginManagerInterface $migration_plugin_manager
|
||||
* The migration plugin manager.
|
||||
*/
|
||||
public function __construct($base_plugin_id, PluginManagerInterface $migration_plugin_manager) {
|
||||
$this->basePluginId = $base_plugin_id;
|
||||
$this->migrationPluginManager = $migration_plugin_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, $base_plugin_id) {
|
||||
return new static(
|
||||
$base_plugin_id,
|
||||
$container->get('plugin.manager.migration')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDerivativeDefinitions($base_plugin_definition, $base_plugin_definitions = NULL) {
|
||||
try {
|
||||
foreach (static::getSourcePlugin('d6_taxonomy_vocabulary') as $row) {
|
||||
$source_vid = $row->getSourceProperty('vid');
|
||||
$definition = $base_plugin_definition;
|
||||
$definition['source']['vid'] = $source_vid;
|
||||
// migrate_drupal_migration_plugins_alter() adds to this definition.
|
||||
$this->derivatives[$source_vid] = $definition;
|
||||
}
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
// It is possible no D6 tables are loaded so just eat exceptions.
|
||||
}
|
||||
return $this->derivatives;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\migrate\builder\d6\TermNode.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\migrate\builder\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\migrate\MigrateMessage;
|
||||
use Drupal\migrate\MigrateTemplateStorageInterface;
|
||||
use Drupal\migrate\Plugin\migrate\builder\BuilderBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @PluginID("d6_term_node")
|
||||
*/
|
||||
class TermNode extends BuilderBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The migration template storage service.
|
||||
*
|
||||
* @var \Drupal\migrate\MigrateTemplateStorage
|
||||
*/
|
||||
protected $templateStorage;
|
||||
|
||||
/**
|
||||
* Constructs a TermNode builder.
|
||||
*
|
||||
* @param array $configuration
|
||||
* Plugin configuration.
|
||||
* @param string $plugin_id
|
||||
* The plugin ID.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin definition.
|
||||
* @param \Drupal\migrate\MigrateTemplateStorageInterface $template_storage
|
||||
* The migration template storage handler.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrateTemplateStorageInterface $template_storage) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->templateStorage = $template_storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('migrate.template_storage')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a map of source vocabulary IDs to expected destination IDs.
|
||||
*
|
||||
* @param array $source
|
||||
* Additional configuration for the d6_taxonomy_vocabulary source.
|
||||
*
|
||||
* @return array
|
||||
* The vid map. The keys are the source IDs and the values are the
|
||||
* (expected) destination IDs.
|
||||
*/
|
||||
protected function getVocabularyIdMap(array $source) {
|
||||
$map = [];
|
||||
|
||||
$template = $this->templateStorage->getTemplateByName('d6_taxonomy_vocabulary');
|
||||
$template['source'] += $source;
|
||||
|
||||
$migration = Migration::create($template);
|
||||
$executable = new MigrateExecutable($migration, new MigrateMessage());
|
||||
// Only process the destination ID properties.
|
||||
$process = array_intersect_key($template['process'], $migration->getDestinationPlugin()->getIds());
|
||||
|
||||
foreach ($migration->getSourcePlugin() as $source_row) {
|
||||
// Process the row to generate the expected destination ID.
|
||||
$executable->processRow($source_row, $process);
|
||||
$map[$source_row->getSourceProperty('vid')] = $source_row->getDestinationProperty('vid');
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildMigrations(array $template) {
|
||||
$migrations = [];
|
||||
|
||||
foreach ($this->getVocabularyIdMap($template['source']) as $source_vid => $destination_vid) {
|
||||
$values = $template;
|
||||
$values['id'] .= '__' . $source_vid;
|
||||
$values['source']['vid'] = $source_vid;
|
||||
$migration = Migration::create($values);
|
||||
$migration->setProcessOfProperty($destination_vid, 'tid');
|
||||
$migrations[] = $migration;
|
||||
}
|
||||
|
||||
return $migrations;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +1,8 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\migrate\cckfield\TaxonomyTermReference.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\migrate\cckfield;
|
||||
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\migrate\source\Term.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\migrate\source\d6\TermNode.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\migrate\source\d6\TermNodeRevision.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\migrate\source\d6\VocabularyPerType.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?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;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\argument\IndexTid.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\argument;
|
||||
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\argument\IndexTidDepth.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\argument;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\argument\IndexTidDepthModifier.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\argument;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\argument\Taxonomy.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\argument;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\argument\VocabularyVid.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\argument;
|
||||
|
||||
use Drupal\views\Plugin\views\argument\NumericArgument;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\argument_default\Tid.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\argument_default;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\argument_validator\Term.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\argument_validator;
|
||||
|
||||
use Drupal\views\ViewExecutable;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\argument_validator\TermName.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\argument_validator;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\field\TaxonomyIndexTid.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\field;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\field\TermName.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\field;
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\filter;
|
||||
|
||||
use Drupal\Core\Entity\Element\EntityAutocomplete;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTidDepth.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\filter;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\relationship\NodeTermData.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\relationship;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\views\wizard\TaxonomyTerm.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\views\wizard;
|
||||
|
||||
use Drupal\views\Plugin\views\wizard\WizardPluginBase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\TaxonomyPermissions.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\TermAccessControlHandler.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy;
|
||||
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\TermBreadcrumbBuilder.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy;
|
||||
|
||||
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\TermForm.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy;
|
||||
|
||||
use Drupal\Core\Entity\ContentEntityForm;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\TermInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy;
|
||||
|
||||
use Drupal\Core\Entity\ContentEntityInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\TermStorage.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy;
|
||||
|
||||
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\TermStorageInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy;
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\TermStorageSchema.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy;
|
||||
|
||||
use Drupal\Core\Entity\ContentEntityTypeInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\TermTranslationHandler.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy;
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\TermViewBuilder.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy;
|
||||
|
||||
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\TermViewsData.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy;
|
||||
|
||||
use Drupal\views\EntityViewsData;
|
||||
|
@ -20,7 +15,7 @@ class TermViewsData extends EntityViewsData {
|
|||
public function getViewsData() {
|
||||
$data = parent::getViewsData();
|
||||
|
||||
$data['taxonomy_term_field_data']['table']['base']['help'] = t('Taxonomy terms are attached to nodes.');
|
||||
$data['taxonomy_term_field_data']['table']['base']['help'] = $this->t('Taxonomy terms are attached to nodes.');
|
||||
$data['taxonomy_term_field_data']['table']['base']['access query tag'] = 'term_access';
|
||||
$data['taxonomy_term_field_data']['table']['wizard_id'] = 'taxonomy_term';
|
||||
|
||||
|
@ -32,21 +27,21 @@ class TermViewsData extends EntityViewsData {
|
|||
),
|
||||
);
|
||||
|
||||
$data['taxonomy_term_field_data']['tid']['help'] = t('The tid of a taxonomy term.');
|
||||
$data['taxonomy_term_field_data']['tid']['help'] = $this->t('The tid of a taxonomy term.');
|
||||
|
||||
$data['taxonomy_term_field_data']['tid']['argument']['id'] = 'taxonomy';
|
||||
$data['taxonomy_term_field_data']['tid']['argument']['name field'] = 'name';
|
||||
$data['taxonomy_term_field_data']['tid']['argument']['zero is null'] = TRUE;
|
||||
|
||||
$data['taxonomy_term_field_data']['tid']['filter']['id'] = 'taxonomy_index_tid';
|
||||
$data['taxonomy_term_field_data']['tid']['filter']['title'] = t('Term');
|
||||
$data['taxonomy_term_field_data']['tid']['filter']['help'] = t('Taxonomy term chosen from autocomplete or select widget.');
|
||||
$data['taxonomy_term_field_data']['tid']['filter']['title'] = $this->t('Term');
|
||||
$data['taxonomy_term_field_data']['tid']['filter']['help'] = $this->t('Taxonomy term chosen from autocomplete or select widget.');
|
||||
$data['taxonomy_term_field_data']['tid']['filter']['hierarchy table'] = 'taxonomy_term_hierarchy';
|
||||
$data['taxonomy_term_field_data']['tid']['filter']['numeric'] = TRUE;
|
||||
|
||||
$data['taxonomy_term_field_data']['tid_raw'] = array(
|
||||
'title' => t('Term ID'),
|
||||
'help' => t('The tid of a taxonomy term.'),
|
||||
'title' => $this->t('Term ID'),
|
||||
'help' => $this->t('The tid of a taxonomy term.'),
|
||||
'real field' => 'tid',
|
||||
'filter' => array(
|
||||
'id' => 'numeric',
|
||||
|
@ -56,9 +51,9 @@ class TermViewsData extends EntityViewsData {
|
|||
|
||||
$data['taxonomy_term_field_data']['tid_representative'] = array(
|
||||
'relationship' => array(
|
||||
'title' => t('Representative node'),
|
||||
'label' => t('Representative node'),
|
||||
'help' => t('Obtains a single representative node for each term, according to a chosen sort criterion.'),
|
||||
'title' => $this->t('Representative node'),
|
||||
'label' => $this->t('Representative node'),
|
||||
'help' => $this->t('Obtains a single representative node for each term, according to a chosen sort criterion.'),
|
||||
'id' => 'groupwise_max',
|
||||
'relationship field' => 'tid',
|
||||
'outer field' => 'taxonomy_term_field_data.tid',
|
||||
|
@ -70,23 +65,23 @@ class TermViewsData extends EntityViewsData {
|
|||
),
|
||||
);
|
||||
|
||||
$data['taxonomy_term_field_data']['vid']['help'] = t('Filter the results of "Taxonomy: Term" to a particular vocabulary.');
|
||||
$data['taxonomy_term_field_data']['vid']['help'] = $this->t('Filter the results of "Taxonomy: Term" to a particular vocabulary.');
|
||||
unset($data['taxonomy_term_field_data']['vid']['field']);
|
||||
unset($data['taxonomy_term_field_data']['vid']['argument']);
|
||||
unset($data['taxonomy_term_field_data']['vid']['sort']);
|
||||
|
||||
$data['taxonomy_term_field_data']['name']['field']['id'] = 'term_name';
|
||||
$data['taxonomy_term_field_data']['name']['argument']['many to one'] = TRUE;
|
||||
$data['taxonomy_term_field_data']['name']['argument']['empty field name'] = t('Uncategorized');
|
||||
$data['taxonomy_term_field_data']['name']['argument']['empty field name'] = $this->t('Uncategorized');
|
||||
|
||||
$data['taxonomy_term_field_data']['description__value']['field']['click sortable'] = FALSE;
|
||||
|
||||
$data['taxonomy_term_field_data']['changed']['title'] = t('Updated date');
|
||||
$data['taxonomy_term_field_data']['changed']['help'] = t('The date the term was last updated.');
|
||||
$data['taxonomy_term_field_data']['changed']['title'] = $this->t('Updated date');
|
||||
$data['taxonomy_term_field_data']['changed']['help'] = $this->t('The date the term was last updated.');
|
||||
|
||||
$data['taxonomy_term_field_data']['changed_fulldate'] = array(
|
||||
'title' => t('Updated date'),
|
||||
'help' => t('Date in the form of CCYYMMDD.'),
|
||||
'title' => $this->t('Updated date'),
|
||||
'help' => $this->t('Date in the form of CCYYMMDD.'),
|
||||
'argument' => array(
|
||||
'field' => 'changed',
|
||||
'id' => 'date_fulldate',
|
||||
|
@ -94,8 +89,8 @@ class TermViewsData extends EntityViewsData {
|
|||
);
|
||||
|
||||
$data['taxonomy_term_field_data']['changed_year_month'] = array(
|
||||
'title' => t('Updated year + month'),
|
||||
'help' => t('Date in the form of YYYYMM.'),
|
||||
'title' => $this->t('Updated year + month'),
|
||||
'help' => $this->t('Date in the form of YYYYMM.'),
|
||||
'argument' => array(
|
||||
'field' => 'changed',
|
||||
'id' => 'date_year_month',
|
||||
|
@ -103,8 +98,8 @@ class TermViewsData extends EntityViewsData {
|
|||
);
|
||||
|
||||
$data['taxonomy_term_field_data']['changed_year'] = array(
|
||||
'title' => t('Updated year'),
|
||||
'help' => t('Date in the form of YYYY.'),
|
||||
'title' => $this->t('Updated year'),
|
||||
'help' => $this->t('Date in the form of YYYY.'),
|
||||
'argument' => array(
|
||||
'field' => 'changed',
|
||||
'id' => 'date_year',
|
||||
|
@ -112,8 +107,8 @@ class TermViewsData extends EntityViewsData {
|
|||
);
|
||||
|
||||
$data['taxonomy_term_field_data']['changed_month'] = array(
|
||||
'title' => t('Updated month'),
|
||||
'help' => t('Date in the form of MM (01 - 12).'),
|
||||
'title' => $this->t('Updated month'),
|
||||
'help' => $this->t('Date in the form of MM (01 - 12).'),
|
||||
'argument' => array(
|
||||
'field' => 'changed',
|
||||
'id' => 'date_month',
|
||||
|
@ -121,8 +116,8 @@ class TermViewsData extends EntityViewsData {
|
|||
);
|
||||
|
||||
$data['taxonomy_term_field_data']['changed_day'] = array(
|
||||
'title' => t('Updated day'),
|
||||
'help' => t('Date in the form of DD (01 - 31).'),
|
||||
'title' => $this->t('Updated day'),
|
||||
'help' => $this->t('Date in the form of DD (01 - 31).'),
|
||||
'argument' => array(
|
||||
'field' => 'changed',
|
||||
'id' => 'date_day',
|
||||
|
@ -130,15 +125,15 @@ class TermViewsData extends EntityViewsData {
|
|||
);
|
||||
|
||||
$data['taxonomy_term_field_data']['changed_week'] = array(
|
||||
'title' => t('Updated week'),
|
||||
'help' => t('Date in the form of WW (01 - 53).'),
|
||||
'title' => $this->t('Updated week'),
|
||||
'help' => $this->t('Date in the form of WW (01 - 53).'),
|
||||
'argument' => array(
|
||||
'field' => 'changed',
|
||||
'id' => 'date_week',
|
||||
),
|
||||
);
|
||||
|
||||
$data['taxonomy_index']['table']['group'] = t('Taxonomy term');
|
||||
$data['taxonomy_index']['table']['group'] = $this->t('Taxonomy term');
|
||||
|
||||
$data['taxonomy_index']['table']['join'] = array(
|
||||
'taxonomy_term_field_data' => array(
|
||||
|
@ -158,13 +153,13 @@ class TermViewsData extends EntityViewsData {
|
|||
);
|
||||
|
||||
$data['taxonomy_index']['nid'] = array(
|
||||
'title' => t('Content with term'),
|
||||
'help' => t('Relate all content tagged with a term.'),
|
||||
'title' => $this->t('Content with term'),
|
||||
'help' => $this->t('Relate all content tagged with a term.'),
|
||||
'relationship' => array(
|
||||
'id' => 'standard',
|
||||
'base' => 'node',
|
||||
'base field' => 'nid',
|
||||
'label' => t('node'),
|
||||
'label' => $this->t('node'),
|
||||
'skip base' => 'node',
|
||||
),
|
||||
);
|
||||
|
@ -172,19 +167,19 @@ class TermViewsData extends EntityViewsData {
|
|||
// @todo This stuff needs to move to a node field since really it's all
|
||||
// about nodes.
|
||||
$data['taxonomy_index']['tid'] = array(
|
||||
'group' => t('Content'),
|
||||
'title' => t('Has taxonomy term ID'),
|
||||
'help' => t('Display content if it has the selected taxonomy terms.'),
|
||||
'group' => $this->t('Content'),
|
||||
'title' => $this->t('Has taxonomy term ID'),
|
||||
'help' => $this->t('Display content if it has the selected taxonomy terms.'),
|
||||
'argument' => array(
|
||||
'id' => 'taxonomy_index_tid',
|
||||
'name table' => 'taxonomy_term_field_data',
|
||||
'name field' => 'name',
|
||||
'empty field name' => t('Uncategorized'),
|
||||
'empty field name' => $this->t('Uncategorized'),
|
||||
'numeric' => TRUE,
|
||||
'skip base' => 'taxonomy_term_field_data',
|
||||
),
|
||||
'filter' => array(
|
||||
'title' => t('Has taxonomy term'),
|
||||
'title' => $this->t('Has taxonomy term'),
|
||||
'id' => 'taxonomy_index_tid',
|
||||
'hierarchy table' => 'taxonomy_term_hierarchy',
|
||||
'numeric' => TRUE,
|
||||
|
@ -194,32 +189,32 @@ class TermViewsData extends EntityViewsData {
|
|||
);
|
||||
|
||||
$data['taxonomy_index']['status'] = [
|
||||
'title' => t('Publish status'),
|
||||
'help' => t('Whether or not the content related to a term is published.'),
|
||||
'title' => $this->t('Publish status'),
|
||||
'help' => $this->t('Whether or not the content related to a term is published.'),
|
||||
'filter' => [
|
||||
'id' => 'boolean',
|
||||
'label' => t('Published status'),
|
||||
'label' => $this->t('Published status'),
|
||||
'type' => 'yes-no',
|
||||
],
|
||||
];
|
||||
|
||||
$data['taxonomy_index']['sticky'] = [
|
||||
'title' => t('Sticky status'),
|
||||
'help' => t('Whether or not the content related to a term is sticky.'),
|
||||
'title' => $this->t('Sticky status'),
|
||||
'help' => $this->t('Whether or not the content related to a term is sticky.'),
|
||||
'filter' => [
|
||||
'id' => 'boolean',
|
||||
'label' => t('Sticky status'),
|
||||
'label' => $this->t('Sticky status'),
|
||||
'type' => 'yes-no',
|
||||
],
|
||||
'sort' => [
|
||||
'id' => 'standard',
|
||||
'help' => t('Whether or not the content related to a term is sticky. To list sticky content first, set this to descending.'),
|
||||
'help' => $this->t('Whether or not the content related to a term is sticky. To list sticky content first, set this to descending.'),
|
||||
],
|
||||
];
|
||||
|
||||
$data['taxonomy_index']['created'] = [
|
||||
'title' => t('Post date'),
|
||||
'help' => t('The date the content related to a term was posted.'),
|
||||
'title' => $this->t('Post date'),
|
||||
'help' => $this->t('The date the content related to a term was posted.'),
|
||||
'sort' => [
|
||||
'id' => 'date'
|
||||
],
|
||||
|
@ -228,7 +223,7 @@ class TermViewsData extends EntityViewsData {
|
|||
],
|
||||
];
|
||||
|
||||
$data['taxonomy_term_hierarchy']['table']['group'] = t('Taxonomy term');
|
||||
$data['taxonomy_term_hierarchy']['table']['group'] = $this->t('Taxonomy term');
|
||||
$data['taxonomy_term_hierarchy']['table']['provider'] = 'taxonomy';
|
||||
|
||||
$data['taxonomy_term_hierarchy']['table']['join'] = array(
|
||||
|
@ -245,20 +240,20 @@ class TermViewsData extends EntityViewsData {
|
|||
);
|
||||
|
||||
$data['taxonomy_term_hierarchy']['parent'] = array(
|
||||
'title' => t('Parent term'),
|
||||
'help' => t('The parent term of the term. This can produce duplicate entries if you are using a vocabulary that allows multiple parents.'),
|
||||
'title' => $this->t('Parent term'),
|
||||
'help' => $this->t('The parent term of the term. This can produce duplicate entries if you are using a vocabulary that allows multiple parents.'),
|
||||
'relationship' => array(
|
||||
'base' => 'taxonomy_term_field_data',
|
||||
'field' => 'parent',
|
||||
'label' => t('Parent'),
|
||||
'label' => $this->t('Parent'),
|
||||
'id' => 'standard',
|
||||
),
|
||||
'filter' => array(
|
||||
'help' => t('Filter the results of "Taxonomy: Term" by the parent pid.'),
|
||||
'help' => $this->t('Filter the results of "Taxonomy: Term" by the parent pid.'),
|
||||
'id' => 'numeric',
|
||||
),
|
||||
'argument' => array(
|
||||
'help' => t('The parent term of the term.'),
|
||||
'help' => $this->t('The parent term of the term.'),
|
||||
'id' => 'taxonomy',
|
||||
),
|
||||
);
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\EfqTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\LegacyTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use \Drupal\taxonomy\Entity\Vocabulary;
|
||||
|
||||
/**
|
||||
* Posts an article with a taxonomy term and a date prior to 1970.
|
||||
|
@ -28,10 +24,10 @@ class LegacyTest extends TaxonomyTestBase {
|
|||
parent::setUp();
|
||||
|
||||
// Create a tags vocabulary for the 'article' content type.
|
||||
$vocabulary = entity_create('taxonomy_vocabulary', array(
|
||||
$vocabulary = Vocabulary::create([
|
||||
'name' => 'Tags',
|
||||
'vid' => 'tags',
|
||||
));
|
||||
]);
|
||||
$vocabulary->save();
|
||||
$field_name = 'field_' . $vocabulary->id();
|
||||
|
||||
|
@ -69,4 +65,5 @@ class LegacyTest extends TaxonomyTestBase {
|
|||
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
|
||||
$this->assertEqual($node->getCreatedTime(), $date->getTimestamp(), 'Legacy node was saved with the right date.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\LoadMultipleTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Migrate\MigrateTaxonomyConfigsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Migrate;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upgrade variables to taxonomy.settings.yml.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateTaxonomyConfigsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('taxonomy');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('taxonomy_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of taxonomy variables to taxonomy.settings.yml.
|
||||
*/
|
||||
public function testTaxonomySettings() {
|
||||
$config = $this->config('taxonomy.settings');
|
||||
$this->assertIdentical(100, $config->get('terms_per_page_admin'));
|
||||
$this->assertIdentical(FALSE, $config->get('override_selector'));
|
||||
$this->assertConfigSchema(\Drupal::service('config.typed'), 'taxonomy.settings', $config->get());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Migrate\MigrateTaxonomyTermStubTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Migrate;
|
||||
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase;
|
||||
use Drupal\migrate_drupal\Tests\StubTestTrait;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
|
||||
/**
|
||||
* Test stub creation for taxonomy terms.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class MigrateTaxonomyTermStubTest extends MigrateDrupalTestBase {
|
||||
|
||||
use StubTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy', 'text'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('taxonomy_term');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests creation of taxonomy term stubs.
|
||||
*/
|
||||
public function testStub() {
|
||||
Vocabulary::create([
|
||||
'vid' => 'test_vocabulary',
|
||||
'name' => 'Test vocabulary',
|
||||
])->save();
|
||||
$this->performStubTest('taxonomy_term');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests creation of stubs when weight is mapped.
|
||||
*/
|
||||
public function testStubWithWeightMapping() {
|
||||
// Create a vocabulary via migration for the terms to reference.
|
||||
$vocabulary_data_rows = [
|
||||
['id' => '1', 'name' => 'tags'],
|
||||
];
|
||||
$ids = ['id' => ['type' => 'integer']];
|
||||
$config = [
|
||||
'id' => 'vocabularies',
|
||||
'migration_tags' => ['Stub test'],
|
||||
'source' => [
|
||||
'plugin' => 'embedded_data',
|
||||
'data_rows' => $vocabulary_data_rows,
|
||||
'ids' => $ids,
|
||||
],
|
||||
'process' => [
|
||||
'vid' => 'id',
|
||||
'name' => 'name',
|
||||
],
|
||||
'destination' => ['plugin' => 'entity:taxonomy_vocabulary'],
|
||||
];
|
||||
$vocabulary_migration = Migration::create($config);
|
||||
$vocabulary_executable = new MigrateExecutable($vocabulary_migration, $this);
|
||||
$vocabulary_executable->import();
|
||||
|
||||
// We have a term referencing an unmigrated parent, forcing a stub to be
|
||||
// created.
|
||||
$term_data_rows = [
|
||||
['id' => '1', 'vocab' => '1', 'name' => 'music', 'parent' => '2'],
|
||||
];
|
||||
$ids = ['id' => ['type' => 'integer']];
|
||||
$config = [
|
||||
'id' => 'terms',
|
||||
'migration_tags' => ['Import and rollback test'],
|
||||
'source' => [
|
||||
'plugin' => 'embedded_data',
|
||||
'data_rows' => $term_data_rows,
|
||||
'ids' => $ids,
|
||||
],
|
||||
'process' => [
|
||||
'tid' => 'id',
|
||||
'vid' => 'vocab',
|
||||
'name' => 'name',
|
||||
'weight' => 'weight',
|
||||
'parent' => [
|
||||
'plugin' => 'migration',
|
||||
'migration' => 'terms',
|
||||
'source' => 'parent',
|
||||
],
|
||||
],
|
||||
'destination' => ['plugin' => 'entity:taxonomy_term'],
|
||||
'migration_dependencies' => ['required' => ['vocabularies']],
|
||||
];
|
||||
|
||||
$term_migration = Migration::create($config);
|
||||
$term_migration->save();
|
||||
$term_executable = new MigrateExecutable($term_migration, $this);
|
||||
$term_executable->import();
|
||||
// Load the referenced term, which should exist as a stub.
|
||||
/** @var \Drupal\Core\Entity\ContentEntityBase $stub_entity */
|
||||
$stub_entity = Term::load(2);
|
||||
$this->assertTrue($stub_entity, 'Stub successfully created');
|
||||
if ($stub_entity) {
|
||||
$this->assertIdentical(count($stub_entity->validate()), 0, 'Stub is a valid entity');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateTaxonomyTermTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upgrade taxonomy terms.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('taxonomy');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('taxonomy_term');
|
||||
$this->executeMigrations(['d6_taxonomy_vocabulary', 'd6_taxonomy_term']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Drupal 6 taxonomy term to Drupal 8 migration.
|
||||
*/
|
||||
public function testTaxonomyTerms() {
|
||||
$expected_results = array(
|
||||
'1' => array(
|
||||
'source_vid' => 1,
|
||||
'vid' => 'vocabulary_1_i_0_',
|
||||
'weight' => 0,
|
||||
'parent' => array(0),
|
||||
),
|
||||
'2' => array(
|
||||
'source_vid' => 2,
|
||||
'vid' => 'vocabulary_2_i_1_',
|
||||
'weight' => 3,
|
||||
'parent' => array(0),
|
||||
),
|
||||
'3' => array(
|
||||
'source_vid' => 2,
|
||||
'vid' => 'vocabulary_2_i_1_',
|
||||
'weight' => 4,
|
||||
'parent' => array(2),
|
||||
),
|
||||
'4' => array(
|
||||
'source_vid' => 3,
|
||||
'vid' => 'vocabulary_3_i_2_',
|
||||
'weight' => 6,
|
||||
'parent' => array(0),
|
||||
),
|
||||
'5' => array(
|
||||
'source_vid' => 3,
|
||||
'vid' => 'vocabulary_3_i_2_',
|
||||
'weight' => 7,
|
||||
'parent' => array(4),
|
||||
),
|
||||
'6' => array(
|
||||
'source_vid' => 3,
|
||||
'vid' => 'vocabulary_3_i_2_',
|
||||
'weight' => 8,
|
||||
'parent' => array(4, 5),
|
||||
),
|
||||
);
|
||||
$terms = Term::loadMultiple(array_keys($expected_results));
|
||||
foreach ($expected_results as $tid => $values) {
|
||||
/** @var Term $term */
|
||||
$term = $terms[$tid];
|
||||
$this->assertIdentical("term {$tid} of vocabulary {$values['source_vid']}", $term->name->value);
|
||||
$this->assertIdentical("description of term {$tid} of vocabulary {$values['source_vid']}", $term->description->value);
|
||||
$this->assertIdentical($values['vid'], $term->vid->target_id);
|
||||
$this->assertIdentical((string) $values['weight'], $term->weight->value);
|
||||
if ($values['parent'] === array(0)) {
|
||||
$this->assertNull($term->parent->target_id);
|
||||
}
|
||||
else {
|
||||
$parents = array();
|
||||
foreach (\Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid) as $parent) {
|
||||
$parents[] = (int) $parent->id();
|
||||
}
|
||||
$this->assertIdentical($parents, $values['parent']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateTaxonomyVocabularyTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Migrate taxonomy vocabularies to taxonomy.vocabulary.*.yml.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateTaxonomyVocabularyTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('taxonomy');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d6_taxonomy_vocabulary');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Drupal 6 taxonomy vocabularies to Drupal 8 migration.
|
||||
*/
|
||||
public function testTaxonomyVocabulary() {
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$j = $i + 1;
|
||||
$vocabulary = Vocabulary::load("vocabulary_{$j}_i_{$i}_");
|
||||
$this->assertIdentical(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());
|
||||
$this->assertIdentical(4 + $i, $vocabulary->get('weight'));
|
||||
}
|
||||
$vocabulary = Vocabulary::load('vocabulary_name_much_longer_than');
|
||||
$this->assertIdentical('vocabulary name much longer than thirty two characters', $vocabulary->label());
|
||||
$this->assertIdentical('description of vocabulary name much longer than thirty two characters', $vocabulary->getDescription());
|
||||
$this->assertIdentical(3, $vocabulary->getHierarchy());
|
||||
$this->assertIdentical(7, $vocabulary->get('weight'));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateTermNodeRevisionTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upgrade taxonomy term node associations.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateTermNodeRevisionTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('node', ['node_access']);
|
||||
$this->migrateContent(TRUE);
|
||||
$this->migrateTaxonomy();
|
||||
$this->executeMigrations(['d6_term_node:*', 'd6_term_node_revision:*']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Drupal 6 term-node revision association to Drupal 8 migration.
|
||||
*/
|
||||
public function testTermRevisionNode() {
|
||||
$node = \Drupal::entityManager()->getStorage('node')->loadRevision(2);
|
||||
$this->assertIdentical(2, count($node->vocabulary_3_i_2_));
|
||||
$this->assertIdentical('4', $node->vocabulary_3_i_2_[0]->target_id);
|
||||
$this->assertIdentical('5', $node->vocabulary_3_i_2_[1]->target_id);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateTermNodeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate\Plugin\MigrateIdMapInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
|
||||
/**
|
||||
* Upgrade taxonomy term node associations.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateTermNodeTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('node', ['node_access']);
|
||||
$this->migrateContent();
|
||||
$this->migrateTaxonomy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Drupal 6 term-node association to Drupal 8 migration.
|
||||
*/
|
||||
public function testTermNode() {
|
||||
$this->executeMigrations(['d6_term_node:*']);
|
||||
|
||||
$this->container->get('entity.manager')
|
||||
->getStorage('node')
|
||||
->resetCache([1, 2]);
|
||||
|
||||
$nodes = Node::loadMultiple([1, 2]);
|
||||
$node = $nodes[1];
|
||||
$this->assertIdentical(1, count($node->vocabulary_1_i_0_));
|
||||
$this->assertIdentical('1', $node->vocabulary_1_i_0_[0]->target_id);
|
||||
$node = $nodes[2];
|
||||
$this->assertIdentical(2, count($node->vocabulary_2_i_1_));
|
||||
$this->assertIdentical('2', $node->vocabulary_2_i_1_[0]->target_id);
|
||||
$this->assertIdentical('3', $node->vocabulary_2_i_1_[1]->target_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that term associations are ignored when they belong to nodes which
|
||||
* were not migrated.
|
||||
*/
|
||||
public function testSkipNonExistentNode() {
|
||||
// Node 2 is migrated by d6_node__story, but we need to pretend that it
|
||||
// failed, so record that in the map table.
|
||||
$this->mockFailure('d6_node__story', ['nid' => 2]);
|
||||
|
||||
// d6_term_node__2 should skip over node 2 (a.k.a. revision 3) because,
|
||||
// according to the map table, it failed.
|
||||
$migration = Migration::load('d6_term_node__2');
|
||||
$this->executeMigration($migration);
|
||||
$this->assertNull($migration->getIdMap()->lookupDestinationId(['vid' => 3])[0]);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateVocabularyEntityDisplayTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Vocabulary entity display migration.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['field', 'taxonomy'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->migrateTaxonomy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
|
||||
*/
|
||||
public function testVocabularyEntityDisplay() {
|
||||
// Test that the field exists.
|
||||
$component = EntityViewDisplay::load('node.page.default')->getComponent('tags');
|
||||
$this->assertIdentical('entity_reference_label', $component['type']);
|
||||
$this->assertIdentical(20, $component['weight']);
|
||||
// Test the Id map.
|
||||
$this->assertIdentical(array('node', 'article', 'default', 'tags'), Migration::load('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateVocabularyEntityFormDisplayTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Vocabulary entity form display migration.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->migrateTaxonomy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
|
||||
*/
|
||||
public function testVocabularyEntityFormDisplay() {
|
||||
// Test that the field exists.
|
||||
$component = EntityFormDisplay::load('node.page.default')->getComponent('tags');
|
||||
$this->assertIdentical('options_select', $component['type']);
|
||||
$this->assertIdentical(20, $component['weight']);
|
||||
// Test the Id map.
|
||||
$this->assertIdentical(array('node', 'article', 'default', 'tags'), Migration::load('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
|
||||
|
||||
// Test the term widget tags setting.
|
||||
$entity_form_display = EntityFormDisplay::load('node.story.default');
|
||||
$this->assertIdentical($entity_form_display->getComponent('vocabulary_1_i_0_')['type'], 'options_select');
|
||||
$this->assertIdentical($entity_form_display->getComponent('vocabulary_2_i_1_')['type'], 'entity_reference_autocomplete_tags');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateVocabularyFieldInstanceTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
|
||||
/**
|
||||
* Vocabulary field instance migration.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->migrateTaxonomy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
|
||||
*/
|
||||
public function testVocabularyFieldInstance() {
|
||||
// Test that the field exists.
|
||||
$field_id = 'node.article.tags';
|
||||
$field = FieldConfig::load($field_id);
|
||||
$this->assertIdentical($field_id, $field->id(), 'Field instance exists on article bundle.');
|
||||
$this->assertIdentical('Tags', $field->label());
|
||||
$this->assertTrue($field->isRequired(), 'Field is required');
|
||||
|
||||
// Test the page bundle as well.
|
||||
$field_id = 'node.page.tags';
|
||||
$field = FieldConfig::load($field_id);
|
||||
$this->assertIdentical($field_id, $field->id(), 'Field instance exists on page bundle.');
|
||||
$this->assertIdentical('Tags', $field->label());
|
||||
$this->assertTrue($field->isRequired(), 'Field is required');
|
||||
|
||||
$settings = $field->getSettings();
|
||||
$this->assertIdentical('default:taxonomy_term', $settings['handler'], 'The handler plugin ID is correct.');
|
||||
$this->assertIdentical(['tags'], $settings['handler_settings']['target_bundles'], 'The target_bundles handler setting is correct.');
|
||||
$this->assertIdentical(TRUE, $settings['handler_settings']['auto_create'], 'The "auto_create" setting is correct.');
|
||||
|
||||
$this->assertIdentical(array('node', 'article', 'tags'), Migration::load('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationID(array(4, 'article')));
|
||||
|
||||
// Test the the field vocabulary_1_i_0_
|
||||
$field_id = 'node.story.vocabulary_1_i_0_';
|
||||
$field = FieldConfig::load($field_id);
|
||||
$this->assertFalse($field->isRequired(), 'Field is not required');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateVocabularyFieldTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Vocabulary field migration.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateVocabularyFieldTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->migrateTaxonomy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
|
||||
*/
|
||||
public function testVocabularyField() {
|
||||
// Test that the field exists.
|
||||
$field_storage_id = 'node.tags';
|
||||
/** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
|
||||
$field_storage = FieldStorageConfig::load($field_storage_id);
|
||||
$this->assertIdentical($field_storage_id, $field_storage->id());
|
||||
|
||||
$settings = $field_storage->getSettings();
|
||||
$this->assertIdentical('taxonomy_term', $settings['target_type'], "Target type is correct.");
|
||||
$this->assertIdentical(1, $field_storage->getCardinality(), "Field cardinality in 1.");
|
||||
|
||||
$this->assertIdentical(array('node', 'tags'), Migration::load('d6_vocabulary_field')->getIdMap()->lookupDestinationID(array(4)), "Test IdMap");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
<?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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
<?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));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
<?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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\RssTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TaxonomyImageTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\user\RoleInterface;
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
||||
/**
|
||||
* Tests access checks of private image fields.
|
||||
|
@ -41,7 +38,7 @@ class TaxonomyImageTest extends TaxonomyTestBase {
|
|||
// Add a field to the vocabulary.
|
||||
$entity_type = 'taxonomy_term';
|
||||
$name = 'field_test';
|
||||
entity_create('field_storage_config', array(
|
||||
FieldStorageConfig::create(array(
|
||||
'field_name' => $name,
|
||||
'entity_type' => $entity_type,
|
||||
'type' => 'image',
|
||||
|
@ -49,12 +46,12 @@ class TaxonomyImageTest extends TaxonomyTestBase {
|
|||
'uri_scheme' => 'private',
|
||||
),
|
||||
))->save();
|
||||
entity_create('field_config', array(
|
||||
FieldConfig::create([
|
||||
'field_name' => $name,
|
||||
'entity_type' => $entity_type,
|
||||
'bundle' => $this->vocabulary->id(),
|
||||
'settings' => array(),
|
||||
))->save();
|
||||
])->save();
|
||||
entity_get_display($entity_type, $this->vocabulary->id(), 'default')
|
||||
->setComponent($name, array(
|
||||
'type' => 'image',
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TaxonomyTermIndentationTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TaxonomyTermPagerTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TaxonomyTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TaxonomyTestTrait.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
|
||||
/**
|
||||
* Provides common helper methods for Taxonomy module tests.
|
||||
|
@ -21,13 +17,13 @@ trait TaxonomyTestTrait {
|
|||
*/
|
||||
function createVocabulary() {
|
||||
// Create a vocabulary.
|
||||
$vocabulary = entity_create('taxonomy_vocabulary', array(
|
||||
$vocabulary = Vocabulary::create([
|
||||
'name' => $this->randomMachineName(),
|
||||
'description' => $this->randomMachineName(),
|
||||
'vid' => Unicode::strtolower($this->randomMachineName()),
|
||||
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
|
||||
'weight' => mt_rand(0, 10),
|
||||
));
|
||||
]);
|
||||
$vocabulary->save();
|
||||
return $vocabulary;
|
||||
}
|
||||
|
@ -47,16 +43,16 @@ trait TaxonomyTestTrait {
|
|||
function createTerm(Vocabulary $vocabulary, $values = array()) {
|
||||
$filter_formats = filter_formats();
|
||||
$format = array_pop($filter_formats);
|
||||
$term = entity_create('taxonomy_term', $values + array(
|
||||
$term = Term::create($values + [
|
||||
'name' => $this->randomMachineName(),
|
||||
'description' => array(
|
||||
'description' => [
|
||||
'value' => $this->randomMachineName(),
|
||||
// Use the first available text format.
|
||||
'format' => $format->id(),
|
||||
),
|
||||
],
|
||||
'vid' => $vocabulary->id(),
|
||||
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
|
||||
));
|
||||
]);
|
||||
$term->save();
|
||||
return $term;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TaxonomyTranslationTestTrait.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TermCacheTagsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
|
||||
/**
|
||||
* Tests the Taxonomy term entity's cache tags.
|
||||
|
@ -26,17 +23,17 @@ class TermCacheTagsTest extends EntityWithUriCacheTagsTestBase {
|
|||
*/
|
||||
protected function createEntity() {
|
||||
// Create a "Camelids" vocabulary.
|
||||
$vocabulary = entity_create('taxonomy_vocabulary', array(
|
||||
$vocabulary = Vocabulary::create([
|
||||
'name' => 'Camelids',
|
||||
'vid' => 'camelids',
|
||||
));
|
||||
]);
|
||||
$vocabulary->save();
|
||||
|
||||
// Create a "Llama" taxonomy term.
|
||||
$term = entity_create('taxonomy_term', array(
|
||||
$term = Term::create([
|
||||
'name' => 'Llama',
|
||||
'vid' => $vocabulary->id(),
|
||||
));
|
||||
]);
|
||||
$term->save();
|
||||
|
||||
return $term;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TermEntityReferenceTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TermIndexTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TermKernelTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TermLanguageTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TermTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Tags;
|
||||
|
@ -495,10 +490,10 @@ class TermTest extends TaxonomyTestBase {
|
|||
|
||||
// Create a new term in a different vocabulary with the same name.
|
||||
$new_vocabulary = $this->createVocabulary();
|
||||
$new_term = entity_create('taxonomy_term', array(
|
||||
$new_term = Term::create([
|
||||
'name' => $term->getName(),
|
||||
'vid' => $new_vocabulary->id(),
|
||||
));
|
||||
]);
|
||||
$new_term->save();
|
||||
|
||||
// Load multiple terms with the same name.
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TermTranslationFieldViewTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\node\Entity\Node;
|
||||
|
||||
/**
|
||||
* Tests the translation of taxonomy terms field on nodes.
|
||||
*
|
||||
|
@ -74,16 +71,16 @@ class TermTranslationFieldViewTest extends TaxonomyTestBase {
|
|||
*/
|
||||
protected function setUpNode() {
|
||||
/** @var \Drupal\node\Entity\Node $node */
|
||||
$node = entity_create('node', array(
|
||||
$node = Node::create([
|
||||
'title' => $this->randomMachineName(),
|
||||
'type' => 'article',
|
||||
'description' => array(
|
||||
'description' => [[
|
||||
'value' => $this->randomMachineName(),
|
||||
'format' => 'basic_html',
|
||||
),
|
||||
'format' => 'basic_html'
|
||||
]],
|
||||
$this->termFieldName => array(array('target_id' => $this->term->id())),
|
||||
'langcode' => $this->baseLangcode,
|
||||
));
|
||||
]);
|
||||
$node->save();
|
||||
$node->addTranslation($this->translateToLangcode, $node->toArray());
|
||||
$node->save();
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TermTranslationTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TermTranslationUITest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\content_translation\Tests\ContentTranslationUITestBase;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
|
||||
/**
|
||||
* Tests the Term Translation UI.
|
||||
|
@ -44,13 +40,13 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
|
|||
parent::setupBundle();
|
||||
|
||||
// Create a vocabulary.
|
||||
$this->vocabulary = entity_create('taxonomy_vocabulary', array(
|
||||
$this->vocabulary = Vocabulary::create([
|
||||
'name' => $this->bundle,
|
||||
'description' => $this->randomMachineName(),
|
||||
'vid' => $this->bundle,
|
||||
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
|
||||
'weight' => mt_rand(0, 10),
|
||||
));
|
||||
]);
|
||||
$this->vocabulary->save();
|
||||
}
|
||||
|
||||
|
@ -113,13 +109,13 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
|
|||
$translatable_tid = $this->createEntity($values, $this->langcodes[0], $this->vocabulary->id());
|
||||
|
||||
// Create an untranslatable vocabulary.
|
||||
$untranslatable_vocabulary = entity_create('taxonomy_vocabulary', array(
|
||||
$untranslatable_vocabulary = Vocabulary::create([
|
||||
'name' => 'untranslatable_voc',
|
||||
'description' => $this->randomMachineName(),
|
||||
'vid' => 'untranslatable_voc',
|
||||
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
|
||||
'weight' => mt_rand(0, 10),
|
||||
));
|
||||
]);
|
||||
$untranslatable_vocabulary->save();
|
||||
|
||||
$values = array(
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TermValidationTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\system\Tests\Entity\EntityUnitTestBase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\ThemeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\TokenReplaceTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\ArgumentValidatorTermTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\RelationshipNodeTermDataTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\RelationshipRepresentativeNodeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyDefaultArgumentTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyFieldAllTermsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyFieldFilterTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
|
||||
/**
|
||||
* Tests taxonomy field filters with translations.
|
||||
|
@ -61,25 +60,25 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
|
|||
);
|
||||
|
||||
// Create a vocabulary.
|
||||
$this->vocabulary = entity_create('taxonomy_vocabulary', array(
|
||||
$this->vocabulary = Vocabulary::create([
|
||||
'name' => 'Views testing tags',
|
||||
'vid' => 'views_testing_tags',
|
||||
));
|
||||
]);
|
||||
$this->vocabulary->save();
|
||||
|
||||
// Add a translatable field to the vocabulary.
|
||||
$field = entity_create('field_storage_config', array(
|
||||
$field = FieldStorageConfig::create(array(
|
||||
'field_name' => 'field_foo',
|
||||
'entity_type' => 'taxonomy_term',
|
||||
'type' => 'text',
|
||||
));
|
||||
$field->save();
|
||||
entity_create('field_config', array(
|
||||
FieldConfig::create([
|
||||
'field_name' => 'field_foo',
|
||||
'entity_type' => 'taxonomy_term',
|
||||
'label' => 'Foo',
|
||||
'bundle' => 'views_testing_tags',
|
||||
))->save();
|
||||
])->save();
|
||||
|
||||
// Create term with translations.
|
||||
$taxonomy = $this->createTermWithProperties(array('name' => $this->termNames['en'], 'langcode' => 'en', 'description' => $this->termNames['en'], 'field_foo' => $this->termNames['en']));
|
||||
|
@ -171,13 +170,13 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
|
|||
'field_foo' => $this->randomMachineName(),
|
||||
);
|
||||
|
||||
$term = entity_create('taxonomy_term', array(
|
||||
$term = Term::create([
|
||||
'name' => $properties['name'],
|
||||
'description' => $properties['description'],
|
||||
'format' => $format->id(),
|
||||
'vid' => $this->vocabulary->id(),
|
||||
'langcode' => $properties['langcode'],
|
||||
));
|
||||
]);
|
||||
$term->field_foo->value = $properties['field_foo'];
|
||||
$term->save();
|
||||
return $term;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyFieldTidTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\Core\Render\RenderContext;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyIndexTidUiTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyParentUITest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyRelationshipTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\node\NodeInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyTermArgumentDepthTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyTermFilterDepthTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyTermViewTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
|
@ -12,6 +7,8 @@ use Drupal\Core\Language\LanguageInterface;
|
|||
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
|
||||
/**
|
||||
* Base class for all taxonomy tests.
|
||||
|
@ -85,10 +82,10 @@ abstract class TaxonomyTestBase extends ViewTestBase {
|
|||
'type' => 'article',
|
||||
));
|
||||
// Create the vocabulary for the tag field.
|
||||
$this->vocabulary = entity_create('taxonomy_vocabulary', array(
|
||||
$this->vocabulary = Vocabulary::create([
|
||||
'name' => 'Views testing tags',
|
||||
'vid' => 'views_testing_tags',
|
||||
));
|
||||
]);
|
||||
$this->vocabulary->save();
|
||||
$field_name = 'field_' . $this->vocabulary->id();
|
||||
|
||||
|
@ -148,7 +145,7 @@ abstract class TaxonomyTestBase extends ViewTestBase {
|
|||
'vid' => $this->vocabulary->id(),
|
||||
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
|
||||
];
|
||||
$term = entity_create('taxonomy_term', $settings);
|
||||
$term = Term::create($settings);
|
||||
$term->save();
|
||||
return $term;
|
||||
}
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyViewsFieldAccessTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\views\Tests\Handler\FieldFieldAccessTestBase;
|
||||
|
||||
/**
|
||||
* Tests base field access in Views for the taxonomy entity.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TaxonomyViewsFieldAccessTest extends FieldFieldAccessTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy', 'text', 'entity_test'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->installEntitySchema('taxonomy_term');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check access for taxonomy fields.
|
||||
*/
|
||||
public function testTermFields() {
|
||||
$vocab = Vocabulary::create([
|
||||
'vid' => 'random',
|
||||
'name' => 'Randomness',
|
||||
]);
|
||||
$vocab->save();
|
||||
$term1 = Term::create([
|
||||
'name' => 'Semi random',
|
||||
'vid' => $vocab->id(),
|
||||
]);
|
||||
$term1->save();
|
||||
|
||||
$term2 = Term::create([
|
||||
'name' => 'Majorly random',
|
||||
'vid' => $vocab->id(),
|
||||
]);
|
||||
$term2->save();
|
||||
|
||||
$term3 = Term::create([
|
||||
'name' => 'Not really random',
|
||||
'vid' => $vocab->id(),
|
||||
]);
|
||||
$term3->save();
|
||||
|
||||
$this->assertFieldAccess('taxonomy_term', 'name', 'Majorly random');
|
||||
$this->assertFieldAccess('taxonomy_term', 'name', 'Semi random');
|
||||
$this->assertFieldAccess('taxonomy_term', 'name', 'Not really random');
|
||||
$this->assertFieldAccess('taxonomy_term', 'tid', $term1->id());
|
||||
$this->assertFieldAccess('taxonomy_term', 'tid', $term2->id());
|
||||
$this->assertFieldAccess('taxonomy_term', 'tid', $term3->id());
|
||||
$this->assertFieldAccess('taxonomy_term', 'uuid', $term1->uuid());
|
||||
$this->assertFieldAccess('taxonomy_term', 'uuid', $term2->uuid());
|
||||
$this->assertFieldAccess('taxonomy_term', 'uuid', $term3->uuid());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\Views\TermNameFieldTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\VocabularyCrudTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
||||
/**
|
||||
* Tests loading, saving and deleting vocabularies.
|
||||
|
@ -154,14 +151,14 @@ class VocabularyCrudTest extends TaxonomyTestBase {
|
|||
'type' => 'text',
|
||||
'cardinality' => 4
|
||||
);
|
||||
entity_create('field_storage_config', $storage_definition)->save();
|
||||
FieldStorageConfig::create($storage_definition)->save();
|
||||
$field_definition = array(
|
||||
'field_name' => $field_name,
|
||||
'entity_type' => 'taxonomy_term',
|
||||
'bundle' => $this->vocabulary->id(),
|
||||
'label' => $this->randomMachineName() . '_label',
|
||||
);
|
||||
entity_create('field_config', $field_definition)->save();
|
||||
FieldConfig::create($field_definition)->save();
|
||||
|
||||
// Remove the third party setting from the memory copy of the vocabulary.
|
||||
// We keep this invalid copy around while the taxonomy module is not even
|
||||
|
@ -178,7 +175,7 @@ class VocabularyCrudTest extends TaxonomyTestBase {
|
|||
// an instance of this field on the same bundle name should be successful.
|
||||
$this->vocabulary->enforceIsNew();
|
||||
$this->vocabulary->save();
|
||||
entity_create('field_storage_config', $storage_definition)->save();
|
||||
entity_create('field_config', $field_definition)->save();
|
||||
FieldStorageConfig::create($storage_definition)->save();
|
||||
FieldConfig::create($field_definition)->save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\VocabularyLanguageTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\VocabularyPermissionsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\VocabularyTranslationTest.
|
||||
*/
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Tests\VocabularyUiTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\VocabularyForm.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy;
|
||||
|
||||
use Drupal\Core\Entity\BundleEntityFormBase;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue