function TaxonomyTermFilterDepthTest::testTermWithDepthFilter
Same name in other branches
- 9 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyTermFilterDepthTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTermFilterDepthTest::testTermWithDepthFilter()
- 9 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermFilterDepthTest.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyTermFilterDepthTest::testTermWithDepthFilter()
- 10 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyTermFilterDepthTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTermFilterDepthTest::testTermWithDepthFilter()
- 11.x core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyTermFilterDepthTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTermFilterDepthTest::testTermWithDepthFilter()
Tests the terms with depth filter.
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ Views/ TaxonomyTermFilterDepthTest.php, line 78
Class
- TaxonomyTermFilterDepthTest
- Test the taxonomy term with depth filter.
Namespace
Drupal\Tests\taxonomy\Functional\ViewsCode
public function testTermWithDepthFilter() {
$column_map = [
'nid' => 'nid',
];
$assert_method = 'assertIdentical';
// Default view has an empty value for this filter, so all nodes should be
// returned.
$expected = [
[
'nid' => 1,
],
[
'nid' => 2,
],
[
'nid' => 3,
],
[
'nid' => 4,
],
[
'nid' => 5,
],
];
$this->executeView($this->view);
$this->assertIdenticalResultsetHelper($this->view, $expected, $column_map, $assert_method);
// Set filter to search on top-level term, with depth 0.
$expected = [
[
'nid' => 4,
],
];
$this->assertTermWithDepthResult($this->terms[0]
->id(), 0, $expected);
// Top-level term, depth 1.
$expected = [
[
'nid' => 4,
],
];
$this->assertTermWithDepthResult($this->terms[0]
->id(), 0, $expected);
// Top-level term, depth 2.
$expected = [
[
'nid' => 4,
],
[
'nid' => 5,
],
];
$this->assertTermWithDepthResult($this->terms[0]
->id(), 2, $expected);
// Second-level term, depth 1.
$expected = [
[
'nid' => 5,
],
];
$this->assertTermWithDepthResult($this->terms[1]
->id(), 1, $expected);
// Third-level term, depth 0.
$expected = [
[
'nid' => 5,
],
];
$this->assertTermWithDepthResult($this->terms[2]
->id(), 0, $expected);
// Third-level term, depth 1.
$expected = [
[
'nid' => 5,
],
];
$this->assertTermWithDepthResult($this->terms[2]
->id(), 1, $expected);
// Third-level term, depth -2.
$expected = [
[
'nid' => 4,
],
[
'nid' => 5,
],
];
$this->assertTermWithDepthResult($this->terms[2]
->id(), -2, $expected);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.