LinksFilterWidgetKernelTest.php in Better Exposed Filters 8.5
File
tests/src/Kernel/Plugin/filter/LinksFilterWidgetKernelTest.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 LinksFilterWidgetKernelTest extends BetterExposedFiltersKernelTestBase {
public static $testViews = [
'bef_test',
];
public function testExposedLinks() {
$view = Views::getView('bef_test');
$display =& $view->storage
->getDisplay('default');
$display['display_options']['filters']['term_node_tid_depth']['hierarchy'] = TRUE;
$this
->setBetterExposedOptions($view, [
'filter' => [
'field_bef_integer_value' => [
'plugin_id' => 'bef_links',
],
'term_node_tid_depth' => [
'plugin_id' => 'bef_links',
],
],
]);
$this
->renderExposedForm($view);
$actual = $this
->xpath('//form//a[starts-with(@name, "field_bef_integer_value")]');
$this
->assertCount(6, $actual, 'Exposed filter "FIELD_BEF_INTEGER" has correct number of exposed links.');
$actual = $this
->xpath("//form//div[contains(concat(' ',normalize-space(@class),' '),' bef-nested ')]");
$this
->assertCount(1, $actual, 'Exposed filter "TERM_NODE_TID_DEPTH" has bef-nested class');
$actual = $this
->xpath('//form//div[@id="edit-term-node-tid-depth--2"]/ul/li/a[starts-with(@name, "term_node_tid_depth")]');
$this
->assertCount(4, $actual, 'Exposed filter "TERM_NODE_TID_DEPTH" has correct number of exposed top-level links.');
$actual = $this
->xpath('//form//div[@id="edit-term-node-tid-depth--2"]/ul/li/ul/li/a[starts-with(@name, "term_node_tid_depth")]');
$this
->assertCount(5, $actual, 'Exposed filter "TERM_NODE_TID_DEPTH" has correct number of exposed second-level links.');
$actual = $this
->xpath('//form//div[@id="edit-term-node-tid-depth--2"]/ul/li/ul/li/ul/li/a[starts-with(@name, "term_node_tid_depth")]');
$this
->assertCount(14, $actual, 'Exposed filter "TERM_NODE_TID_DEPTH" has correct number of exposed third-level links.');
$view
->destroy();
}
}