public function ViewsIntegrationTest::testChildrenSummaryField in Entity Reference Hierarchy 3.x
Tests the child summary field.
File
- tests/
src/ Kernel/ ViewsIntegrationTest.php, line 280
Class
- ViewsIntegrationTest
- Defines a class for testing views integration.
Namespace
Drupal\Tests\entity_hierarchy\KernelCode
public function testChildrenSummaryField() {
$children = $this
->createChildEntities($this->parent
->id(), 1, 'First');
$child = reset($children);
$children = $this
->createChildEntities($child
->id(), 2, 'Second');
foreach ($children as $key => $child) {
$children = $this
->createChildEntities($child
->id(), 3, "Third-{$key}");
}
$child = reset($children);
$this
->createChildEntities($child
->id(), 1, 'Fourth');
$this
->createChildEntities($this->parent
->id(), 1, 'Other');
$executable = Views::getView('entity_hierarchy_test_fields_view');
$output = $executable
->preview('summary_child_counts');
$output = \Drupal::service('renderer')
->renderRoot($output);
$this
->assertStringContainsString('Parent child counts are 2 / 2 / 6 / 1', $output);
$this
->assertStringContainsString('Child First1 child counts are 2 / 6 / 1', $output);
$this
->assertStringContainsString('Child Second2 child counts are 3 / 1', $output);
$this
->assertStringContainsString('Child Third-Child Second21 child counts are 1', $output);
$this
->assertStringContainsString('Child Second1 child counts are 3', $output);
}