function AreaResultTest::testResultEmpty
Same name in other branches
- 8.9.x core/modules/views/tests/src/Kernel/Handler/AreaResultTest.php \Drupal\Tests\views\Kernel\Handler\AreaResultTest::testResultEmpty()
- 10 core/modules/views/tests/src/Kernel/Handler/AreaResultTest.php \Drupal\Tests\views\Kernel\Handler\AreaResultTest::testResultEmpty()
- 11.x core/modules/views/tests/src/Kernel/Handler/AreaResultTest.php \Drupal\Tests\views\Kernel\Handler\AreaResultTest::testResultEmpty()
Tests the results area handler.
File
-
core/
modules/ views/ tests/ src/ Kernel/ Handler/ AreaResultTest.php, line 40
Class
- AreaResultTest
- Tests the result area handler.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
public function testResultEmpty() {
$view = Views::getView('test_area_result');
// Test that the area is displayed if we have checked the empty checkbox.
$view->setDisplay('default');
// Add a filter that will make the result set empty.
$view->displayHandlers
->get('default')
->overrideOption('filters', [
'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
'operator' => '=',
'value' => 'non-existing-name',
],
]);
$this->executeView($view);
$output = $view->render();
$output = \Drupal::service('renderer')->renderRoot($output);
$this->setRawContent($output);
$this->assertText('start: 0 | end: 0 | total: 0 | label: test_area_result | per page: 0 | current page: 1 | current record count: 0 | page count: 1');
$this->assertRaw('<header>');
// Test that the area is not displayed if we have not checked the empty
// checkbox.
$view->setDisplay('page_1');
$this->executeView($view);
$output = $view->render();
$output = \Drupal::service('renderer')->renderRoot($output);
$this->setRawContent($output);
$this->assertNoText('start: 0 | end: 0 | total: 0 | label: test_area_result | per page: 0 | current page: 1 | current record count: 0 | page count: 1');
// Make sure the empty header region isn't rendered.
$this->assertNoRaw('<header>');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.