Exemplo n.º 1
0
 public function testFromData()
 {
     $dr1 = DateRange::fromData((object) array('start' => '2010-09-06', 'end' => '2011-06-07'));
     $dr2 = DateRange::fromData(array('start' => '2010-09-06', 'end' => '2011-06-07'));
     foreach (array($dr1, $dr2) as $dr) {
         $this->assertEquals(new DateTime('2010-09-06'), $dr->getStart());
         $this->assertEquals(new DateTime('2011-06-07'), $dr->getEnd());
     }
     $dr3 = DateRange::fromData(array('start' => '2010-09-07'));
     $this->assertEquals(new DateTime('2010-09-07'), $dr3->getStart());
     $this->assertEquals(new DateTime(DateRange::FUTURE), $dr3->getEnd());
     $dr4 = DateRange::fromData(array('end' => '2011-06-08'));
     $this->assertEquals(new DateTime(DateRange::PAST), $dr4->getStart());
     $this->assertEquals(new DateTime('2011-06-08'), $dr4->getEnd());
 }