You are here

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

Test getting the range for today when within todays range.

File

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

Class

SmsFrameworkUserActiveHoursServiceTest
Tests active hours service.

Namespace

Drupal\Tests\sms_user\Kernel

Code

public function testFindNextTimeSameDay() {
  $this
    ->setActiveHours([
    [
      'start' => '2016-03-15 tuesday 9:00',
      'end' => '2016-03-15 tuesday 17:00',
    ],
    [
      'start' => '2016-03-16 wednesday 9:00',
      'end' => '2016-03-16 wednesday 17:00',
    ],
    [
      'start' => '2016-03-17 thursday 9:00',
      'end' => '2016-03-17 thursday 17:00',
    ],
  ]);
  $user = $this
    ->createUser([
    'timezone' => 'America/New_York',
  ]);
  $now = '2016-03-16 Wednesday 1pm America/New_York';
  $range = $this->activeHoursService
    ->findNextTime($user, $now);
  $this
    ->assertEquals(new DrupalDateTime('2016-03-16 Wednesday 9am America/New_York'), $range
    ->getStartDate());
  $this
    ->assertEquals(new DrupalDateTime('2016-03-16 Wednesday 5pm America/New_York'), $range
    ->getEndDate());
}