Ejemplo n.º 1
0
 /**
  * @dataProvider providerNow
  *
  * @param integer $epochSecond The epoch second.
  * @param string  $timeZone    The time-zone.
  * @param integer $year        The expected year.
  * @param integer $month       The expected month.
  */
 public function testNow($epochSecond, $timeZone, $year, $month)
 {
     $previousClock = Clock::setDefault(new FixedClock(Instant::of($epochSecond)));
     $this->assertYearMonthIs($year, $month, YearMonth::now(TimeZone::parse($timeZone)));
     Clock::setDefault($previousClock);
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider providerNow
  *
  * @param integer $epochSecond The epoch second.
  * @param string  $timeZone    The time-zone.
  * @param integer $month       The expected month.
  * @param integer $day         The expected day.
  */
 public function testNow($epochSecond, $timeZone, $month, $day)
 {
     $previousClock = Clock::setDefault(new FixedClock(Instant::of($epochSecond)));
     $this->assertMonthDayIs($month, $day, MonthDay::now(TimeZone::parse($timeZone)));
     Clock::setDefault($previousClock);
 }
Ejemplo n.º 3
0
 /**
  * @dataProvider providerCompareTo
  *
  * @param integer $testSecond The second of the test instant.
  * @param integer $testNano   The nanosecond adjustment to the test instant.
  * @param integer $nowSecond  The second of the current time.
  * @param integer $nowNano    The nanosecond adjustment to the current time.
  * @param integer $cmp        The comparison value.
  */
 public function testIsPast($testSecond, $testNano, $nowSecond, $nowNano, $cmp)
 {
     Clock::setDefault(new FixedClock(Instant::of($nowSecond, $nowNano)));
     $this->assertSame($cmp === -1, Instant::of($testSecond, $testNano)->isPast());
 }
Ejemplo n.º 4
0
 /**
  * @param integer $epochSecond    The epoch second.
  * @param integer $nanoAdjustment The nanosecond adjustment to the epoch second.
  */
 protected function setClockTime($epochSecond, $nanoAdjustment = 0)
 {
     Clock::setDefault(new FixedClock(Instant::of($epochSecond, $nanoAdjustment)));
 }