You are here

public function ScheduleDataTest::testMakeSchedule in Loft Data Grids 7.2

@dataProvider DataForTestMakeScheduleProvider

File

vendor/aklump/loft_data_grids/tests/phpunit/ScheduleDataTest.php, line 94

Class

ScheduleDataTest

Namespace

AKlump\LoftDataGrids

Code

public function testMakeSchedule($json, $hash, $hoursPerDay, $todos, $weekdays = array(), $holidays = array(), $stats = false) {
  $data = $this->obj;
  $data
    ->setHoursPerDay($hoursPerDay)
    ->setHoursKey('time')
    ->setStartDate(new \DateTime('2017-03-19', new \DateTimeZone('America/Los_Angeles')));
  foreach ($weekdays as $weekday) {
    $data
      ->addWeekdayOff($weekday);
  }
  foreach ($holidays as $holiday) {
    $data
      ->addDateOff(new \DateTime($holiday, new \DateTimeZone('America/Los_Angeles')));
  }

  // Add all tasks
  foreach ($todos as $todo) {
    $data
      ->add('task', $todo[0])
      ->add('time', $todo[1])
      ->next();
  }

  // Now schedule
  $data
    ->makeSchedule();
  if ($stats) {
    $data
      ->addStatsPage();
  }
  $out = new JSONExporter($data);
  $this
    ->assertSame($json, $out
    ->export());
  $this
    ->assertSame($hash, strval($data));
}