HiddenFilterWidgetKernelTest.php in Better Exposed Filters 8.5
File
tests/src/Kernel/Plugin/filter/HiddenFilterWidgetKernelTest.php
View source
<?php
namespace Drupal\Tests\better_exposed_filters\Kernel\Plugin\filter;
use Drupal\Tests\better_exposed_filters\Kernel\BetterExposedFiltersKernelTestBase;
use Drupal\views\Views;
class HiddenFilterWidgetKernelTest extends BetterExposedFiltersKernelTestBase {
public static $testViews = [
'bef_test',
];
public function testSingleExposedHiddenElement() {
$view = Views::getView('bef_test');
$display =& $view->storage
->getDisplay('default');
$this
->setBetterExposedOptions($view, [
'filter' => [
'field_bef_boolean_value' => [
'plugin_id' => 'bef_hidden',
],
],
]);
$this
->renderExposedForm($view);
$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();
}
public function testMultipleExposedHiddenElement() {
$view = Views::getView('bef_test');
$display =& $view->storage
->getDisplay('default');
$display['display_options']['filters']['field_bef_integer_value']['expose']['multiple'] = TRUE;
$this
->setBetterExposedOptions($view, [
'filter' => [
'field_bef_integer_value' => [
'plugin_id' => 'bef_hidden',
],
],
]);
$this
->renderExposedForm($view);
$actual = $this
->xpath('//form//label[@type="label" and starts-with(@for, "edit-field-bef-integer-value")]');
$this
->assertCount(0, $actual, 'Exposed filter "FIELD_BEF_INTEGER" is hidden.');
$actual = $this
->xpath('//form//input[@type="hidden" and starts-with(@name, "field_bef_integer_value")]');
$this
->assertCount(0, $actual, 'Exposed filter "FIELD_BEF_INTEGER" has no selected values.');
}
}