Skip to content
Snippets Groups Projects

Issue #2829178: Views Term ID has broken filters ("All of", "Is none of") and contextual filters "allow multiple"

Open Issue #2829178: Views Term ID has broken filters ("All of", "Is none of") and contextual filters "allow multiple"
Open Bryan Heisler requested to merge issue/drupal-2829178:2829178-views-term-id into 9.4.x
Files
22
@@ -358,4 +358,46 @@ public function testExposedUnpublishedFilterOptions() {
$this->assertEmpty($this->cssSelect('option[value="' . $this->terms[1][0]->id() . '"]'));
}
/**
* Tests using the TaxonomyIndexTid in a filter group.
*/
public function testFilterGrouping() {
$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 3 nodes: 1 without a term and 2 with different terms.
$this->drupalCreateNode();
$this->drupalCreateNode([
$field_name => [['target_id' => $this->terms[1][0]->id()]],
]);
$this->drupalCreateNode([
$field_name => [['target_id' => $this->terms[2][0]->id()]],
]);
// Create two groups. The first group contains the published filter and set
// up the second group as an 'OR' group for two different terms.
$view = View::load('test_filter_taxonomy_index_tid');
$display =& $view->getDisplay('default');
$display['display_options']['filters']['tid']['value'][0] = $this->terms[1][0]->id();
$display['display_options']['filters']['tid']['group'] = 2;
$display['display_options']['filters']['tid_2'] = $display['display_options']['filters']['tid'];
$display['display_options']['filters']['tid_2']['id'] = 'tid_2';
$display['display_options']['filters']['tid_2']['value'][0] = $this->terms[2][0]->id();
$display['display_options']['filter_groups'] = [
'operator' => 'AND',
'groups' => [
1 => 'AND',
2 => 'OR',
],
];
$view->save();
$this->drupalGet('test-filter-taxonomy-index-tid');
$xpath = $this->xpath('//div[@class="view-content"]//a');
// We expect both nodes with terms but not the node without a term.
$this->assertCount(2, $xpath);
}
}
Loading