summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/bootstrap.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest/tests/bootstrap.test')
-rw-r--r--modules/simpletest/tests/bootstrap.test32
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/simpletest/tests/bootstrap.test b/modules/simpletest/tests/bootstrap.test
index ddc94460d..b6bfd54e8 100644
--- a/modules/simpletest/tests/bootstrap.test
+++ b/modules/simpletest/tests/bootstrap.test
@@ -311,3 +311,35 @@ class BootstrapGetFilenameTestCase extends DrupalUnitTestCase {
$this->assertIdentical(drupal_get_filename('profile', 'default'), 'profiles/default/default.profile', t('Retrieve install profile location.'));
}
}
+
+class BootstrapTimerTestCase extends DrupalUnitTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Timer test',
+ 'description' => 'Test that timer_read() works both when a timer is running and when a timer is stopped.',
+ 'group' => 'Bootstrap',
+ );
+ }
+
+ /**
+ * Test timer_read() to ensure it properly accumulates time when the timer
+ * started and stopped multiple times.
+ * @return
+ */
+ function testTimer() {
+ timer_start('test');
+ sleep(1);
+ $this->assertTrue(timer_read('test') >= 1000, t('Timer measured 1 second of sleeping while running.'));
+ sleep(1);
+ timer_stop('test');
+ $this->assertTrue(timer_read('test') >= 2000, t('Timer measured 2 seconds of sleeping after being stopped.'));
+ timer_start('test');
+ sleep(1);
+ $this->assertTrue(timer_read('test') >= 3000, t('Timer measured 3 seconds of sleeping after being restarted.'));
+ sleep(1);
+ $timer = timer_stop('test');
+ $this->assertTrue(timer_read('test') >= 4000, t('Timer measured 4 seconds of sleeping after being stopped for a second time.'));
+ $this->assertEqual($timer['count'], 2, t('Timer counted 2 instances of being started.'));
+ }
+}