Adding missing parameters to assertEqual() wrapper.

Adding assertNotEqual() wrapper.
Adding expectError() but it doesn't work because of Debugger's error handler being set.
Fixing fatal error where getDescription would not be defined.
This commit is contained in:
Mark Story 2010-05-08 11:42:04 -04:00
parent 82a1bd6f80
commit e7ff0bdf66
2 changed files with 14 additions and 3 deletions

View file

@ -386,8 +386,12 @@ class CakeTestCase extends PHPUnit_Framework_TestCase {
} }
} }
protected function assertEqual($a, $b) { protected function assertEqual($a, $b, $message = '') {
return $this->assertEquals($a, $b); return $this->assertEquals($a, $b, $message);
}
protected function assertNotEqual($a, $b, $message = '') {
return $this->assertNotEquals($a, $b, $message);
} }
protected function assertPattern($pattern, $string, $message = '') { protected function assertPattern($pattern, $string, $message = '') {
@ -405,6 +409,13 @@ class CakeTestCase extends PHPUnit_Framework_TestCase {
protected function assertNoErrors() { protected function assertNoErrors() {
} }
protected function expectError($expected = false, $message = '') {
if (!$expected) {
$expected = 'Exception';
}
$this->setExpectedException($expected, $message);
}
protected function expectException($name = null) { protected function expectException($name = null) {
$this->setExpectedException($name); $this->setExpectedException($name);
} }

View file

@ -257,7 +257,7 @@ class CakeHtmlReporter extends CakeBaseReporter implements PHPUnit_Framework_Tes
echo "<li class='fail'>\n"; echo "<li class='fail'>\n";
echo "<span>Failed</span>"; echo "<span>Failed</span>";
echo "<div class='msg'><pre>" . $this->_htmlEntities($message->getDescription()) . "</pre></div>\n"; echo "<div class='msg'><pre>" . $this->_htmlEntities($message->toString()) . "</pre></div>\n";
echo "<div class='msg'>" . sprintf(__('File: %s'), $context['file']) . "</div>\n"; echo "<div class='msg'>" . sprintf(__('File: %s'), $context['file']) . "</div>\n";
echo "<div class='msg'>" . sprintf(__('Method: %s'), $realContext['function']) . "</div>\n"; echo "<div class='msg'>" . sprintf(__('Method: %s'), $realContext['function']) . "</div>\n";
echo "<div class='msg'>" . sprintf(__('Line: %s'), $context['line']) . "</div>\n"; echo "<div class='msg'>" . sprintf(__('Line: %s'), $context['line']) . "</div>\n";