You are here

public function SmsFrameworkProviderTest::testIncomingNoDirection in SMS Framework 8

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

Ensures direction is set by the provider.

@covers ::incoming

File

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

Class

SmsFrameworkProviderTest
Tests SMS Framework provider service.

Namespace

Drupal\Tests\sms\Kernel

Code

public function testIncomingNoDirection() {
  $sms_message = SmsMessage::create()
    ->setMessage($this
    ->randomString())
    ->addRecipients($this
    ->randomPhoneNumbers())
    ->setGateway($this->incomingGateway);
  $sms_message
    ->setResult($this
    ->createMessageResult($sms_message));

  // This method will set direction.
  $this->smsProvider
    ->incoming($sms_message);
  $messages = $this
    ->getIncomingMessages($this->incomingGateway);
  $this
    ->assertEquals(1, count($messages), 'Message was added to incoming queue without direction being explicitly set');
  $this
    ->assertEquals(Direction::INCOMING, $messages[0]
    ->getDirection(), 'Message direction set to incoming.');
}