SingleFilterWidgetKernelTest.php in Better Exposed Filters 8.5
File
tests/src/Kernel/Plugin/filter/SingleFilterWidgetKernelTest.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 SingleFilterWidgetKernelTest extends BetterExposedFiltersKernelTestBase {
public static $testViews = [
'bef_test',
];
public function testSingleExposedCheckbox() {
$view = Views::getView('bef_test');
$display =& $view->storage
->getDisplay('default');
$this
->setBetterExposedOptions($view, [
'filter' => [
'field_bef_boolean_value' => [
'plugin_id' => 'bef_single',
],
],
]);
$this
->renderExposedForm($view);
$actual = $this
->xpath('//form//input[@type="checkbox" and starts-with(@name, "field_bef_boolean_value")]');
$this
->assertCount(1, $actual, 'Exposed filter "FIELD_BEF_BOOLEAN" is rendered as a checkbox.');
$view
->destroy();
}
}