public function ViewsIntegrationTest::testViewsIntegrationParents in Entity Reference Hierarchy 3.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/ViewsIntegrationTest.php \Drupal\Tests\entity_hierarchy\Kernel\ViewsIntegrationTest::testViewsIntegrationParents()
Tests views integration.
File
- tests/
src/ Kernel/ ViewsIntegrationTest.php, line 161
Class
- ViewsIntegrationTest
- Defines a class for testing views integration.
Namespace
Drupal\Tests\entity_hierarchy\KernelCode
public function testViewsIntegrationParents() {
$children = $this
->createChildEntities($this->parent
->id(), 1);
$child = reset($children);
$grandchildren = $this
->createChildEntities($child
->id(), 1);
// Tree is as follows
// 1 : Parent
// - 2 : Child 1
// - - 3 : Child 1
// Test showing single hierarchy.
$expected = [
[
'name' => 'Parent',
'id' => 1,
],
[
'name' => 'Child 1',
'id' => 2,
],
];
$executable = Views::getView('entity_hierarchy_test_children_view');
$executable
->preview('block_3', [
$this
->getArgumentFromEntity(reset($grandchildren)),
]);
$this
->assertCount(2, $executable->result);
$this
->assertIdenticalResultset($executable, $expected, [
'name' => 'name',
'id' => 'id',
]);
}