Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542

This commit is contained in:
Pantheon Automation 2015-08-27 12:03:05 -07:00 committed by Greg Anderson
parent 3b2511d96d
commit 81ccda77eb
2155 changed files with 54307 additions and 46870 deletions

View file

@ -7,6 +7,7 @@
namespace Drupal\taxonomy\Controller;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Controller\ControllerBase;
use Drupal\taxonomy\TermInterface;
@ -54,7 +55,7 @@ class TaxonomyController extends ControllerBase {
* The term label.
*/
public function vocabularyTitle(VocabularyInterface $taxonomy_vocabulary) {
return Xss::filter($taxonomy_vocabulary->label());
return SafeMarkup::xssFilter($taxonomy_vocabulary->label());
}
/**
@ -67,7 +68,7 @@ class TaxonomyController extends ControllerBase {
* The term label.
*/
public function termTitle(TermInterface $taxonomy_term) {
return Xss::filter($taxonomy_term->getName());
return SafeMarkup::xssFilter($taxonomy_term->getName());
}
}

View file

@ -0,0 +1,30 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Plugin\migrate\destination\EntityTaxonomyTerm.
*/
namespace Drupal\taxonomy\Plugin\migrate\destination;
use Drupal\migrate\Row;
use Drupal\migrate\Plugin\migrate\destination\EntityContentBase;
/**
* @MigrateDestination(
* id = "entity:taxonomy_term"
* )
*/
class EntityTaxonomyTerm extends EntityContentBase {
/**
* {@inheritdoc}
*/
protected function getEntity(Row $row, array $old_destination_id_values) {
if ($row->isStub()) {
$row->setDestinationProperty('name', $this->t('Stub name for source tid:') . $row->getSourceProperty('tid'));
}
return parent::getEntity($row, $old_destination_id_values);
}
}

View file

@ -0,0 +1,64 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Plugin\migrate\load\d6\LoadTermNode.
*/
namespace Drupal\taxonomy\Plugin\migrate\load\d6;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\load\LoadEntity;
/**
* @PluginID("d6_term_node")
*/
class LoadTermNode extends LoadEntity {
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, MigrationInterface $migration) {
$configuration['bundle_migration'] = 'd6_taxonomy_vocabulary';
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
}
/**
* {@inheritdoc}
*/
public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = NULL) {
/** @var \Drupal\migrate\Entity\MigrationInterface $bundle_migration */
$bundle_migration = $storage->load('d6_taxonomy_vocabulary');
$migrate_executable = new MigrateExecutable($bundle_migration, new MigrateMessage());
$process = array_intersect_key($bundle_migration->get('process'), $bundle_migration->getDestinationPlugin()->getIds());
$migrations = array();
$vid_map = array();
foreach ($bundle_migration->getIdMap() as $key => $value) {
$old_vid = unserialize($key)['sourceid1'];
$new_vid = $value['destid1'];
$vid_map[$old_vid] = $new_vid;
}
foreach ($bundle_migration->getSourcePlugin()->getIterator() as $source_row) {
$row = new Row($source_row, $source_row);
$migrate_executable->processRow($row, $process);
$old_vid = $source_row['vid'];
$new_vid = $row->getDestinationProperty('vid');
$vid_map[$old_vid] = $new_vid;
}
foreach ($vid_map as $old_vid => $new_vid) {
$values = $this->migration->toArray();
$migration_id = $this->migration->id() . ':' . $old_vid;
$values['id'] = $migration_id;
$values['source']['vid'] = $old_vid;
$values['process'][$new_vid] = 'tid';
$migrations[$migration_id] = $storage->create($values);;
}
return $migrations;
}
}

View file

