Inheritance: extends Roomify\Bat\Constraint\Constraint
Example #1
0
 /**
  * Test to Constraints Base functionality.
  */
 public function testConstraintsBaseFunctions()
 {
     $u1 = new Unit(1, 10, array());
     $u2 = new Unit(2, 10, array());
     $units = array($u1, $u2);
     $sd = new \DateTime('2016-01-01 15:10');
     $ed = new \DateTime('2016-06-30 18:00');
     $sd1 = new \DateTime('2016-01-07 02:12');
     $ed1 = new \DateTime('2016-01-13 13:12');
     // Create some events for units 1,2
     $e1u1 = new Event($sd1, $ed1, $u1, 11);
     $e1u2 = new Event($sd1, $ed1, $u2, 13);
     $store = new SqlLiteDBStore($this->pdo, 'availability_event', SqlDBStore::BAT_STATE);
     $calendar = new Calendar($units, $store);
     // Add the events.
     $calendar->addEvents(array($e1u1, $e1u2), Event::BAT_HOURLY);
     $response = $calendar->getMatchingUnits($sd, $ed, array(10, 11, 13), array());
     // Add the constraint with Start and End dates.
     $constraint = new MinMaxDaysConstraint(array($u1, $u2), 3, 0, $sd, $ed);
     $constraint->setStartDate($sd1);
     $this->assertEquals($constraint->getStartDate(), $sd1);
     $constraint->setEndDate($ed1);
     $this->assertEquals($constraint->getEndDate(), $ed1);
     $constraint->getAffectedUnits();
 }