public function TaxonomyIndexTidUiTest::testFilterUI in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php \Drupal\taxonomy\Tests\Views\TaxonomyIndexTidUiTest::testFilterUI()
Tests the filter UI.
File
- core/
modules/ taxonomy/ src/ Tests/ Views/ TaxonomyIndexTidUiTest.php, line 81 - Contains \Drupal\taxonomy\Tests\Views\TaxonomyIndexTidUiTest.
Class
- TaxonomyIndexTidUiTest
- Tests the taxonomy index filter handler UI.
Namespace
Drupal\taxonomy\Tests\ViewsCode
public function testFilterUI() {
$this
->drupalGet('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid');
$result = $this
->xpath('//select[@id="edit-options-value"]/option');
// Ensure that the expected hierarchy is available in the UI.
$counter = 0;
for ($i = 0; $i < 3; $i++) {
for ($j = 0; $j <= $i; $j++) {
$option = $result[$counter++];
$prefix = $this->terms[$i][$j]->parent->target_id ? '-' : '';
$attributes = $option
->attributes();
$tid = (string) $attributes->value;
$this
->assertEqual($prefix . $this->terms[$i][$j]
->getName(), (string) $option);
$this
->assertEqual($this->terms[$i][$j]
->id(), $tid);
}
}
// Ensure the autocomplete input element appears when using the 'textfield'
// type.
$view = entity_load('view', 'test_filter_taxonomy_index_tid');
$display =& $view
->getDisplay('default');
$display['display_options']['filters']['tid']['type'] = 'textfield';
$view
->save();
$this
->drupalGet('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid');
$this
->assertFieldByXPath('//input[@id="edit-options-value"]');
// Tests \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::calculateDependencies().
$expected = [
'config' => [
'taxonomy.vocabulary.tags',
],
'content' => [
'taxonomy_term:tags:' . Term::load(2)
->uuid(),
],
'module' => [
'node',
'taxonomy',
'user',
],
];
$this
->assertIdentical($expected, $view
->calculateDependencies()
->getDependencies());
}