function SystemMessageTest::getMessages

Retrieves the stored messages.

Parameters

null|string $type: (optional) The type of messages to return. Defaults to NULL which causes all messages to be returned.

Return value

array|null A multidimensional array with keys corresponding to the set message types. The indexed array values of each contain the set messages for that type. The messages returned are limited to the type specified in the $type parameter. If there are no messages of the specified type, an empty array is returned.

2 calls to SystemMessageTest::getMessages()
SystemMessageTest::testActionExecution in tests/src/Unit/Integration/RulesAction/SystemMessageTest.php
Tests the action execution.
SystemMessageTest::testOptionalRepeat in tests/src/Unit/Integration/RulesAction/SystemMessageTest.php
Tests that the action works if the optional repeat flag is not set.

File

tests/src/Unit/Integration/RulesAction/SystemMessageTest.php, line 121

Class

SystemMessageTest
@coversDefaultClass \Drupal\rules\Plugin\RulesAction\SystemMessage @group RulesAction

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

protected function getMessages($type = NULL) {
    $messages = $this->messenger
        ->all();
    if (isset($type)) {
        return $messages[$type] ?? NULL;
    }
    return $messages;
}