AreaResultTest.php in Drupal 10
File
core/modules/views/tests/src/Kernel/Handler/AreaResultTest.php
View source
<?php
namespace Drupal\Tests\views\Kernel\Handler;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
class AreaResultTest extends ViewsKernelTestBase {
public static $testViews = [
'test_area_result',
];
public function testResult() {
$view = Views::getView('test_area_result');
$view
->setDisplay('default');
$this
->executeView($view);
$output = $view
->render();
$output = \Drupal::service('renderer')
->renderRoot($output);
$this
->setRawContent($output);
$this
->assertText('start: 1 | end: 5 | total: 5 | label: test_area_result | per page: 0 | current page: 1 | current record count: 5 | page count: 1');
$this
->assertNoRaw('<script />');
}
public function testResultEmpty() {
$view = Views::getView('test_area_result');
$view
->setDisplay('default');
$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>');
$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');
$this
->assertNoRaw('<header>');
}
}