Exemplo n.º 1
0
 public function testIsDuring()
 {
     $interval = TimeIntervalFactory::create('2012-01-01 20:00', '2012-01-01 21:59');
     $intervalA = TimeIntervalFactory::create('2012-01-01 19:30', '2012-01-01 21:30');
     // is during
     $intervalB = TimeIntervalFactory::create('2012-01-01 21:30', '2012-01-01 22:30');
     // is during
     $intervalC = TimeIntervalFactory::create('2012-01-01 15:00', '2012-01-01 23:00');
     // is during?
     $this->assertTrue($interval->isDuring($intervalA));
     $this->assertTrue($intervalA->isDuring($interval));
     $this->assertTrue($interval->isDuring($intervalB));
     $this->assertTrue($intervalB->isDuring($interval));
     $this->assertTrue($interval->isDuring($intervalC));
     $this->assertTrue($intervalC->isDuring($interval));
 }
Exemplo n.º 2
0
 public function testHowToAddNewAppointment()
 {
     $event = new Event(TimeIntervalFactory::create('2012-01-01 17:00', '2012-01-01 18:00'));
     $this->calendar->add($event);
     $this->assertCount(4, $this->calendar);
 }
Exemplo n.º 3
0
 public function testAddWithNoOverlapStrategy()
 {
     $this->calendar->setStrategy(new NoOverlapStrategy());
     $this->assertCount(2, $this->calendar);
     $this->calendar->add(new Event(TimeIntervalFactory::create('2012-01-15 15:30', '2012-01-15 15:59')));
     $this->assertCount(3, $this->calendar);
     try {
         $this->calendar->add(new Event(TimeIntervalFactory::create('2012-01-15 15:00', '2012-01-15 15:40')));
         $this->fail('A CalendarEventException should be thrown');
     } catch (CalendarEventException $e) {
     }
     try {
         // exact same Event as reference
         $this->calendar->add(new Event(TimeIntervalFactory::create('2012-01-15 15:30', '2012-01-15 15:59')));
         $this->fail('A CalendarEventException should be thrown');
     } catch (CalendarEventException $e) {
     }
     $this->calendar->add(new Event(TimeIntervalFactory::create('2012-01-16 17:50', '2012-01-17 18:00')));
     $this->assertCount(4, $this->calendar);
 }
 public function __construct()
 {
     $this->calendar = new Calendar('Doctor Smith\'s appointments', array(new Event(TimeIntervalFactory::create('2012-01-01 8:00', '2012-01-01 09:00')), new Event(TimeIntervalFactory::create('2012-01-05 8:00', '2012-01-05 10:15')), new Event(TimeIntervalFactory::create('2012-01-10 15:00', '2012-01-10 15:30'))));
 }