@ -0,0 +1,79 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Plugin\migrate\source\d6\Term.
*/
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 6 taxonomy terms source from database.
*
* @todo Support term_relation, term_synonym table if possible.
*
* @MigrateSource(
* id = "d6_taxonomy_term",
* source_provider = "taxonomy"
* )
*/
class Term extends DrupalSqlBase {
/**
* {@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.
->distinct()
->orderBy('tid');
if (isset($this->configuration['vocabulary'])) {
$query->condition('vid', $this->configuration['vocabulary'], 'IN');
}
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
return array(
'tid' => $this->t('The term ID.'),
'vid' => $this->t('Existing term VID'),
'name' => $this->t('The name of the term.'),
'description' => $this->t('The term description.'),
'weight' => $this->t('Weight'),
'parent' => $this->t("The Drupal term IDs of the term's parents."),
);
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
// Find parents for this row.
$parents = $this->select('term_hierarchy', 'th')
->fields('th', array('parent', 'tid'))
->condition('tid', $row->getSourceProperty('tid'))
->execute()
->fetchCol();
$row->setSourceProperty('parent', $parents);
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['tid']['type'] = 'integer';
return $ids;
}
}

View file

@ -0,0 +1,93 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Plugin\migrate\source\d6\TermNode.
*/
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
use Drupal\migrate\Plugin\SourceEntityInterface;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Source returning tids from the term_node table for the current revision.
*
* @MigrateSource(
* id = "d6_term_node",
* source_provider = "taxonomy"
* )
*/
class TermNode extends DrupalSqlBase implements SourceEntityInterface {
/**
* The join options between the node and the term node table.
*/
const JOIN = 'tn.vid = n.vid';
/**
* {@inheritdoc}
*/
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'));
// Because this is an inner join it enforces the current revision.
$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;
}
/**
* {@inheritdoc}
*/
public function fields() {
return array(
'nid' => $this->t('The node revision ID.'),
'vid' => $this->t('The node revision ID.'),
'tid' => $this->t('The term ID.'),
);
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
// Select the terms belonging to the revision selected.
$query = $this->select('term_node', 'tn')
->fields('tn', array('tid'))
->condition('n.nid', $row->getSourceProperty('nid'));
$query->join('node', 'n', static::JOIN);
$query->innerJoin('term_data', 'td', 'td.tid = tn.tid AND td.vid = :vid', array(':vid' => $this->configuration['vid']));
$row->setSourceProperty('tid', $query->execute()->fetchCol());
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['vid']['type'] = 'integer';
$ids['vid']['alias'] = 'tn';
return $ids;
}
/**
* {@inheritdoc}
*/
public function bundleMigrationRequired() {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function entityTypeId() {
return 'taxonomy_term';
}
}

View file

@ -0,0 +1,24 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Plugin\migrate\source\d6\TermNodeRevision.
*/
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
/**
* Source returning tids from the term_node table for the non-current revision.
*
* @MigrateSource(
* id = "d6_term_node_revision"
* )
*/
class TermNodeRevision extends TermNode {
/**
* {@inheritdoc}
*/
const JOIN = 'tn.nid = n.nid AND tn.vid != n.vid';
}

View file

@ -0,0 +1,44 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary.
*/
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
use Drupal\migrate\Row;
/**
* Drupal 6 vocabularies source from database.
*
* @MigrateSource(
* id = "d6_taxonomy_vocabulary",
* source_provider = "taxonomy"
* )
*/
class Vocabulary extends VocabularyBase {
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
// Find node types for this row.
$node_types = $this->select('vocabulary_node_types', 'nt')
->fields('nt', array('type', 'vid'))
->condition('vid', $row->getSourceProperty('vid'))
->execute()
->fetchCol();
$row->setSourceProperty('node_types', $node_types);
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['vid']['type'] = 'integer';
return $ids;
}
}

View file

@ -0,0 +1,58 @@
<?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

@ -0,0 +1,42 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Plugin\migrate\source\d6\VocabularyPerType.
*/
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
/**
* Gets all the vocabularies based on the node types that have Taxonomy enabled.
*
* @MigrateSource(
* id = "d6_taxonomy_vocabulary_per_type",
* source_provider = "taxonomy"
* )
*/
class VocabularyPerType extends Vocabulary {
/**
* {@inheritdoc}
*/
public function query() {
$query = parent::query();
$query->fields('nt', array(
'type',
));
$query->join('vocabulary_node_types', 'nt', 'v.vid = nt.vid');
return $query;
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['vid']['type'] = 'integer';
$ids['vid']['alias'] = 'nt';
$ids['type']['type'] = 'string';
return $ids;
}
}

View file

