You are here

public function SmsFrameworkProviderTest::testIncoming in SMS Framework 8

Same name and namespace in other branches
  1. 2.x tests/src/Kernel/SmsFrameworkProviderTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkProviderTest::testIncoming()
  2. 2.1.x tests/src/Kernel/SmsFrameworkProviderTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkProviderTest::testIncoming()

Test message is received.

@covers ::incoming

File

tests/src/Kernel/SmsFrameworkProviderTest.php, line 120

Class

SmsFrameworkProviderTest
Tests SMS Framework provider service.

Namespace

Drupal\Tests\sms\Kernel

Code

public function testIncoming() {
  $message = $this
    ->randomString();
  $sms_message = SmsMessage::create()
    ->setDirection(Direction::INCOMING)
    ->setMessage($message)
    ->setGateway($this->gateway);
  $sms_message
    ->setResult($this
    ->createMessageResult($sms_message));
  $sms_messages = $this->smsProvider
    ->incoming($sms_message);
  $this
    ->assertEquals($message, sms_test_gateway_get_incoming()['message'], 'Message was received.');
  $this
    ->assertEquals(1, count($sms_messages), 'Return value contains 1 item.');
  $this
    ->assertTrue($sms_messages[0] instanceof StandardSmsMessageInterface, 'Return value is a SMS message.');
  $this
    ->assertTrue($sms_messages[0]
    ->getResult() instanceof SmsMessageResultInterface);
}