Ejemplo n.º 1
0
 /**
  * @covers Mce\Date\Math\Month::getRange
  */
 public function testGetRange()
 {
     $date = new DateTime("2013-04-13 12:00:00");
     $expectedRange = new InclusiveRange(new DateTime('2013-04-01 00:00:00'), new DateTime('2013-04-30 23:59:59'));
     $range = Month::getRange($date);
     $this->assertEquals($range->getStart(), $expectedRange->getStart());
     $this->assertEquals($range->getEnd(), $expectedRange->getEnd());
 }
Ejemplo n.º 2
0
 public function testGetRangeFromNumber()
 {
     // test the basic functionality
     $week = 2;
     $month = new DateTime('2013-04-01');
     $weekStart = 3;
     $expected = new InclusiveRange(new DateTime('2013-04-10 00:00:00'), new DateTime('2013-04-16 23:59:59'));
     $actual = WeekOfMonth::getRangeFromNumber($week, $month, $weekStart);
     $this->assertEquals($expected->getStart(), $actual->getStart());
     $this->assertEquals($expected->getEnd(), $actual->getEnd());
     // out of bounds
     $week = 5;
     $this->setExpectedException('\\RangeException');
     WeekOfMonth::getRangeFromNumber($week, $month, $weekStart);
 }
Ejemplo n.º 3
0
 /**
  * @covers Mce\Date\Range\Inclusive::contains
  *
  * @author Matthew Conger-Eldeen <*****@*****.**>
  */
 public function testContains()
 {
     $start = new DateTime("2012-01-01 00:00:00");
     $middle = new DateTime("2012-01-15 12:00:00");
     $end = new DateTime("2012-01-31 23:59:59");
     $before = clone $start;
     $before->sub(new DateInterval("PT1S"));
     $after = clone $end;
     $after->add(new DateInterval("PT1S"));
     $range = new Range($start, $end);
     $this->assertTrue($range->contains($start));
     $this->assertTrue($range->contains($middle));
     $this->assertTrue($range->contains($end));
     $this->assertFalse($range->contains($before));
     $this->assertFalse($range->contains($after));
 }