Skip to content

Commit a272fd9

Browse files
committed
Testing close enough...
1 parent 5535126 commit a272fd9

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

tests/system/Test/TestCaseTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,19 @@ public function testPHPUnitHeadersEmitted()
7676
$this->assertHeaderNotEmitted('Set-Cookie: foo=bar;');
7777
}
7878

79+
//--------------------------------------------------------------------
80+
public function testCloseEnough()
81+
{
82+
$this->assertCloseEnough(1, 1);
83+
$this->assertCloseEnough(1, 0);
84+
$this->assertCloseEnough(1, 2);
85+
}
86+
87+
public function testCloseEnoughString()
88+
{
89+
$this->assertCloseEnough('1000', '0959');
90+
$this->assertCloseEnough('1000', '1000');
91+
$this->assertCloseEnough('1000', '1001');
92+
}
93+
7994
}

user_guide_src/source/testing/overview.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ between expected and actual time is within the prescribed tolerance.::
152152
$timer->start('longjohn', strtotime('-11 minutes'));
153153
$this->assertCloseEnough(11 * 60, $timer->getElapsedTime('longjohn'));
154154

155-
The above test will allow the actual time to be either 600 or 601 seconds.
155+
The above test will allow the actual time to be either 660 or 661 seconds.
156156

157157
**assertCloseEnoughString($expected, $actual, $message='', $tolerance=1)**
158158

@@ -163,7 +163,8 @@ between expected and actual time, formatted as strings, is within the prescribed
163163
$timer->start('longjohn', strtotime('-11 minutes'));
164164
$this->assertCloseEnoughString(11 * 60, $timer->getElapsedTime('longjohn'));
165165

166-
The above test will allow the actual time to be either 600 or 601 seconds.
166+
The above test will allow the actual time to be either 660 or 661 seconds.
167+
167168

168169
Accessing Protected/Private Properties
169170
--------------------------------------

0 commit comments

Comments
 (0)