You are here

protected function SmsFrameworkTestTrait::getLastIncomingMessage in SMS Framework 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/SmsFrameworkTestTrait.php \Drupal\Tests\sms\Functional\SmsFrameworkTestTrait::getLastIncomingMessage()
  2. 2.1.x tests/src/Functional/SmsFrameworkTestTrait.php \Drupal\Tests\sms\Functional\SmsFrameworkTestTrait::getLastIncomingMessage()

Get the last message sent to gateway.

Parameters

\Drupal\sms\Entity\SmsGatewayInterface $sms_gateway: A gateway plugin.

Return value

\Drupal\sms\Message\SmsMessageInterface|false The last message, or FALSE if no messages were received.

File

tests/src/Functional/SmsFrameworkTestTrait.php, line 126

Class

SmsFrameworkTestTrait
Shared SMS Framework helpers for kernel and web tests.

Namespace

Drupal\Tests\sms\Functional

Code

protected function getLastIncomingMessage(SmsGatewayInterface $sms_gateway) {
  $gateway_id = $sms_gateway
    ->id();
  $sms_messages = \Drupal::state()
    ->get('sms_test_gateway.memory.incoming', []);
  return isset($sms_messages[$gateway_id]) ? end($sms_messages[$gateway_id]) : FALSE;
}