mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding another compatibility test method: assertWithinMargin
This commit is contained in:
parent
88d21fbea4
commit
508d707a7a
1 changed files with 14 additions and 0 deletions
|
@ -480,5 +480,19 @@ class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
protected function assertReference(&$first, &$second, $message = '') {
|
||||
return $this->assertSame($first, $second, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatibility function to test if value is between an acceptable range
|
||||
* @param mixed $value
|
||||
* @param mixed $expected
|
||||
* @param mixed $margin the rage of acceptation
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertWithinMargin($value, $expected, $margin, $message = '') {
|
||||
$upper = $value + $margin;
|
||||
$lower = $value - $margin;
|
||||
$this->assertTrue((($expected <= $upper) && ($expected >= $lower)), $message);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue