Modified: incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/TestCase.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/TestCase.php?rev=719967&r1=719966&r2=719967&view=diff ============================================================================== --- incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/TestCase.php (original) +++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/TestCase.php Sun Nov 23 01:17:03 2008 @@ -68,181 +68,167 @@ * @link http://www.phpunit.de/ * @since Class available since Release 3.2.0 */ -abstract class PHPUnit_Extensions_Database_TestCase extends PHPUnit_Framework_TestCase -{ - - /** - * @var PHPUnit_Extensions_Database_ITester - */ - protected $databaseTester; - - /** - * Closes the specified connection. - * - * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection - */ - protected function closeConnection(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection) - { - $this->getDatabaseTester()->closeConnection($connection); - } - - /** - * Returns the test database connection. - * - * @return PHPUnit_Extensions_Database_DB_IDatabaseConnection - */ - protected abstract function getConnection(); - - /** - * Gets the IDatabaseTester for this testCase. If the IDatabaseTester is - * not set yet, this method calls newDatabaseTester() to obtain a new - * instance. - * - * @return PHPUnit_Extensions_Database_ITester - */ - protected function getDatabaseTester() - { - if (empty($this->databaseTester)) { - $this->databaseTester = $this->newDatabaseTester(); - } - - return $this->databaseTester; - } - - /** - * Returns the test dataset. - * - * @return PHPUnit_Extensions_Database_DataSet_IDataSet - */ - protected abstract function getDataSet(); - - /** - * Returns the database operation executed in test setup. - * - * @return PHPUnit_Extensions_Database_Operation_DatabaseOperation - */ - protected function getSetUpOperation() - { - return PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT(); - } - - /** - * Returns the database operation executed in test cleanup. - * - * @return PHPUnit_Extensions_Database_Operation_DatabaseOperation - */ - protected function getTearDownOperation() - { - return PHPUnit_Extensions_Database_Operation_Factory::NONE(); - } - - /** - * Creates a IDatabaseTester for this testCase. - * - * @return PHPUnit_Extensions_Database_ITester - */ - protected function newDatabaseTester() - { - return new PHPUnit_Extensions_Database_DefaultTester($this->getConnection()); - } - - /** - * Creates a new DefaultDatabaseConnection using the given PDO connection - * and database schema name. - * - * @param PDO $connection - * @param string $schema - * @return PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection - */ - protected function createDefaultDBConnection(PDO $connection, $schema) - { - return new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($connection, $schema); +abstract class PHPUnit_Extensions_Database_TestCase extends PHPUnit_Framework_TestCase { + + /** + * @var PHPUnit_Extensions_Database_ITester + */ + protected $databaseTester; + + /** + * Closes the specified connection. + * + * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection + */ + protected function closeConnection(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection) { + $this->getDatabaseTester()->closeConnection($connection); + } + + /** + * Returns the test database connection. + * + * @return PHPUnit_Extensions_Database_DB_IDatabaseConnection + */ + protected abstract function getConnection(); + + /** + * Gets the IDatabaseTester for this testCase. If the IDatabaseTester is + * not set yet, this method calls newDatabaseTester() to obtain a new + * instance. + * + * @return PHPUnit_Extensions_Database_ITester + */ + protected function getDatabaseTester() { + if (empty($this->databaseTester)) { + $this->databaseTester = $this->newDatabaseTester(); } - /** - * Creates a new FlatXmlDataSet with the given $xmlFile. (absolute path.) - * - * @param string $xmlFile - * @return PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet - */ - protected function createFlatXMLDataSet($xmlFile) - { - require_once 'PHPUnit/Extensions/Database/DataSet/FlatXmlDataSet.php'; - return new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet($xmlFile); - } - - /** - * Creates a new XMLDataSet with the given $xmlFile. (absolute path.) - * - * @param string $xmlFile - * @return PHPUnit_Extensions_Database_DataSet_XmlDataSet - */ - protected function createXMLDataSet($xmlFile) - { - require_once 'PHPUnit/Extensions/Database/DataSet/XmlDataSet.php'; - return new PHPUnit_Extensions_Database_DataSet_XmlDataSet($xmlFile); - } + return $this->databaseTester; + } + + /** + * Returns the test dataset. + * + * @return PHPUnit_Extensions_Database_DataSet_IDataSet + */ + protected abstract function getDataSet(); + + /** + * Returns the database operation executed in test setup. + * + * @return PHPUnit_Extensions_Database_Operation_DatabaseOperation + */ + protected function getSetUpOperation() { + return PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT(); + } + + /** + * Returns the database operation executed in test cleanup. + * + * @return PHPUnit_Extensions_Database_Operation_DatabaseOperation + */ + protected function getTearDownOperation() { + return PHPUnit_Extensions_Database_Operation_Factory::NONE(); + } + + /** + * Creates a IDatabaseTester for this testCase. + * + * @return PHPUnit_Extensions_Database_ITester + */ + protected function newDatabaseTester() { + return new PHPUnit_Extensions_Database_DefaultTester($this->getConnection()); + } + + /** + * Creates a new DefaultDatabaseConnection using the given PDO connection + * and database schema name. + * + * @param PDO $connection + * @param string $schema + * @return PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection + */ + protected function createDefaultDBConnection(PDO $connection, $schema) { + return new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($connection, $schema); + } + + /** + * Creates a new FlatXmlDataSet with the given $xmlFile. (absolute path.) + * + * @param string $xmlFile + * @return PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet + */ + protected function createFlatXMLDataSet($xmlFile) { + require_once 'PHPUnit/Extensions/Database/DataSet/FlatXmlDataSet.php'; + return new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet($xmlFile); + } + + /** + * Creates a new XMLDataSet with the given $xmlFile. (absolute path.) + * + * @param string $xmlFile + * @return PHPUnit_Extensions_Database_DataSet_XmlDataSet + */ + protected function createXMLDataSet($xmlFile) { + require_once 'PHPUnit/Extensions/Database/DataSet/XmlDataSet.php'; + return new PHPUnit_Extensions_Database_DataSet_XmlDataSet($xmlFile); + } + + /** + * Returns an operation factory instance that can be used to instantiate + * new operations. + * + * @return PHPUnit_Extensions_Database_Operation_Factory + */ + protected function getOperations() { + require_once 'PHPUnit/Extensions/Database/Operation/Factory.php'; + return new PHPUnit_Extensions_Database_Operation_Factory(); + } + + /** + * Performs operation returned by getSetUpOperation(). + */ + protected function setUp() { + parent::setUp(); - /** - * Returns an operation factory instance that can be used to instantiate - * new operations. - * - * @return PHPUnit_Extensions_Database_Operation_Factory - */ - protected function getOperations() - { - require_once 'PHPUnit/Extensions/Database/Operation/Factory.php'; - return new PHPUnit_Extensions_Database_Operation_Factory(); - } + $this->getDatabaseTester()->setSetUpOperation($this->getSetUpOperation()); + $this->getDatabaseTester()->setDataSet($this->getDataSet()); + $this->getDatabaseTester()->onSetUp(); + } + + /** + * Performs operation returned by getSetUpOperation(). + */ + protected function tearDown() { + $this->getDatabaseTester()->setTearDownOperation($this->getTearDownOperation()); + $this->getDatabaseTester()->setDataSet($this->getDataSet()); + $this->getDatabaseTester()->onTearDown(); + } + + /** + * Asserts that two given tables are equal. + * + * @param PHPUnit_Extensions_Database_DataSet_ITable $expected + * @param PHPUnit_Extensions_Database_DataSet_ITable $actual + * @param string $message + */ + public static function assertTablesEqual(PHPUnit_Extensions_Database_DataSet_ITable $expected, PHPUnit_Extensions_Database_DataSet_ITable $actual, $message = '') { + $constraint = new PHPUnit_Extensions_Database_Constraint_TableIsEqual($expected); - /** - * Performs operation returned by getSetUpOperation(). - */ - protected function setUp() - { - parent::setUp(); - - $this->getDatabaseTester()->setSetUpOperation($this->getSetUpOperation()); - $this->getDatabaseTester()->setDataSet($this->getDataSet()); - $this->getDatabaseTester()->onSetUp(); - } + self::assertThat($actual, $constraint, $message); + } - /** - * Performs operation returned by getSetUpOperation(). - */ - protected function tearDown() - { - $this->getDatabaseTester()->setTearDownOperation($this->getTearDownOperation()); - $this->getDatabaseTester()->setDataSet($this->getDataSet()); - $this->getDatabaseTester()->onTearDown(); - } - - /** - * Asserts that two given tables are equal. - * - * @param PHPUnit_Extensions_Database_DataSet_ITable $expected - * @param PHPUnit_Extensions_Database_DataSet_ITable $actual - * @param string $message - */ - public static function assertTablesEqual(PHPUnit_Extensions_Database_DataSet_ITable $expected, PHPUnit_Extensions_Database_DataSet_ITable $actual, $message = '') - { - $constraint = new PHPUnit_Extensions_Database_Constraint_TableIsEqual($expected); - - self::assertThat($actual, $constraint, $message); - } - - /** - * Asserts that two given datasets are equal. - * - * @param PHPUnit_Extensions_Database_DataSet_ITable $expected - * @param PHPUnit_Extensions_Database_DataSet_ITable $actual - * @param string $message - */ - public static function assertDataSetsEqual(PHPUnit_Extensions_Database_DataSet_IDataSet $expected, PHPUnit_Extensions_Database_DataSet_IDataSet $actual, $message = '') - { - $constraint = new PHPUnit_Extensions_Database_Constraint_DataSetIsEqual($expected); - - self::assertThat($actual, $constraint, $message); - } + /** + * Asserts that two given datasets are equal. + * + * @param PHPUnit_Extensions_Database_DataSet_ITable $expected + * @param PHPUnit_Extensions_Database_DataSet_ITable $actual + * @param string $message + */ + public static function assertDataSetsEqual(PHPUnit_Extensions_Database_DataSet_IDataSet $expected, PHPUnit_Extensions_Database_DataSet_IDataSet $actual, $message = '') { + $constraint = new PHPUnit_Extensions_Database_Constraint_DataSetIsEqual($expected); + + self::assertThat($actual, $constraint, $message); + } } ?>
Modified: incubator/shindig/trunk/php/external/PHPUnit/Extensions/ExceptionTestCase.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/ExceptionTestCase.php?rev=719967&r1=719966&r2=719967&view=diff ============================================================================== --- incubator/shindig/trunk/php/external/PHPUnit/Extensions/ExceptionTestCase.php (original) +++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/ExceptionTestCase.php Sun Nov 23 01:17:03 2008 @@ -49,11 +49,7 @@ PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT'); -trigger_error( - "Class PHPUnit_Extensions_ExceptionTestCase is deprecated. ". - "It will be removed in PHPUnit 3.3. ". - "The functionality has been merged into PHPUnit_Framework_TestCase." -); +trigger_error("Class PHPUnit_Extensions_ExceptionTestCase is deprecated. " . "It will be removed in PHPUnit 3.3. " . "The functionality has been merged into PHPUnit_Framework_TestCase."); /** * A TestCase that expects a specified Exception to be thrown. @@ -67,7 +63,6 @@ * @link http://www.phpunit.de/ * @since Class available since Release 2.0.0 */ -abstract class PHPUnit_Extensions_ExceptionTestCase extends PHPUnit_Framework_TestCase -{ +abstract class PHPUnit_Extensions_ExceptionTestCase extends PHPUnit_Framework_TestCase { } ?> Modified: incubator/shindig/trunk/php/external/PHPUnit/Extensions/OutputTestCase.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/OutputTestCase.php?rev=719967&r1=719966&r2=719967&view=diff ============================================================================== --- incubator/shindig/trunk/php/external/PHPUnit/Extensions/OutputTestCase.php (original) +++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/OutputTestCase.php Sun Nov 23 01:17:03 2008 @@ -61,147 +61,138 @@ * @link http://www.phpunit.de/ * @since Class available since Release 3.0.0 */ -abstract class PHPUnit_Extensions_OutputTestCase extends PHPUnit_Framework_TestCase -{ - /** - * @var string - * @access protected - */ - protected $expectedRegex = NULL; - - /** - * @var string - * @access protected - */ - protected $expectedString = NULL; - - /** - * @var string - * @access protected - */ - protected $output = ''; - - /** - * @var mixed - * @access protected - */ - protected $outputCallback = FALSE; - - /** - * @return bool - * @access public - */ - public function setOutputCallback($callback) - { - if (is_callable($callback)) { - $this->outputCallback = $callback; - $set = TRUE; - } else { - $set = FALSE; - } - - return $set; - } - - /** - * @return string - * @access public - */ - public function normalizeOutput($buffer) - { - return str_replace("\r", '', $buffer); - } - - /** - * @return string - * @access public - */ - public function getActualOutput() - { - return $this->output; - } - - /** - * @return string - * @access public - */ - public function expectedRegex() - { - return $this->expectedRegex; - } - - /** - * @param string $expectedRegex - * @access public - */ - public function expectOutputRegex($expectedRegex) - { - if ($this->expectedString !== NULL) { - throw new RuntimeException; - } - - if (is_string($expectedRegex) || is_null($expectedRegex)) { - $this->expectedRegex = $expectedRegex; - } - } - - /** - * @return string - * @access public - */ - public function expectedString() - { - return $this->expectedOutput; - } - - /** - * @param string $expectedString - * @access public - */ - public function expectOutputString($expectedString) - { - if ($this->expectedRegex !== NULL) { - throw new RuntimeException; - } - - if (is_string($expectedString) || is_null($expectedString)) { - $this->expectedString = $expectedString; - } - } - - /** - * @access protected - */ - protected function runTest() - { - ob_start(); - - try { - parent::runTest(); - } - - catch (Exception $e) { - ob_end_clean(); - throw $e; - } - - if ($this->outputCallback === FALSE) { - $this->output = ob_get_contents(); - } else { - $this->output = call_user_func_array($this->outputCallback, array(ob_get_contents())); - } - - ob_end_clean(); - - if ($this->expectedRegex !== NULL) { - $this->assertRegExp($this->expectedRegex, $this->output); - $this->expectedRegex = NULL; - } - - else if ($this->expectedString !== NULL) { - $this->assertEquals($this->expectedString, $this->output); - $this->expectedString = NULL; - } +abstract class PHPUnit_Extensions_OutputTestCase extends PHPUnit_Framework_TestCase { + /** + * @var string + * @access protected + */ + protected $expectedRegex = NULL; + + /** + * @var string + * @access protected + */ + protected $expectedString = NULL; + + /** + * @var string + * @access protected + */ + protected $output = ''; + + /** + * @var mixed + * @access protected + */ + protected $outputCallback = FALSE; + + /** + * @return bool + * @access public + */ + public function setOutputCallback($callback) { + if (is_callable($callback)) { + $this->outputCallback = $callback; + $set = TRUE; + } else { + $set = FALSE; + } + + return $set; + } + + /** + * @return string + * @access public + */ + public function normalizeOutput($buffer) { + return str_replace("\r", '', $buffer); + } + + /** + * @return string + * @access public + */ + public function getActualOutput() { + return $this->output; + } + + /** + * @return string + * @access public + */ + public function expectedRegex() { + return $this->expectedRegex; + } + + /** + * @param string $expectedRegex + * @access public + */ + public function expectOutputRegex($expectedRegex) { + if ($this->expectedString !== NULL) { + throw new RuntimeException(); + } + + if (is_string($expectedRegex) || is_null($expectedRegex)) { + $this->expectedRegex = $expectedRegex; + } + } + + /** + * @return string + * @access public + */ + public function expectedString() { + return $this->expectedOutput; + } + + /** + * @param string $expectedString + * @access public + */ + public function expectOutputString($expectedString) { + if ($this->expectedRegex !== NULL) { + throw new RuntimeException(); + } + + if (is_string($expectedString) || is_null($expectedString)) { + $this->expectedString = $expectedString; + } + } + + /** + * @access protected + */ + protected function runTest() { + ob_start(); + + try { + parent::runTest(); + } + + catch (Exception $e) { + ob_end_clean(); + throw $e; + } + + if ($this->outputCallback === FALSE) { + $this->output = ob_get_contents(); + } else { + $this->output = call_user_func_array($this->outputCallback, array(ob_get_contents())); + } + + ob_end_clean(); + + if ($this->expectedRegex !== NULL) { + $this->assertRegExp($this->expectedRegex, $this->output); + $this->expectedRegex = NULL; + } + + else if ($this->expectedString !== NULL) { + $this->assertEquals($this->expectedString, $this->output); + $this->expectedString = NULL; } + } } ?> Modified: incubator/shindig/trunk/php/external/PHPUnit/Extensions/PerformanceTestCase.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/PerformanceTestCase.php?rev=719967&r1=719966&r2=719967&view=diff ============================================================================== --- incubator/shindig/trunk/php/external/PHPUnit/Extensions/PerformanceTestCase.php (original) +++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/PerformanceTestCase.php Sun Nov 23 01:17:03 2008 @@ -63,60 +63,49 @@ * @link http://www.phpunit.de/ * @since Class available since Release 2.1.0 */ -abstract class PHPUnit_Extensions_PerformanceTestCase extends PHPUnit_Framework_TestCase -{ - /** - * @var integer - * @access protected - */ - protected $maxRunningTime = 0; +abstract class PHPUnit_Extensions_PerformanceTestCase extends PHPUnit_Framework_TestCase { + /** + * @var integer + * @access protected + */ + protected $maxRunningTime = 0; - /** - * @access protected - */ - protected function runTest() - { - PHPUnit_Util_Timer::start(); - parent::runTest(); - $time = PHPUnit_Util_Timer::stop(); + /** + * @access protected + */ + protected function runTest() { + PHPUnit_Util_Timer::start(); + parent::runTest(); + $time = PHPUnit_Util_Timer::stop(); + + if ($this->maxRunningTime != 0 && $time > $this->maxRunningTime) { + $this->fail(sprintf('expected running time: <= %s but was: %s', - if ($this->maxRunningTime != 0 && - $time > $this->maxRunningTime) { - $this->fail( - sprintf( - 'expected running time: <= %s but was: %s', - - $this->maxRunningTime, - $time - ) - ); - } + $this->maxRunningTime, $time)); } + } - /** - * @param integer $maxRunningTime - * @throws InvalidArgumentException - * @access public - * @since Method available since Release 2.3.0 - */ - public function setMaxRunningTime($maxRunningTime) - { - if (is_integer($maxRunningTime) && - $maxRunningTime >= 0) { - $this->maxRunningTime = $maxRunningTime; - } else { - throw new InvalidArgumentException; - } + /** + * @param integer $maxRunningTime + * @throws InvalidArgumentException + * @access public + * @since Method available since Release 2.3.0 + */ + public function setMaxRunningTime($maxRunningTime) { + if (is_integer($maxRunningTime) && $maxRunningTime >= 0) { + $this->maxRunningTime = $maxRunningTime; + } else { + throw new InvalidArgumentException(); } + } - /** - * @return integer - * @access public - * @since Method available since Release 2.3.0 - */ - public function getMaxRunningTime() - { - return $this->maxRunningTime; - } + /** + * @return integer + * @access public + * @since Method available since Release 2.3.0 + */ + public function getMaxRunningTime() { + return $this->maxRunningTime; + } } ?> Modified: incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase.php?rev=719967&r1=719966&r2=719967&view=diff ============================================================================== --- incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase.php (original) +++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase.php Sun Nov 23 01:17:03 2008 @@ -64,185 +64,158 @@ * @link http://www.phpunit.de/ * @since Class available since Release 3.1.4 */ -class PHPUnit_Extensions_PhptTestCase implements PHPUnit_Framework_Test -{ - /** - * The filename of the .phpt file. - * - * @var string - * @access protected - */ - protected $filename; - - protected $options = array(); - - /** - * Constructs a test case with the given filename. - * - * @param string $filename - * @param array $options Array with ini settings for the php instance run, - * key being the name if the setting, value the ini value. - * @access public - */ - public function __construct($filename, $options = array()) - { - if (!is_string($filename)) { - throw new InvalidArgumentException; - } - - if (!is_file($filename)) { - throw new RuntimeException( - sprintf( - 'File "%s" does not exist.', - $filename - ) - ); - } - - if (!is_array($options)) { - throw new InvalidArgumentException; - } - - $this->filename = $filename; - $this->options = $options; - } - - /** - * Counts the number of test cases executed by run(TestResult result). - * - * @return integer - * @access public - */ - public function count() - { - return 1; - } - - /** - * Runs a test and collects its result in a TestResult instance. - * - * @param PHPUnit_Framework_TestResult $result - * @param array $options Array with ini settings for the php instance run, - * key being the name if the setting, value the ini value. - * @return PHPUnit_Framework_TestResult - * @access public - */ - public function run(PHPUnit_Framework_TestResult $result = NULL, $options = array()) - { - if (!class_exists('PEAR_RunTest', FALSE)) { - throw new RuntimeException('Class PEAR_RunTest not found.'); - } - - if ($result === NULL) { - $result = new PHPUnit_Framework_TestResult; - } - - if (!is_array($options)) { - throw new InvalidArgumentException; - } - - $options = array_merge($options, $this->options); - - $coverage = $result->getCollectCodeCoverageInformation(); - - if ($coverage) { - $options = array('coverage' => TRUE); - } else { - $options = array(); - } - - $runner = new PEAR_RunTest(new PHPUnit_Extensions_PhptTestCase_Logger, $options); - - if ($coverage){ - $runner->xdebug_loaded = TRUE; - } else { - $runner->xdebug_loaded = FALSE; - } - - $result->startTest($this); - - PHPUnit_Util_Timer::start(); - $buffer = $runner->run($this->filename, $options); - $time = PHPUnit_Util_Timer::stop(); - - $base = basename($this->filename); - $path = dirname($this->filename); - $coverageFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.xdebug', $base); - $diffFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.diff', $base); - $expFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.exp', $base); - $logFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.log', $base); - $outFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.out', $base); - $phpFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.php', $base); - - if (is_object($buffer) && $buffer instanceof PEAR_Error) { - $result->addError( - $this, - new RuntimeException($buffer->getMessage()), - $time - ); - } - - else if ($buffer == 'SKIPPED') { - $result->addFailure($this, new PHPUnit_Framework_SkippedTestError, 0); - } - - else if ($buffer != 'PASSED') { - $result->addFailure( - $this, - PHPUnit_Framework_ComparisonFailure::diffEqual( - file_get_contents($expFile), - file_get_contents($outFile), - FALSE, - $this->getName() - ), - $time - ); - } - - foreach (array($diffFile, $expFile, $logFile, $phpFile, $outFile) as $file) { - if (file_exists($file)) { - unlink($file); - } - } - - if ($coverage) { - eval('$coverageData = ' . file_get_contents($coverageFile) . ';'); - unset($coverageData[$phpFile]); - - $codeCoverageInformation = array( - 'test' => $this, - 'files' => $coverageData - ); - - $result->appendCodeCoverageInformation($this, $codeCoverageInformation); - unlink($coverageFile); - } - - $result->endTest($this, $time); - - return $result; - } - - /** - * Returns the name of the test case. - * - * @return string - * @access public - */ - public function getName() - { - return $this->toString(); - } - - /** - * Returns a string representation of the test case. - * - * @return string - * @access public - */ - public function toString() - { - return $this->filename; +class PHPUnit_Extensions_PhptTestCase implements PHPUnit_Framework_Test { + /** + * The filename of the .phpt file. + * + * @var string + * @access protected + */ + protected $filename; + + protected $options = array(); + + /** + * Constructs a test case with the given filename. + * + * @param string $filename + * @param array $options Array with ini settings for the php instance run, + * key being the name if the setting, value the ini value. + * @access public + */ + public function __construct($filename, $options = array()) { + if (! is_string($filename)) { + throw new InvalidArgumentException(); } + + if (! is_file($filename)) { + throw new RuntimeException(sprintf('File "%s" does not exist.', $filename)); + } + + if (! is_array($options)) { + throw new InvalidArgumentException(); + } + + $this->filename = $filename; + $this->options = $options; + } + + /** + * Counts the number of test cases executed by run(TestResult result). + * + * @return integer + * @access public + */ + public function count() { + return 1; + } + + /** + * Runs a test and collects its result in a TestResult instance. + * + * @param PHPUnit_Framework_TestResult $result + * @param array $options Array with ini settings for the php instance run, + * key being the name if the setting, value the ini value. + * @return PHPUnit_Framework_TestResult + * @access public + */ + public function run(PHPUnit_Framework_TestResult $result = NULL, $options = array()) { + if (! class_exists('PEAR_RunTest', FALSE)) { + throw new RuntimeException('Class PEAR_RunTest not found.'); + } + + if ($result === NULL) { + $result = new PHPUnit_Framework_TestResult(); + } + + if (! is_array($options)) { + throw new InvalidArgumentException(); + } + + $options = array_merge($options, $this->options); + + $coverage = $result->getCollectCodeCoverageInformation(); + + if ($coverage) { + $options = array('coverage' => TRUE); + } else { + $options = array(); + } + + $runner = new PEAR_RunTest(new PHPUnit_Extensions_PhptTestCase_Logger(), $options); + + if ($coverage) { + $runner->xdebug_loaded = TRUE; + } else { + $runner->xdebug_loaded = FALSE; + } + + $result->startTest($this); + + PHPUnit_Util_Timer::start(); + $buffer = $runner->run($this->filename, $options); + $time = PHPUnit_Util_Timer::stop(); + + $base = basename($this->filename); + $path = dirname($this->filename); + $coverageFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.xdebug', $base); + $diffFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.diff', $base); + $expFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.exp', $base); + $logFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.log', $base); + $outFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.out', $base); + $phpFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.php', $base); + + if (is_object($buffer) && $buffer instanceof PEAR_Error) { + $result->addError($this, new RuntimeException($buffer->getMessage()), $time); + } + + else if ($buffer == 'SKIPPED') { + $result->addFailure($this, new PHPUnit_Framework_SkippedTestError(), 0); + } + + else if ($buffer != 'PASSED') { + $result->addFailure($this, PHPUnit_Framework_ComparisonFailure::diffEqual(file_get_contents($expFile), file_get_contents($outFile), FALSE, $this->getName()), $time); + } + + foreach (array($diffFile, $expFile, $logFile, $phpFile, $outFile) as $file) { + if (file_exists($file)) { + unlink($file); + } + } + + if ($coverage) { + eval('$coverageData = ' . file_get_contents($coverageFile) . ';'); + unset($coverageData[$phpFile]); + + $codeCoverageInformation = array('test' => $this, 'files' => $coverageData); + + $result->appendCodeCoverageInformation($this, $codeCoverageInformation); + unlink($coverageFile); + } + + $result->endTest($this, $time); + + return $result; + } + + /** + * Returns the name of the test case. + * + * @return string + * @access public + */ + public function getName() { + return $this->toString(); + } + + /** + * Returns a string representation of the test case. + * + * @return string + * @access public + */ + public function toString() { + return $this->filename; + } } ?> Modified: incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase/Logger.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase/Logger.php?rev=719967&r1=719966&r2=719967&view=diff ============================================================================== --- incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase/Logger.php (original) +++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase/Logger.php Sun Nov 23 01:17:03 2008 @@ -60,10 +60,8 @@ * @link http://www.phpunit.de/ * @since Class available since Release 3.1.4 */ -class PHPUnit_Extensions_PhptTestCase_Logger -{ - public function log($level, $msg, $append_crlf = TRUE) - { - } +class PHPUnit_Extensions_PhptTestCase_Logger { + + public function log($level, $msg, $append_crlf = TRUE) {} } ?> Modified: incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestSuite.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestSuite.php?rev=719967&r1=719966&r2=719967&view=diff ============================================================================== --- incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestSuite.php (original) +++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestSuite.php Sun Nov 23 01:17:03 2008 @@ -62,35 +62,29 @@ * @link http://www.phpunit.de/ * @since Class available since Release 3.1.4 */ -class PHPUnit_Extensions_PhptTestSuite extends PHPUnit_Framework_TestSuite -{ - /** - * Constructs a new TestSuite for .phpt test cases. - * - * @param string $directory - * @param array $options Array with ini settings for the php instance run, - * key being the name if the setting, value the ini value. - * @throws InvalidArgumentException - * @access public - */ - public function __construct($directory, $options = array()) - { - if (is_dir($directory)) { - $this->setName($directory); +class PHPUnit_Extensions_PhptTestSuite extends PHPUnit_Framework_TestSuite { - $iterator = new PHPUnit_Util_FilterIterator( - new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($directory) - ), - '.phpt' - ); - - foreach ($iterator as $testFile) { - $this->addTestFile($testFile->getPathname(), TRUE, $options); - } - } else { - throw new InvalidArgumentException; - } + /** + * Constructs a new TestSuite for .phpt test cases. + * + * @param string $directory + * @param array $options Array with ini settings for the php instance run, + * key being the name if the setting, value the ini value. + * @throws InvalidArgumentException + * @access public + */ + public function __construct($directory, $options = array()) { + if (is_dir($directory)) { + $this->setName($directory); + + $iterator = new PHPUnit_Util_FilterIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)), '.phpt'); + + foreach ($iterator as $testFile) { + $this->addTestFile($testFile->getPathname(), TRUE, $options); + } + } else { + throw new InvalidArgumentException(); } + } } ?> Modified: incubator/shindig/trunk/php/external/PHPUnit/Extensions/RepeatedTest.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/RepeatedTest.php?rev=719967&r1=719966&r2=719967&view=diff ============================================================================== --- incubator/shindig/trunk/php/external/PHPUnit/Extensions/RepeatedTest.php (original) +++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/RepeatedTest.php Sun Nov 23 01:17:03 2008 @@ -62,99 +62,90 @@ * @link http://www.phpunit.de/ * @since Class available since Release 2.0.0 */ -class PHPUnit_Extensions_RepeatedTest extends PHPUnit_Extensions_TestDecorator -{ - /** - * @var mixed - * @access protected - */ - protected $filter = FALSE; - - /** - * @var array - * @access protected - */ - protected $groups = array(); - - /** - * @var array - * @access protected - */ - protected $excludeGroups = array(); - - /** - * @var integer - * @access protected - */ - protected $timesRepeat = 1; - - /** - * Constructor. - * - * @param PHPUnit_Framework_Test $test - * @param integer $timesRepeat - * @param mixed $filter - * @param array $groups - * @param array $excludeGroups - * @throws InvalidArgumentException - * @access public - */ - public function __construct(PHPUnit_Framework_Test $test, $timesRepeat = 1, $filter = FALSE, array $groups = array(), array $excludeGroups = array()) - { - parent::__construct($test); - - if (is_integer($timesRepeat) && - $timesRepeat >= 0) { - $this->timesRepeat = $timesRepeat; - } else { - throw new InvalidArgumentException( - 'Argument 2 must be a positive integer.' - ); - } - - $this->filter = $filter; - $this->groups = $groups; - $this->excludeGroups = $excludeGroups; +class PHPUnit_Extensions_RepeatedTest extends PHPUnit_Extensions_TestDecorator { + /** + * @var mixed + * @access protected + */ + protected $filter = FALSE; + + /** + * @var array + * @access protected + */ + protected $groups = array(); + + /** + * @var array + * @access protected + */ + protected $excludeGroups = array(); + + /** + * @var integer + * @access protected + */ + protected $timesRepeat = 1; + + /** + * Constructor. + * + * @param PHPUnit_Framework_Test $test + * @param integer $timesRepeat + * @param mixed $filter + * @param array $groups + * @param array $excludeGroups + * @throws InvalidArgumentException + * @access public + */ + public function __construct(PHPUnit_Framework_Test $test, $timesRepeat = 1, $filter = FALSE, array $groups = array(), array $excludeGroups = array()) { + parent::__construct($test); + + if (is_integer($timesRepeat) && $timesRepeat >= 0) { + $this->timesRepeat = $timesRepeat; + } else { + throw new InvalidArgumentException('Argument 2 must be a positive integer.'); } - - /** - * Counts the number of test cases that - * will be run by this test. - * - * @return integer - * @access public - */ - public function count() - { - return $this->timesRepeat * count($this->test); + + $this->filter = $filter; + $this->groups = $groups; + $this->excludeGroups = $excludeGroups; + } + + /** + * Counts the number of test cases that + * will be run by this test. + * + * @return integer + * @access public + */ + public function count() { + return $this->timesRepeat * count($this->test); + } + + /** + * Runs the decorated test and collects the + * result in a TestResult. + * + * @param PHPUnit_Framework_TestResult $result + * @return PHPUnit_Framework_TestResult + * @throws InvalidArgumentException + * @access public + */ + public function run(PHPUnit_Framework_TestResult $result = NULL) { + if ($result === NULL) { + $result = $this->createResult(); } - - /** - * Runs the decorated test and collects the - * result in a TestResult. - * - * @param PHPUnit_Framework_TestResult $result - * @return PHPUnit_Framework_TestResult - * @throws InvalidArgumentException - * @access public - */ - public function run(PHPUnit_Framework_TestResult $result = NULL) - { - if ($result === NULL) { - $result = $this->createResult(); - } - - for ($i = 0; $i < $this->timesRepeat && !$result->shouldStop(); $i++) { - if ($this->test instanceof PHPUnit_Framework_TestSuite) { - $this->test->run( - $result, $this->filter, $this->groups, $this->excludeGroups - ); - } else { - $this->test->run($result); - } - } - - return $result; + + for ($i = 0; $i < $this->timesRepeat && ! $result->shouldStop(); $i ++) { + if ($this->test instanceof PHPUnit_Framework_TestSuite) { + $this->test->run($result, $this->filter, $this->groups, $this->excludeGroups); + } else { + $this->test->run($result); + } } + + return $result; + } } ?>
