Skip to content

Commit af7eb03

Browse files
committed
Additional Timer tests
1 parent a0422d1 commit af7eb03

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/system/Debug/TimerTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,36 @@ public function testThrowsExceptionStoppingNonTimer()
8383

8484
//--------------------------------------------------------------------
8585

86+
public function testLongExecutionTime()
87+
{
88+
$timer = new Timer();
8689

90+
$timer->start('longjohn', strtotime('-11 minutes'));
91+
92+
// Use floor here to account for fractional differences in seconds.
93+
$this->assertEquals(11 * 60, floor($timer->getElapsedTime('longjohn')));
94+
}
95+
96+
//--------------------------------------------------------------------
97+
98+
public function testLongExecutionTimeThroughCommonFunc()
99+
{
100+
timer()->start('longjohn', strtotime('-11 minutes'));
101+
102+
// Use floor here to account for fractional differences in seconds.
103+
$this->assertEquals(11 * 60, floor(timer()->getElapsedTime('longjohn')));
104+
}
105+
106+
//--------------------------------------------------------------------
107+
108+
public function testCommonStartStop()
109+
{
110+
timer('test1');
111+
sleep(1);
112+
timer('test1');
113+
114+
$this->assertGreaterThanOrEqual(1.0, timer()->getElapsedTime('test1'));
115+
}
116+
117+
//--------------------------------------------------------------------
87118
}

0 commit comments

Comments
 (0)