You are here

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

Test if in hours for 24 hours with different timezone.

File

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

Class

SmsFrameworkUserActiveHoursServiceTest
Tests active hours service.

Namespace

Drupal\Tests\sms_user\Kernel

Code

public function testInHoursAllDayDifferentTimezone() {
  $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/Los_Angeles';
  $this
    ->assertFalse($this->activeHoursService
    ->inHours($user, $now));
  $now = '2016-03-15 Tuesday 11:59:59pm America/Los_Angeles';
  $this
    ->assertTrue($this->activeHoursService
    ->inHours($user, $now));
  $now = '2016-03-16 Wednesday 12am America/Los_Angeles';
  $this
    ->assertTrue($this->activeHoursService
    ->inHours($user, $now));
  $now = '2016-03-16 Wednesday 12pm America/Los_Angeles';
  $this
    ->assertTrue($this->activeHoursService
    ->inHours($user, $now));
  $now = '2016-03-16 Wednesday 11:59pm America/Los_Angeles';
  $this
    ->assertFalse($this->activeHoursService
    ->inHours($user, $now));
  $now = '2016-03-17 Thursday 12am America/Los_Angeles';
  $this
    ->assertFalse($this->activeHoursService
    ->inHours($user, $now));
  $now = '2016-03-17 Thursday 12:01:01am America/Los_Angeles';
  $this
    ->assertFalse($this->activeHoursService
    ->inHours($user, $now));
}