public function LegacyMessengerTest::testLegacyMessenger in Service Container 7.2
Same name and namespace in other branches
- 7 lib/Drupal/service_container/Tests/LegacyMessengerTest.php \Drupal\service_container\Tests\LegacyMessengerTest::testLegacyMessenger()
File
- lib/
Drupal/ service_container/ Tests/ LegacyMessengerTest.php, line 25 - Contains \Drupal\service_container\Tests\LegacyMessengerTest.
Class
Namespace
Drupal\service_container\TestsCode
public function testLegacyMessenger() {
/** @var \Drupal\service_container\Messenger\LegacyMessenger $messenger_service */
$messenger_service = $this->container
->get('messenger');
$this
->assertTrue($messenger_service instanceof LegacyMessenger);
$random_message = $this
->randomString();
drupal_set_message($random_message, $messenger_service::WARNING);
$messages = $messenger_service
->getMessages();
$warning_messages = $messages[$messenger_service::WARNING];
$this
->assertTrue(in_array($random_message, $warning_messages));
$random_message = $this
->randomString();
$messenger_service
->addMessage($random_message, $messenger_service::STATUS);
$messages = drupal_get_messages();
$status_messages = $messages[$messenger_service::STATUS];
$this
->assertTrue(in_array($random_message, $status_messages));
}