<?php
use PHPUnit\Framework\TestCase;
class TimeTest extends TestCase
{
public function testInTime() : void
{
// testing duration of a script is not
// a good test method since runtime can be
// affected by other causes.
PHP_Timer::start();
sleep(1);
$time = PHP_Timer::stop();
$message = sprintf('execution time was %s',
PHP_Timer::secondsToTimeString($time));
$this->assertLessThan(0, $time, $message);
}
}
Result
Time: 00:00.004, Memory: 18.00 MB
There was 1 error:
1) TimeTest::testInTime
Class "PHP_Timer" not found
PhpunitExec.php:21
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.