@ -276,6 +276,12 @@ class TaxonomyIndexTid extends ManyToOne {
if (empty($this->options['exposed'])) {
return TRUE;
}
// We need to know the operator, which is normally set in
// \Drupal\views\Plugin\views\filter\FilterPluginBase::acceptExposedInput(),
// before we actually call the parent version of ourselves.
if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']) && isset($input[$this->options['expose']['operator_id']])) {
$this->operator = $input[$this->options['expose']['operator_id']];
}
// If view is an attachment and is inheriting exposed filters, then assume
// exposed input has already been validated
@ -283,6 +289,12 @@ class TaxonomyIndexTid extends ManyToOne {
$this->validated_exposed_input = (array) $this->view->exposed_raw_input[$this->options['expose']['identifier']];
}
// If we're checking for EMPTY or NOT, we don't need any input, and we can
// say that our input conditions are met by just having the right operator.
if ($this->operator == 'empty' || $this->operator == 'not empty') {
return TRUE;
}
// If it's non-required and there's no value don't bother filtering.
if (!$this->options['expose']['required'] && empty($this->validated_exposed_input)) {
return FALSE;

View file

@ -96,8 +96,8 @@ class TermForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state);
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
// Ensure numeric values.
if ($form_state->hasValue('weight') && !is_numeric($form_state->getValue('weight'))) {

View file

@ -318,23 +318,24 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
/**
* {@inheritdoc}
*/
public function getNodeTerms($nids, $vocabs = array(), $langcode = NULL) {
public function getNodeTerms(array $nids, array $vocabs = array(), $langcode = NULL) {
$query = db_select('taxonomy_term_field_data', 'td');
$query->innerJoin('taxonomy_index', 'tn', 'td.tid = tn.tid');
$query->fields('td', array('tid'));
$query->addField('tn', 'nid', 'node_nid');
$query->orderby('td.weight');
$query->orderby('td.name');
$query->condition('tn.nid', $nids);
$query->condition('tn.nid', $nids, 'IN');
$query->addTag('term_access');
if (!empty($vocabs)) {
$query->condition('td.vid', $vocabs);
$query->condition('td.vid', $vocabs, 'IN');
}
if (!empty($langcode)) {
$query->condition('td.langcode', $langcode);
}
$results = array();
$all_tids = array();
foreach ($query->execute() as $term_record) {
$results[$term_record->node_nid][] = $term_record->tid;
$all_tids[] = $term_record->tid;
@ -344,7 +345,7 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
$terms = array();
foreach ($results as $nid => $tids) {
foreach ($tids as $tid) {
$terms[$nid][$tid] = $all_terms[$term_record->tid];
$terms[$nid][$tid] = $all_terms[$tid];
}
}
return $terms;

View file

@ -121,6 +121,6 @@ interface TermStorageInterface extends EntityStorageInterface {
* @return array
* An array of nids and the term entities they were tagged with.
*/
public function getNodeTerms($nids, $vocabs = array(), $langcode = NULL);
public function getNodeTerms(array $nids, array $vocabs = array(), $langcode = NULL);
}

View file

@ -0,0 +1,48 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateTaxonomyConfigsTest.
*/
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade variables to taxonomy.settings.yml.
*
* @group taxonomy
*/
class MigrateTaxonomyConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('taxonomy');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->loadDumps(['Variable.php']);
$this->executeMigration('d6_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());
}
}

View file

@ -0,0 +1,108 @@
<?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 taxonomy
*/
class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
static $modules = array('taxonomy', 'text');
/**
* {@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->loadDumps([
'TermData.php',
'TermHierarchy.php',
'Vocabulary.php',
'VocabularyNodeTypes.php',
]);
$this->executeMigration('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']);
}
}
}
}

View file

@ -0,0 +1,56 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateTaxonomyVocabularyTest.
*/
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Migrate taxonomy vocabularies to taxonomy.vocabulary.*.yml.
*
* @group taxonomy
*/
class MigrateTaxonomyVocabularyTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('taxonomy');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->loadDumps(['Vocabulary.php', 'VocabularyNodeTypes.php']);
$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(entity_load('migration', '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'));
}
}

View file

@ -0,0 +1,51 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateTermNodeRevisionTest.
*/
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\migrate\MigrateExecutable;
/**
* Upgrade taxonomy term node associations.
*
* @group taxonomy
*/
class MigrateTermNodeRevisionTest extends MigrateTermNodeTestBase {
/**
* {@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);
/** @var \Drupal\migrate\entity\Migration $migration */
$migrations = entity_load_multiple('migration', array('d6_term_node_revision:*'));
foreach ($migrations as $migration) {
$executable = new MigrateExecutable($migration, $this);
$executable->import();
}
}
/**
* 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);
}
}

View file

@ -0,0 +1,49 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateTermNodeTest.
*/
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\migrate\MigrateExecutable;
use Drupal\node\Entity\Node;
/**
* Upgrade taxonomy term node associations.
*
* @group taxonomy
*/
class MigrateTermNodeTest extends MigrateTermNodeTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
/** @var \Drupal\migrate\entity\Migration $migration */
$migrations = entity_load_multiple('migration', array('d6_term_node:*'));
foreach ($migrations as $migration) {
$executable = new MigrateExecutable($migration, $this);
$executable->import();
}
}
/**
* 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));
$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);
}
}

View file

@ -0,0 +1,98 @@
<?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),
));
$node->enforceIsNew();
$node->save();
if ($i == 1) {
$node->vid->value = array_shift($vids);
$node->enforceIsNew(FALSE);
$node->setNewRevision();
$node->isDefaultRevision(FALSE);
$node->save();
}
}
$this->loadDumps([
'Node.php',
'NodeRevisions.php',
'ContentTypeStory.php',
'ContentTypeTestPlanet.php',
'TermNode.php',
'TermHierarchy.php',
'TermData.php',
'Vocabulary.php',
'VocabularyNodeTypes.php',
]);
}
}

View file

@ -0,0 +1,89 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateVocabularyEntityDisplayTest.
*/
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Vocabulary entity display migration.
*
* @group taxonomy
*/
class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
*/
static $modules = array('field', 'node', 'taxonomy', 'text', 'entity_reference');
/**
* {@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->loadDumps(['Vocabulary.php', 'VocabularyNodeTypes.php']);
$this->executeMigration('d6_vocabulary_entity_display');
}
/**
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
*/
public function testVocabularyEntityDisplay() {
// Test that the field exists.
$component = entity_get_display('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')));
}
}

