From 04e4a9ce26d55b4da7758f4ba7a1440c9fb3a361 Mon Sep 17 00:00:00 2001 From: jepso Date: Fri, 18 Jan 2008 19:35:15 +0000 Subject: [PATCH] added assertNull() and assertNotNull() --- tests/DoctrineTest/UnitTestCase.php | 31 +++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/tests/DoctrineTest/UnitTestCase.php b/tests/DoctrineTest/UnitTestCase.php index 072246d07..fef827f98 100644 --- a/tests/DoctrineTest/UnitTestCase.php +++ b/tests/DoctrineTest/UnitTestCase.php @@ -2,9 +2,9 @@ class UnitTestCase { protected $_passed = 0; - + protected $_failed = 0; - + protected $_messages = array(); public function assertEqual($value, $value2) @@ -62,13 +62,32 @@ class UnitTestCase $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++; } public function fail($message = "") { - $this->_fail($message); + $this->_fail($message); } public function _fail($message = "") { @@ -92,7 +111,7 @@ class UnitTestCase } $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) { if (substr($method, 0, 4) === 'test') { @@ -102,7 +121,7 @@ class UnitTestCase } } } - public function getMessages() + public function getMessages() { return $this->_messages; }