You are here

class LegacyMessengerTest in Service Container 7

Same name in this branch
  1. 7 tests/src/Messenger/LegacyMessengerTest.php \Drupal\Tests\service_container\Messenger\LegacyMessengerTest
  2. 7 lib/Drupal/service_container/Tests/LegacyMessengerTest.php \Drupal\service_container\Tests\LegacyMessengerTest
Same name and namespace in other branches
  1. 7.2 lib/Drupal/service_container/Tests/LegacyMessengerTest.php \Drupal\service_container\Tests\LegacyMessengerTest

Hierarchy

Expanded class hierarchy of LegacyMessengerTest

File

lib/Drupal/service_container/Tests/LegacyMessengerTest.php, line 12
Contains \Drupal\service_container\Tests\LegacyMessengerTest.

Namespace

Drupal\service_container\Tests
View source
class LegacyMessengerTest extends ServiceContainerIntegrationTestBase {

  /**
   * {@inheritdoc}
   */
  public static function getInfo() {
    return array(
      'name' => 'LegacyMessenger',
      'description' => 'Tests the messenger integration',
      'group' => 'service_container',
    );
  }
  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));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LegacyMessengerTest::getInfo public static function
LegacyMessengerTest::testLegacyMessenger public function
ServiceContainerIntegrationTestBase::$container protected property The dependency injection container usable in the test.
ServiceContainerIntegrationTestBase::$profile protected property The profile to install as a basis for testing. 1
ServiceContainerIntegrationTestBase::setUp protected function 5