public function testEndTime() { $event = new StopwatchEvent(microtime(true) * 1000); $this->assertEquals(0, $event->getEndTime()); $event = new StopwatchEvent(microtime(true) * 1000); $event->start(); $this->assertEquals(0, $event->getEndTime()); $event = new StopwatchEvent(microtime(true) * 1000); $event->start(); usleep(10000); $event->stop(); $event->start(); usleep(10000); $event->stop(); $end = $event->getEndTime(); $this->assertTrue($end >= 18 && $end <= 30); }
public function testEndTime() { $event = new StopwatchEvent(microtime(true) * 1000); $this->assertEquals(0, $event->getEndTime()); $event = new StopwatchEvent(microtime(true) * 1000); $event->start(); $this->assertEquals(0, $event->getEndTime()); $event = new StopwatchEvent(microtime(true) * 1000); $event->start(); usleep(10000); $event->stop(); $event->start(); usleep(10000); $event->stop(); $end = $event->getEndTime(); $this->assertTrue($end >= 11 && $end <= 29, $end . ' should be 20 (between 11 and 29)'); }