From ec3acb2a1e1569e2e6a6ca6fa20af731e30f1ad5 Mon Sep 17 00:00:00 2001 From: Tim Plunkett <git@plnktt.com> Date: Mon, 24 Sep 2012 18:24:38 -0400 Subject: [PATCH] The standard profile cannot be used by a module that provides a bundle. --- .../Taxonomy/RelationshipNodeTermDataTest.php | 81 ++++++++++++++++--- 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/lib/Drupal/views/Tests/Taxonomy/RelationshipNodeTermDataTest.php b/lib/Drupal/views/Tests/Taxonomy/RelationshipNodeTermDataTest.php index f96cbb1b0bdb..dbfd8fae472c 100644 --- a/lib/Drupal/views/Tests/Taxonomy/RelationshipNodeTermDataTest.php +++ b/lib/Drupal/views/Tests/Taxonomy/RelationshipNodeTermDataTest.php @@ -14,8 +14,6 @@ */ class RelationshipNodeTermDataTest extends ViewTestBase { - protected $profile = 'standard'; - /** * Modules to enable. * @@ -23,6 +21,13 @@ class RelationshipNodeTermDataTest extends ViewTestBase { */ public static $modules = array('taxonomy'); + /** + * The vocabulary for the test. + * + * @var Drupal\taxonomy\Vocabulary + */ + protected $vocabulary; + public static function getInfo() { return array( 'name' => 'Taxonomy: Node term data Relationship', @@ -34,13 +39,13 @@ public static function getInfo() { /** * Returns a new term with random properties in vocabulary $vid. */ - function createTerm($vocabulary) { + function createTerm() { $term = entity_create('taxonomy_term', array( 'name' => $this->randomName(), 'description' => $this->randomName(), // Use the first available text format. 'format' => db_query_range('SELECT format FROM {filter_format}', 0, 1)->fetchField(), - 'vid' => $vocabulary->vid, + 'vid' => $this->vocabulary->vid, 'langcode' => LANGUAGE_NOT_SPECIFIED, )); taxonomy_term_save($term); @@ -49,18 +54,76 @@ function createTerm($vocabulary) { function setUp() { parent::setUp(); + $this->mockStandardInstall(); - $vocabulary = taxonomy_vocabulary_machine_name_load('tags'); - $this->term_1 = $this->createTerm($vocabulary); - $this->term_2 = $this->createTerm($vocabulary); + $this->term_1 = $this->createTerm(); + $this->term_2 = $this->createTerm(); $node = array(); $node['type'] = 'article'; - $node['field_tags'][LANGUAGE_NOT_SPECIFIED][]['tid'] = $this->term_1->tid; - $node['field_tags'][LANGUAGE_NOT_SPECIFIED][]['tid'] = $this->term_2->tid; + $node['field_views_testing_tags'][LANGUAGE_NOT_SPECIFIED][]['tid'] = $this->term_1->tid; + $node['field_views_testing_tags'][LANGUAGE_NOT_SPECIFIED][]['tid'] = $this->term_2->tid; $this->node = $this->drupalCreateNode($node); } + /** + * Provides a workaround for the inability to use the standard profile. + * + * @see http://drupal.org/node/1708692 + */ + protected function mockStandardInstall() { + $type = array( + 'type' => 'article', + ); + + $type = node_type_set_defaults($type); + node_type_save($type); + node_add_body_field($type); + + // Create the vocabulary for the tag field. + $this->vocabulary = entity_create('taxonomy_vocabulary', array( + 'name' => 'Views testing tags', + 'machine_name' => 'views_testing_tags', + )); + $this->vocabulary->save(); + $field = array( + 'field_name' => 'field_' . $this->vocabulary->machine_name, + 'type' => 'taxonomy_term_reference', + // Set cardinality to unlimited for tagging. + 'cardinality' => FIELD_CARDINALITY_UNLIMITED, + 'settings' => array( + 'allowed_values' => array( + array( + 'vocabulary' => $this->vocabulary->machine_name, + 'parent' => 0, + ), + ), + ), + ); + field_create_field($field); + $instance = array( + 'field_name' => 'field_' . $this->vocabulary->machine_name, + 'entity_type' => 'node', + 'label' => 'Tags', + 'bundle' => 'article', + 'widget' => array( + 'type' => 'taxonomy_autocomplete', + 'weight' => -4, + ), + 'display' => array( + 'default' => array( + 'type' => 'taxonomy_term_reference_link', + 'weight' => 10, + ), + 'teaser' => array( + 'type' => 'taxonomy_term_reference_link', + 'weight' => 10, + ), + ), + ); + field_create_instance($instance); + } + function testViewsHandlerRelationshipNodeTermData() { $this->executeView($this->view, array($this->term_1->tid, $this->term_2->tid)); $resultset = array( -- GitLab