public function HiddenFilterWidgetKernelTest::testSingleExposedHiddenElement in Better Exposed Filters 8.5
Same name and namespace in other branches
- 8.4 tests/src/Kernel/Plugin/filter/HiddenFilterWidgetKernelTest.php \Drupal\Tests\better_exposed_filters\Kernel\Plugin\filter\HiddenFilterWidgetKernelTest::testSingleExposedHiddenElement()
Tests hiding element with single option.
File
- tests/
src/ Kernel/ Plugin/ filter/ HiddenFilterWidgetKernelTest.php, line 25
Class
- HiddenFilterWidgetKernelTest
- Tests the options of a hidden filter widget.
Namespace
Drupal\Tests\better_exposed_filters\Kernel\Plugin\filterCode
public function testSingleExposedHiddenElement() {
$view = Views::getView('bef_test');
$display =& $view->storage
->getDisplay('default');
// Change exposed filter "field_bef_boolean" to hidden (i.e. 'bef_hidden').
$this
->setBetterExposedOptions($view, [
'filter' => [
'field_bef_boolean_value' => [
'plugin_id' => 'bef_hidden',
],
],
]);
// Render the exposed form.
$this
->renderExposedForm($view);
// Check our "FIELD_BEF_BOOLEAN" filter is rendered as a hidden element.
$actual = $this
->xpath('//form//input[@type="hidden" and starts-with(@name, "field_bef_boolean_value")]');
$this
->assertCount(1, $actual, 'Exposed filter "FIELD_BEF_BOOLEAN" is hidden.');
$view
->destroy();
}