public function SmsFrameworkProviderTest::testEventsQueueOutgoing in SMS Framework 8
Same name and namespace in other branches
- 2.x tests/src/Kernel/SmsFrameworkProviderTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkProviderTest::testEventsQueueOutgoing()
- 2.1.x tests/src/Kernel/SmsFrameworkProviderTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkProviderTest::testEventsQueueOutgoing()
Ensure events are executed when a message added to the outgoing queue.
File
- tests/
src/ Kernel/ SmsFrameworkProviderTest.php, line 400
Class
- SmsFrameworkProviderTest
- Tests SMS Framework provider service.
Namespace
Drupal\Tests\sms\KernelCode
public function testEventsQueueOutgoing() {
$sms_message = $this
->createSmsMessage()
->setGateway($this->gateway)
->setDirection(Direction::OUTGOING)
->addRecipients($this
->randomPhoneNumbers());
$this->smsProvider
->queue($sms_message);
$expected = [
SmsEvents::MESSAGE_PRE_PROCESS,
SmsEvents::MESSAGE_QUEUE_PRE_PROCESS,
SmsEvents::MESSAGE_QUEUE_POST_PROCESS,
];
$execution_order = \Drupal::state()
->get('sms_test_event_subscriber__execution_order', []);
$this
->assertEquals($expected, $execution_order);
// Ensure SmsEvents::MESSAGE_PRE_PROCESS is not executed. See
// '_skip_preprocess_event' option.
$this->container
->get('cron')
->run();
$expected[] = SmsEvents::MESSAGE_OUTGOING_PRE_PROCESS;
$expected[] = SmsEvents::MESSAGE_OUTGOING_POST_PROCESS;
$expected[] = SmsEvents::MESSAGE_POST_PROCESS;
$execution_order = \Drupal::state()
->get('sms_test_event_subscriber__execution_order', []);
$this
->assertEquals($expected, $execution_order);
}