View file

@ -0,0 +1,89 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateVocabularyEntityFormDisplayTest.
*/
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Vocabulary entity form display migration.
*
* @group taxonomy
*/
class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
*/
static $modules = array('node', 'taxonomy', 'field', 'text', 'entity_reference');
/**
* {@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->loadDumps(['Vocabulary.php', 'VocabularyNodeTypes.php']);
$this->executeMigration('d6_vocabulary_entity_form_display');
}
/**
* Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
*/
public function testVocabularyEntityFormDisplay() {
// Test that the field exists.
$component = entity_get_form_display('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')));
}
}

View file

@ -0,0 +1,97 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateVocabularyFieldInstanceTest.
*/
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Vocabulary field instance migration.
*
* @group taxonomy
*/
class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
*/
static $modules = array('node', 'field', 'taxonomy', 'text', 'entity_reference');
/**
* {@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->loadDumps(['Vocabulary.php', 'VocabularyNodeTypes.php']);
$this->executeMigration('d6_vocabulary_field_instance');
}
/**
* 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.');
// 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.');
$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(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')));
}
}

View file

@ -0,0 +1,66 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Migrate\d6\MigrateVocabularyFieldTest.
*/
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Vocabulary field migration.
*
* @group taxonomy
*/
class MigrateVocabularyFieldTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
*/
static $modules = array('node', 'taxonomy', 'field', 'text', 'entity_reference');
/**
* {@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->loadDumps(['Vocabulary.php', 'VocabularyNodeTypes.php']);
$this->executeMigration('d6_vocabulary_field');
}
/**
* 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';
$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(array('node', 'tags'), entity_load('migration', 'd6_vocabulary_field')->getIdMap()->lookupDestinationID(array(4)), "Test IdMap");
}
}

View file

@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Tests;
use Drupal\user\RoleInterface;
use Drupal\file\Entity\File;
/**
* Tests access checks of private image fields.
@ -86,7 +87,7 @@ class TaxonomyImageTest extends TaxonomyTestBase {
// Create a user that should have access to the file and one that doesn't.
$access_user = $this->drupalCreateUser(array('access content'));
$no_access_user = $this->drupalCreateUser();
$image = file_load($term->field_test->target_id);
$image = File::load($term->field_test->target_id);
$this->drupalLogin($access_user);
$this->drupalGet(file_create_url($image->getFileUri()));
$this->assertResponse(200, 'Private image on term is accessible with right permission');

View file

@ -78,8 +78,12 @@ trait TaxonomyTranslationTestTrait {
/**
* Adds term reference field for the article content type.
*
* @param bool $translatable
* (optional) If TRUE, create a translatable term reference field. Defaults
* to FALSE.
*/
protected function setUpTermReferenceField() {
protected function setUpTermReferenceField($translatable = FALSE) {
$handler_settings = array(
'target_bundles' => array(
$this->vocabulary->id() => $this->vocabulary->id(),
@ -88,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(FALSE);
$field_storage->setTranslatable($translatable);
$field_storage->save();
entity_get_form_display('node', 'article', 'default')

View file

@ -50,7 +50,7 @@ class TermTranslationFieldViewTest extends TaxonomyTestBase {
$this->vocabulary = $this->createVocabulary();
$this->enableTranslation();
$this->setUpTerm();
$this->setUpTermReferenceField();
$this->setUpTermReferenceField(TRUE);
$this->setUpNode();
}
@ -85,7 +85,7 @@ class TermTranslationFieldViewTest extends TaxonomyTestBase {
'langcode' => $this->baseLangcode,
));
$node->save();
$node->addTranslation($this->translateToLangcode, array());
$node->addTranslation($this->translateToLangcode, $node->toArray());
$node->save();
$this->node = $node;
}

View file

@ -10,6 +10,7 @@ namespace Drupal\taxonomy\Tests;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Render\BubbleableMetadata;
/**
* Generates text using placeholders for dummy content to check taxonomy token
@ -91,10 +92,26 @@ class TokenReplaceTest extends TaxonomyTestBase {
$tests['[term:node-count]'] = 0;
$tests['[term:parent:name]'] = '[term:parent:name]';
$tests['[term:vocabulary:name]'] = SafeMarkup::checkPlain($this->vocabulary->label());
$tests['[term:vocabulary]'] = SafeMarkup::checkPlain($this->vocabulary->label());
$base_bubbleable_metadata = BubbleableMetadata::createFromObject($term1);
$metadata_tests = array();
$metadata_tests['[term:tid]'] = $base_bubbleable_metadata;
$metadata_tests['[term:name]'] = $base_bubbleable_metadata;
$metadata_tests['[term:description]'] = $base_bubbleable_metadata;
$metadata_tests['[term:url]'] = $base_bubbleable_metadata;
$metadata_tests['[term:node-count]'] = $base_bubbleable_metadata;
$metadata_tests['[term:parent:name]'] = $base_bubbleable_metadata;
$bubbleable_metadata = clone $base_bubbleable_metadata;
$metadata_tests['[term:vocabulary:name]'] = $bubbleable_metadata->addCacheTags($this->vocabulary->getCacheTags());
$metadata_tests['[term:vocabulary]'] = $bubbleable_metadata->addCacheTags($this->vocabulary->getCacheTags());
foreach ($tests as $input => $expected) {
$output = $token_service->replace($input, array('term' => $term1), array('langcode' => $language_interface->getId()));
$bubbleable_metadata = new BubbleableMetadata();
$output = $token_service->replace($input, array('term' => $term1), array('langcode' => $language_interface->getId()), $bubbleable_metadata);
$this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input)));
$this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
}
// Generate and test sanitized tokens for term2.

View file

@ -0,0 +1,42 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyFieldAllTerms.
*/
namespace Drupal\taxonomy\Tests\Views;
use Drupal\views\Views;
/**
* Tests the "All terms" taxonomy term field handler.
*
* @group taxonomy
*/
class TaxonomyFieldAllTermsTest extends TaxonomyTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('taxonomy_all_terms_test');
function testViewsHandlerAllTermsField() {
$view = Views::getView('taxonomy_all_terms_test');
$this->executeView($view);
$this->drupalGet('taxonomy_all_terms_test');
$actual = $this->xpath('//a[@href="' . $this->term1->url() . '"]');
$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());
$actual = $this->xpath('//a[@href="' . $this->term2->url() . '"]');
$this->assertEqual(count($actual), 2, 'Correct number of taxonomy term2 links');
$this->assertEqual($actual[0]->__toString(), $this->term2->label());
$this->assertEqual($actual[1]->__toString(), $this->term2->label());
}
}

