public function BEF_TestCase::testsimpletest_befTaxonomyFilters in Better Exposed Filters 7
Same name and namespace in other branches
- 8.3 tests/better_exposed_filters.test \BEF_TestCase::testsimpletest_befTaxonomyFilters()
- 6.3 tests/better_exposed_filters.test \BEF_TestCase::testsimpletest_befTaxonomyFilters()
- 6 tests/better_exposed_filters.test \BEF_TestCase::testsimpletest_befTaxonomyFilters()
- 6.2 tests/better_exposed_filters.test \BEF_TestCase::testsimpletest_befTaxonomyFilters()
Verify taxonomy-based exposed filters display correctly as both radio buttons and checkboxes
File
- tests/
better_exposed_filters.test, line 267 - Tests for the Better Exposed Filters module @author mikeker
Class
- BEF_TestCase
- Functional test for Better Exposed Filters
Code
public function testsimpletest_befTaxonomyFilters() {
$this->taxonomy_user = $this
->drupalCreateUser(array(
'access content',
'administer views',
'administer taxonomy',
));
$this
->drupalLogin($this->taxonomy_user);
// Add a vocabulary and populate with a few terms
$edit = array(
'name' => 'BEF test vocab',
'nodes[page]' => TRUE,
'nodes[story]' => TRUE,
);
$this
->drupalPost('admin/content/taxonomy/add/vocabulary', $edit, 'Save');
$terms = array(
'test1',
'test2',
'test3',
'test4',
);
foreach ($terms as $term) {
$this
->drupalPost('admin/content/taxonomy/1/add/term', array(
'name' => $term,
), 'Save');
}
// Exposed the taxonomy filter
$addl = array(
'options[vid]' => TRUE,
'options[type]' => 'select',
'options[hierarchy]' => FALSE,
);
$this
->_befAddFilter('term_node.tid', TRUE, 'default', $addl);
// Exposed filter settings
$bef_settings = array(
'bef_format' => 'bef',
'bef_filter_description' => $this
->randomName(16),
);
$this
->_befExposedFilterSettings('tid', $bef_settings);
// Add a page view to the default view
$settings = array(
'path' => array(
'path' => $this
->randomName(8),
),
);
$this
->_befCreateDisplay('page', $settings);
$this
->_befSaveView();
// Verify taxonomy filter as radio buttons
$this
->drupalGet($settings['path']['path']);
$this
->assertText(t('Taxonomy: Term'), 'Verify exposed filter label', 'Better Exposed Filters');
$this
->assertFieldByXpath('//input[@name="tid" and @type="radio"]', NULL, 'Exposed filter is shown as radio buttons', 'Better Exposed Filters');
// Set Force single to FALSE to display as checkboxes and set select all/none option
$bef_settings = array(
'bef_select_all_none' => TRUE,
'single' => FALSE,
);
$this
->_befExposedFilterSettings('tid', $bef_settings);
$this
->_befSaveView();
// Verify taxonomy filter as checkboxes
$this
->drupalGet($settings['path']['path']);
$this
->assertText(t('Taxonomy: Term'), 'Verify exposed filter label', 'Better Exposed Filters');
$this
->assertFieldByXpath('//input[@name="tid[]" and @type="checkbox"]', NULL, 'Exposed filter is shown as checkboxes', 'Better Exposed Filters');
$this
->assertFieldByXpath('//div[contains(@class, "bef-select-all-none")]', NULL, 'Class is set correctly for JS to build select all/none links', 'Beter Exposed Filters');
}