function PageTest::testBatchProgressPageTheme

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Batch/PageTest.php \Drupal\Tests\system\Functional\Batch\PageTest::testBatchProgressPageTheme()
  2. 8.9.x core/modules/system/tests/src/Functional/Batch/PageTest.php \Drupal\Tests\system\Functional\Batch\PageTest::testBatchProgressPageTheme()
  3. 10 core/modules/system/tests/src/Functional/Batch/PageTest.php \Drupal\Tests\system\Functional\Batch\PageTest::testBatchProgressPageTheme()

Tests that the batch API progress page uses the correct theme.

File

core/modules/system/tests/src/Functional/Batch/PageTest.php, line 31

Class

PageTest
Tests the content of the progress page.

Namespace

Drupal\Tests\system\Functional\Batch

Code

public function testBatchProgressPageTheme() : void {
    // Make sure that the page which starts the batch (an administrative page)
    // is using a different theme than would normally be used by the batch API.
    $this->container
        ->get('theme_installer')
        ->install([
        'claro',
        'olivero',
    ]);
    $this->config('system.theme')
        ->set('default', 'olivero')
        ->set('admin', 'claro')
        ->save();
    // Log in as an administrator who can see the administrative theme.
    $admin_user = $this->drupalCreateUser([
        'view the administration theme',
    ]);
    $this->drupalLogin($admin_user);
    // Visit an administrative page that runs a test batch, and check that the
    // theme that was used during batch execution (which the batch callback
    // function saved as a variable) matches the theme used on the
    // administrative page.
    $this->drupalGet('admin/batch-test/test-theme');
    // The stack should contain the name of the theme used on the progress
    // page.
    $this->assertEquals([
        'claro',
    ], batch_test_stack(), 'A progressive batch correctly uses the theme of the page that started the batch.');
}

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