function AreaTitleTest::testTitleText

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Kernel/Handler/AreaTitleTest.php \Drupal\Tests\views\Kernel\Handler\AreaTitleTest::testTitleText()
  2. 10 core/modules/views/tests/src/Kernel/Handler/AreaTitleTest.php \Drupal\Tests\views\Kernel\Handler\AreaTitleTest::testTitleText()
  3. 11.x core/modules/views/tests/src/Kernel/Handler/AreaTitleTest.php \Drupal\Tests\views\Kernel\Handler\AreaTitleTest::testTitleText()

Tests the title area handler.

File

core/modules/views/tests/src/Kernel/Handler/AreaTitleTest.php, line 26

Class

AreaTitleTest
Tests the title area handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testTitleText() {
    $view = Views::getView('test_area_title');
    $view->setDisplay('default');
    $this->executeView($view);
    $view->render();
    $this->assertEmpty($view->getTitle(), 'The title area does not override the title if the view is not empty.');
    $view->destroy();
    $view->setDisplay('default');
    $this->executeView($view);
    $view->result = [];
    $view->render();
    $this->assertEquals('test_title_empty', $view->getTitle(), 'The title area should override the title if the result is empty.');
    $view->destroy();
    $view->setDisplay('page_1');
    $this->executeView($view);
    $view->render();
    $this->assertEquals('test_title_header', $view->getTitle(), 'The title area on the header should override the title if the result is not empty.');
    $view->destroy();
    $view->setDisplay('page_1');
    $this->executeView($view);
    $view->result = [];
    $view->render();
    $this->assertEquals('test_title_empty', $view->getTitle(), 'The title area should override the title if the result is empty.');
    $view->destroy();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.