1
0
mirror of synced 2024-12-13 06:46:03 +03:00

added assertNull() and assertNotNull()

This commit is contained in:
jepso 2008-01-18 19:35:15 +00:00
parent 6737c5cea4
commit 04e4a9ce26

View File

@ -2,9 +2,9 @@
class UnitTestCase class UnitTestCase
{ {
protected $_passed = 0; protected $_passed = 0;
protected $_failed = 0; protected $_failed = 0;
protected $_messages = array(); protected $_messages = array();
public function assertEqual($value, $value2) public function assertEqual($value, $value2)
@ -62,13 +62,32 @@ class UnitTestCase
$this->_fail(); $this->_fail();
} }
} }
public function pass()
public function assertNull($expr)
{
if (is_null($expr)) {
$this->pass();
} else {
$this->fail();
}
}
public function assertNotNull($expr)
{
if (is_null($expr)) {
$this->fail();
} else {
$this->pass();
}
}
public function pass()
{ {
$this->_passed++; $this->_passed++;
} }
public function fail($message = "") public function fail($message = "")
{ {
$this->_fail($message); $this->_fail($message);
} }
public function _fail($message = "") public function _fail($message = "")
{ {
@ -92,7 +111,7 @@ class UnitTestCase
} }
$this->_failed++; $this->_failed++;
} }
public function run(DoctrineTest_Reporter $reporter = null, $filter = null) public function run(DoctrineTest_Reporter $reporter = null, $filter = null)
{ {
foreach (get_class_methods($this) as $method) { foreach (get_class_methods($this) as $method) {
if (substr($method, 0, 4) === 'test') { if (substr($method, 0, 4) === 'test') {
@ -102,7 +121,7 @@ class UnitTestCase
} }
} }
} }
public function getMessages() public function getMessages()
{ {
return $this->_messages; return $this->_messages;
} }