function AreaTest::testTitleArea

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Functional/Handler/AreaTest.php \Drupal\Tests\views\Functional\Handler\AreaTest::testTitleArea()
  2. 8.9.x core/modules/views/tests/src/Functional/Handler/AreaTest.php \Drupal\Tests\views\Functional\Handler\AreaTest::testTitleArea()
  3. 10 core/modules/views/tests/src/Functional/Handler/AreaTest.php \Drupal\Tests\views\Functional\Handler\AreaTest::testTitleArea()

Tests overriding the view title using the area title handler.

File

core/modules/views/tests/src/Functional/Handler/AreaTest.php, line 141

Class

AreaTest
Tests the plugin base of the area handler.

Namespace

Drupal\Tests\views\Functional\Handler

Code

public function testTitleArea() : void {
    $view = Views::getView('frontpage');
    $view->initDisplay('page_1');
    // Add the title area handler to the empty area.
    $view->displayHandlers
        ->get('page_1')
        ->overrideOption('empty', [
        'title' => [
            'id' => 'title',
            'table' => 'views',
            'field' => 'title',
            'admin_label' => '',
            'empty' => '0',
            'title' => 'Overridden title',
            'plugin_id' => 'title',
        ],
    ]);
    $view->storage
        ->enable()
        ->save();
    $this->drupalGet('node');
    $this->assertSession()
        ->pageTextContains('Overridden title');
}

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