diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-10-18 11:36:49 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-10-18 11:36:49 +0000 |
commit | 8c6ee08ddf01c1266c10ef940c08d1a9a1ba90e4 (patch) | |
tree | a0e71a14e66e0456f3f0a0cfdb2c89536784de02 /modules | |
parent | 2dc3c05a2b40653f10bd57e76007de22b6468a8f (diff) | |
download | brdo-8c6ee08ddf01c1266c10ef940c08d1a9a1ba90e4.tar.gz brdo-8c6ee08ddf01c1266c10ef940c08d1a9a1ba90e4.tar.bz2 |
Patch #84008 by deviantintegral, plumbley, lilou, lambic: fixed timer_read() returns NULL (no value) after timer_stop(). Added timer tests.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/simpletest/tests/bootstrap.test | 32 |
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.')); + } +} |