View file

@ -7,6 +7,7 @@
namespace Drupal\taxonomy\Tests\Views;
use Drupal\Core\Render\RenderContext;
use Drupal\views\Views;
/**
@ -24,10 +25,15 @@ class TaxonomyFieldTidTest extends TaxonomyTestBase {
public static $testViews = array('test_taxonomy_tid_field');
function testViewsHandlerTidField() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$view = Views::getView('test_taxonomy_tid_field');
$this->executeView($view);
$actual = $view->field['name']->advancedRender($view->result[0]);
$actual = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$expected = \Drupal::l($this->term1->label(), $this->term1->urlInfo());
$this->assertEqual($expected, $actual);

View file

@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests\Views;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\entity_reference\Tests\EntityReferenceTestTrait;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\views\Tests\ViewTestData;
@ -20,6 +22,8 @@ use Drupal\views_ui\Tests\UITestBase;
*/
class TaxonomyIndexTidUiTest extends UITestBase {
use EntityReferenceTestTrait;
/**
* Views used by this test.
*
@ -32,7 +36,7 @@ class TaxonomyIndexTidUiTest extends UITestBase {
*
* @var array
*/
public static $modules = array('node', 'taxonomy', 'taxonomy_test_views');
public static $modules = array('node', 'taxonomy', 'taxonomy_test_views', 'entity_reference');
/**
* A nested array of \Drupal\taxonomy\TermInterface objects.
@ -120,4 +124,72 @@ class TaxonomyIndexTidUiTest extends UITestBase {
$this->assertIdentical($expected, $view->calculateDependencies());
}
/**
* Tests exposed taxonomy filters.
*/
public function testExposedFilter() {
$node_type = $this->drupalCreateContentType(['type' => 'page']);
// Create the tag field itself.
$field_name = 'taxonomy_tags';
$this->createEntityReferenceField('node', $node_type->id(), $field_name, NULL, 'taxonomy_term');
// Create 4 nodes: 1 without a term, 2 with the same term, and 1 with a
// different term.
$node1 = $this->drupalCreateNode();
$node2 = $this->drupalCreateNode([
$field_name => [['target_id' => $this->terms[1][0]->id()]],
]);
$node3 = $this->drupalCreateNode([
$field_name => [['target_id' => $this->terms[1][0]->id()]],
]);
$node4 = $this->drupalCreateNode([
$field_name => [['target_id' => $this->terms[2][0]->id()]],
]);
// Only the nodes with the selected term should be shown.
$this->drupalGet('test-filter-taxonomy-index-tid');
$xpath = $this->xpath('//div[@class="view-content"]//a');
$this->assertIdentical(2, count($xpath));
$xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node2->url()]);
$this->assertIdentical(1, count($xpath));
$xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node3->url()]);
$this->assertIdentical(1, count($xpath));
// Expose the filter.
$this->drupalPostForm('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid', [], 'Expose filter');
// Set the operator to 'empty' and remove the default term ID.
$this->drupalPostForm(NULL, [
'options[operator]' => 'empty',
'options[value][]' => [],
], 'Apply');
// Save the view.
$this->drupalPostForm(NULL, [], 'Save');
// After switching to 'empty' operator, the node without a term should be
// shown.
$this->drupalGet('test-filter-taxonomy-index-tid');
$xpath = $this->xpath('//div[@class="view-content"]//a');
$this->assertIdentical(1, count($xpath));
$xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node1->url()]);
$this->assertIdentical(1, count($xpath));
// Set the operator to 'not empty'.
$this->drupalPostForm('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid', ['options[operator]' => 'not empty'], 'Apply');
// Save the view.
$this->drupalPostForm(NULL, [], 'Save');
// After switching to 'not empty' operator, all nodes with terms should be
// shown.
$this->drupalGet('test-filter-taxonomy-index-tid');
$xpath = $this->xpath('//div[@class="view-content"]//a');
$this->assertIdentical(3, count($xpath));
$xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node2->url()]);
$this->assertIdentical(1, count($xpath));
$xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node3->url()]);
$this->assertIdentical(1, count($xpath));
$xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node4->url()]);
$this->assertIdentical(1, count($xpath));
}
}