cvs: pear /PHPUnit2 package.xml /PHPUnit2/Framework TestCase.php TestResult.php /PHPUnit2/TextUI TestRunner.php
| From: | Sebastian Bergmann | Date: | Mon, 23 May 2005 04:37:27 +0000 |
| Subject: | cvs: pear /PHPUnit2 package.xml /PHPUnit2/Framework TestCase.php TestResult.php /PHPUnit2/TextUI TestRunner.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-32044@lists.php.net to get a copy of this message | ||
sebastian Mon May 23 00:37:27 2005 EDT
Modified files:
/pear/PHPUnit2 package.xml
/pear/PHPUnit2/Framework TestCase.php TestResult.php
/pear/PHPUnit2/TextUI TestRunner.php
Log:
Move code from TestCase to TestResult.
http://cvs.php.net/diff.php/pear/PHPUnit2/package.xml?r1=1.105&r2=1.106&ty=u
Index: pear/PHPUnit2/package.xml
diff -u pear/PHPUnit2/package.xml:1.105 pear/PHPUnit2/package.xml:1.106
--- pear/PHPUnit2/package.xml:1.105 Thu May 19 02:21:54 2005
+++ pear/PHPUnit2/package.xml Mon May 23 00:37:26 2005
@@ -22,9 +22,11 @@
+ Added BankAccount and Money samples.
-* PHPUnit2_Framework_TestCase::runTest() now saves the $GLOBALS array before and restores it after
each test execution for better isolation.
+* PHPUnit2_Framework_TestResult::run() now saves the $GLOBALS array before and restores it after
each test execution for better isolation.
-* PHPUnit2_Framework_TestCase no longer collects Code Coverage information by default (when the
Xdebug extension is available). PHPUnit2_Framework_TestCase::$collectCodeCoverageInformation has to
be set to TRUE to collect Code Coverage information.
+* Code Coverage collection has been moved from PHPUnit2_Framework_TestCase to
PHPUnit2_Framework_TestResult. This allows for Code Coverage analysis of tests that are written in a
class that does not inherit from PHPUnit2_Framework_TestCase.
+
+* Code Coverage information is no longer collected by default (when the Xdebug extension is
available) but only when it is requested (by using the --coverage-* parameters with the TextUI
TestRunner, for instance). PHPUnit2_Framework_TestResult::$collectCodeCoverageInformation has to be
set to TRUE to collect Code Coverage information.
* PHPUnit2_Framework_Assert::assertType() and PHPUnit2_Framework_AssertNotType() now consider
subclasses when used on objects.
http://cvs.php.net/diff.php/pear/PHPUnit2/Framework/TestCase.php?r1=1.30&r2=1.31&ty=u
Index: pear/PHPUnit2/Framework/TestCase.php
diff -u pear/PHPUnit2/Framework/TestCase.php:1.30 pear/PHPUnit2/Framework/TestCase.php:1.31
--- pear/PHPUnit2/Framework/TestCase.php:1.30 Thu May 5 07:43:33 2005
+++ pear/PHPUnit2/Framework/TestCase.php Mon May 23 00:37:27 2005
@@ -15,7 +15,7 @@
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: TestCase.php,v 1.30 2005/05/05 11:43:33 sebastian Exp $
+ * @version CVS: $Id: TestCase.php,v 1.31 2005/05/23 04:37:27 sebastian Exp $
* @link http://pear.php.net/package/PHPUnit2
* @since File available since Release 2.0.0
*/
@@ -81,21 +81,6 @@
*/
abstract class PHPUnit2_Framework_TestCase extends PHPUnit2_Framework_Assert implements
PHPUnit2_Framework_Test {
/**
- * @var boolean
- * @access public
- * @static
- */
- public static $collectCodeCoverageInformation = FALSE;
-
- /**
- * Code Coverage information provided by Xdebug.
- *
- * @var array
- * @access private
- */
- private $codeCoverageInformation = array();
-
- /**
* The name of the test case.
*
* @var string
@@ -143,16 +128,6 @@
}
/**
- * Returns the Code Coverage information provided by Xdebug.
- *
- * @return array
- * @access public
- */
- public function getCodeCoverageInformation() {
- return $this->codeCoverageInformation;
- }
-
- /**
* Gets the name of a TestCase.
*
* @return string
@@ -238,23 +213,7 @@
PHPUnit2_Util_Filter::addFileToFilter($class->getFileName());
- $useXdebug = (extension_loaded('xdebug') &&
self::$collectCodeCoverageInformation);
-
- if ($useXdebug) {
- xdebug_start_code_coverage(XDEBUG_CC_UNUSED);
- }
-
- $globalsBackup = $GLOBALS;
$method->invoke($this);
- $GLOBALS = $globalsBackup;
-
- if ($useXdebug) {
- $this->codeCoverageInformation = PHPUnit2_Util_Filter::getFilteredCodeCoverage(
- xdebug_get_code_coverage()
- );
-
- xdebug_stop_code_coverage();
- }
}
/**
http://cvs.php.net/diff.php/pear/PHPUnit2/Framework/TestResult.php?r1=1.23&r2=1.24&ty=u
Index: pear/PHPUnit2/Framework/TestResult.php
diff -u pear/PHPUnit2/Framework/TestResult.php:1.23 pear/PHPUnit2/Framework/TestResult.php:1.24
--- pear/PHPUnit2/Framework/TestResult.php:1.23 Tue Apr 26 06:56:32 2005
+++ pear/PHPUnit2/Framework/TestResult.php Mon May 23 00:37:27 2005
@@ -15,7 +15,7 @@
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: TestResult.php,v 1.23 2005/04/26 10:56:32 sebastian Exp $
+ * @version CVS: $Id: TestResult.php,v 1.24 2005/05/23 04:37:27 sebastian Exp $
* @link http://pear.php.net/package/PHPUnit2
* @since File available since Release 2.0.0
*/
@@ -74,6 +74,13 @@
private $codeCoverageInformation = array();
/**
+ * @var boolean
+ * @access public
+ * @static
+ */
+ public static $collectCodeCoverageInformation = FALSE;
+
+ /**
* Current test.
*
* @var PHPUnit2_Framework_Test
@@ -206,10 +213,6 @@
* @access public
*/
public function endTest(PHPUnit2_Framework_Test $test) {
- if ($test instanceof PHPUnit2_Framework_TestCase) {
- $this->codeCoverageInformation[$test->getName()] =
$test->getCodeCoverageInformation();
- }
-
foreach ($this->listeners as $listener) {
$listener->endTest($test);
}
@@ -319,6 +322,14 @@
set_error_handler(array($this, 'errorHandler'));
+ $useXdebug = (extension_loaded('xdebug') &&
self::$collectCodeCoverageInformation);
+
+ if ($useXdebug) {
+ xdebug_start_code_coverage(XDEBUG_CC_UNUSED);
+ }
+
+ $globalsBackup = $GLOBALS;
+
try {
$test->runBare();
}
@@ -331,6 +342,16 @@
$this->addError($test, $e);
}
+ $GLOBALS = $globalsBackup;
+
+ if ($useXdebug) {
+ $this->codeCoverageInformation[$test->getName()] =
PHPUnit2_Util_Filter::getFilteredCodeCoverage(
+ xdebug_get_code_coverage()
+ );
+
+ xdebug_stop_code_coverage();
+ }
+
restore_error_handler();
$this->endTest($test);
http://cvs.php.net/diff.php/pear/PHPUnit2/TextUI/TestRunner.php?r1=1.56&r2=1.57&ty=u
Index: pear/PHPUnit2/TextUI/TestRunner.php
diff -u pear/PHPUnit2/TextUI/TestRunner.php:1.56 pear/PHPUnit2/TextUI/TestRunner.php:1.57
--- pear/PHPUnit2/TextUI/TestRunner.php:1.56 Tue Apr 26 06:56:33 2005
+++ pear/PHPUnit2/TextUI/TestRunner.php Mon May 23 00:37:27 2005
@@ -15,7 +15,7 @@
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: TestRunner.php,v 1.56 2005/04/26 10:56:33 sebastian Exp $
+ * @version CVS: $Id: TestRunner.php,v 1.57 2005/05/23 04:37:27 sebastian Exp $
* @link http://pear.php.net/package/PHPUnit2
* @since File available since Release 2.0.0
*/
@@ -384,7 +384,7 @@
if ($coverageDataFile !== FALSE ||
$coverageHTMLFile !== FALSE ||
$coverageTextFile !== FALSE) {
- PHPUnit2_Framework_TestCase::$collectCodeCoverageInformation = TRUE;
+ PHPUnit2_Framework_TestResult::$collectCodeCoverageInformation = TRUE;
}
$timer->start();