Example #1
0
 public function testGettersSetters()
 {
     $t = new \Application\BookingOrder();
     $t->setEmpId(1);
     $this->assertEquals(1, $t->getEmpId());
     $t->setRecurring(1, 3);
     $this->assertEquals(1, $t->getRecurring());
     $this->assertEquals(3, $t->getDuration());
     $t->setRecurring(1, 5);
     $this->assertEquals(1, $t->getRecurring());
     $this->assertEquals(4, $t->getDuration());
     $t->setRecurring(2, 2);
     $this->assertEquals(2, $t->getRecurring());
     $this->assertEquals(2, $t->getDuration());
     $t->setRecurring(2, 3);
     $this->assertEquals(2, $t->getRecurring());
     $this->assertEquals(2, $t->getDuration());
     $t->setRecurring(2, 1);
     $this->assertEquals(2, $t->getRecurring());
     $this->assertEquals(0, $t->getDuration());
     $t->setRecurring(2, 6);
     $this->assertEquals(2, $t->getRecurring());
     $this->assertEquals(4, $t->getDuration());
     $t->setRecurring(3, 1);
     $this->assertEquals(3, $t->getRecurring());
     $this->assertEquals(1, $t->getDuration());
     $t->setRecurring(3, 7);
     $this->assertEquals(3, $t->getRecurring());
     $this->assertEquals(7, $t->getDuration());
     $t->setNotes('note');
     $this->assertEquals('note', $t->getNotes());
     $t->setDate(2015, 1, 2);
     $t->setStartTime24(10, 20);
     $this->assertEquals((new \DateTime('2015-01-02 10:20:00'))->getTimestamp(), $t->getStartTime()->getTimestamp());
     $t->setEndTime24(11, 22);
     $this->assertEquals((new \DateTime('2015-01-02 11:22:00'))->getTimestamp(), $t->getEndTime()->getTimestamp());
     $t->setStartTime12(8, 25, 'am');
     $this->assertEquals((new \DateTime('2015-01-02 08:25:00'))->getTimestamp(), $t->getStartTime()->getTimestamp());
     $t->setEndTime12(9, 35, 'pm');
     $this->assertEquals((new \DateTime('2015-01-02 21:35:00'))->getTimestamp(), $t->getEndTime()->getTimestamp());
     $t->setEndTime12(12, 00, 'pm');
     $this->assertEquals((new \DateTime('2015-01-03 00:00:00'))->getTimestamp(), $t->getEndTime()->getTimestamp());
     $t->setEndTime12(12, 15, 'pm');
     $this->assertEquals((new \DateTime('2015-01-02 00:15:00'))->getTimestamp(), $t->getEndTime()->getTimestamp());
     $this->assertFalse($t->isTimeValid());
     $t->setEndTime12(8, 30, 'am');
     $this->assertTrue($t->isTimeValid());
     $this->assertTrue($t->isPeriodBeforeTime(new \DateTime('2015-01-02 08:30:00')));
     $this->assertTrue($t->isPeriodBeforeTime(new \DateTime('2015-01-02 08:40:00')));
     $this->assertFalse($t->isPeriodBeforeTime(new \DateTime('2015-01-02 08:27:00')));
     $this->assertFalse($t->isPeriodBeforeTime(new \DateTime('2015-01-02 08:25:00')));
     $this->assertFalse($t->isPeriodBeforeTime(new \DateTime('2015-01-01 08:27:00')));
 }
 public function testMakeRecurringMonthly()
 {
     $order = new \Application\BookingOrder();
     $order->setDate(2015, 10, 17);
     $order->setStartTime24(8, 15);
     $order->setEndTime24(9, 25);
     $order->setNotes('notes');
     $order->setEmpId(3);
     $order->setRecurring(BookingOrder::RECURRING_MONTHLY, 2);
     $start = new \DateTime('2015-10-17 08:15:00');
     $end = new \DateTime('2015-10-17 09:25:00');
     $matcher = new \Application\AppointmentMatcher();
     $chain = $matcher->makeChain($order, 1, 2);
     $counted = 0;
     $step = new \DateInterval('P1M');
     foreach ($chain as $res) {
         $this->assertEquals($start->getTimestamp(), $res->getTimeStart()->getTimestamp());
         $this->assertEquals($end->getTimestamp(), $res->getTimeEnd()->getTimestamp());
         $this->assertEquals('notes', $res->getNotes());
         $this->assertEquals(3, $res->getEmpId());
         $this->assertEquals(2, $res->getRoomId());
         $start->add($step);
         $end->add($step);
         ++$counted;
     }
     $this->assertEquals(3, $counted);
 }