1 bootstrap.test BootstrapTimerTestCase::testTimer()

Test timer_read() to ensure it properly accumulates time when the timer started and stopped multiple times.

Return value

:

File

core/modules/simpletest/tests/bootstrap.test, line 504

Class

BootstrapTimerTestCase

Code

function testTimer() {
  timer_start('test');
  sleep(1);
  $this->assertTrue(timer_read('test') >= 1000, 'Timer measured 1 second of sleeping while running.');
  sleep(1);
  timer_stop('test');
  $this->assertTrue(timer_read('test') >= 2000, 'Timer measured 2 seconds of sleeping after being stopped.');
  timer_start('test');
  sleep(1);
  $this->assertTrue(timer_read('test') >= 3000, 'Timer measured 3 seconds of sleeping after being restarted.');
  sleep(1);
  $timer = timer_stop('test');
  $this->assertTrue(timer_read('test') >= 4000, 'Timer measured 4 seconds of sleeping after being stopped for a second time.');
  $this->assertEqual($timer['count'], 2, 'Timer counted 2 instances of being started.');
}