DrupalMessengerServiceTest.php in Drupal 9
File
core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Bootstrap;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
class DrupalMessengerServiceTest extends BrowserTestBase {
protected static $modules = [
'system_test',
];
protected $defaultTheme = 'stark';
public function testDrupalMessengerService() {
$this
->drupalGet(Url::fromRoute('system_test.messenger_service'));
$this
->assertSession()
->pageTextNotContains('First message (removed).');
$this
->assertSession()
->responseContains('Second message with <em>markup!</em> (not removed).');
$this
->assertSession()
->pageTextMatchesCount(1, '/Non Duplicated message/');
$this
->assertSession()
->pageTextMatchesCount(3, '/Duplicated message/');
$this
->assertSession()
->responseContains('Markup with <em>markup!</em>');
$this
->assertSession()
->pageTextMatchesCount(1, '/Markup with markup!/');
$this
->assertSession()
->responseContains('Markup2 with <em>markup!</em>');
$this
->assertSession()
->pageTextMatchesCount(1, '$Non duplicate Markup / string.$');
$this
->assertSession()
->pageTextMatchesCount(2, '$Duplicate Markup / string.$');
$this
->assertSession()
->assertEscaped('<em>This<span>markup will be</span> escaped</em>.');
$assert = $this
->assertSession();
$this
->drupalLogin($this->rootUser);
$edit = [];
$edit["modules[help][enable]"] = TRUE;
$this
->drupalGet('admin/modules');
$this
->submitForm($edit, 'Install');
$assert
->pageTextContains('Help has been enabled');
$assert
->pageTextContains('system_test_preinstall_module called');
}
}