ClassyTest.php in Drupal 9
File
core/modules/system/tests/src/Kernel/Render/ClassyTest.php
View source
<?php
namespace Drupal\Tests\system\Kernel\Render;
use Drupal\KernelTests\KernelTestBase;
class ClassyTest extends KernelTestBase {
protected static $modules = [
'system',
'twig_theme_test',
];
public function setUp() : void {
parent::setUp();
$this->container
->get('theme_installer')
->install([
'classy',
]);
$this->container
->get('config.factory')
->getEditable('system.theme')
->set('default', 'classy')
->save();
$this->container
->set('theme.registry', NULL);
}
public function testClassyTheme() {
\Drupal::messenger()
->addError('An error occurred');
\Drupal::messenger()
->addStatus('But then something nice happened');
$messages = [
'#type' => 'status_messages',
];
$this
->render($messages);
$this
->assertNoText('custom-test-messages-class', 'The custom class attribute value added in the status messages preprocess function is not displayed as page content.');
}
}