You are here

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

Test if in hours for 24 hours with same timezone.

File

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

Class

SmsFrameworkUserActiveHoursServiceTest
Tests active hours service.

Namespace

Drupal\Tests\sms_user\Kernel

Code

public function testInHoursAllDay() {
  $this
    ->activeHoursStatus(TRUE);
  $this
    ->setActiveHours([
    [
      'start' => '2016-03-16 wednesday',
      'end' => '2016-03-16 wednesday +1 day',
    ],
  ]);
  $user = $this
    ->createUser([
    'timezone' => 'America/New_York',
  ]);
  $now = '2016-03-15 Tuesday 8pm America/New_York';
  $this
    ->assertFalse($this->activeHoursService
    ->inHours($user, $now));
  $now = '2016-03-15 Tuesday 11:59:59pm America/New_York';
  $this
    ->assertFalse($this->activeHoursService
    ->inHours($user, $now));
  $now = '2016-03-16 Wednesday 12am America/New_York';
  $this
    ->assertTrue($this->activeHoursService
    ->inHours($user, $now));
  $now = '2016-03-16 Wednesday 12pm America/New_York';
  $this
    ->assertTrue($this->activeHoursService
    ->inHours($user, $now));
  $now = '2016-03-16 Wednesday 11:59pm America/New_York';
  $this
    ->assertTrue($this->activeHoursService
    ->inHours($user, $now));
  $now = '2016-03-17 Thursday 12am America/New_York';
  $this
    ->assertTrue($this->activeHoursService
    ->inHours($user, $now));
  $now = '2016-03-17 Thursday 12:01:01am America/New_York';
  $this
    ->assertFalse($this->activeHoursService
    ->inHours($user, $now));
}