Projet

Général

Profil

Révision b1ab1c0c

Ajouté par Assos Assos il y a environ 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/entityreference/tests/entityreference.taxonomy.test
112 112
    $this->assertFalse(taxonomy_select_nodes(1));
113 113
  }
114 114

  
115
  /**
116
   * Add a second ER field from node/article to taxonomy.
117
   *
118
   * This should not cause {taxonomy_index} to receive duplicate entries.
119
   */
120
  protected function setupForIndexDuplicates() {
121
    // Create an entity reference field.
122
    $field = array(
123
      'entity_types' => array('node'),
124
      'settings' => array(
125
        'handler' => 'base',
126
        'target_type' => 'taxonomy_term',
127
        'handler_settings' => array(
128
          'target_bundles' => array(),
129
        ),
130
      ),
131
      'field_name' => 'field_entityreference_term2',
132
      'type' => 'entityreference',
133
    );
134
    $field = field_create_field($field);
135
    $instance = array(
136
      'field_name' => 'field_entityreference_term2',
137
      'bundle' => 'article',
138
      'entity_type' => 'node',
139
    );
140

  
141
    // Enable the taxonomy-index behavior.
142
    $instance['settings']['behaviors']['taxonomy-index']['status'] = TRUE;
143
    field_create_instance($instance);
144
  }
145

  
146
  /**
147
   * Make sure the index only contains one entry for a given node->term
148
   * reference, even when multiple ER fields link from the node bundle to terms.
149
   */
150
  public function testIndexDuplicates() {
151
    // Extra setup for this test: add another ER field on this content type.
152
    $this->setupForIndexDuplicates();
153

  
154
    // Assert node insert with reference to term in first field.
155
    $tid = 1;
156
    $settings = array();
157
    $settings['type'] = 'article';
158
    $settings['field_entityreference_term'][LANGUAGE_NONE][0]['target_id'] = $tid;
159
    $node = $this->drupalCreateNode($settings);
160

  
161
    $this->assertEqual(taxonomy_select_nodes($tid), array($node->nid));
162
  }
115 163
}

Formats disponibles : Unified diff