8c16b63088d9a1ead0ba712d676ba73f048bca9d
[yaffs-website] / web / core / modules / views / tests / src / Kernel / Handler / AreaTitleTest.php
1 <?php
2
3 namespace Drupal\Tests\views\Kernel\Handler;
4
5 use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
6 use Drupal\views\Views;
7
8 /**
9  * Tests the title area handler.
10  *
11  * @group views
12  * @see \Drupal\views\Plugin\views\area\Title
13  */
14 class AreaTitleTest extends ViewsKernelTestBase {
15
16   /**
17    * Views used by this test.
18    *
19    * @var array
20    */
21   public static $testViews = ['test_area_title'];
22
23   /**
24    * Tests the title area handler.
25    */
26   public function testTitleText() {
27     $view = Views::getView('test_area_title');
28
29     $view->setDisplay('default');
30     $this->executeView($view);
31     $view->render();
32     $this->assertFalse($view->getTitle(), 'The title area does not override the title if the view is not empty.');
33     $view->destroy();
34
35     $view->setDisplay('default');
36     $this->executeView($view);
37     $view->result = [];
38     $view->render();
39     $this->assertEqual($view->getTitle(), 'test_title_empty', 'The title area should override the title if the result is empty.');
40     $view->destroy();
41
42     $view->setDisplay('page_1');
43     $this->executeView($view);
44     $view->render();
45     $this->assertEqual($view->getTitle(), 'test_title_header', 'The title area on the header should override the title if the result is not empty.');
46     $view->destroy();
47
48     $view->setDisplay('page_1');
49     $this->executeView($view);
50     $view->result = [];
51     $view->render();
52     $this->assertEqual($view->getTitle(), 'test_title_empty', 'The title area should override the title if the result is empty.');
53     $view->destroy();
54   }
55
56 }