You are here

public function SmsFrameworkProviderTest::testEventsOutgoing in SMS Framework 8

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

Ensure events are executed when a message is sent.

File

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

Class

SmsFrameworkProviderTest
Tests SMS Framework provider service.

Namespace

Drupal\Tests\sms\Kernel

Code

public function testEventsOutgoing() {
  $sms_message = $this
    ->createSmsMessage()
    ->setGateway($this->gateway)
    ->setDirection(Direction::OUTGOING)
    ->addRecipients($this
    ->randomPhoneNumbers());
  $this->smsProvider
    ->send($sms_message);
  $expected = [
    SmsEvents::MESSAGE_PRE_PROCESS,
    SmsEvents::MESSAGE_OUTGOING_PRE_PROCESS,
    SmsEvents::MESSAGE_OUTGOING_POST_PROCESS,
    SmsEvents::MESSAGE_POST_PROCESS,
  ];
  $execution_order = \Drupal::state()
    ->get('sms_test_event_subscriber__execution_order', []);
  $this
    ->assertEquals($expected, $execution_order);
}