You are here

public function SmsFrameworkUserActiveHoursServiceTest::testDelaySmsMessage in SMS Framework 8

Same name and namespace in other branches
  1. 2.x modules/sms_user/tests/src/Kernel/SmsFrameworkUserActiveHoursServiceTest.php \Drupal\Tests\sms_user\Kernel\SmsFrameworkUserActiveHoursServiceTest::testDelaySmsMessage()
  2. 2.1.x modules/sms_user/tests/src/Kernel/SmsFrameworkUserActiveHoursServiceTest.php \Drupal\Tests\sms_user\Kernel\SmsFrameworkUserActiveHoursServiceTest::testDelaySmsMessage()

Tests delay was applied to a SMS message.

Checks invokation of sms_user_entity_presave(). This happens when queue() is called and the SMS message is saved.

File

modules/sms_user/tests/src/Kernel/SmsFrameworkUserActiveHoursServiceTest.php, line 221

Class

SmsFrameworkUserActiveHoursServiceTest
Tests active hours service.

Namespace

Drupal\Tests\sms_user\Kernel

Code

public function testDelaySmsMessage() {
  $timestamp = (new DrupalDateTime('next tuesday 9:00'))
    ->format('U');
  $this
    ->activeHoursStatus(TRUE);
  $this
    ->setActiveHours([
    [
      'start' => 'next tuesday 9:00',
      'end' => 'next tuesday 17:00',
    ],
  ]);
  $user = $this
    ->createUser();
  $sms_message = SmsMessage::create()
    ->setMessage($this
    ->randomString())
    ->addRecipients($this
    ->randomPhoneNumbers())
    ->setDirection(Direction::OUTGOING)
    ->setRecipientEntity($user)
    ->setAutomated(TRUE);
  $return = $this->smsProvider
    ->queue($sms_message);
  $this
    ->assertEquals($timestamp, $return[0]
    ->getSendTime());
}