function PagerTest::testPagerHeadingLevel

Same name in other branches
  1. 10 core/modules/views/tests/src/Functional/Plugin/PagerTest.php \Drupal\Tests\views\Functional\Plugin\PagerTest::testPagerHeadingLevel()

Tests changing the heading level.

File

core/modules/views/tests/src/Functional/Plugin/PagerTest.php, line 382

Class

PagerTest
Tests the pluggable pager system.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function testPagerHeadingLevel() : void {
    // Create 2 nodes and make sure that everyone is returned.
    $this->drupalCreateContentType([
        'type' => 'page',
    ]);
    for ($i = 0; $i < 2; $i++) {
        $this->drupalCreateNode();
    }
    // Set "Pager Heading" to h2 and check that it is correct.
    $view = Views::getView('test_pager_full');
    $view->setDisplay();
    $pager = [
        'type' => 'full',
        'options' => [
            'pagination_heading_level' => 'h2',
            'items_per_page' => 1,
            'quantity' => 1,
        ],
    ];
    $view->display_handler
        ->setOption('pager', $pager);
    $view->save();
    $themes = [
        'stark',
        'olivero',
        'claro',
        'starterkit_theme',
        'stable9',
    ];
    $this->container
        ->get('theme_installer')
        ->install($themes);
    foreach ($themes as $theme) {
        $this->config('system.theme')
            ->set('default', $theme)
            ->save();
        $this->drupalGet('test_pager_full');
        $this->assertEquals('h2', $this->assertSession()
            ->elementExists('css', ".pager .visually-hidden")
            ->getTagName());
    }
}

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