ThemeTokenTest.php in Drupal 10
File
core/modules/system/tests/src/Functional/Theme/ThemeTokenTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Theme;
use Drupal\Tests\BrowserTestBase;
class ThemeTokenTest extends BrowserTestBase {
protected static $modules = [
'block',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$account = $this
->drupalCreateUser([
'administer blocks',
'view the administration theme',
]);
$this
->drupalLogin($account);
}
public function testThemeToken() {
$this
->drupalGet('admin/structure/block');
$settings = $this
->getDrupalSettings();
$this
->assertNull($settings['ajaxPageState']['theme_token']);
$this->container
->get('theme_installer')
->install([
'claro',
]);
$this
->config('system.theme')
->set('admin', 'claro')
->save();
$this
->drupalGet('admin/structure/block');
$settings = $this
->getDrupalSettings();
$this
->assertNotNull($settings['ajaxPageState']['theme_token']);
$this
->assertIsString($settings['ajaxPageState']['theme_token']);
$this
->assertEquals(43, strlen($settings['ajaxPageState']['theme_token']));
}
}
Classes
Name |
Description |
ThemeTokenTest |
Tests the generation of 'theme_token' key in Drupal settings. |