Skip to content

Commit f4974de

Browse files
committed
Adjust Debug/TimerTest for fractional differences
1 parent adc5717 commit f4974de

1 file changed

Lines changed: 34 additions & 27 deletions

File tree

tests/system/Debug/TimerTest.php

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
<?php namespace CodeIgniter\Debug;
1+
<?php
2+
namespace CodeIgniter\Debug;
23

34
class TimerTest extends \CIUnitTestCase
45
{
56

6-
public function setUp() { }
7+
public function setUp()
8+
{
9+
10+
}
711

812
//--------------------------------------------------------------------
913

10-
public function tearDown() { }
14+
public function tearDown()
15+
{
16+
17+
}
1118

1219
//--------------------------------------------------------------------
1320

@@ -83,38 +90,38 @@ public function testThrowsExceptionStoppingNonTimer()
8390

8491
//--------------------------------------------------------------------
8592

86-
public function testLongExecutionTime()
87-
{
88-
$timer = new Timer();
93+
public function testLongExecutionTime()
94+
{
95+
$timer = new Timer();
8996

90-
$timer->start('longjohn', strtotime('-11 minutes'));
97+
$timer->start('longjohn', strtotime('-11 minutes'));
9198

92-
// Use floor here to account for fractional differences in seconds.
93-
$this->assertEquals(11 * 60, (int)$timer->getElapsedTime('longjohn'));
94-
}
99+
// Use floor here to account for fractional differences in seconds.
100+
$this->assertEquals(11 * 60, (int) floor($timer->getElapsedTime('longjohn')));
101+
}
95102

96-
//--------------------------------------------------------------------
103+
//--------------------------------------------------------------------
97104

98-
public function testLongExecutionTimeThroughCommonFunc()
99-
{
100-
timer()->start('longjohn', strtotime('-11 minutes'));
105+
public function testLongExecutionTimeThroughCommonFunc()
106+
{
107+
timer()->start('longjohn', strtotime('-11 minutes'));
101108

102-
// Use floor here to account for fractional differences in seconds.
103-
$this->assertEquals(11 * 60, (int)timer()->getElapsedTime('longjohn'));
104-
}
109+
// Use floor here to account for fractional differences in seconds.
110+
$this->assertEquals(11 * 60, (int) floor(timer()->getElapsedTime('longjohn')));
111+
}
105112

106-
//--------------------------------------------------------------------
113+
//--------------------------------------------------------------------
107114

108-
public function testCommonStartStop()
109-
{
110-
timer('test1');
111-
sleep(1);
112-
timer('test1');
115+
public function testCommonStartStop()
116+
{
117+
timer('test1');
118+
sleep(1);
119+
timer('test1');
113120

114-
$this->assertGreaterThanOrEqual(1.0, timer()->getElapsedTime('test1'));
115-
}
121+
$this->assertGreaterThanOrEqual(1.0, timer()->getElapsedTime('test1'));
122+
}
116123

117-
//--------------------------------------------------------------------
124+
//--------------------------------------------------------------------
118125

119126
public function testReturnsNullGettingElapsedTimeOfNonTimer()
120127
{
@@ -123,5 +130,5 @@ public function testReturnsNullGettingElapsedTimeOfNonTimer()
123130
$this->assertNull($timer->getElapsedTime('test1'));
124131
}
125132

126-
//--------------------------------------------------------------------
133+
//--------------------------------------------------------------------
127134
}

0 commit comments

Comments
 (0)