ClockTest.php 659 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace Tools\Test\TestCase\Utility;
  3. use Shim\TestSuite\TestCase;
  4. use Tools\Utility\Clock;
  5. /**
  6. * @coversDefaultClass \Tools\Utility\Clock
  7. */
  8. class ClockTest extends TestCase {
  9. /**
  10. * @covers ::returnElapsedTime
  11. * @return void
  12. */
  13. public function testTime() {
  14. Clock::startClock();
  15. time_nanosleep(0, 200000000);
  16. $res = Clock::returnElapsedTime();
  17. $this->assertTrue(round($res, 1) === 0.2);
  18. time_nanosleep(0, 100000000);
  19. $res = Clock::returnElapsedTime(8, true);
  20. $this->assertTrue(round($res, 1) === 0.3);
  21. time_nanosleep(0, 100000000);
  22. $res = Clock::returnElapsedTime();
  23. $this->assertTrue(round($res, 1) === 0.1);
  24. }
  25. }