mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Updating compatibility assertions so they correctly reverse arguments
for SimpleTest wrappers. Reformated doc blocks. Fixes #1827
This commit is contained in:
parent
a2e7c0febe
commit
011d9b4d37
1 changed files with 79 additions and 68 deletions
|
@ -382,66 +382,73 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Compatibility wrapper function for assertEquals
|
||||
* @param mixed $a
|
||||
* @param mixed $b
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertEqual($a, $b, $message = '') {
|
||||
return $this->assertEquals($a, $b, $message);
|
||||
* Compatibility wrapper function for assertEquals
|
||||
*
|
||||
* @param mixed $result
|
||||
* @param mixed $expected
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertEqual($result, $expected, $message = '') {
|
||||
return $this->assertEquals($expected, $result, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatibility wrapper function for assertNotEquals
|
||||
* @param mixed $a
|
||||
* @param mixed $b
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertNotEqual($a, $b, $message = '') {
|
||||
return $this->assertNotEquals($a, $b, $message);
|
||||
* Compatibility wrapper function for assertNotEquals
|
||||
*
|
||||
* @param mixed $result
|
||||
* @param mixed $expected
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertNotEqual($result, $expected, $message = '') {
|
||||
return $this->assertNotEquals($expected, $result, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatibility wrapper function for assertRegexp
|
||||
* @param mixed $pattern a regular expression
|
||||
* @param string $string the text to be matched
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
* Compatibility wrapper function for assertRegexp
|
||||
*
|
||||
* @param mixed $pattern a regular expression
|
||||
* @param string $string the text to be matched
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertPattern($pattern, $string, $message = '') {
|
||||
return $this->assertRegExp($pattern, $string, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatibility wrapper function for assertEquals
|
||||
* @param mixed $expected
|
||||
* @param mixed $actual
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertIdentical($expected, $actual, $message = '') {
|
||||
* Compatibility wrapper function for assertEquals
|
||||
*
|
||||
* @param mixed $actual
|
||||
* @param mixed $expected
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertIdentical($actual, $expected, $message = '') {
|
||||
return $this->assertSame($expected, $actual, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatibility wrapper function for assertNotEquals
|
||||
* @param mixed $expected
|
||||
* @param mixed $actual
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertNotIdentical($expected, $actual, $message = '') {
|
||||
* Compatibility wrapper function for assertNotEquals
|
||||
*
|
||||
* @param mixed $actual
|
||||
* @param mixed $expected
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertNotIdentical($actual, $expected, $message = '') {
|
||||
return $this->assertNotSame($expected, $actual, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatibility wrapper function for assertNotRegExp
|
||||
* @param mixed $pattern a regular expression
|
||||
* @param string $string the text to be matched
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
* Compatibility wrapper function for assertNotRegExp
|
||||
*
|
||||
* @param mixed $pattern a regular expression
|
||||
* @param string $string the text to be matched
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertNoPattern($pattern, $string, $message = '') {
|
||||
return $this->assertNotRegExp($pattern, $string, $message);
|
||||
}
|
||||
|
@ -450,11 +457,12 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Compatibility wrapper function for setExpectedException
|
||||
* @param mixed $expected the name of the Exception or error
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
* Compatibility wrapper function for setExpectedException
|
||||
*
|
||||
* @param mixed $expected the name of the Exception or error
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function expectError($expected = false, $message = '') {
|
||||
if (!$expected) {
|
||||
$expected = 'Exception';
|
||||
|
@ -463,22 +471,24 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Compatibility wrapper function for setExpectedException
|
||||
* @param mixed $expected the name of the Exception
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
* Compatibility wrapper function for setExpectedException
|
||||
*
|
||||
* @param mixed $expected the name of the Exception
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function expectException($name = 'Exception', $message = '') {
|
||||
$this->setExpectedException($name, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatibility wrapper function for assertSame
|
||||
* @param mixed $expected
|
||||
* @param mixed $actual
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
* Compatibility wrapper function for assertSame
|
||||
*
|
||||
* @param mixed $first
|
||||
* @param mixed $second
|
||||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertReference(&$first, &$second, $message = '') {
|
||||
return $this->assertSame($first, $second, $message);
|
||||
}
|
||||
|
@ -496,16 +506,17 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
* Compatibility function to test if value is between an acceptable range
|
||||
*
|
||||
* @param mixed $result
|
||||
* @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($result, $expected, $margin, $message = '') {
|
||||
$upper = $result + $margin;
|
||||
$lower = $result - $margin;
|
||||
$this->assertTrue((($expected <= $upper) && ($expected >= $lower)), $message);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue