function MiniPagerTest::testPagerHeadingLevel

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

Tests changing the heading level.

File

core/modules/views/tests/src/Functional/Plugin/MiniPagerTest.php, line 152

Class

MiniPagerTest
Tests the mini pager plugin.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function testPagerHeadingLevel() : void {
    // Set "Pager Heading" to h3 and check that it is correct.
    $view = Views::getView('test_mini_pager');
    $view->setDisplay();
    $pager = [
        'type' => 'mini',
        'options' => [
            'pagination_heading_level' => 'h3',
            'items_per_page' => 5,
        ],
    ];
    $view->display_handler
        ->setOption('pager', $pager);
    $view->save();
    // Stark and Stable9 are handled below.
    $themes = [
        'olivero',
        'claro',
        'starterkit_theme',
    ];
    $this->container
        ->get('theme_installer')
        ->install($themes);
    foreach ($themes as $theme) {
        $this->config('system.theme')
            ->set('default', $theme)
            ->save();
        $this->drupalGet('test_mini_pager');
        $this->assertEquals('h3', $this->assertSession()
            ->elementExists('css', ".pager .visually-hidden")
            ->getTagName());
    }
    // The core views template and Stable9 use a different class structure than other core themes.
    $themes = [
        'stark',
        'stable9',
    ];
    $this->container
        ->get('theme_installer')
        ->install($themes);
    foreach ($themes as $theme) {
        $this->config('system.theme')
            ->set('default', $theme)
            ->save();
        $this->drupalGet('test_mini_pager');
        $this->assertEquals('h3', $this->assertSession()
            ->elementExists('css', "#pagination-heading")
            ->getTagName());
    }
}

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