public function RadioButtonsSortWidgetKernelTest::testExposedRadioButtons in Better Exposed Filters 8.5
Same name and namespace in other branches
- 8.4 tests/src/Kernel/Plugin/sort/RadioButtonsSortWidgetKernelTest.php \Drupal\Tests\better_exposed_filters\Kernel\Plugin\sort\RadioButtonsSortWidgetKernelTest::testExposedRadioButtons()
Tests the exposed radio buttons sort widget.
File
- tests/
src/ Kernel/ Plugin/ sort/ RadioButtonsSortWidgetKernelTest.php, line 25
Class
- RadioButtonsSortWidgetKernelTest
- Tests the radio buttons sort widget (i.e. "bef").
Namespace
Drupal\Tests\better_exposed_filters\Kernel\Plugin\sortCode
public function testExposedRadioButtons() {
$view = Views::getView('bef_test');
$display =& $view->storage
->getDisplay('default');
// Change exposed sort to radio buttons (i.e. 'bef').
$this
->setBetterExposedOptions($view, [
'sort' => [
'plugin_id' => 'bef',
],
]);
// Render the exposed form.
$this
->renderExposedForm($view);
// Check our sort item "sort_by" is rendered as links.
$actual = $this
->xpath('//form//input[@type="radio" and starts-with(@id, "edit-sort-by")]');
$this
->assertCount(1, $actual, 'Exposed sort "sort_by" has correct number of exposed radio buttons.');
// Check our sort item "sort_order" is rendered as links.
$actual = $this
->xpath('//form//input[@type="radio" and starts-with(@id, "edit-sort-order")]');
$this
->assertCount(2, $actual, 'Exposed sort "sort_order" has correct number of exposed radio buttons.');
$view
->destroy();
}