You are here

public function SmsFrameworkUserActiveHoursServiceTest::testDelaySmsMessageNotAutomated 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::testDelaySmsMessageNotAutomated()
  2. 2.1.x modules/sms_user/tests/src/Kernel/SmsFrameworkUserActiveHoursServiceTest.php \Drupal\Tests\sms_user\Kernel\SmsFrameworkUserActiveHoursServiceTest::testDelaySmsMessageNotAutomated()

Tests delay was not applied to a SMS message if it is tagged as automated.

File

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

Class

SmsFrameworkUserActiveHoursServiceTest
Tests active hours service.

Namespace

Drupal\Tests\sms_user\Kernel

Code

public function testDelaySmsMessageNotAutomated() {
  $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()
    ->addRecipients($this
    ->randomPhoneNumbers(1))
    ->setMessage($this
    ->randomString())
    ->setDirection(Direction::OUTGOING)
    ->setRecipientEntity($user)
    ->setAutomated(FALSE);
  $this->smsProvider
    ->queue($sms_message);
  $this
    ->assertNotEquals($timestamp, $sms_message
    ->getSendTime());
}