cvs: pear /PHPUnit2 package.xml /PHPUnit2/Extensions ExceptionTestCase.php
| From: | Sebastian Bergmann | Date: | Wed, 08 Feb 2006 08:22:05 +0000 |
| Subject: | cvs: pear /PHPUnit2 package.xml /PHPUnit2/Extensions ExceptionTestCase.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-38045@lists.php.net to get a copy of this message | ||
sebastian Wed Feb 8 08:22:05 2006 UTC
Modified files:
/pear/PHPUnit2 package.xml
/pear/PHPUnit2/Extensions ExceptionTestCase.php
Log:
Implement RFE #6669: Unintuitive behavior in ExceptionTestCase.
http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/package.xml?r1=1.167&r2=1.168&diff_format=u
Index: pear/PHPUnit2/package.xml
diff -u pear/PHPUnit2/package.xml:1.167 pear/PHPUnit2/package.xml:1.168
--- pear/PHPUnit2/package.xml:1.167 Wed Feb 8 08:20:12 2006
+++ pear/PHPUnit2/package.xml Wed Feb 8 08:22:05 2006
@@ -61,6 +61,8 @@
* Implemented RFE #5932: Make the PHP syntax check of files optional.
+* Implemented RFE #6669: Unintuitive behavior in ExceptionTestCase.
+
- Removed PHPUnit2_Framework_Assert::setLooselyTyped().
- Removed dependency on the Benchmark_Timer, Console_Getopt, and PEAR_Config PEAR classes.
http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Extensions/ExceptionTestCase.php?r1=1.22&r2=1.23&diff_format=u
Index: pear/PHPUnit2/Extensions/ExceptionTestCase.php
diff -u pear/PHPUnit2/Extensions/ExceptionTestCase.php:1.22
pear/PHPUnit2/Extensions/ExceptionTestCase.php:1.23
--- pear/PHPUnit2/Extensions/ExceptionTestCase.php:1.22 Wed Jan 4 07:04:51 2006
+++ pear/PHPUnit2/Extensions/ExceptionTestCase.php Wed Feb 8 08:22:05 2006
@@ -13,7 +13,7 @@
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
@@ -41,7 +41,7 @@
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/bsd-license.php
BSD License
- * @version CVS: $Id: ExceptionTestCase.php,v 1.22 2006/01/04 07:04:51 sebastian Exp $
+ * @version CVS: $Id: ExceptionTestCase.php,v 1.23 2006/02/08 08:22:05 sebastian Exp $
* @link http://pear.php.net/package/PHPUnit2
* @since File available since Release 2.0.0
*/
@@ -74,10 +74,10 @@
/**
* The name of the expected Exception.
*
- * @var string
+ * @var mixed
* @access private
*/
- private $expectedException = 'Exception';
+ private $expectedException = NULL;
/**
* @return string
@@ -90,17 +90,14 @@
}
/**
- * @param string $exceptionName
- * @throws InvalidArgumentException
+ * @param mixed $exceptionName
* @access public
* @since Method available since Release 2.2.0
*/
public function setExpectedException($exceptionName)
{
- if (is_string($exceptionName) && class_exists($exceptionName)) {
+ if ((is_string($exceptionName) && class_exists($exceptionName)) || $exceptionName
=== NULL) {
$this->expectedException = $exceptionName;
- } else {
- throw new InvalidArgumentException;
}
}
@@ -109,19 +106,23 @@
*/
protected function runTest()
{
- try {
- parent::runTest();
- }
+ if ($this->expectedException !== NULL) {
+ try {
+ parent::runTest();
+ }
- catch (Exception $e) {
- if ($e instanceof $this->expectedException) {
- return;
- } else {
- throw $e;
+ catch (Exception $e) {
+ if ($e instanceof $this->expectedException) {
+ return;
+ } else {
+ throw $e;
+ }
}
- }
- $this->fail('Expected exception ' . $this->expectedException);
+ $this->fail('Expected exception ' . $this->expectedException);
+ } else {
+ parent::runTest();
+ }
}
}