You are here

protected function OpignoILTTest::createDummyDateRange in Opigno Instructor-led Trainings 3.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/OpignoILTTest.php \Drupal\Tests\opigno_ilt\Functional\OpignoILTTest::createDummyDateRange()

Create dummy date ranfge for ILT (interval +1 hour)

Return value

array Array with Start date and End date.

File

tests/src/Functional/OpignoILTTest.php, line 70

Class

OpignoILTTest
Common tests for Opigno ILT.

Namespace

Drupal\Tests\opigno_ilt\Functional

Code

protected function createDummyDateRange() {
  $display_format = 'm-d-Y H:i:s';
  $start_date = date($display_format, strtotime("1 hour"));
  $end_date = date($display_format, strtotime("2 hour"));
  $start_date_value = DrupalDateTime::createFromFormat($display_format, $start_date);
  $end_date_value = DrupalDateTime::createFromFormat($display_format, $end_date);
  $date_range = [
    'value' => $start_date_value
      ->setTimezone(new \DateTimeZone(date_default_timezone_get()))
      ->format(DrupalDateTime::FORMAT),
    'end_value' => $end_date_value
      ->setTimezone(new \DateTimeZone(date_default_timezone_get()))
      ->format(DrupalDateTime::FORMAT),
  ];
  return $date_range;
}