Exemplo n.º 1
0
 public function testCreatedAt()
 {
     $cron = new Cron();
     $dateTime = DateTime::dateTime();
     $expected = $dateTime;
     $cron->setCreatedAt($dateTime);
     $actual = $cron->getCreatedAt();
     $this->assertSame($expected, $actual);
 }
Exemplo n.º 2
0
 public function testDeletedAt()
 {
     $post = new Post();
     $deletedAt = DateTime::dateTime();
     $expected = $deletedAt;
     $post->setDeletedAt($deletedAt);
     $actual = $post->getDeletedAt();
     $this->assertSame($expected, $actual);
 }
 public function testFixedSeedWithMaximumTimestamp()
 {
     $max = '2018-03-01 12:00:00';
     mt_srand(1);
     $unixTime = DateTimeProvider::unixTime($max);
     $datetimeAD = DateTimeProvider::dateTimeAD($max);
     $dateTime1 = DateTimeProvider::dateTime($max);
     $dateTimeBetween = DateTimeProvider::dateTimeBetween('2014-03-01 06:00:00', $max);
     $date = DateTimeProvider::date('Y-m-d', $max);
     $time = DateTimeProvider::time('H:i:s', $max);
     $iso8601 = DateTimeProvider::iso8601($max);
     $dateTimeThisCentury = DateTimeProvider::dateTimeThisCentury($max);
     $dateTimeThisDecade = DateTimeProvider::dateTimeThisDecade($max);
     $dateTimeThisMonth = DateTimeProvider::dateTimeThisMonth($max);
     $amPm = DateTimeProvider::amPm($max);
     $dayOfMonth = DateTimeProvider::dayOfMonth($max);
     $dayOfWeek = DateTimeProvider::dayOfWeek($max);
     $month = DateTimeProvider::month($max);
     $monthName = DateTimeProvider::monthName($max);
     $year = DateTimeProvider::year($max);
     $dateTimeThisYear = DateTimeProvider::dateTimeThisYear($max);
     mt_srand();
     //regenerate Random Date with same seed and same maximum end timestamp
     mt_srand(1);
     $this->assertEquals($unixTime, DateTimeProvider::unixTime($max));
     $this->assertEquals($datetimeAD, DateTimeProvider::dateTimeAD($max));
     $this->assertEquals($dateTime1, DateTimeProvider::dateTime($max));
     $this->assertEquals($dateTimeBetween, DateTimeProvider::dateTimeBetween('2014-03-01 06:00:00', $max));
     $this->assertEquals($date, DateTimeProvider::date('Y-m-d', $max));
     $this->assertEquals($time, DateTimeProvider::time('H:i:s', $max));
     $this->assertEquals($iso8601, DateTimeProvider::iso8601($max));
     $this->assertEquals($dateTimeThisCentury, DateTimeProvider::dateTimeThisCentury($max));
     $this->assertEquals($dateTimeThisDecade, DateTimeProvider::dateTimeThisDecade($max));
     $this->assertEquals($dateTimeThisMonth, DateTimeProvider::dateTimeThisMonth($max));
     $this->assertEquals($amPm, DateTimeProvider::amPm($max));
     $this->assertEquals($dayOfMonth, DateTimeProvider::dayOfMonth($max));
     $this->assertEquals($dayOfWeek, DateTimeProvider::dayOfWeek($max));
     $this->assertEquals($month, DateTimeProvider::month($max));
     $this->assertEquals($monthName, DateTimeProvider::monthName($max));
     $this->assertEquals($year, DateTimeProvider::year($max));
     $this->assertEquals($dateTimeThisYear, DateTimeProvider::dateTimeThisYear($max));
     mt_srand();
 }