예제 #1
0
 public function testMonthOffsetReturnsExpectedDates()
 {
     $this->object->setFirstDate(\DateTime::createFromFormat('Y-m-d', '2014-01-01'));
     $this->object->setLastDate(\DateTime::createFromFormat('Y-m-d', '2014-03-01'));
     $this->object->setOpt('interval', 'P1M');
     $range = $this->object->getRange();
     $this->assertEquals('2014-01-01', $range['2014-01-01']['formatted']);
     $this->assertEquals('2014-02-01', $range['2014-02-01']['formatted']);
     $this->assertEquals('2014-03-01', $range['2014-03-01']['formatted']);
 }
예제 #2
0
 /**
  * @dataProvider getTestDataWithRelativeDatetime
  *
  * @param $inputValue
  * @param $relativeTo
  * @param $expectedResult
  */
 public function testTransformWithARelativeDateTime($inputValue, $relativeTo, $expectedResult)
 {
     $this->assertEquals($expectedResult, Relative::inflect($inputValue, $relativeTo));
 }
 public function testGetLastDateReturnsPositiveOffsetDate()
 {
     $dataset = new Relative(array('length' => '7 DAY', 'modify' => '+1 day'));
     $date = $dataset->getLastDate();
     $this->assertEquals(date('Y-m-d', strtotime('now +1 day')), $date->format('Y-m-d'));
 }