diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Autoload.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Autoload.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Autoload.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Autoload.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.5.0 - */ - -require_once 'PHPUnit/Util/Filesystem.php'; -require_once 'PHP/CodeCoverage/Filter.php'; - -if (!function_exists('phpunit_autoload')) { - function phpunit_autoload($class) - { - if (strpos($class, 'PHPUnit_') === 0) { - $file = str_replace('_', '/', $class) . '.php'; - $file = PHPUnit_Util_Filesystem::fileExistsInIncludePath($file); - - if ($file) { - require_once $file; - } - } - } - - spl_autoload_register('phpunit_autoload'); - - $dir = dirname(__FILE__); - $filter = PHP_CodeCoverage_Filter::getInstance(); - - $filter->addDirectoryToBlacklist( - $dir . '/Extensions', '.php', '', 'PHPUNIT', FALSE - ); - - $filter->addDirectoryToBlacklist( - $dir . '/Framework', '.php', '', 'PHPUNIT', FALSE - ); - - $filter->addDirectoryToBlacklist( - $dir . '/Runner', '.php', '', 'PHPUNIT', FALSE - ); - - $filter->addDirectoryToBlacklist( - $dir . '/TextUI', '.php', '', 'PHPUNIT', FALSE - ); - - $filter->addDirectoryToBlacklist( - $dir . '/Util', '.php', '', 'PHPUNIT', FALSE - ); - - $filter->addFileToBlacklist(__FILE__, 'PHPUNIT', FALSE); - - unset($dir, $filter); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/GroupTestSuite.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/GroupTestSuite.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/GroupTestSuite.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/GroupTestSuite.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * We have a TestSuite object A. - * In TestSuite object A we have Tests tagged with @group. - * We want a TestSuite object B that contains TestSuite objects C, D, ... - * for the Tests tagged with @group C, @group D, ... - * Running the Tests from TestSuite object B results in Tests tagged with both - * @group C and @group D in TestSuite object A to be run twice . - * - * - * $suite = new PHPUnit_Extensions_GroupTestSuite($A, array('C', 'D')); - * - * - * @package PHPUnit - * @subpackage Extensions - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Extensions_GroupTestSuite extends PHPUnit_Framework_TestSuite -{ - public function __construct(PHPUnit_Framework_TestSuite $suite, array $groups) - { - $groupSuites = array(); - $name = $suite->getName(); - - foreach ($groups as $group) { - $groupSuites[$group] = new PHPUnit_Framework_TestSuite($name . ' - ' . $group); - $this->addTest($groupSuites[$group]); - } - - $tests = new RecursiveIteratorIterator( - new PHPUnit_Util_TestSuiteIterator($suite), - RecursiveIteratorIterator::LEAVES_ONLY - ); - - foreach ($tests as $test) { - if ($test instanceof PHPUnit_Framework_TestCase) { - $testGroups = PHPUnit_Util_Test::getGroups( - get_class($test), $test->getName(FALSE) - ); - - foreach ($groups as $group) { - foreach ($testGroups as $testGroup) { - if ($group == $testGroup) { - $groupSuites[$group]->addTest($test); - } - } - } - } - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/OutputTestCase.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/OutputTestCase.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/OutputTestCase.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/OutputTestCase.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,202 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * A TestCase that expects a specified output. - * - * @package PHPUnit - * @subpackage Extensions - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -abstract class PHPUnit_Extensions_OutputTestCase extends PHPUnit_Framework_TestCase -{ - /** - * @var string - */ - protected $expectedRegex = NULL; - - /** - * @var string - */ - protected $expectedString = NULL; - - /** - * @var string - */ - protected $output = ''; - - /** - * @var boolean - */ - protected $obActive = FALSE; - - /** - * @var mixed - */ - protected $outputCallback = FALSE; - - /** - * @return bool - */ - public function setOutputCallback($callback) - { - if (is_callable($callback)) { - $this->outputCallback = $callback; - return TRUE; - } - - return FALSE; - } - - /** - * @return string - */ - public function normalizeOutput($buffer) - { - return str_replace("\r", '', $buffer); - } - - /** - * @return string - */ - public function getActualOutput() - { - if (!$this->obActive) { - return $this->output; - } else { - return ob_get_contents(); - } - } - - /** - * @return string - */ - public function expectedRegex() - { - return $this->expectedRegex; - } - - /** - * @param string $expectedRegex - */ - public function expectOutputRegex($expectedRegex) - { - if ($this->expectedString !== NULL) { - throw new PHPUnit_Framework_Exception; - } - - if (is_string($expectedRegex) || is_null($expectedRegex)) { - $this->expectedRegex = $expectedRegex; - } - } - - /** - * @return string - */ - public function expectedString() - { - return $this->expectedString; - } - - /** - * @param string $expectedString - */ - public function expectOutputString($expectedString) - { - if ($this->expectedRegex !== NULL) { - throw new PHPUnit_Framework_Exception; - } - - if (is_string($expectedString) || is_null($expectedString)) { - $this->expectedString = $expectedString; - } - } - - /** - * @return mixed - * @throws RuntimeException - */ - protected function runTest() - { - ob_start(); - $this->obActive = TRUE; - - try { - $testResult = parent::runTest(); - } - - catch (Exception $e) { - ob_end_clean(); - $this->obActive = FALSE; - 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(); - $this->obActive = FALSE; - - 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; - } - - return $testResult; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/PhptTestCase/Logger.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/PhptTestCase/Logger.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/PhptTestCase/Logger.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/PhptTestCase/Logger.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_PhptTestCase - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.1.4 - */ - -/** - * Dummy logger for PEAR_RunTest. - * - * @package PHPUnit - * @subpackage Extensions_PhptTestCase - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @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) - { - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/PhptTestCase.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/PhptTestCase.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/PhptTestCase.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/PhptTestCase.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,277 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_PhptTestCase - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.1.4 - */ - -if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('PEAR/RunTest.php')) { - $currentErrorReporting = error_reporting(E_ERROR | E_WARNING | E_PARSE); - PHPUnit_Util_Filesystem::collectStart(); - require_once 'PEAR/RunTest.php'; - error_reporting($currentErrorReporting); - - PHPUnit_Util_Filesystem::collectEndAndAddToBlacklist(); -} - -require_once 'PHP/CodeCoverage.php'; -require_once 'PHP/Timer.php'; - -/** - * Wrapper to run .phpt test cases. - * - * @package PHPUnit - * @subpackage Extensions_PhptTestCase - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.1.4 - */ -class PHPUnit_Extensions_PhptTestCase implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing -{ - /** - * The filename of the .phpt file. - * - * @var string - */ - protected $filename; - - /** - * Options for PEAR_RunTest. - * - * @var array - */ - protected $options = array(); - - /** - * Constructs a test case with the given filename. - * - * @param string $filename - * @param array $options - */ - public function __construct($filename, array $options = array()) - { - if (!is_string($filename)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_file($filename)) { - throw new PHPUnit_Framework_Exception( - sprintf( - 'File "%s" does not exist.', - $filename - ) - ); - } - - $this->filename = $filename; - $this->options = $options; - } - - /** - * Counts the number of test cases executed by run(TestResult result). - * - * @return integer - */ - public function count() - { - return 1; - } - - /** - * Runs a test and collects its result in a TestResult instance. - * - * @param PHPUnit_Framework_TestResult $result - * @param array $options - * @return PHPUnit_Framework_TestResult - */ - public function run(PHPUnit_Framework_TestResult $result = NULL, array $options = array()) - { - if (!class_exists('PEAR_RunTest', FALSE)) { - throw new PHPUnit_Framework_Exception('Class PEAR_RunTest not found.'); - } - - if (isset($GLOBALS['_PEAR_destructor_object_list']) && - is_array($GLOBALS['_PEAR_destructor_object_list']) && - !empty($GLOBALS['_PEAR_destructor_object_list'])) { - $pearDestructorObjectListCount = count($GLOBALS['_PEAR_destructor_object_list']); - } else { - $pearDestructorObjectListCount = 0; - } - - if ($result === NULL) { - $result = new PHPUnit_Framework_TestResult; - } - - $coverage = $result->getCollectCodeCoverageInformation(); - $options = array_merge($options, $this->options); - - if (!isset($options['include_path'])) { - $options['include_path'] = get_include_path(); - } - - if ($coverage) { - $options['coverage'] = TRUE; - } else { - $options['coverage'] = FALSE; - } - - $currentErrorReporting = error_reporting(E_ERROR | E_WARNING | E_PARSE); - $runner = new PEAR_RunTest(new PHPUnit_Extensions_PhptTestCase_Logger, $options); - - if ($coverage) { - $runner->xdebug_loaded = TRUE; - } else { - $runner->xdebug_loaded = FALSE; - } - - $result->startTest($this); - - PHP_Timer::start(); - - $buffer = $runner->run($this->filename, $options); - $time = PHP_Timer::stop(); - - error_reporting($currentErrorReporting); - - $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 (file_exists($phpFile)) { - PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist( - $phpFile, 'TESTS' - ); - } - - 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) - ), - $time - ); - } - - foreach (array($diffFile, $expFile, $logFile, $phpFile, $outFile) as $file) { - if (file_exists($file)) { - unlink($file); - } - } - - if ($coverage && file_exists($coverageFile)) { - eval('$coverageData = ' . file_get_contents($coverageFile) . ';'); - unset($coverageData[$phpFile]); - - $result->getCodeCoverage()->append($coverageData, $this); - unlink($coverageFile); - } - - $result->endTest($this, $time); - - // Do not invoke PEAR's destructor mechanism for PHP 4 - // as it raises an E_STRICT. - if ($pearDestructorObjectListCount == 0) { - unset($GLOBALS['_PEAR_destructor_object_list']); - } else { - $count = count($GLOBALS['_PEAR_destructor_object_list']) - $pearDestructorObjectListCount; - - for ($i = 0; $i < $count; $i++) { - array_pop($GLOBALS['_PEAR_destructor_object_list']); - } - } - - return $result; - } - - /** - * Returns the name of the test case. - * - * @return string - */ - public function getName() - { - return $this->toString(); - } - - /** - * Returns a string representation of the test case. - * - * @return string - */ - public function toString() - { - return $this->filename; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/PhptTestSuite.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/PhptTestSuite.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/PhptTestSuite.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/PhptTestSuite.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_PhptTestCase - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.1.4 - */ - -require_once 'File/Iterator/Factory.php'; - -/** - * Suite for .phpt test cases. - * - * @package PHPUnit - * @subpackage Extensions_PhptTestCase - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @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 - */ - public function __construct($directory, array $options = array()) - { - if (is_string($directory) && is_dir($directory)) { - $this->setName($directory); - - $iterator = File_Iterator_Factory::getFileIterator( - $directory, '.phpt' - ); - - foreach ($iterator as $testFile) { - $this->addTestFile($testFile->getPathname(), TRUE, $options); - } - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'directory name'); - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/RepeatedTest.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/RepeatedTest.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/RepeatedTest.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/RepeatedTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,154 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * A Decorator that runs a test repeatedly. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -class PHPUnit_Extensions_RepeatedTest extends PHPUnit_Extensions_TestDecorator -{ - /** - * @var mixed - */ - protected $filter = FALSE; - - /** - * @var array - */ - protected $groups = array(); - - /** - * @var array - */ - protected $excludeGroups = array(); - - /** - * @var boolean - */ - protected $processIsolation = FALSE; - - /** - * @var integer - */ - protected $timesRepeat = 1; - - /** - * Constructor. - * - * @param PHPUnit_Framework_Test $test - * @param integer $timesRepeat - * @param mixed $filter - * @param array $groups - * @param array $excludeGroups - * @param boolean $processIsolation - * @throws InvalidArgumentException - */ - public function __construct(PHPUnit_Framework_Test $test, $timesRepeat = 1, $filter = FALSE, array $groups = array(), array $excludeGroups = array(), $processIsolation = FALSE) - { - parent::__construct($test); - - if (is_integer($timesRepeat) && - $timesRepeat >= 0) { - $this->timesRepeat = $timesRepeat; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 2, 'positive integer' - ); - } - - $this->filter = $filter; - $this->groups = $groups; - $this->excludeGroups = $excludeGroups; - $this->processIsolation = $processIsolation; - } - - /** - * Counts the number of test cases that - * will be run by this test. - * - * @return integer - */ - 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 - */ - 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, - $this->processIsolation - ); - } else { - $this->test->run($result); - } - } - - return $result; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Given.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Given.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Given.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Given.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * A "Given" step. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Extensions_Story_Given extends PHPUnit_Extensions_Story_Step -{ - /** - * Returns this step's name. - * - * @return string - */ - public function getName() - { - return 'Given'; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/HTML.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/HTML.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/HTML.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/HTML.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,212 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * Prints stories in HTML format. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Extensions_Story_ResultPrinter_HTML extends PHPUnit_Extensions_Story_ResultPrinter -{ - /** - * @var boolean - */ - protected $printsHTML = TRUE; - - /** - * @var integer - */ - protected $id = 0; - - /** - * @var string - */ - protected $scenarios = ''; - - /** - * @var string - */ - protected $templatePath; - - /** - * Constructor. - * - * @param mixed $out - * @throws InvalidArgumentException - */ - public function __construct($out = NULL) - { - parent::__construct($out); - - $this->templatePath = sprintf( - '%s%sTemplate%s', - - dirname(__FILE__), - DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR - ); - } - - /** - * Handler for 'start class' event. - * - * @param string $name - */ - protected function startClass($name) - { - $scenarioHeaderTemplate = new Text_Template( - $this->templatePath . 'scenario_header.html' - ); - - $scenarioHeaderTemplate->setVar( - array( - 'name' => $this->currentTestClassPrettified - ) - ); - - $this->scenarios .= $scenarioHeaderTemplate->render(); - } - - /** - * Handler for 'on test' event. - * - * @param string $name - * @param boolean $success - * @param array $steps - */ - protected function onTest($name, $success = TRUE, array $steps = array()) - { - if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) { - $scenarioStatus = 'scenarioFailed'; - } - - else if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED) { - $scenarioStatus = 'scenarioSkipped'; - } - - else if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE) { - $scenarioStatus = 'scenarioIncomplete'; - } - - else { - $scenarioStatus = 'scenarioSuccess'; - } - - $lastStepName = ''; - $stepsBuffer = ''; - - foreach ($steps as $step) { - $currentStepName = $step->getName(); - - if ($lastStepName == $currentStepName) { - $stepText = 'and'; - } else { - $stepText = $currentStepName; - } - - $lastStepName = $currentStepName; - - $stepTemplate = new Text_Template( - $this->templatePath . 'step.html' - ); - - $stepTemplate->setVar( - array( - 'text' => $stepText, - 'action' => $step->getAction() . ' ' . $step->getArguments(TRUE), - ) - ); - - $stepsBuffer .= $stepTemplate->render(); - } - - $scenarioTemplate = new Text_Template( - $this->templatePath . 'scenario.html' - ); - - $scenarioTemplate->setVar( - array( - 'id' => ++$this->id, - 'name' => $name, - 'scenarioStatus' => $scenarioStatus, - 'steps' => $stepsBuffer, - ) - ); - - $this->scenarios .= $scenarioTemplate->render(); - } - - /** - * Handler for 'end run' event. - * - */ - protected function endRun() - { - $scenariosTemplate = new Text_Template( - $this->templatePath . 'scenarios.html' - ); - - $scenariosTemplate->setVar( - array( - 'scenarios' => $this->scenarios, - 'successfulScenarios' => $this->successful, - 'failedScenarios' => $this->failed, - 'skippedScenarios' => $this->skipped, - 'incompleteScenarios' => $this->incomplete - ) - ); - - $this->write($scenariosTemplate->render()); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/scenario.html.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/scenario.html.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/scenario.html.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/scenario.html.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ - - -

[+] {name}

- - - - - -{steps} -
- - - diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/scenario_header.html.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/scenario_header.html.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/scenario_header.html.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/scenario_header.html.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ - - -

{name}

- - - diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/scenarios.html.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/scenarios.html.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/scenarios.html.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/scenarios.html.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ - - - - - - - -{scenarios} - - - -
-

[+] Summary:

- -
- - diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/step.html.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/step.html.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/step.html.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Template/step.html.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ - - {text} - {action} -   - - diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Text.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Text.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Text.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter/Text.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * Prints stories in HTML format. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Extensions_Story_ResultPrinter_Text extends PHPUnit_Extensions_Story_ResultPrinter -{ - /** - * Handler for 'start class' event. - * - * @param string $name - */ - protected function startClass($name) - { - $this->write($this->currentTestClassPrettified . "\n"); - } - - /** - * Handler for 'on test' event. - * - * @param string $name - * @param boolean $success - * @param array $steps - */ - protected function onTest($name, $success = TRUE, array $steps = array()) - { - if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) { - $scenarioStatus = 'failed'; - } - - else if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED) { - $scenarioStatus = 'skipped'; - } - - else if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE) { - $scenarioStatus = 'incomplete'; - } - - else { - $scenarioStatus = 'successful'; - } - - $this->write( - sprintf( - " [%s] %s\n\n", - $scenarioStatus == 'successful' ? 'x' : ' ', - $name - ) - ); - - $lastStepName = ''; - $stepsBuffer = ''; - - foreach ($steps as $step) { - $currentStepName = $step->getName(); - - if ($lastStepName == $currentStepName) { - $stepText = 'and'; - } else { - $stepText = $currentStepName; - } - - $lastStepName = $currentStepName; - - $this->write( - sprintf( - " %5s %s %s\n", - $stepText, - $step->getAction(), - $step->getArguments(TRUE) - ) - ); - } - - $this->write("\n"); - } - - /** - * Handler for 'end run' event. - * - */ - protected function endRun() - { - $this->write( - sprintf( - "Scenarios: %d, Failed: %d, Skipped: %d, Incomplete: %d.\n", - - $this->successful + $this->failed + - $this->skipped + $this->incomplete, - $this->failed, - $this->skipped, - $this->incomplete - ) - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/ResultPrinter.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * Base for Story result printers. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Extensions_Story_ResultPrinter extends PHPUnit_Util_TestDox_ResultPrinter -{ - /** - * A test ended. - * - * @param PHPUnit_Framework_Test $test - * @param float $time - */ - public function endTest(PHPUnit_Framework_Test $test, $time) - { - if ($test instanceof PHPUnit_Extensions_Story_TestCase || - $test instanceof PHPUnit_Extensions_Story_SeleniumTestCase) { - if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) { - $this->successful++; - $success = TRUE; - } else { - $success = FALSE; - } - - $this->onTest( - $this->currentTestMethodPrettified, - $success, - $test->getScenario()->getSteps() - ); - } - } - - /** - */ - protected function doEndClass() - { - $this->endClass($this->testClass); - } - - /** - * Handler for 'on test' event. - * - * @param string $name - * @param boolean $success - * @param array $steps - */ - protected function onTest($name, $success = TRUE, array $steps = array()) - { - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Scenario.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Scenario.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Scenario.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Scenario.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,189 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * A scenario. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Extensions_Story_Scenario -{ - /** - * @var PHPUnit_Extensions_Story_TestCase - */ - protected $test; - - /** - * @var array - */ - protected $steps = array(); - - /** - * @var string - */ - protected $lastCalledMethod; - - /** - * Constructor. - * - * @param PHPUnit_Extensions_Story_TestCase $caller - */ - public function __construct($test) - { - if ($test instanceof PHPUnit_Extensions_Story_TestCase || - $test instanceof PHPUnit_Extensions_Story_SeleniumTestCase) { - $this->test = $test; - } else { - throw new Exception('$test must either be PHPUnit_Extensions_Story_TestCase or PHPUnit_Extensions_Story_SeleniumTestCase'); - } - } - - /** - * Adds a "Given" step to the scenario. - * - * @param array $arguments - * @return PHPUnit_Extensions_Story_TestCase - */ - public function given($arguments) - { - return $this->addStep(new PHPUnit_Extensions_Story_Given($arguments)); - } - - /** - * Adds a "When" step to the scenario. - * - * @param array $arguments - * @return PHPUnit_Extensions_Story_TestCase - */ - public function when($arguments) - { - return $this->addStep(new PHPUnit_Extensions_Story_When($arguments)); - } - - /** - * Adds a "Then" step to the scenario. - * - * @param array $arguments - * @return PHPUnit_Extensions_Story_TestCase - */ - public function then($arguments) - { - return $this->addStep(new PHPUnit_Extensions_Story_Then($arguments)); - } - - /** - * Add another step of the same type as the step that was added before. - * - * @param array $arguments - * @return PHPUnit_Extensions_Story_TestCase - */ - public function _and($arguments) - { - $lastCalledStepClass = get_class($this->steps[count($this->steps)-1]); - - return $this->addStep(new $lastCalledStepClass($arguments)); - } - - /** - * Runs this scenario. - * - * @param array $world - */ - public function run(array &$world) - { - foreach ($this->steps as $step) - { - if ($step instanceof PHPUnit_Extensions_Story_Given) { - $this->test->runGiven( - $world, $step->getAction(), $step->getArguments() - ); - } - - else if ($step instanceof PHPUnit_Extensions_Story_When) { - $this->test->runWhen( - $world, $step->getAction(), $step->getArguments() - ); - } - - else { - $this->test->runThen( - $world, $step->getAction(), $step->getArguments() - ); - } - } - } - - /** - * Adds a step to the scenario. - * - * @param PHPUnit_Extensions_Story_Step $step - * @return PHPUnit_Extensions_Story_TestCase - */ - protected function addStep(PHPUnit_Extensions_Story_Step $step) - { - $this->steps[] = $step; - - return $this->test; - } - - /** - * Returns the steps of this scenario. - * - * @return array - */ - public function getSteps() - { - return $this->steps; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Step.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Step.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Step.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Step.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * A step of a scenario. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -abstract class PHPUnit_Extensions_Story_Step -{ - /** - * @var string - */ - protected $action; - - /** - * @var array - */ - protected $arguments; - - /** - * Constructor. - * - * @param array $arguments - */ - public function __construct(array $arguments) - { - $this->action = array_shift($arguments); - $this->arguments = $arguments; - } - - /** - * Returns this step's action. - * - * @return string - */ - public function getAction() - { - return $this->action; - } - - /** - * Returns this step's arguments. - * - * @param boolean $asString - * @return array|string - */ - public function getArguments($asString = FALSE) - { - if (!$asString) { - return $this->arguments; - } else { - switch (count($this->arguments)) { - case 0: { - return ''; - } - break; - - case 1: { - return $this->arguments[0]; - } - break; - - default: { - return var_export($this->arguments, TRUE); - } - } - } - } - - /** - * Returns this step's name. - * - * @return string - */ - abstract public function getName(); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/TestCase.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/TestCase.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/TestCase.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/TestCase.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,210 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * A story test case. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -abstract class PHPUnit_Extensions_Story_TestCase extends PHPUnit_Framework_TestCase -{ - /** - * @var PHPUnit_Extensions_Story_Scenario - */ - protected $scenario; - - /** - * @var array - */ - protected $world = array(); - - /** - * Constructs a test case with the given name. - * - * @param string $name - * @param array $data - * @param string $dataName - */ - public function __construct($name = NULL, array $data = array(), $dataName = '') - { - parent::__construct($name, $data, $dataName); - $this->scenario = new PHPUnit_Extensions_Story_Scenario($this); - } - - /** - * @method PHPUnit_Extensions_Story_Step and($contextOrOutcome) - */ - public function __call($command, $arguments) - { - switch ($command) { - case 'and': { - return $this->scenario->_and($arguments); - } - break; - - default: { - throw new BadMethodCallException( - "Method $command not defined." - ); - } - } - } - - /** - * Returns this test's scenario. - * - * @return PHPUnit_Extensions_Story_Scenario - */ - public function getScenario() - { - return $this->scenario; - } - - /** - * - * - */ - protected function notImplemented($action) - { - if (strstr($action, ' ')) { - $this->markTestIncomplete("step: $action not implemented."); - } - - throw new BadMethodCallException("Method $action not defined."); - } - - /** - * Adds a "Given" step to the scenario. - * - * @param array $arguments - * @return PHPUnit_Extensions_Story_TestCase - */ - protected function given($context) - { - return $this->scenario->given(func_get_args()); - } - - /** - * Adds a "When" step to the scenario. - * - * @param array $arguments - * @return PHPUnit_Extensions_Story_TestCase - */ - protected function when($event) - { - return $this->scenario->when(func_get_args()); - } - - /** - * Adds a "Then" step to the scenario. - * - * @param array $arguments - * @return PHPUnit_Extensions_Story_TestCase - */ - protected function then($outcome) - { - return $this->scenario->then(func_get_args()); - } - - /** - * Add another step of the same type as the step that was added before. - * - * @param array $arguments - * @return PHPUnit_Extensions_Story_TestCase - */ - protected function _and($contextOrOutcome) - { - return $this->scenario->_and(func_get_args()); - } - - /** - * Run this test's scenario. - * - * @return mixed - * @throws RuntimeException - */ - protected function runTest() - { - $testResult = parent::runTest(); - $this->scenario->run($this->world); - return $testResult; - } - - /** - * Implementation for "Given" steps. - * - * @param array $world - * @param string $action - * @param array $arguments - */ - abstract protected function runGiven(&$world, $action, $arguments); - - /** - * Implementation for "When" steps. - * - * @param array $world - * @param string $action - * @param array $arguments - */ - abstract protected function runWhen(&$world, $action, $arguments); - - /** - * Implementation for "Then" steps. - * - * @param array $world - * @param string $action - * @param array $arguments - */ - abstract protected function runThen(&$world, $action, $arguments); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Then.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Then.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Then.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/Then.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * A "Then" step. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Extensions_Story_Then extends PHPUnit_Extensions_Story_Step -{ - /** - * Returns this step's name. - * - * @return string - */ - public function getName() - { - return 'Then'; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/When.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/When.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/Story/When.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/Story/When.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * A "When" step. - * - * @package PHPUnit - * @subpackage Extensions_Story - * @author Mattis Stordalen Flister - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Extensions_Story_When extends PHPUnit_Extensions_Story_Step -{ - /** - * Returns this step's name. - * - * @return string - */ - public function getName() - { - return 'When'; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/TestDecorator.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/TestDecorator.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/TestDecorator.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/TestDecorator.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,151 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * A Decorator for Tests. - * - * Use TestDecorator as the base class for defining new - * test decorators. Test decorator subclasses can be introduced - * to add behaviour before or after a test is run. - * - * @package PHPUnit - * @subpackage Extensions - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -class PHPUnit_Extensions_TestDecorator extends PHPUnit_Framework_Assert implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing -{ - /** - * The Test to be decorated. - * - * @var object - */ - protected $test = NULL; - - /** - * Constructor. - * - * @param PHPUnit_Framework_Test $test - */ - public function __construct(PHPUnit_Framework_Test $test) - { - $this->test = $test; - } - - /** - * Returns a string representation of the test. - * - * @return string - */ - public function toString() - { - return $this->test->toString(); - } - - /** - * Runs the test and collects the - * result in a TestResult. - * - * @param PHPUnit_Framework_TestResult $result - */ - public function basicRun(PHPUnit_Framework_TestResult $result) - { - $this->test->run($result); - } - - /** - * Counts the number of test cases that - * will be run by this test. - * - * @return integer - */ - public function count() - { - return count($this->test); - } - - /** - * Creates a default TestResult object. - * - * @return PHPUnit_Framework_TestResult - */ - protected function createResult() - { - return new PHPUnit_Framework_TestResult; - } - - /** - * Returns the test to be run. - * - * @return PHPUnit_Framework_Test - */ - public function getTest() - { - return $this->test; - } - - /** - * Runs the decorated test and collects the - * result in a TestResult. - * - * @param PHPUnit_Framework_TestResult $result - * @return PHPUnit_Framework_TestResult - * @throws InvalidArgumentException - */ - public function run(PHPUnit_Framework_TestResult $result = NULL) - { - if ($result === NULL) { - $result = $this->createResult(); - } - - $this->basicRun($result); - - return $result; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener/GitHub.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener/GitHub.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener/GitHub.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener/GitHub.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,204 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_TicketListener - * @author Raphael Stolt - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.5.0 - */ - -/** - * A ticket listener that interacts with the GitHub issue API. - * - * @package PHPUnit - * @subpackage Extensions_TicketListener - * @author Raphael Stolt - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.5.0 - */ -class PHPUnit_Extensions_TicketListener_GitHub extends PHPUnit_Extensions_TicketListener -{ - const STATUS_CLOSE = 'closed'; - const STATUS_REOPEN = 'reopened'; - - private $username; - private $apiToken; - private $repository; - private $apiPath = 'http://github.com/api/v2/json/issues'; - private $printTicketStateChanges; - - /** - * @param string $username The username associated with the GitHub account. - * @param string $apiToken The API token associated with the GitHub account. - * @param string $repository The repository of the system under test (SUT) on GitHub. - * @param string $printTicketChanges Boolean flag to print the ticket state - * changes in the test result. - * @throws RuntimeException - */ - public function __construct($username, $apiToken, $repository, $printTicketStateChanges = FALSE) - { - if (!extension_loaded('curl')) { - throw new RuntimeException('ext/curl is not available'); - } - - if (!extension_loaded('json')) { - throw new RuntimeException('ext/json is not available'); - } - - $this->username = $username; - $this->apiToken = $apiToken; - $this->repository = $repository; - $this->printTicketStateChanges = $printTicketStateChanges; - } - - /** - * @param integer $ticketId - * @return string - * @throws RuntimeException - */ - public function getTicketInfo($ticketId = NULL) - { - if (!is_numeric($ticketId)) { - return array('status' => 'invalid_ticket_id'); - } - - $ticket = $this->callGitHub( - $this->apiPath . '/show/' . $this->username . '/' . - $this->repository . '/' . $ticketId, - TRUE - ); - - if ($ticket['state'] === 'open') { - return array('status' => 'new'); - } - - if ($ticket['state'] === 'closed') { - return array('status' => 'closed'); - } - - if ($ticket['state'] === 'unknown_ticket') { - return array('status' => 'unknown_ticket'); - } - } - - /** - * @param string $ticketId The ticket number of the ticket under test (TUT). - * @param string $statusToBe The status of the TUT after running the associated test. - * @param string $message The additional message for the TUT. - * @param string $resolution The resolution for the TUT. - * @throws RuntimeException - */ - protected function updateTicket($ticketId, $statusToBe, $message, $resolution) - { - $acceptedResponseIssueStates = array('open', 'closed'); - - if ($statusToBe === self::STATUS_CLOSE) { - $apiEndpoint = $this->apiPath . '/close/' . - $this->username . '/' . $this->repository . '/' . - $ticketId; - } - - else if ($statusToBe === self::STATUS_REOPEN) { - $apiEndpoint = $this->apiPath . '/reopen/' . - $this->username . '/' . $this->repository . '/' . - $ticketId; - } - - if (isset($apiEndpoint)) { - $ticket = $this->callGitHub($apiEndpoint); - - if (!in_array($ticket['state'], $acceptedResponseIssueStates)) { - throw new RuntimeException( - 'Received an unaccepted issue state from the GitHub Api' - ); - } - - if ($this->printTicketStateChanges) { - printf( - "\nUpdating GitHub issue #%d, status: %s\n", - $ticketId, - $statusToBe - ); - } - } - } - - /** - * @param string $apiEndpoint API endpoint to call against the GitHub issue API. - * @param boolean $isShowMethodCall Show method of the GitHub issue API is called? - * @return array - * @throws RuntimeException - */ - private function callGitHub($apiEndpoint, $isShowMethodCall = FALSE) - { - $curlHandle = curl_init(); - - curl_setopt($curlHandle, CURLOPT_URL, $apiEndpoint); - curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, TRUE); - curl_setopt($curlHandle, CURLOPT_FAILONERROR, TRUE); - curl_setopt($curlHandle, CURLOPT_FRESH_CONNECT, TRUE); - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, TRUE); - curl_setopt($curlHandle, CURLOPT_HTTPPROXYTUNNEL, TRUE); - curl_setopt($curlHandle, CURLOPT_USERAGENT, __CLASS__); - curl_setopt( - $curlHandle, - CURLOPT_POSTFIELDS, - 'login=' . $this->username . '&token=' . $this->apiToken - ); - - $response = curl_exec($curlHandle); - - if (!$response && $isShowMethodCall) { - return array('state' => 'unknown_ticket'); - } - - if (!$response) { - throw new RuntimeException(curl_error($curlHandle)); - } - - curl_close($curlHandle); - - $issue = (array)json_decode($response); - - return (array)$issue['issue']; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener/GoogleCode.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener/GoogleCode.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener/GoogleCode.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener/GoogleCode.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,271 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_TicketListener - * @author Jan Sorgalla - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.5.0 - */ - -/** - * A ticket listener that interacts with the GoogleCode issue API. - * - * @package PHPUnit - * @subpackage Extensions_TicketListener - * @author Jan Sorgalla - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.5.0 - */ -class PHPUnit_Extensions_TicketListener_GoogleCode extends PHPUnit_Extensions_TicketListener -{ - private $email; - private $password; - private $project; - - private $statusClosed; - private $statusReopened; - - private $printTicketStateChanges; - - private $authUrl = 'https://www.google.com/accounts/ClientLogin'; - private $apiBaseUrl = 'http://code.google.com/feeds/issues/p/%s/issues'; - private $authToken; - - /** - * @param string $email The email associated with the Google account. - * @param string $password The password associated with the Google account. - * @param string $project The project name of the system under test (SUT) on Google Code. - * @param string $printTicketChanges Boolean flag to print the ticket state changes in the test result. - * @param string $statusClosed The status name of the closed state. - * @param string $statusReopened The status name of the reopened state. - * @throws RuntimeException - */ - public function __construct($email, $password, $project, $printTicketStateChanges = FALSE, $statusClosed = 'Fixed', $statusReopened = 'Started') - { - if (!extension_loaded('curl')) { - throw new RuntimeException('ext/curl is not available'); - } - - $this->email = $email; - $this->password = $password; - $this->project = $project; - $this->statusClosed = $statusClosed; - $this->statusReopened = $statusReopened; - $this->printTicketStateChanges = $printTicketStateChanges; - $this->apiBaseUrl = sprintf($this->apiBaseUrl, $project); - } - - /** - * @param integer $ticketId - * @return array - * @throws RuntimeException - */ - public function getTicketInfo($ticketId = NULL) - { - if (!is_numeric($ticketId)) { - return array('status' => 'invalid_ticket_id'); - } - - $url = $this->apiBaseUrl . '/full/' . $ticketId; - $header = array( - 'Authorization: GoogleLogin auth=' . $this->getAuthToken() - ); - - list($status, $response) = $this->callGoogleCode($url, $header); - - if ($status != 200 || !$response) { - return array('state' => 'unknown_ticket'); - } - - $ticket = new SimpleXMLElement(str_replace("xmlns=", "ns=", $response)); - $result = $ticket->xpath('//issues:state'); - $state = (string)$result[0]; - - if ($state === 'open') { - return array('status' => 'new'); - } - - if ($state === 'closed') { - return array('status' => 'closed'); - } - - return array('status' => $state); - } - - /** - * @param string $ticketId The ticket number of the ticket under test (TUT). - * @param string $statusToBe The status of the TUT after running the associated test. - * @param string $message The additional message for the TUT. - * @param string $resolution The resolution for the TUT. - * @throws RuntimeException - */ - protected function updateTicket($ticketId, $statusToBe, $message, $resolution) - { - $url = $this->apiBaseUrl . '/' . $ticketId . '/comments/full'; - - $header = array( - 'Authorization: GoogleLogin auth=' . $this->getAuthToken(), - 'Content-Type: application/atom+xml' - ); - - if ($statusToBe == 'closed') { - $ticketStatus = $this->statusClosed; - } else { - $ticketStatus = $this->statusReopened; - } - - list($author,) = explode('@', $this->email); - - $post = '' . - '' . - ' ' . htmlspecialchars($message, ENT_COMPAT, 'UTF-8') . '' . - ' ' . - ' ' . htmlspecialchars($author, ENT_COMPAT, 'UTF-8') . '' . - ' ' . - ' ' . - ' ' . htmlspecialchars($ticketStatus, ENT_COMPAT, 'UTF-8') . '' . - ' ' . - ''; - - list($status, $response) = $this->callGoogleCode($url, $header, $post); - - if ($status != 201) { - throw new RuntimeException('Updating GoogleCode issue failed with status code ' . $status); - } - - if ($this->printTicketStateChanges) { - printf( - "\nUpdating GoogleCode issue #%d, status: %s\n", - $ticketId, - $statusToBe - ); - } - } - - /** - * @return string The auth token - * @throws RuntimeException - */ - private function getAuthToken() - { - if (NULL !== $this->authToken) { - return $this->authToken; - } - - $header = array( - 'Content-Type: application/x-www-form-urlencoded', - ); - - $post = array( - 'accountType' => 'GOOGLE', - 'Email' => $this->email, - 'Passwd' => $this->password, - 'service' => 'code', - 'source' => 'PHPUnit-TicketListener_GoogleCode-' . PHPUnit_Runner_Version::id(), - ); - - list($status, $response) = $this->callGoogleCode( - $this->authUrl, - $header, - http_build_query($post, NULL, '&') - ); - - if ($status != 200) { - throw new RuntimeException('Google account authentication failed'); - } - - foreach (explode("\n", $response) as $line) { - if (strpos(trim($line), 'Auth') === 0) { - list($name, $token) = explode('=', $line); - $this->authToken = trim($token); - break; - } - } - - if (NULL === $this->authToken) { - throw new RuntimeException('Could not detect auth token in response'); - } - - return $this->authToken; - } - - /** - * @param string $url URL to call - * @param array $header Header - * @param string $post Post data - * @return array - */ - private function callGoogleCode($url, array $header = NULL, $post = NULL) - { - $curlHandle = curl_init(); - - curl_setopt($curlHandle, CURLOPT_URL, $url); - curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, TRUE); - curl_setopt($curlHandle, CURLOPT_FAILONERROR, TRUE); - curl_setopt($curlHandle, CURLOPT_FRESH_CONNECT, TRUE); - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, TRUE); - curl_setopt($curlHandle, CURLOPT_HTTPPROXYTUNNEL, TRUE); - curl_setopt($curlHandle, CURLOPT_USERAGENT, __CLASS__); - curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, FALSE); - - if (NULL !== $header) { - curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $header); - } - - if (NULL !== $post) { - curl_setopt($curlHandle, CURLOPT_POST, TRUE); - curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $post); - } - - $response = curl_exec($curlHandle); - $status = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE); - - if (!$response) { - throw new RuntimeException(curl_error($curlHandle)); - } - - curl_close($curlHandle); - - return array($status, $response); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener/Trac.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener/Trac.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener/Trac.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener/Trac.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,189 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit - * @author Graham Christensen - * @author Sean Coates - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since Class available since Release 3.5.4 - */ - -/** - * A ticket listener that interacts with Trac. - * - * - * - * - * - * - * - * - * trac_username - * trac_password - * - * - * 127.0.0.1/trac/login/xmlrpc - * - * - * - * - * - * - * @category Testing - * @package PHPUnit - * @author Graham Christensen - * @author Sean Coates - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.5.4 - */ -class PHPUnit_Extensions_TicketListener_Trac extends PHPUnit_Extensions_TicketListener -{ - protected $username; - protected $password; - protected $hostpath; - protected $scheme; - private $printTicketStateChanges; - - /** - * Constructor - * - * @param string $username Trac-XMLRPC username - * @param string $password Trac-XMLRPC password - * @param string $hostpath Trac-XMLRPC Host+Path (e.g. example.com/trac/login/xmlrpc) - * @param string $scheme Trac scheme (http or https) - * @param bool $printTicketStateChanges To display changes or not - */ - public function __construct($username, $password, $hostpath, $scheme = 'http', $printTicketStateChanges = FALSE) - { - $this->username = $username; - $this->password = $password; - $this->hostpath = $hostpath; - $this->scheme = $scheme; - $this->printTicketStateChanges = $printTicketStateChanges; - } - - /** - * Get the status of a ticket message - * - * @param integer $ticketId The ticket ID - * @return array('status' => $status) ($status = new|closed|unknown_ticket) - */ - public function getTicketInfo($ticketId = NULL) - { - if (!is_numeric($ticketId)) { - return array('status' => 'invalid_ticket_id'); - } - - try { - $info = $this->getClient()->get($ticketId); - - switch ($info[3]['status']) { - case 'closed': { - return array('status' => 'closed'); - } - break; - - case 'new': - case 'reopened': { - return array('status' => 'new'); - } - break; - - default: { - return array('status' => 'unknown_ticket'); - } - } - } - - catch (Exception $e) { - return array('status' => 'unknown_ticket'); - } - } - - /** - * Update a ticket with a new status - * - * @param string $ticketId The ticket number of the ticket under test (TUT). - * @param string $statusToBe The status of the TUT after running the associated test. - * @param string $message The additional message for the TUT. - * @param string $resolution The resolution for the TUT. - */ - protected function updateTicket($ticketId, $statusToBe, $message, $resolution) - { - $change = array('status' => $statusToBe, 'resolution' => $resolution); - - $this->getClient()->update((int)$ticketId, $message, $change); - - if ($this->printTicketStateChanges) { - printf( - "\nUpdating Trac issue #%d, status: %s\n", $ticketId, $statusToBe - ); - } - } - - /** - * Get a Trac XML_RPC2 client - * - * @return XML_RPC2_Client - */ - protected function getClient() - { - if (!PHPUnit_Util_Filesystem::fileExistsInIncludePath('XML/RPC2/Client.php')) { - throw new PHPUnit_Framework_Exception('PEAR/XML_RPC2 is not available.'); - } - - require_once 'XML/RPC2/Client.php'; - - $url = sprintf( - '%s://%s:%s@%s', - $this->scheme, - $this->username, - $this->password, - $this->hostpath - ); - - return XML_RPC2_Client::create($url, array('prefix' => 'ticket.')); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Extensions/TicketListener.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,225 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Extensions_TicketListener - * @author Sean Coates - * @author Raphael Stolt - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.4.0 - */ - -/** - * Base class for test listeners that interact with an issue tracker. - * - * @package PHPUnit - * @subpackage Extensions_TicketListener - * @author Sean Coates - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.4.0 - */ -abstract class PHPUnit_Extensions_TicketListener implements PHPUnit_Framework_TestListener -{ - /** - * @var array - */ - protected $ticketCounts = array(); - - /** - * @var boolean - */ - protected $ran = FALSE; - - /** - * An error occurred. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - } - - /** - * A failure occurred. - * - * @param PHPUnit_Framework_Test $test - * @param PHPUnit_Framework_AssertionFailedError $e - * @param float $time - */ - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) - { - } - - /** - * Incomplete test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - } - - /** - * Skipped test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - * @since Method available since Release 3.0.0 - */ - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - } - - /** - * A test suite started. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - } - - /** - * A test suite ended. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - } - - /** - * A test started. - * - * @param PHPUnit_Framework_Test $test - */ - public function startTest(PHPUnit_Framework_Test $test) - { - if (!$test instanceof PHPUnit_Framework_Warning) { - if ($this->ran) { - return; - } - - $name = $test->getName(); - $tickets = PHPUnit_Util_Test::getTickets(get_class($test), $name); - - foreach ($tickets as $ticket) { - $this->ticketCounts[$ticket][$name] = 1; - } - - $this->ran = TRUE; - } - } - - /** - * A test ended. - * - * @param PHPUnit_Framework_Test $test - * @param float $time - */ - public function endTest(PHPUnit_Framework_Test $test, $time) - { - if (!$test instanceof PHPUnit_Framework_Warning) { - if ($test->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) { - $ifStatus = array('assigned', 'new', 'reopened'); - $newStatus = 'closed'; - $message = 'Automatically closed by PHPUnit (test passed).'; - $resolution = 'fixed'; - $cumulative = TRUE; - } - - else if ($test->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) { - $ifStatus = array('closed'); - $newStatus = 'reopened'; - $message = 'Automatically reopened by PHPUnit (test failed).'; - $resolution = ''; - $cumulative = FALSE; - } - - else { - return; - } - - $name = $test->getName(); - $tickets = PHPUnit_Util_Test::getTickets(get_class($test), $name); - - foreach ($tickets as $ticket) { - // Remove this test from the totals (if it passed). - if ($test->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) { - unset($this->ticketCounts[$ticket][$name]); - } - - // Only close tickets if ALL referenced cases pass - // but reopen tickets if a single test fails. - if ($cumulative) { - // Determine number of to-pass tests: - if (count($this->ticketCounts[$ticket]) > 0) { - // There exist remaining test cases with this reference. - $adjustTicket = FALSE; - } else { - // No remaining tickets, go ahead and adjust. - $adjustTicket = TRUE; - } - } else { - $adjustTicket = TRUE; - } - - $ticketInfo = $this->getTicketInfo($ticket); - - if ($adjustTicket && in_array($ticketInfo['status'], $ifStatus)) { - $this->updateTicket($ticket, $newStatus, $message, $resolution); - } - } - } - } - - abstract protected function getTicketInfo($ticketId = NULL); - abstract protected function updateTicket($ticketId, $newStatus, $message, $resolution); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Assert/Functions.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Assert/Functions.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Assert/Functions.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Assert/Functions.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,1827 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.5.0 - */ - -/** - * Returns a matcher that matches when the method it is evaluated for - * is executed zero or more times. - * - * @return PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount - * @since Method available since Release 3.0.0 - */ -function any() -{ - return PHPUnit_Framework_TestCase::any(); -} - -/** - * Returns a PHPUnit_Framework_Constraint_IsAnything matcher object. - * - * @return PHPUnit_Framework_Constraint_IsAnything - * @since Method available since Release 3.0.0 - */ -function anything() -{ - return PHPUnit_Framework_Assert::anything(); -} - -/** - * Returns a PHPUnit_Framework_Constraint_ArrayHasKey matcher object. - * - * @param mixed $key - * @return PHPUnit_Framework_Constraint_ArrayHasKey - * @since Method available since Release 3.0.0 - */ -function arrayHasKey($key) -{ - return PHPUnit_Framework_Assert::arrayHasKey($key); -} - -/** - * Asserts that an array has a specified key. - * - * @param mixed $key - * @param array $array - * @param string $message - * @since Method available since Release 3.0.0 - */ -function assertArrayHasKey($key, array $array, $message = '') -{ - return PHPUnit_Framework_Assert::assertArrayHasKey($key, $array, $message); -} - -/** - * Asserts that an array does not have a specified key. - * - * @param mixed $key - * @param array $array - * @param string $message - * @since Method available since Release 3.0.0 - */ -function assertArrayNotHasKey($key, array $array, $message = '') -{ - return PHPUnit_Framework_Assert::assertArrayNotHasKey($key, $array, $message); -} - -/** - * Asserts that a haystack that is stored in a static attribute of a class - * or an attribute of an object contains a needle. - * - * @param mixed $needle - * @param string $haystackAttributeName - * @param mixed $haystackClassOrObject - * @param string $message - * @param boolean $ignoreCase - * @since Method available since Release 3.0.0 - */ -function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message, $ignoreCase); -} - -/** - * Asserts that a haystack that is stored in a static attribute of a class - * or an attribute of an object contains only values of a given type. - * - * @param string $type - * @param string $haystackAttributeName - * @param mixed $haystackClassOrObject - * @param boolean $isNativeType - * @param string $message - * @since Method available since Release 3.1.4 - */ -function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType, $message); -} - -/** - * Asserts that a static attribute of a class or an attribute of an object - * is empty. - * - * @param string $haystackAttributeName - * @param mixed $haystackClassOrObject - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message); -} - -/** - * Asserts that a variable is equal to an attribute of an object. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param string $actualClassOrObject - * @param string $message - * @param float $delta - * @param integer $maxDepth - * @param boolean $canonicalize - * @param boolean $ignoreCase - */ -function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); -} - -/** - * Asserts that an attribute is greater than another value. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param string $actualClassOrObject - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message); -} - -/** - * Asserts that an attribute is greater than or equal to another value. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param string $actualClassOrObject - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message); -} - -/** - * Asserts that an attribute is of a given type. - * - * @param string $expected - * @param string $attributeName - * @param mixed $classOrObject - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message); -} - -/** - * Asserts that an attribute is of a given type. - * - * @param string $expected - * @param string $attributeName - * @param mixed $classOrObject - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeInternalType($expected, $attributeName, $classOrObject, $message); -} - -/** - * Asserts that an attribute is smaller than another value. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param string $actualClassOrObject - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message); -} - -/** - * Asserts that an attribute is smaller than or equal to another value. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param string $actualClassOrObject - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message); -} - -/** - * Asserts that a haystack that is stored in a static attribute of a class - * or an attribute of an object does not contain a needle. - * - * @param mixed $needle - * @param string $haystackAttributeName - * @param mixed $haystackClassOrObject - * @param string $message - * @param boolean $ignoreCase - * @since Method available since Release 3.0.0 - */ -function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message, $ignoreCase); -} - -/** - * Asserts that a haystack that is stored in a static attribute of a class - * or an attribute of an object does not contain only values of a given - * type. - * - * @param string $type - * @param string $haystackAttributeName - * @param mixed $haystackClassOrObject - * @param boolean $isNativeType - * @param string $message - * @since Method available since Release 3.1.4 - */ -function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType, $message); -} - -/** - * Asserts that a static attribute of a class or an attribute of an object - * is not empty. - * - * @param string $haystackAttributeName - * @param mixed $haystackClassOrObject - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message); -} - -/** - * Asserts that a variable is not equal to an attribute of an object. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param string $actualClassOrObject - * @param string $message - * @param float $delta - * @param integer $maxDepth - * @param boolean $canonicalize - * @param boolean $ignoreCase - */ -function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); -} - -/** - * Asserts that an attribute is of a given type. - * - * @param string $expected - * @param string $attributeName - * @param mixed $classOrObject - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message); -} - -/** - * Asserts that an attribute is of a given type. - * - * @param string $expected - * @param string $attributeName - * @param mixed $classOrObject - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message); -} - -/** - * Asserts that a variable and an attribute of an object do not have the - * same type and value. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param object $actualClassOrObject - * @param string $message - */ -function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message); -} - -/** - * Asserts that an attribute is of a given type. - * - * @param string $expected - * @param string $attributeName - * @param mixed $classOrObject - * @param string $message - * @since Method available since Release 3.4.0 - */ -function assertAttributeNotType($expected, $attributeName, $classOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeNotType($expected, $attributeName, $classOrObject, $message); -} - -/** - * Asserts that a variable and an attribute of an object have the same type - * and value. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param object $actualClassOrObject - * @param string $message - */ -function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message); -} - -/** - * Asserts that an attribute is of a given type. - * - * @param string $expected - * @param string $attributeName - * @param mixed $classOrObject - * @param string $message - * @since Method available since Release 3.4.0 - */ -function assertAttributeType($expected, $attributeName, $classOrObject, $message = '') -{ - return PHPUnit_Framework_Assert::assertAttributeType($expected, $attributeName, $classOrObject, $message); -} - -/** - * Asserts that a class has a specified attribute. - * - * @param string $attributeName - * @param string $className - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertClassHasAttribute($attributeName, $className, $message = '') -{ - return PHPUnit_Framework_Assert::assertClassHasAttribute($attributeName, $className, $message); -} - -/** - * Asserts that a class has a specified static attribute. - * - * @param string $attributeName - * @param string $className - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertClassHasStaticAttribute($attributeName, $className, $message = '') -{ - return PHPUnit_Framework_Assert::assertClassHasStaticAttribute($attributeName, $className, $message); -} - -/** - * Asserts that a class does not have a specified attribute. - * - * @param string $attributeName - * @param string $className - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertClassNotHasAttribute($attributeName, $className, $message = '') -{ - return PHPUnit_Framework_Assert::assertClassNotHasAttribute($attributeName, $className, $message); -} - -/** - * Asserts that a class does not have a specified static attribute. - * - * @param string $attributeName - * @param string $className - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertClassNotHasStaticAttribute($attributeName, $className, $message = '') -{ - return PHPUnit_Framework_Assert::assertClassNotHasStaticAttribute($attributeName, $className, $message); -} - -/** - * Asserts that a haystack contains a needle. - * - * @param mixed $needle - * @param mixed $haystack - * @param string $message - * @param boolean $ignoreCase - * @since Method available since Release 2.1.0 - */ -function assertContains($needle, $haystack, $message = '', $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::assertContains($needle, $haystack, $message, $ignoreCase); -} - -/** - * Asserts that a haystack contains only values of a given type. - * - * @param string $type - * @param mixed $haystack - * @param boolean $isNativeType - * @param string $message - * @since Method available since Release 3.1.4 - */ -function assertContainsOnly($type, $haystack, $isNativeType = NULL, $message = '') -{ - return PHPUnit_Framework_Assert::assertContainsOnly($type, $haystack, $isNativeType, $message); -} - -/** - * Asserts that a variable is empty. - * - * @param mixed $actual - * @param string $message - * @throws PHPUnit_Framework_AssertionFailedError - */ -function assertEmpty($actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertEmpty($actual, $message); -} - -/** - * Asserts that a hierarchy of DOMNodes matches. - * - * @param DOMNode $expectedNode - * @param DOMNode $actualNode - * @param boolean $checkAttributes - * @param string $message - * @author Mattis Stordalen Flister - * @since Method available since Release 3.3.0 - */ -function assertEqualXMLStructure(DOMNode $expectedNode, DOMNode $actualNode, $checkAttributes = FALSE, $message = '') -{ - return PHPUnit_Framework_Assert::assertEqualXMLStructure($expectedNode, $actualNode, $checkAttributes, $message); -} - -/** - * Asserts that two variables are equal. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @param float $delta - * @param integer $maxDepth - * @param boolean $canonicalize - * @param boolean $ignoreCase - */ -function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); -} - -/** - * Asserts that a condition is false. - * - * @param boolean $condition - * @param string $message - * @throws PHPUnit_Framework_AssertionFailedError - */ -function assertFalse($condition, $message = '') -{ - return PHPUnit_Framework_Assert::assertFalse($condition, $message); -} - -/** - * Asserts that the contents of one file is equal to the contents of another - * file. - * - * @param string $expected - * @param string $actual - * @param string $message - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @since Method available since Release 3.2.14 - */ -function assertFileEquals($expected, $actual, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::assertFileEquals($expected, $actual, $message, $canonicalize, $ignoreCase); -} - -/** - * Asserts that a file exists. - * - * @param string $filename - * @param string $message - * @since Method available since Release 3.0.0 - */ -function assertFileExists($filename, $message = '') -{ - return PHPUnit_Framework_Assert::assertFileExists($filename, $message); -} - -/** - * Asserts that the contents of one file is not equal to the contents of - * another file. - * - * @param string $expected - * @param string $actual - * @param string $message - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @since Method available since Release 3.2.14 - */ -function assertFileNotEquals($expected, $actual, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::assertFileNotEquals($expected, $actual, $message, $canonicalize, $ignoreCase); -} - -/** - * Asserts that a file does not exist. - * - * @param string $filename - * @param string $message - * @since Method available since Release 3.0.0 - */ -function assertFileNotExists($filename, $message = '') -{ - return PHPUnit_Framework_Assert::assertFileNotExists($filename, $message); -} - -/** - * Asserts that a value is greater than another value. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertGreaterThan($expected, $actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertGreaterThan($expected, $actual, $message); -} - -/** - * Asserts that a value is greater than or equal to another value. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertGreaterThanOrEqual($expected, $actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertGreaterThanOrEqual($expected, $actual, $message); -} - -/** - * Asserts that a variable is of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertInstanceOf($expected, $actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertInstanceOf($expected, $actual, $message); -} - -/** - * Asserts that a variable is of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertInternalType($expected, $actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertInternalType($expected, $actual, $message); -} - -/** - * Asserts that a value is smaller than another value. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertLessThan($expected, $actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertLessThan($expected, $actual, $message); -} - -/** - * Asserts that a value is smaller than or equal to another value. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertLessThanOrEqual($expected, $actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertLessThanOrEqual($expected, $actual, $message); -} - -/** - * Asserts that a haystack does not contain a needle. - * - * @param mixed $needle - * @param mixed $haystack - * @param string $message - * @param boolean $ignoreCase - * @since Method available since Release 2.1.0 - */ -function assertNotContains($needle, $haystack, $message = '', $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::assertNotContains($needle, $haystack, $message, $ignoreCase); -} - -/** - * Asserts that a haystack does not contain only values of a given type. - * - * @param string $type - * @param mixed $haystack - * @param boolean $isNativeType - * @param string $message - * @since Method available since Release 3.1.4 - */ -function assertNotContainsOnly($type, $haystack, $isNativeType = NULL, $message = '') -{ - return PHPUnit_Framework_Assert::assertNotContainsOnly($type, $haystack, $isNativeType, $message); -} - -/** - * Asserts that a variable is not empty. - * - * @param mixed $actual - * @param string $message - * @throws PHPUnit_Framework_AssertionFailedError - */ -function assertNotEmpty($actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertNotEmpty($actual, $message); -} - -/** - * Asserts that two variables are not equal. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @param float $delta - * @param integer $maxDepth - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @since Method available since Release 2.3.0 - */ -function assertNotEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::assertNotEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); -} - -/** - * Asserts that a variable is not of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertNotInstanceOf($expected, $actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertNotInstanceOf($expected, $actual, $message); -} - -/** - * Asserts that a variable is not of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertNotInternalType($expected, $actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertNotInternalType($expected, $actual, $message); -} - -/** - * Asserts that a variable is not NULL. - * - * @param mixed $actual - * @param string $message - */ -function assertNotNull($actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertNotNull($actual, $message); -} - -/** - * Asserts that a string does not match a given regular expression. - * - * @param string $pattern - * @param string $string - * @param string $message - * @since Method available since Release 2.1.0 - */ -function assertNotRegExp($pattern, $string, $message = '') -{ - return PHPUnit_Framework_Assert::assertNotRegExp($pattern, $string, $message); -} - -/** - * Asserts that two variables do not have the same type and value. - * Used on objects, it asserts that two variables do not reference - * the same object. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - */ -function assertNotSame($expected, $actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertNotSame($expected, $actual, $message); -} - -/** - * This assertion is the exact opposite of assertTag(). - * - * Rather than asserting that $matcher results in a match, it asserts that - * $matcher does not match. - * - * @param array $matcher - * @param string $actual - * @param string $message - * @param boolean $isHtml - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ -function assertNotTag($matcher, $actual, $message = '', $isHtml = TRUE) -{ - return PHPUnit_Framework_Assert::assertNotTag($matcher, $actual, $message, $isHtml); -} - -/** - * Asserts that a variable is not of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 2.2.0 - */ -function assertNotType($expected, $actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertNotType($expected, $actual, $message); -} - -/** - * Asserts that a variable is NULL. - * - * @param mixed $actual - * @param string $message - */ -function assertNull($actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertNull($actual, $message); -} - -/** - * Asserts that an object has a specified attribute. - * - * @param string $attributeName - * @param object $object - * @param string $message - * @since Method available since Release 3.0.0 - */ -function assertObjectHasAttribute($attributeName, $object, $message = '') -{ - return PHPUnit_Framework_Assert::assertObjectHasAttribute($attributeName, $object, $message); -} - -/** - * Asserts that an object does not have a specified attribute. - * - * @param string $attributeName - * @param object $object - * @param string $message - * @since Method available since Release 3.0.0 - */ -function assertObjectNotHasAttribute($attributeName, $object, $message = '') -{ - return PHPUnit_Framework_Assert::assertObjectNotHasAttribute($attributeName, $object, $message); -} - -/** - * Asserts that a string matches a given regular expression. - * - * @param string $pattern - * @param string $string - * @param string $message - */ -function assertRegExp($pattern, $string, $message = '') -{ - return PHPUnit_Framework_Assert::assertRegExp($pattern, $string, $message); -} - -/** - * Asserts that two variables have the same type and value. - * Used on objects, it asserts that two variables reference - * the same object. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - */ -function assertSame($expected, $actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertSame($expected, $actual, $message); -} - -/** - * Assert the presence, absence, or count of elements in a document matching - * the CSS $selector, regardless of the contents of those elements. - * - * The first argument, $selector, is the CSS selector used to match - * the elements in the $actual document. - * - * The second argument, $count, can be either boolean or numeric. - * When boolean, it asserts for presence of elements matching the selector - * (TRUE) or absence of elements (FALSE). - * When numeric, it asserts the count of elements. - * - * assertSelectCount("#binder", true, $xml); // any? - * assertSelectCount(".binder", 3, $xml); // exactly 3? - * - * @param array $selector - * @param integer $count - * @param mixed $actual - * @param string $message - * @param boolean $isHtml - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ -function assertSelectCount($selector, $count, $actual, $message = '', $isHtml = TRUE) -{ - return PHPUnit_Framework_Assert::assertSelectCount($selector, $count, $actual, $message, $isHtml); -} - -/** - * assertSelectEquals("#binder .name", "Chuck", true, $xml); // any? - * assertSelectEquals("#binder .name", "Chuck", false, $xml); // none? - * - * @param array $selector - * @param string $content - * @param integer $count - * @param mixed $actual - * @param string $message - * @param boolean $isHtml - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ -function assertSelectEquals($selector, $content, $count, $actual, $message = '', $isHtml = TRUE) -{ - return PHPUnit_Framework_Assert::assertSelectEquals($selector, $content, $count, $actual, $message, $isHtml); -} - -/** - * assertSelectRegExp("#binder .name", "/Mike|Derek/", true, $xml); // any? - * assertSelectRegExp("#binder .name", "/Mike|Derek/", 3, $xml);// 3? - * - * @param array $selector - * @param string $pattern - * @param integer $count - * @param mixed $actual - * @param string $message - * @param boolean $isHtml - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ -function assertSelectRegExp($selector, $pattern, $count, $actual, $message = '', $isHtml = TRUE) -{ - return PHPUnit_Framework_Assert::assertSelectRegExp($selector, $pattern, $count, $actual, $message, $isHtml); -} - -/** - * Asserts that a string ends not with a given prefix. - * - * @param string $suffix - * @param string $string - * @param string $message - * @since Method available since Release 3.4.0 - */ -function assertStringEndsNotWith($suffix, $string, $message = '') -{ - return PHPUnit_Framework_Assert::assertStringEndsNotWith($suffix, $string, $message); -} - -/** - * Asserts that a string ends with a given prefix. - * - * @param string $suffix - * @param string $string - * @param string $message - * @since Method available since Release 3.4.0 - */ -function assertStringEndsWith($suffix, $string, $message = '') -{ - return PHPUnit_Framework_Assert::assertStringEndsWith($suffix, $string, $message); -} - -/** - * Asserts that the contents of a string is equal - * to the contents of a file. - * - * @param string $expectedFile - * @param string $actualString - * @param string $message - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @since Method available since Release 3.3.0 - */ -function assertStringEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::assertStringEqualsFile($expectedFile, $actualString, $message, $canonicalize, $ignoreCase); -} - -/** - * Asserts that a string matches a given format string. - * - * @param string $format - * @param string $string - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertStringMatchesFormat($format, $string, $message = '') -{ - return PHPUnit_Framework_Assert::assertStringMatchesFormat($format, $string, $message); -} - -/** - * Asserts that a string matches a given format file. - * - * @param string $formatFile - * @param string $string - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertStringMatchesFormatFile($formatFile, $string, $message = '') -{ - return PHPUnit_Framework_Assert::assertStringMatchesFormatFile($formatFile, $string, $message); -} - -/** - * Asserts that the contents of a string is not equal - * to the contents of a file. - * - * @param string $expectedFile - * @param string $actualString - * @param string $message - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @since Method available since Release 3.3.0 - */ -function assertStringNotEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::assertStringNotEqualsFile($expectedFile, $actualString, $message, $canonicalize, $ignoreCase); -} - -/** - * Asserts that a string does not match a given format string. - * - * @param string $format - * @param string $string - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertStringNotMatchesFormat($format, $string, $message = '') -{ - return PHPUnit_Framework_Assert::assertStringNotMatchesFormat($format, $string, $message); -} - -/** - * Asserts that a string does not match a given format string. - * - * @param string $formatFile - * @param string $string - * @param string $message - * @since Method available since Release 3.5.0 - */ -function assertStringNotMatchesFormatFile($formatFile, $string, $message = '') -{ - return PHPUnit_Framework_Assert::assertStringNotMatchesFormatFile($formatFile, $string, $message); -} - -/** - * Asserts that a string starts not with a given prefix. - * - * @param string $prefix - * @param string $string - * @param string $message - * @since Method available since Release 3.4.0 - */ -function assertStringStartsNotWith($prefix, $string, $message = '') -{ - return PHPUnit_Framework_Assert::assertStringStartsNotWith($prefix, $string, $message); -} - -/** - * Asserts that a string starts with a given prefix. - * - * @param string $prefix - * @param string $string - * @param string $message - * @since Method available since Release 3.4.0 - */ -function assertStringStartsWith($prefix, $string, $message = '') -{ - return PHPUnit_Framework_Assert::assertStringStartsWith($prefix, $string, $message); -} - -/** - * Evaluate an HTML or XML string and assert its structure and/or contents. - * - * The first argument ($matcher) is an associative array that specifies the - * match criteria for the assertion: - * - * - `id` : the node with the given id attribute must match the - * corresponsing value. - * - `tag` : the node type must match the corresponding value. - * - `attributes` : a hash. The node's attributres must match the - * corresponsing values in the hash. - * - `content` : The text content must match the given value. - * - `parent` : a hash. The node's parent must match the - * corresponsing hash. - * - `child`: a hash. At least one of the node's immediate children - * must meet the criteria described by the hash. - * - `ancestor` : a hash. At least one of the node's ancestors must - * meet the criteria described by the hash. - * - `descendant` : a hash. At least one of the node's descendants must - * meet the criteria described by the hash. - * - `children` : a hash, for counting children of a node. - * Accepts the keys: - *- `count`: a number which must equal the number of children - * that match - *- `less_than`: the number of matching children must be greater - * than this number - *- `greater_than` : the number of matching children must be less than - * this number - *- `only` : another hash consisting of the keys to use to match - * on the children, and only matching children will be - * counted - * - * - * // Matcher that asserts that there is an element with an id="my_id". - * $matcher = array('id' => 'my_id'); - * - * // Matcher that asserts that there is a "span" tag. - * $matcher = array('tag' => 'span'); - * - * // Matcher that asserts that there is a "span" tag with the content - * // "Hello World". - * $matcher = array('tag' => 'span', 'content' => 'Hello World'); - * - * // Matcher that asserts that there is a "span" tag with content matching - * // the regular expression pattern. - * $matcher = array('tag' => 'span', 'content' => '/Try P(HP|ython)/'); - * - * // Matcher that asserts that there is a "span" with an "list" class - * // attribute. - * $matcher = array( - * 'tag'=> 'span', - * 'attributes' => array('class' => 'list') - * ); - * - * // Matcher that asserts that there is a "span" inside of a "div". - * $matcher = array( - * 'tag'=> 'span', - * 'parent' => array('tag' => 'div') - * ); - * - * // Matcher that asserts that there is a "span" somewhere inside a - * // "table". - * $matcher = array( - * 'tag' => 'span', - * 'ancestor' => array('tag' => 'table') - * ); - * - * // Matcher that asserts that there is a "span" with at least one "em" - * // child. - * $matcher = array( - * 'tag' => 'span', - * 'child' => array('tag' => 'em') - * ); - * - * // Matcher that asserts that there is a "span" containing a (possibly - * // nested) "strong" tag. - * $matcher = array( - * 'tag'=> 'span', - * 'descendant' => array('tag' => 'strong') - * ); - * - * // Matcher that asserts that there is a "span" containing 5-10 "em" tags - * // as immediate children. - * $matcher = array( - * 'tag' => 'span', - * 'children' => array( - * 'less_than'=> 11, - * 'greater_than' => 4, - * 'only' => array('tag' => 'em') - * ) - * ); - * - * // Matcher that asserts that there is a "div", with an "ul" ancestor and - * // a "li" parent (with class="enum"), and containing a "span" descendant - * // that contains an element with id="my_test" and the text "Hello World". - * $matcher = array( - * 'tag'=> 'div', - * 'ancestor' => array('tag' => 'ul'), - * 'parent' => array( - * 'tag'=> 'li', - * 'attributes' => array('class' => 'enum') - * ), - * 'descendant' => array( - * 'tag' => 'span', - * 'child' => array( - * 'id' => 'my_test', - * 'content' => 'Hello World' - * ) - * ) - * ); - * - * // Use assertTag() to apply a $matcher to a piece of $html. - * $this->assertTag($matcher, $html); - * - * // Use assertTag() to apply a $matcher to a piece of $xml. - * $this->assertTag($matcher, $xml, '', FALSE); - * - * - * The second argument ($actual) is a string containing either HTML or - * XML text to be tested. - * - * The third argument ($message) is an optional message that will be - * used if the assertion fails. - * - * The fourth argument ($html) is an optional flag specifying whether - * to load the $actual string into a DOMDocument using the HTML or - * XML load strategy. It is TRUE by default, which assumes the HTML - * load strategy. In many cases, this will be acceptable for XML as well. - * - * @param array $matcher - * @param string $actual - * @param string $message - * @param boolean $isHtml - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ -function assertTag($matcher, $actual, $message = '', $isHtml = TRUE) -{ - return PHPUnit_Framework_Assert::assertTag($matcher, $actual, $message, $isHtml); -} - -/** - * Evaluates a PHPUnit_Framework_Constraint matcher object. - * - * @param mixed$value - * @param PHPUnit_Framework_Constraint $constraint - * @param string $message - * @since Method available since Release 3.0.0 - */ -function assertThat($value, PHPUnit_Framework_Constraint $constraint, $message = '') -{ - return PHPUnit_Framework_Assert::assertThat($value, $constraint, $message); -} - -/** - * Asserts that a condition is true. - * - * @param boolean $condition - * @param string $message - * @throws PHPUnit_Framework_AssertionFailedError - */ -function assertTrue($condition, $message = '') -{ - return PHPUnit_Framework_Assert::assertTrue($condition, $message); -} - -/** - * Asserts that a variable is of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - */ -function assertType($expected, $actual, $message = '') -{ - return PHPUnit_Framework_Assert::assertType($expected, $actual, $message); -} - -/** - * Asserts that two XML files are equal. - * - * @param string $expectedFile - * @param string $actualFile - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = '') -{ - return PHPUnit_Framework_Assert::assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message); -} - -/** - * Asserts that two XML files are not equal. - * - * @param string $expectedFile - * @param string $actualFile - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = '') -{ - return PHPUnit_Framework_Assert::assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message); -} - -/** - * Asserts that two XML documents are equal. - * - * @param string $expectedFile - * @param string $actualXml - * @param string $message - * @since Method available since Release 3.3.0 - */ -function assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = '') -{ - return PHPUnit_Framework_Assert::assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message); -} - -/** - * Asserts that two XML documents are equal. - * - * @param string $expectedXml - * @param string $actualXml - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '') -{ - return PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message); -} - -/** - * Asserts that two XML documents are not equal. - * - * @param string $expectedFile - * @param string $actualXml - * @param string $message - * @since Method available since Release 3.3.0 - */ -function assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = '') -{ - return PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message); -} - -/** - * Asserts that two XML documents are not equal. - * - * @param string $expectedXml - * @param string $actualXml - * @param string $message - * @since Method available since Release 3.1.0 - */ -function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = '') -{ - return PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message); -} - -/** - * Returns a matcher that matches when the method it is evaluated for - * is invoked at the given $index. - * - * @param integer $index - * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex - * @since Method available since Release 3.0.0 - */ -function at($index) -{ - return PHPUnit_Framework_TestCase::at($index); -} - -/** - * Returns a matcher that matches when the method it is evaluated for - * is executed at least once. - * - * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce - * @since Method available since Release 3.0.0 - */ -function atLeastOnce() -{ - return PHPUnit_Framework_TestCase::atLeastOnce(); -} - -/** - * Returns a PHPUnit_Framework_Constraint_Attribute matcher object. - * - * @param PHPUnit_Framework_Constraint $constraint - * @param string $attributeName - * @return PHPUnit_Framework_Constraint_Attribute - * @since Method available since Release 3.1.0 - */ -function attribute(PHPUnit_Framework_Constraint $constraint, $attributeName) -{ - return PHPUnit_Framework_Assert::attribute($constraint, $attributeName); -} - -/** - * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object - * that is wrapped in a PHPUnit_Framework_Constraint_Attribute matcher - * object. - * - * @param string $attributeName - * @param mixed $value - * @param float $delta - * @param integer $maxDepth - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @return PHPUnit_Framework_Constraint_Attribute - * @since Method available since Release 3.1.0 - */ -function attributeEqualTo($attributeName, $value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::attributeEqualTo($attributeName, $value, $delta, $maxDepth, $canonicalize, $ignoreCase); -} - -/** - * Returns a PHPUnit_Framework_Constraint_ClassHasAttribute matcher object. - * - * @param string $attributeName - * @return PHPUnit_Framework_Constraint_ClassHasAttribute - * @since Method available since Release 3.1.0 - */ -function classHasAttribute($attributeName) -{ - return PHPUnit_Framework_Assert::classHasAttribute($attributeName); -} - -/** - * Returns a PHPUnit_Framework_Constraint_ClassHasStaticAttribute matcher - * object. - * - * @param string $attributeName - * @return PHPUnit_Framework_Constraint_ClassHasStaticAttribute - * @since Method available since Release 3.1.0 - */ -function classHasStaticAttribute($attributeName) -{ - return PHPUnit_Framework_Assert::classHasStaticAttribute($attributeName); -} - -/** - * Returns a PHPUnit_Framework_Constraint_TraversableContains matcher - * object. - * - * @param mixed $value - * @return PHPUnit_Framework_Constraint_TraversableContains - * @since Method available since Release 3.0.0 - */ -function contains($value) -{ - return PHPUnit_Framework_Assert::contains($value); -} - -/** - * Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher - * object. - * - * @param string $type - * @return PHPUnit_Framework_Constraint_TraversableContainsOnly - * @since Method available since Release 3.1.4 - */ -function containsOnly($type) -{ - return PHPUnit_Framework_Assert::containsOnly($type); -} - -/** - * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object. - * - * @param mixed $value - * @param float $delta - * @param integer $maxDepth - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @return PHPUnit_Framework_Constraint_IsEqual - * @since Method available since Release 3.0.0 - */ -function equalTo($value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) -{ - return PHPUnit_Framework_Assert::equalTo($value, $delta, $maxDepth, $canonicalize, $ignoreCase); -} - -/** - * Returns a matcher that matches when the method it is evaluated for - * is executed exactly $count times. - * - * @param integer $count - * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount - * @since Method available since Release 3.0.0 - */ -function exactly($count) -{ - return PHPUnit_Framework_TestCase::exactly($count); -} - -/** - * Returns a PHPUnit_Framework_Constraint_FileExists matcher object. - * - * @return PHPUnit_Framework_Constraint_FileExists - * @since Method available since Release 3.0.0 - */ -function fileExists() -{ - return PHPUnit_Framework_Assert::fileExists(); -} - -/** - * Returns a PHPUnit_Framework_Constraint_GreaterThan matcher object. - * - * @param mixed $value - * @return PHPUnit_Framework_Constraint_GreaterThan - * @since Method available since Release 3.0.0 - */ -function greaterThan($value) -{ - return PHPUnit_Framework_Assert::greaterThan($value); -} - -/** - * Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps - * a PHPUnit_Framework_Constraint_IsEqual and a - * PHPUnit_Framework_Constraint_GreaterThan matcher object. - * - * @param mixed $value - * @return PHPUnit_Framework_Constraint_Or - * @since Method available since Release 3.1.0 - */ -function greaterThanOrEqual($value) -{ - return PHPUnit_Framework_Assert::greaterThanOrEqual($value); -} - -/** - * Returns a PHPUnit_Framework_Constraint_IsIdentical matcher object. - * - * @param mixed $value - * @return PHPUnit_Framework_Constraint_IsIdentical - * @since Method available since Release 3.0.0 - */ -function identicalTo($value) -{ - return PHPUnit_Framework_Assert::identicalTo($value); -} - -/** - * Returns a PHPUnit_Framework_Constraint_IsEmpty matcher object. - * - * @return PHPUnit_Framework_Constraint_IsEmpty - * @since Method available since Release 3.5.0 - */ -function isEmpty() -{ - return PHPUnit_Framework_Assert::isEmpty(); -} - -/** - * Returns a PHPUnit_Framework_Constraint_IsFalse matcher object. - * - * @return PHPUnit_Framework_Constraint_IsFalse - * @since Method available since Release 3.3.0 - */ -function isFalse() -{ - return PHPUnit_Framework_Assert::isFalse(); -} - -/** - * Returns a PHPUnit_Framework_Constraint_IsInstanceOf matcher object. - * - * @param string $className - * @return PHPUnit_Framework_Constraint_IsInstanceOf - * @since Method available since Release 3.0.0 - */ -function isInstanceOf($className) -{ - return PHPUnit_Framework_Assert::isInstanceOf($className); -} - -/** - * Returns a PHPUnit_Framework_Constraint_IsNull matcher object. - * - * @return PHPUnit_Framework_Constraint_IsNull - * @since Method available since Release 3.3.0 - */ -function isNull() -{ - return PHPUnit_Framework_Assert::isNull(); -} - -/** - * Returns a PHPUnit_Framework_Constraint_IsTrue matcher object. - * - * @return PHPUnit_Framework_Constraint_IsTrue - * @since Method available since Release 3.3.0 - */ -function isTrue() -{ - return PHPUnit_Framework_Assert::isTrue(); -} - -/** - * Returns a PHPUnit_Framework_Constraint_IsType matcher object. - * - * @param string $type - * @return PHPUnit_Framework_Constraint_IsType - * @since Method available since Release 3.0.0 - */ -function isType($type) -{ - return PHPUnit_Framework_Assert::isType($type); -} - -/** - * Returns a PHPUnit_Framework_Constraint_LessThan matcher object. - * - * @param mixed $value - * @return PHPUnit_Framework_Constraint_LessThan - * @since Method available since Release 3.0.0 - */ -function lessThan($value) -{ - return PHPUnit_Framework_Assert::lessThan($value); -} - -/** - * Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps - * a PHPUnit_Framework_Constraint_IsEqual and a - * PHPUnit_Framework_Constraint_LessThan matcher object. - * - * @param mixed $value - * @return PHPUnit_Framework_Constraint_Or - * @since Method available since Release 3.1.0 - */ -function lessThanOrEqual($value) -{ - return PHPUnit_Framework_Assert::lessThanOrEqual($value); -} - -/** - * Returns a PHPUnit_Framework_Constraint_And matcher object. - * - * @return PHPUnit_Framework_Constraint_And - * @since Method available since Release 3.0.0 - */ -function logicalAnd() -{ - return PHPUnit_Framework_Assert::logicalAnd(); -} - -/** - * Returns a PHPUnit_Framework_Constraint_Not matcher object. - * - * @param PHPUnit_Framework_Constraint $constraint - * @return PHPUnit_Framework_Constraint_Not - * @since Method available since Release 3.0.0 - */ -function logicalNot(PHPUnit_Framework_Constraint $constraint) -{ - return PHPUnit_Framework_Assert::logicalNot($constraint); -} - -/** - * Returns a PHPUnit_Framework_Constraint_Or matcher object. - * - * @return PHPUnit_Framework_Constraint_Or - * @since Method available since Release 3.0.0 - */ -function logicalOr() -{ - return PHPUnit_Framework_Assert::logicalOr(); -} - -/** - * Returns a PHPUnit_Framework_Constraint_Xor matcher object. - * - * @return PHPUnit_Framework_Constraint_Xor - * @since Method available since Release 3.0.0 - */ -function logicalXor() -{ - return PHPUnit_Framework_Assert::logicalXor(); -} - -/** - * Returns a PHPUnit_Framework_Constraint_StringMatches matcher object. - * - * @param string $string - * @return PHPUnit_Framework_Constraint_StringMatches - * @since Method available since Release 3.5.0 - */ -function matches($string) -{ - return PHPUnit_Framework_Assert::matches($string); -} - -/** - * Returns a PHPUnit_Framework_Constraint_PCREMatch matcher object. - * - * @param string $pattern - * @return PHPUnit_Framework_Constraint_PCREMatch - * @since Method available since Release 3.0.0 - */ -function matchesRegularExpression($pattern) -{ - return PHPUnit_Framework_Assert::matchesRegularExpression($pattern); -} - -/** - * Returns a matcher that matches when the method it is evaluated for - * is never executed. - * - * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount - * @since Method available since Release 3.0.0 - */ -function never() -{ - return PHPUnit_Framework_TestCase::never(); -} - -/** - * Returns a PHPUnit_Framework_Constraint_ObjectHasAttribute matcher object. - * - * @param string $attributeName - * @return PHPUnit_Framework_Constraint_ObjectHasAttribute - * @since Method available since Release 3.0.0 - */ -function objectHasAttribute($attributeName) -{ - return PHPUnit_Framework_Assert::objectHasAttribute($attributeName); -} - -/** - * - * - * @param mixed $value, ... - * @return PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls - * @since Method available since Release 3.0.0 - */ -function onConsecutiveCalls() -{ - return PHPUnit_Framework_TestCase::onConsecutiveCalls(); -} - -/** - * Returns a matcher that matches when the method it is evaluated for - * is executed exactly once. - * - * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount - * @since Method available since Release 3.0.0 - */ -function once() -{ - return PHPUnit_Framework_TestCase::once(); -} - -/** - * - * - * @param integer $argumentIndex - * @return PHPUnit_Framework_MockObject_Stub_ReturnArgument - * @since Method available since Release 3.3.0 - */ -function returnArgument($argumentIndex) -{ - return PHPUnit_Framework_TestCase::returnArgument($argumentIndex); -} - -/** - * - * - * @param mixed $callback - * @return PHPUnit_Framework_MockObject_Stub_ReturnCallback - * @since Method available since Release 3.3.0 - */ -function returnCallback($callback) -{ - return PHPUnit_Framework_TestCase::returnCallback($callback); -} - -/** - * - * - * @param mixed $value - * @return PHPUnit_Framework_MockObject_Stub_Return - * @since Method available since Release 3.0.0 - */ -function returnValue($value) -{ - return PHPUnit_Framework_TestCase::returnValue($value); -} - -/** - * Returns a PHPUnit_Framework_Constraint_StringContains matcher object. - * - * @param string $string - * @param boolean $case - * @return PHPUnit_Framework_Constraint_StringContains - * @since Method available since Release 3.0.0 - */ -function stringContains($string, $case = TRUE) -{ - return PHPUnit_Framework_Assert::stringContains($string, $case); -} - -/** - * Returns a PHPUnit_Framework_Constraint_StringEndsWith matcher object. - * - * @param mixed $suffix - * @return PHPUnit_Framework_Constraint_StringEndsWith - * @since Method available since Release 3.4.0 - */ -function stringEndsWith($suffix) -{ - return PHPUnit_Framework_Assert::stringEndsWith($suffix); -} - -/** - * Returns a PHPUnit_Framework_Constraint_StringStartsWith matcher object. - * - * @param mixed $prefix - * @return PHPUnit_Framework_Constraint_StringStartsWith - * @since Method available since Release 3.4.0 - */ -function stringStartsWith($prefix) -{ - return PHPUnit_Framework_Assert::stringStartsWith($prefix); -} - -/** - * - * - * @param Exception $exception - * @return PHPUnit_Framework_MockObject_Stub_Exception - * @since Method available since Release 3.1.0 - */ -function throwException(Exception $exception) -{ - return PHPUnit_Framework_TestCase::throwException($exception); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Assert.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Assert.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Assert.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Assert.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,2595 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * A set of assert methods. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -abstract class PHPUnit_Framework_Assert -{ - /** - * @var integer - */ - private static $count = 0; - - /** - * Asserts that an array has a specified key. - * - * @param mixed $key - * @param array $array - * @param string $message - * @since Method available since Release 3.0.0 - */ - public static function assertArrayHasKey($key, array $array, $message = '') - { - if (!(is_integer($key) || is_string($key))) { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 1, 'integer or string' - ); - } - - $constraint = new PHPUnit_Framework_Constraint_ArrayHasKey($key); - - self::assertThat($array, $constraint, $message); - } - - /** - * Asserts that an array does not have a specified key. - * - * @param mixed $key - * @param array $array - * @param string $message - * @since Method available since Release 3.0.0 - */ - public static function assertArrayNotHasKey($key, array $array, $message = '') - { - if (!(is_integer($key) || is_string($key))) { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 1, 'integer or string' - ); - } - - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_ArrayHasKey($key) - ); - - self::assertThat($array, $constraint, $message); - } - - /** - * Asserts that a haystack contains a needle. - * - * @param mixed $needle - * @param mixed $haystack - * @param string $message - * @param boolean $ignoreCase - * @since Method available since Release 2.1.0 - */ - public static function assertContains($needle, $haystack, $message = '', $ignoreCase = FALSE) - { - if (is_array($haystack) || - is_object($haystack) && $haystack instanceof Traversable) { - $constraint = new PHPUnit_Framework_Constraint_TraversableContains( - $needle - ); - } - - else if (is_string($haystack)) { - $constraint = new PHPUnit_Framework_Constraint_StringContains( - $needle, $ignoreCase - ); - } - - else { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 2, 'array, iterator or string' - ); - } - - self::assertThat($haystack, $constraint, $message); - } - - /** - * Asserts that a haystack that is stored in a static attribute of a class - * or an attribute of an object contains a needle. - * - * @param mixed $needle - * @param string $haystackAttributeName - * @param mixed $haystackClassOrObject - * @param string $message - * @param boolean $ignoreCase - * @since Method available since Release 3.0.0 - */ - public static function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = FALSE) - { - self::assertContains( - $needle, - self::readAttribute($haystackClassOrObject, $haystackAttributeName), - $message, - $ignoreCase - ); - } - - /** - * Asserts that a haystack does not contain a needle. - * - * @param mixed $needle - * @param mixed $haystack - * @param string $message - * @param boolean $ignoreCase - * @since Method available since Release 2.1.0 - */ - public static function assertNotContains($needle, $haystack, $message = '', $ignoreCase = FALSE) - { - if (is_array($haystack) || - is_object($haystack) && $haystack instanceof Traversable) { - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_TraversableContains($needle) - ); - } - - else if (is_string($haystack)) { - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_StringContains( - $needle, $ignoreCase - ) - ); - } - - else { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 2, 'array, iterator or string' - ); - } - - self::assertThat($haystack, $constraint, $message); - } - - /** - * Asserts that a haystack that is stored in a static attribute of a class - * or an attribute of an object does not contain a needle. - * - * @param mixed $needle - * @param string $haystackAttributeName - * @param mixed $haystackClassOrObject - * @param string $message - * @param boolean $ignoreCase - * @since Method available since Release 3.0.0 - */ - public static function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = FALSE) - { - self::assertNotContains( - $needle, - self::readAttribute($haystackClassOrObject, $haystackAttributeName), - $message, - $ignoreCase - ); - } - - /** - * Asserts that a haystack contains only values of a given type. - * - * @param string $type - * @param mixed $haystack - * @param boolean $isNativeType - * @param string $message - * @since Method available since Release 3.1.4 - */ - public static function assertContainsOnly($type, $haystack, $isNativeType = NULL, $message = '') - { - if (!(is_array($haystack) || - is_object($haystack) && $haystack instanceof Traversable)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 2, 'array or iterator' - ); - } - - if ($isNativeType == NULL) { - $isNativeType = PHPUnit_Util_Type::isType($type); - } - - self::assertThat( - $haystack, - new PHPUnit_Framework_Constraint_TraversableContainsOnly( - $type, $isNativeType - ), - $message - ); - } - - /** - * Asserts that a haystack that is stored in a static attribute of a class - * or an attribute of an object contains only values of a given type. - * - * @param string $type - * @param string $haystackAttributeName - * @param mixed $haystackClassOrObject - * @param boolean $isNativeType - * @param string $message - * @since Method available since Release 3.1.4 - */ - public static function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '') - { - self::assertContainsOnly( - $type, - self::readAttribute($haystackClassOrObject, $haystackAttributeName), - $isNativeType, - $message - ); - } - - /** - * Asserts that a haystack does not contain only values of a given type. - * - * @param string $type - * @param mixed $haystack - * @param boolean $isNativeType - * @param string $message - * @since Method available since Release 3.1.4 - */ - public static function assertNotContainsOnly($type, $haystack, $isNativeType = NULL, $message = '') - { - if (!(is_array($haystack) || - is_object($haystack) && $haystack instanceof Traversable)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 2, 'array or iterator' - ); - } - - if ($isNativeType == NULL) { - $isNativeType = PHPUnit_Util_Type::isType($type); - } - - self::assertThat( - $haystack, - new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_TraversableContainsOnly( - $type, $isNativeType - ) - ), - $message - ); - } - - /** - * Asserts that a haystack that is stored in a static attribute of a class - * or an attribute of an object does not contain only values of a given - * type. - * - * @param string $type - * @param string $haystackAttributeName - * @param mixed $haystackClassOrObject - * @param boolean $isNativeType - * @param string $message - * @since Method available since Release 3.1.4 - */ - public static function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '') - { - self::assertNotContainsOnly( - $type, - self::readAttribute($haystackClassOrObject, $haystackAttributeName), - $isNativeType, - $message - ); - } - - /** - * Asserts that two variables are equal. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @param float $delta - * @param integer $maxDepth - * @param boolean $canonicalize - * @param boolean $ignoreCase - */ - public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) - { - $constraint = new PHPUnit_Framework_Constraint_IsEqual( - $expected, $delta, $maxDepth, $canonicalize, $ignoreCase - ); - - self::assertThat($actual, $constraint, $message); - } - - /** - * Asserts that a variable is equal to an attribute of an object. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param string $actualClassOrObject - * @param string $message - * @param float $delta - * @param integer $maxDepth - * @param boolean $canonicalize - * @param boolean $ignoreCase - */ - public static function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) - { - self::assertEquals( - $expected, - self::readAttribute($actualClassOrObject, $actualAttributeName), - $message, - $delta, - $maxDepth, - $canonicalize, - $ignoreCase - ); - } - - /** - * Asserts that two variables are not equal. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @param float $delta - * @param integer $maxDepth - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @since Method available since Release 2.3.0 - */ - public static function assertNotEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) - { - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_IsEqual( - $expected, $delta, $maxDepth, $canonicalize, $ignoreCase - ) - ); - - self::assertThat($actual, $constraint, $message); - } - - /** - * Asserts that a variable is not equal to an attribute of an object. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param string $actualClassOrObject - * @param string $message - * @param float $delta - * @param integer $maxDepth - * @param boolean $canonicalize - * @param boolean $ignoreCase - */ - public static function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) - { - self::assertNotEquals( - $expected, - self::readAttribute($actualClassOrObject, $actualAttributeName), - $message, - $delta, - $maxDepth, - $canonicalize, - $ignoreCase - ); - } - - /** - * Asserts that a variable is empty. - * - * @param mixed $actual - * @param string $message - * @throws PHPUnit_Framework_AssertionFailedError - */ - public static function assertEmpty($actual, $message = '') - { - self::assertThat($actual, self::isEmpty(), $message); - } - - /** - * Asserts that a static attribute of a class or an attribute of an object - * is empty. - * - * @param string $haystackAttributeName - * @param mixed $haystackClassOrObject - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') - { - self::assertEmpty( - self::readAttribute($haystackClassOrObject, $haystackAttributeName), - $message - ); - } - - /** - * Asserts that a variable is not empty. - * - * @param mixed $actual - * @param string $message - * @throws PHPUnit_Framework_AssertionFailedError - */ - public static function assertNotEmpty($actual, $message = '') - { - self::assertThat($actual, self::logicalNot(self::isEmpty()), $message); - } - - /** - * Asserts that a static attribute of a class or an attribute of an object - * is not empty. - * - * @param string $haystackAttributeName - * @param mixed $haystackClassOrObject - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') - { - self::assertNotEmpty( - self::readAttribute($haystackClassOrObject, $haystackAttributeName), - $message - ); - } - - /** - * Asserts that a value is greater than another value. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertGreaterThan($expected, $actual, $message = '') - { - self::assertThat($actual, self::greaterThan($expected), $message); - } - - /** - * Asserts that an attribute is greater than another value. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param string $actualClassOrObject - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') - { - self::assertGreaterThan( - $expected, - self::readAttribute($actualClassOrObject, $actualAttributeName), - $message - ); - } - - /** - * Asserts that a value is greater than or equal to another value. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertGreaterThanOrEqual($expected, $actual, $message = '') - { - self::assertThat( - $actual, self::greaterThanOrEqual($expected), $message - ); - } - - /** - * Asserts that an attribute is greater than or equal to another value. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param string $actualClassOrObject - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') - { - self::assertGreaterThanOrEqual( - $expected, - self::readAttribute($actualClassOrObject, $actualAttributeName), - $message - ); - } - - /** - * Asserts that a value is smaller than another value. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertLessThan($expected, $actual, $message = '') - { - self::assertThat($actual, self::lessThan($expected), $message); - } - - /** - * Asserts that an attribute is smaller than another value. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param string $actualClassOrObject - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') - { - self::assertLessThan( - $expected, - self::readAttribute($actualClassOrObject, $actualAttributeName), - $message - ); - } - - /** - * Asserts that a value is smaller than or equal to another value. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertLessThanOrEqual($expected, $actual, $message = '') - { - self::assertThat($actual, self::lessThanOrEqual($expected), $message); - } - - /** - * Asserts that an attribute is smaller than or equal to another value. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param string $actualClassOrObject - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') - { - self::assertLessThanOrEqual( - $expected, - self::readAttribute($actualClassOrObject, $actualAttributeName), - $message - ); - } - - /** - * Asserts that the contents of one file is equal to the contents of another - * file. - * - * @param string $expected - * @param string $actual - * @param string $message - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @since Method available since Release 3.2.14 - */ - public static function assertFileEquals($expected, $actual, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) - { - self::assertFileExists($expected, $message); - self::assertFileExists($actual, $message); - - self::assertEquals( - file_get_contents($expected), - file_get_contents($actual), - $message, - 0, - 10, - $canonicalize, - $ignoreCase - ); - } - - /** - * Asserts that the contents of one file is not equal to the contents of - * another file. - * - * @param string $expected - * @param string $actual - * @param string $message - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @since Method available since Release 3.2.14 - */ - public static function assertFileNotEquals($expected, $actual, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) - { - self::assertFileExists($expected, $message); - self::assertFileExists($actual, $message); - - self::assertNotEquals( - file_get_contents($expected), - file_get_contents($actual), - $message, - 0, - 10, - $canonicalize, - $ignoreCase - ); - } - - /** - * Asserts that the contents of a string is equal - * to the contents of a file. - * - * @param string $expectedFile - * @param string $actualString - * @param string $message - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @since Method available since Release 3.3.0 - */ - public static function assertStringEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) - { - self::assertFileExists($expectedFile, $message); - - self::assertEquals( - file_get_contents($expectedFile), - $actualString, - $message, - 0, - 10, - $canonicalize, - $ignoreCase - ); - } - - /** - * Asserts that the contents of a string is not equal - * to the contents of a file. - * - * @param string $expectedFile - * @param string $actualString - * @param string $message - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @since Method available since Release 3.3.0 - */ - public static function assertStringNotEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) - { - self::assertFileExists($expectedFile, $message); - - self::assertNotEquals( - file_get_contents($expectedFile), - $actualString, - $message, - 0, - 10, - $canonicalize, - $ignoreCase - ); - } - - /** - * Asserts that a file exists. - * - * @param string $filename - * @param string $message - * @since Method available since Release 3.0.0 - */ - public static function assertFileExists($filename, $message = '') - { - if (!is_string($filename)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - $constraint = new PHPUnit_Framework_Constraint_FileExists; - - self::assertThat($filename, $constraint, $message); - } - - /** - * Asserts that a file does not exist. - * - * @param string $filename - * @param string $message - * @since Method available since Release 3.0.0 - */ - public static function assertFileNotExists($filename, $message = '') - { - if (!is_string($filename)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_FileExists - ); - - self::assertThat($filename, $constraint, $message); - } - - /** - * Asserts that a condition is true. - * - * @param boolean $condition - * @param string $message - * @throws PHPUnit_Framework_AssertionFailedError - */ - public static function assertTrue($condition, $message = '') - { - self::assertThat($condition, self::isTrue(), $message); - } - - /** - * Asserts that a condition is false. - * - * @param boolean $condition - * @param string $message - * @throws PHPUnit_Framework_AssertionFailedError - */ - public static function assertFalse($condition, $message = '') - { - self::assertThat($condition, self::isFalse(), $message); - } - - /** - * Asserts that a variable is not NULL. - * - * @param mixed $actual - * @param string $message - */ - public static function assertNotNull($actual, $message = '') - { - self::assertThat($actual, self::logicalNot(self::isNull()), $message); - } - - /** - * Asserts that a variable is NULL. - * - * @param mixed $actual - * @param string $message - */ - public static function assertNull($actual, $message = '') - { - self::assertThat($actual, self::isNull(), $message); - } - - /** - * Asserts that a class has a specified attribute. - * - * @param string $attributeName - * @param string $className - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertClassHasAttribute($attributeName, $className, $message = '') - { - if (!is_string($attributeName)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_string($className) || !class_exists($className, FALSE)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name'); - } - - $constraint = new PHPUnit_Framework_Constraint_ClassHasAttribute( - $attributeName - ); - - self::assertThat($className, $constraint, $message); - } - - /** - * Asserts that a class does not have a specified attribute. - * - * @param string $attributeName - * @param string $className - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertClassNotHasAttribute($attributeName, $className, $message = '') - { - if (!is_string($attributeName)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_string($className) || !class_exists($className, FALSE)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name'); - } - - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_ClassHasAttribute($attributeName) - ); - - self::assertThat($className, $constraint, $message); - } - - /** - * Asserts that a class has a specified static attribute. - * - * @param string $attributeName - * @param string $className - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertClassHasStaticAttribute($attributeName, $className, $message = '') - { - if (!is_string($attributeName)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_string($className) || !class_exists($className, FALSE)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name'); - } - - $constraint = new PHPUnit_Framework_Constraint_ClassHasStaticAttribute( - $attributeName - ); - - self::assertThat($className, $constraint, $message); - } - - /** - * Asserts that a class does not have a specified static attribute. - * - * @param string $attributeName - * @param string $className - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertClassNotHasStaticAttribute($attributeName, $className, $message = '') - { - if (!is_string($attributeName)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_string($className) || !class_exists($className, FALSE)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name'); - } - - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_ClassHasStaticAttribute( - $attributeName - ) - ); - - self::assertThat($className, $constraint, $message); - } - - /** - * Asserts that an object has a specified attribute. - * - * @param string $attributeName - * @param object $object - * @param string $message - * @since Method available since Release 3.0.0 - */ - public static function assertObjectHasAttribute($attributeName, $object, $message = '') - { - if (!is_string($attributeName)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_object($object)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'object'); - } - - $constraint = new PHPUnit_Framework_Constraint_ObjectHasAttribute( - $attributeName - ); - - self::assertThat($object, $constraint, $message); - } - - /** - * Asserts that an object does not have a specified attribute. - * - * @param string $attributeName - * @param object $object - * @param string $message - * @since Method available since Release 3.0.0 - */ - public static function assertObjectNotHasAttribute($attributeName, $object, $message = '') - { - if (!is_string($attributeName)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_object($object)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'object'); - } - - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_ObjectHasAttribute($attributeName) - ); - - self::assertThat($object, $constraint, $message); - } - - /** - * Asserts that two variables have the same type and value. - * Used on objects, it asserts that two variables reference - * the same object. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - */ - public static function assertSame($expected, $actual, $message = '') - { - if (is_bool($expected) && is_bool($actual)) { - self::assertEquals($expected, $actual, $message); - } else { - $constraint = new PHPUnit_Framework_Constraint_IsIdentical( - $expected - ); - - self::assertThat($actual, $constraint, $message); - } - } - - /** - * Asserts that a variable and an attribute of an object have the same type - * and value. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param object $actualClassOrObject - * @param string $message - */ - public static function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') - { - self::assertSame( - $expected, - self::readAttribute($actualClassOrObject, $actualAttributeName), - $message - ); - } - - /** - * Asserts that two variables do not have the same type and value. - * Used on objects, it asserts that two variables do not reference - * the same object. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - */ - public static function assertNotSame($expected, $actual, $message = '') - { - if (is_bool($expected) && is_bool($actual)) { - self::assertNotEquals($expected, $actual, $message); - } else { - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_IsIdentical($expected) - ); - - self::assertThat($actual, $constraint, $message); - } - } - - /** - * Asserts that a variable and an attribute of an object do not have the - * same type and value. - * - * @param mixed $expected - * @param string $actualAttributeName - * @param object $actualClassOrObject - * @param string $message - */ - public static function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') - { - self::assertNotSame( - $expected, - self::readAttribute($actualClassOrObject, $actualAttributeName), - $message - ); - } - - /** - * Asserts that a variable is of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertInstanceOf($expected, $actual, $message = '') - { - if (is_string($expected)) { - if (class_exists($expected) || interface_exists($expected)) { - $constraint = new PHPUnit_Framework_Constraint_IsInstanceOf( - $expected - ); - } - - else { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 1, 'class or interface name' - ); - } - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - self::assertThat($actual, $constraint, $message); - } - - /** - * Asserts that an attribute is of a given type. - * - * @param string $expected - * @param string $attributeName - * @param mixed $classOrObject - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '') - { - self::assertInstanceOf( - $expected, - self::readAttribute($classOrObject, $attributeName), - $message - ); - } - - /** - * Asserts that a variable is not of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertNotInstanceOf($expected, $actual, $message = '') - { - if (is_string($expected)) { - if (class_exists($expected) || interface_exists($expected)) { - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_IsInstanceOf($expected) - ); - } - - else { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 1, 'class or interface name' - ); - } - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - self::assertThat($actual, $constraint, $message); - } - - /** - * Asserts that an attribute is of a given type. - * - * @param string $expected - * @param string $attributeName - * @param mixed $classOrObject - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '') - { - self::assertNotInstanceOf( - $expected, - self::readAttribute($classOrObject, $attributeName), - $message - ); - } - - /** - * Asserts that a variable is of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertInternalType($expected, $actual, $message = '') - { - if (is_string($expected)) { - $constraint = new PHPUnit_Framework_Constraint_IsType( - $expected - ); - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - self::assertThat($actual, $constraint, $message); - } - - /** - * Asserts that an attribute is of a given type. - * - * @param string $expected - * @param string $attributeName - * @param mixed $classOrObject - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '') - { - self::assertInternalType( - $expected, - self::readAttribute($classOrObject, $attributeName), - $message - ); - } - - /** - * Asserts that a variable is not of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertNotInternalType($expected, $actual, $message = '') - { - if (is_string($expected)) { - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_IsType($expected) - ); - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - self::assertThat($actual, $constraint, $message); - } - - /** - * Asserts that an attribute is of a given type. - * - * @param string $expected - * @param string $attributeName - * @param mixed $classOrObject - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '') - { - self::assertNotInternalType( - $expected, - self::readAttribute($classOrObject, $attributeName), - $message - ); - } - - /** - * Asserts that a variable is of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - */ - public static function assertType($expected, $actual, $message = '') - { - if (is_string($expected)) { - if (PHPUnit_Util_Type::isType($expected)) { - if (class_exists($expected) || interface_exists($expected)) { - throw new InvalidArgumentException( - sprintf('"%s" is ambigious', $expected) - ); - } - - $constraint = new PHPUnit_Framework_Constraint_IsType( - $expected - ); - } - - else if (class_exists($expected) || interface_exists($expected)) { - $constraint = new PHPUnit_Framework_Constraint_IsInstanceOf( - $expected - ); - } - - else { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 1, 'class or interface name' - ); - } - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - self::assertThat($actual, $constraint, $message); - } - - /** - * Asserts that an attribute is of a given type. - * - * @param string $expected - * @param string $attributeName - * @param mixed $classOrObject - * @param string $message - * @since Method available since Release 3.4.0 - */ - public static function assertAttributeType($expected, $attributeName, $classOrObject, $message = '') - { - self::assertType( - $expected, - self::readAttribute($classOrObject, $attributeName), - $message - ); - } - - /** - * Asserts that a variable is not of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - * @since Method available since Release 2.2.0 - */ - public static function assertNotType($expected, $actual, $message = '') - { - if (is_string($expected)) { - if (PHPUnit_Util_Type::isType($expected)) { - if (class_exists($expected) || interface_exists($expected)) { - throw new InvalidArgumentException( - sprintf('"%s" is ambigious', $expected) - ); - } - - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_IsType($expected) - ); - } - - else if (class_exists($expected) || interface_exists($expected)) { - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_IsInstanceOf($expected) - ); - } - - else { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 1, 'class or interface name' - ); - } - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - self::assertThat($actual, $constraint, $message); - } - - /** - * Asserts that an attribute is of a given type. - * - * @param string $expected - * @param string $attributeName - * @param mixed $classOrObject - * @param string $message - * @since Method available since Release 3.4.0 - */ - public static function assertAttributeNotType($expected, $attributeName, $classOrObject, $message = '') - { - self::assertNotType( - $expected, - self::readAttribute($classOrObject, $attributeName), - $message - ); - } - - /** - * Asserts that a string matches a given regular expression. - * - * @param string $pattern - * @param string $string - * @param string $message - */ - public static function assertRegExp($pattern, $string, $message = '') - { - if (!is_string($pattern)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_string($string)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } - - $constraint = new PHPUnit_Framework_Constraint_PCREMatch($pattern); - - self::assertThat($string, $constraint, $message); - } - - /** - * Asserts that a string does not match a given regular expression. - * - * @param string $pattern - * @param string $string - * @param string $message - * @since Method available since Release 2.1.0 - */ - public static function assertNotRegExp($pattern, $string, $message = '') - { - if (!is_string($pattern)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_string($string)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } - - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_PCREMatch($pattern) - ); - - self::assertThat($string, $constraint, $message); - } - - /** - * Asserts that a string matches a given format string. - * - * @param string $format - * @param string $string - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertStringMatchesFormat($format, $string, $message = '') - { - if (!is_string($format)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_string($string)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } - - $constraint = new PHPUnit_Framework_Constraint_StringMatches($format); - - self::assertThat($string, $constraint, $message); - } - - /** - * Asserts that a string does not match a given format string. - * - * @param string $format - * @param string $string - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertStringNotMatchesFormat($format, $string, $message = '') - { - if (!is_string($format)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_string($string)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } - - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_StringMatches($format) - ); - - self::assertThat($string, $constraint, $message); - } - - /** - * Asserts that a string matches a given format file. - * - * @param string $formatFile - * @param string $string - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertStringMatchesFormatFile($formatFile, $string, $message = '') - { - self::assertFileExists($formatFile, $message); - - if (!is_string($string)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } - - $constraint = new PHPUnit_Framework_Constraint_StringMatches( - file_get_contents($formatFile) - ); - - self::assertThat($string, $constraint, $message); - } - - /** - * Asserts that a string does not match a given format string. - * - * @param string $formatFile - * @param string $string - * @param string $message - * @since Method available since Release 3.5.0 - */ - public static function assertStringNotMatchesFormatFile($formatFile, $string, $message = '') - { - self::assertFileExists($formatFile, $message); - - if (!is_string($string)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } - - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_StringMatches( - file_get_contents($formatFile) - ) - ); - - self::assertThat($string, $constraint, $message); - } - - /** - * Asserts that a string starts with a given prefix. - * - * @param string $prefix - * @param string $string - * @param string $message - * @since Method available since Release 3.4.0 - */ - public static function assertStringStartsWith($prefix, $string, $message = '') - { - if (!is_string($prefix)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_string($string)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } - - $constraint = new PHPUnit_Framework_Constraint_StringStartsWith( - $prefix - ); - - self::assertThat($string, $constraint, $message); - } - - /** - * Asserts that a string starts not with a given prefix. - * - * @param string $prefix - * @param string $string - * @param string $message - * @since Method available since Release 3.4.0 - */ - public static function assertStringStartsNotWith($prefix, $string, $message = '') - { - if (!is_string($prefix)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_string($string)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } - - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_StringStartsWith($prefix) - ); - - self::assertThat($string, $constraint, $message); - } - - /** - * Asserts that a string ends with a given prefix. - * - * @param string $suffix - * @param string $string - * @param string $message - * @since Method available since Release 3.4.0 - */ - public static function assertStringEndsWith($suffix, $string, $message = '') - { - if (!is_string($suffix)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_string($string)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } - - $constraint = new PHPUnit_Framework_Constraint_StringEndsWith($suffix); - - self::assertThat($string, $constraint, $message); - } - - /** - * Asserts that a string ends not with a given prefix. - * - * @param string $suffix - * @param string $string - * @param string $message - * @since Method available since Release 3.4.0 - */ - public static function assertStringEndsNotWith($suffix, $string, $message = '') - { - if (!is_string($suffix)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!is_string($string)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } - - $constraint = new PHPUnit_Framework_Constraint_Not( - new PHPUnit_Framework_Constraint_StringEndsWith($suffix) - ); - - self::assertThat($string, $constraint, $message); - } - - /** - * Asserts that two XML files are equal. - * - * @param string $expectedFile - * @param string $actualFile - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = '') - { - self::assertFileExists($expectedFile); - self::assertFileExists($actualFile); - - $expected = new DOMDocument; - $expected->preserveWhiteSpace = FALSE; - $expected->load($expectedFile); - - $actual = new DOMDocument; - $actual->preserveWhiteSpace = FALSE; - $actual->load($actualFile); - - self::assertEquals($expected, $actual, $message); - } - - /** - * Asserts that two XML files are not equal. - * - * @param string $expectedFile - * @param string $actualFile - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = '') - { - self::assertFileExists($expectedFile); - self::assertFileExists($actualFile); - - $expected = new DOMDocument; - $expected->preserveWhiteSpace = FALSE; - $expected->load($expectedFile); - - $actual = new DOMDocument; - $actual->preserveWhiteSpace = FALSE; - $actual->load($actualFile); - - self::assertNotEquals($expected, $actual, $message); - } - - /** - * Asserts that two XML documents are equal. - * - * @param string $expectedFile - * @param string $actualXml - * @param string $message - * @since Method available since Release 3.3.0 - */ - public static function assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = '') - { - self::assertFileExists($expectedFile); - - $expected = new DOMDocument; - $expected->preserveWhiteSpace = FALSE; - $expected->load($expectedFile); - - $actual = new DOMDocument; - $actual->preserveWhiteSpace = FALSE; - $actual->loadXML($actualXml); - - self::assertEquals($expected, $actual, $message); - } - - /** - * Asserts that two XML documents are not equal. - * - * @param string $expectedFile - * @param string $actualXml - * @param string $message - * @since Method available since Release 3.3.0 - */ - public static function assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = '') - { - self::assertFileExists($expectedFile); - - $expected = new DOMDocument; - $expected->preserveWhiteSpace = FALSE; - $expected->load($expectedFile); - - $actual = new DOMDocument; - $actual->preserveWhiteSpace = FALSE; - $actual->loadXML($actualXml); - - self::assertNotEquals($expected, $actual, $message); - } - - /** - * Asserts that two XML documents are equal. - * - * @param string $expectedXml - * @param string $actualXml - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '') - { - $expected = new DOMDocument; - $expected->preserveWhiteSpace = FALSE; - $expected->loadXML($expectedXml); - - $actual = new DOMDocument; - $actual->preserveWhiteSpace = FALSE; - $actual->loadXML($actualXml); - - self::assertEquals($expected, $actual, $message); - } - - /** - * Asserts that two XML documents are not equal. - * - * @param string $expectedXml - * @param string $actualXml - * @param string $message - * @since Method available since Release 3.1.0 - */ - public static function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = '') - { - $expected = new DOMDocument; - $expected->preserveWhiteSpace = FALSE; - $expected->loadXML($expectedXml); - - $actual = new DOMDocument; - $actual->preserveWhiteSpace = FALSE; - $actual->loadXML($actualXml); - - self::assertNotEquals($expected, $actual, $message); - } - - /** - * Asserts that a hierarchy of DOMNodes matches. - * - * @param DOMNode $expectedNode - * @param DOMNode $actualNode - * @param boolean $checkAttributes - * @param string $message - * @author Mattis Stordalen Flister - * @since Method available since Release 3.3.0 - */ - public static function assertEqualXMLStructure(DOMNode $expectedNode, DOMNode $actualNode, $checkAttributes = FALSE, $message = '') - { - self::assertEquals( - $expectedNode->tagName, - $actualNode->tagName, - $message - ); - - if ($checkAttributes) { - self::assertEquals( - $expectedNode->attributes->length, - $actualNode->attributes->length, - sprintf( - '%s%sNumber of attributes on node "%s" does not match', - $message, - !empty($message) ? "\n" : '', - $expectedNode->tagName - ) - ); - - for ($i = 0 ; $i < $expectedNode->attributes->length; $i++) { - $expectedAttribute = $expectedNode->attributes->item($i); - $actualAttribute = $actualNode->attributes->getNamedItem( - $expectedAttribute->name - ); - - if (!$actualAttribute) { - self::fail( - sprintf( - '%s%sCould not find attribute "%s" on node "%s"', - $message, - !empty($message) ? "\n" : '', - $expectedAttribute->name, - $expectedNode->tagName - ) - ); - } - } - } - - PHPUnit_Util_XML::removeCharacterDataNodes($expectedNode); - PHPUnit_Util_XML::removeCharacterDataNodes($actualNode); - - self::assertEquals( - $expectedNode->childNodes->length, - $actualNode->childNodes->length, - sprintf( - '%s%sNumber of child nodes of "%s" differs', - $message, - !empty($message) ? "\n" : '', - $expectedNode->tagName - ) - ); - - for ($i = 0; $i < $expectedNode->childNodes->length; $i++) { - self::assertEqualXMLStructure( - $expectedNode->childNodes->item($i), - $actualNode->childNodes->item($i), - $checkAttributes, - $message - ); - } - } - - /** - * Assert the presence, absence, or count of elements in a document matching - * the CSS $selector, regardless of the contents of those elements. - * - * The first argument, $selector, is the CSS selector used to match - * the elements in the $actual document. - * - * The second argument, $count, can be either boolean or numeric. - * When boolean, it asserts for presence of elements matching the selector - * (TRUE) or absence of elements (FALSE). - * When numeric, it asserts the count of elements. - * - * assertSelectCount("#binder", true, $xml); // any? - * assertSelectCount(".binder", 3, $xml); // exactly 3? - * - * @param array $selector - * @param integer $count - * @param mixed $actual - * @param string $message - * @param boolean $isHtml - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ - public static function assertSelectCount($selector, $count, $actual, $message = '', $isHtml = TRUE) - { - self::assertSelectEquals( - $selector, TRUE, $count, $actual, $message, $isHtml - ); - } - - /** - * assertSelectRegExp("#binder .name", "/Mike|Derek/", true, $xml); // any? - * assertSelectRegExp("#binder .name", "/Mike|Derek/", 3, $xml); // 3? - * - * @param array $selector - * @param string $pattern - * @param integer $count - * @param mixed $actual - * @param string $message - * @param boolean $isHtml - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ - public static function assertSelectRegExp($selector, $pattern, $count, $actual, $message = '', $isHtml = TRUE) - { - self::assertSelectEquals( - $selector, "regexp:$pattern", $count, $actual, $message, $isHtml - ); - } - - /** - * assertSelectEquals("#binder .name", "Chuck", true, $xml); // any? - * assertSelectEquals("#binder .name", "Chuck", false, $xml); // none? - * - * @param array $selector - * @param string $content - * @param integer $count - * @param mixed $actual - * @param string $message - * @param boolean $isHtml - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ - public static function assertSelectEquals($selector, $content, $count, $actual, $message = '', $isHtml = TRUE) - { - $tags = PHPUnit_Util_XML::cssSelect( - $selector, $content, $actual, $isHtml - ); - - // assert specific number of elements - if (is_numeric($count)) { - $counted = $tags ? count($tags) : 0; - self::assertEquals($count, $counted, $message); - } - - // assert any elements exist if true, assert no elements exist if false - else if (is_bool($count)) { - $any = count($tags) > 0 && $tags[0] instanceof DOMNode; - - if ($count) { - self::assertTrue($any, $message); - } else { - self::assertFalse($any, $message); - } - } - - // check for range number of elements - else if (is_array($count) && - (isset($count['>']) || isset($count['<']) || - isset($count['>=']) || isset($count['<=']))) { - $counted = $tags ? count($tags) : 0; - - if (isset($count['>'])) { - self::assertTrue($counted > $count['>'], $message); - } - - if (isset($count['>='])) { - self::assertTrue($counted >= $count['>='], $message); - } - - if (isset($count['<'])) { - self::assertTrue($counted < $count['<'], $message); - } - - if (isset($count['<='])) { - self::assertTrue($counted <= $count['<='], $message); - } - } else { - throw new InvalidArgumentException(); - } - } - - /** - * Evaluate an HTML or XML string and assert its structure and/or contents. - * - * The first argument ($matcher) is an associative array that specifies the - * match criteria for the assertion: - * - * - `id` : the node with the given id attribute must match the - * corresponsing value. - * - `tag` : the node type must match the corresponding value. - * - `attributes` : a hash. The node's attributres must match the - * corresponsing values in the hash. - * - `content` : The text content must match the given value. - * - `parent` : a hash. The node's parent must match the - * corresponsing hash. - * - `child` : a hash. At least one of the node's immediate children - * must meet the criteria described by the hash. - * - `ancestor` : a hash. At least one of the node's ancestors must - * meet the criteria described by the hash. - * - `descendant` : a hash. At least one of the node's descendants must - * meet the criteria described by the hash. - * - `children` : a hash, for counting children of a node. - * Accepts the keys: - * - `count` : a number which must equal the number of children - * that match - * - `less_than` : the number of matching children must be greater - * than this number - * - `greater_than` : the number of matching children must be less than - * this number - * - `only` : another hash consisting of the keys to use to match - * on the children, and only matching children will be - * counted - * - * - * // Matcher that asserts that there is an element with an id="my_id". - * $matcher = array('id' => 'my_id'); - * - * // Matcher that asserts that there is a "span" tag. - * $matcher = array('tag' => 'span'); - * - * // Matcher that asserts that there is a "span" tag with the content - * // "Hello World". - * $matcher = array('tag' => 'span', 'content' => 'Hello World'); - * - * // Matcher that asserts that there is a "span" tag with content matching - * // the regular expression pattern. - * $matcher = array('tag' => 'span', 'content' => '/Try P(HP|ython)/'); - * - * // Matcher that asserts that there is a "span" with an "list" class - * // attribute. - * $matcher = array( - * 'tag' => 'span', - * 'attributes' => array('class' => 'list') - * ); - * - * // Matcher that asserts that there is a "span" inside of a "div". - * $matcher = array( - * 'tag' => 'span', - * 'parent' => array('tag' => 'div') - * ); - * - * // Matcher that asserts that there is a "span" somewhere inside a - * // "table". - * $matcher = array( - * 'tag' => 'span', - * 'ancestor' => array('tag' => 'table') - * ); - * - * // Matcher that asserts that there is a "span" with at least one "em" - * // child. - * $matcher = array( - * 'tag' => 'span', - * 'child' => array('tag' => 'em') - * ); - * - * // Matcher that asserts that there is a "span" containing a (possibly - * // nested) "strong" tag. - * $matcher = array( - * 'tag' => 'span', - * 'descendant' => array('tag' => 'strong') - * ); - * - * // Matcher that asserts that there is a "span" containing 5-10 "em" tags - * // as immediate children. - * $matcher = array( - * 'tag' => 'span', - * 'children' => array( - * 'less_than' => 11, - * 'greater_than' => 4, - * 'only' => array('tag' => 'em') - * ) - * ); - * - * // Matcher that asserts that there is a "div", with an "ul" ancestor and - * // a "li" parent (with class="enum"), and containing a "span" descendant - * // that contains an element with id="my_test" and the text "Hello World". - * $matcher = array( - * 'tag' => 'div', - * 'ancestor' => array('tag' => 'ul'), - * 'parent' => array( - * 'tag' => 'li', - * 'attributes' => array('class' => 'enum') - * ), - * 'descendant' => array( - * 'tag' => 'span', - * 'child' => array( - * 'id' => 'my_test', - * 'content' => 'Hello World' - * ) - * ) - * ); - * - * // Use assertTag() to apply a $matcher to a piece of $html. - * $this->assertTag($matcher, $html); - * - * // Use assertTag() to apply a $matcher to a piece of $xml. - * $this->assertTag($matcher, $xml, '', FALSE); - * - * - * The second argument ($actual) is a string containing either HTML or - * XML text to be tested. - * - * The third argument ($message) is an optional message that will be - * used if the assertion fails. - * - * The fourth argument ($html) is an optional flag specifying whether - * to load the $actual string into a DOMDocument using the HTML or - * XML load strategy. It is TRUE by default, which assumes the HTML - * load strategy. In many cases, this will be acceptable for XML as well. - * - * @param array $matcher - * @param string $actual - * @param string $message - * @param boolean $isHtml - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ - public static function assertTag($matcher, $actual, $message = '', $isHtml = TRUE) - { - $dom = PHPUnit_Util_XML::load($actual, $isHtml); - $tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $isHtml); - $matched = count($tags) > 0 && $tags[0] instanceof DOMNode; - - self::assertTrue($matched, $message); - } - - /** - * This assertion is the exact opposite of assertTag(). - * - * Rather than asserting that $matcher results in a match, it asserts that - * $matcher does not match. - * - * @param array $matcher - * @param string $actual - * @param string $message - * @param boolean $isHtml - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ - public static function assertNotTag($matcher, $actual, $message = '', $isHtml = TRUE) - { - $dom = PHPUnit_Util_XML::load($actual, $isHtml); - $tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $isHtml); - $matched = count($tags) > 0 && $tags[0] instanceof DOMNode; - - self::assertFalse($matched, $message); - } - - /** - * Evaluates a PHPUnit_Framework_Constraint matcher object. - * - * @param mixed $value - * @param PHPUnit_Framework_Constraint $constraint - * @param string $message - * @since Method available since Release 3.0.0 - */ - public static function assertThat($value, PHPUnit_Framework_Constraint $constraint, $message = '') - { - self::$count += count($constraint); - - if (!$constraint->evaluate($value)) { - $constraint->fail($value, $message); - } - } - - /** - * Returns a PHPUnit_Framework_Constraint_And matcher object. - * - * @return PHPUnit_Framework_Constraint_And - * @since Method available since Release 3.0.0 - */ - public static function logicalAnd() - { - $constraints = func_get_args(); - - $constraint = new PHPUnit_Framework_Constraint_And; - $constraint->setConstraints($constraints); - - return $constraint; - } - - /** - * Returns a PHPUnit_Framework_Constraint_Or matcher object. - * - * @return PHPUnit_Framework_Constraint_Or - * @since Method available since Release 3.0.0 - */ - public static function logicalOr() - { - $constraints = func_get_args(); - - $constraint = new PHPUnit_Framework_Constraint_Or; - $constraint->setConstraints($constraints); - - return $constraint; - } - - /** - * Returns a PHPUnit_Framework_Constraint_Not matcher object. - * - * @param PHPUnit_Framework_Constraint $constraint - * @return PHPUnit_Framework_Constraint_Not - * @since Method available since Release 3.0.0 - */ - public static function logicalNot(PHPUnit_Framework_Constraint $constraint) - { - return new PHPUnit_Framework_Constraint_Not($constraint); - } - - /** - * Returns a PHPUnit_Framework_Constraint_Xor matcher object. - * - * @return PHPUnit_Framework_Constraint_Xor - * @since Method available since Release 3.0.0 - */ - public static function logicalXor() - { - $constraints = func_get_args(); - - $constraint = new PHPUnit_Framework_Constraint_Xor; - $constraint->setConstraints($constraints); - - return $constraint; - } - - /** - * Returns a PHPUnit_Framework_Constraint_IsAnything matcher object. - * - * @return PHPUnit_Framework_Constraint_IsAnything - * @since Method available since Release 3.0.0 - */ - public static function anything() - { - return new PHPUnit_Framework_Constraint_IsAnything; - } - - /** - * Returns a PHPUnit_Framework_Constraint_IsTrue matcher object. - * - * @return PHPUnit_Framework_Constraint_IsTrue - * @since Method available since Release 3.3.0 - */ - public static function isTrue() - { - return new PHPUnit_Framework_Constraint_IsTrue; - } - - /** - * Returns a PHPUnit_Framework_Constraint_IsFalse matcher object. - * - * @return PHPUnit_Framework_Constraint_IsFalse - * @since Method available since Release 3.3.0 - */ - public static function isFalse() - { - return new PHPUnit_Framework_Constraint_IsFalse; - } - - /** - * Returns a PHPUnit_Framework_Constraint_IsNull matcher object. - * - * @return PHPUnit_Framework_Constraint_IsNull - * @since Method available since Release 3.3.0 - */ - public static function isNull() - { - return new PHPUnit_Framework_Constraint_IsNull; - } - - /** - * Returns a PHPUnit_Framework_Constraint_Attribute matcher object. - * - * @param PHPUnit_Framework_Constraint $constraint - * @param string $attributeName - * @return PHPUnit_Framework_Constraint_Attribute - * @since Method available since Release 3.1.0 - */ - public static function attribute(PHPUnit_Framework_Constraint $constraint, $attributeName) - { - return new PHPUnit_Framework_Constraint_Attribute( - $constraint, $attributeName - ); - } - - /** - * Returns a PHPUnit_Framework_Constraint_TraversableContains matcher - * object. - * - * @param mixed $value - * @return PHPUnit_Framework_Constraint_TraversableContains - * @since Method available since Release 3.0.0 - */ - public static function contains($value) - { - return new PHPUnit_Framework_Constraint_TraversableContains($value); - } - - /** - * Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher - * object. - * - * @param string $type - * @return PHPUnit_Framework_Constraint_TraversableContainsOnly - * @since Method available since Release 3.1.4 - */ - public static function containsOnly($type) - { - return new PHPUnit_Framework_Constraint_TraversableContainsOnly($type); - } - - /** - * Returns a PHPUnit_Framework_Constraint_ArrayHasKey matcher object. - * - * @param mixed $key - * @return PHPUnit_Framework_Constraint_ArrayHasKey - * @since Method available since Release 3.0.0 - */ - public static function arrayHasKey($key) - { - return new PHPUnit_Framework_Constraint_ArrayHasKey($key); - } - - /** - * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object. - * - * @param mixed $value - * @param float $delta - * @param integer $maxDepth - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @return PHPUnit_Framework_Constraint_IsEqual - * @since Method available since Release 3.0.0 - */ - public static function equalTo($value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) - { - return new PHPUnit_Framework_Constraint_IsEqual( - $value, $delta, $maxDepth, $canonicalize, $ignoreCase - ); - } - - /** - * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object - * that is wrapped in a PHPUnit_Framework_Constraint_Attribute matcher - * object. - * - * @param string $attributeName - * @param mixed $value - * @param float $delta - * @param integer $maxDepth - * @param boolean $canonicalize - * @param boolean $ignoreCase - * @return PHPUnit_Framework_Constraint_Attribute - * @since Method available since Release 3.1.0 - */ - public static function attributeEqualTo($attributeName, $value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) - { - return self::attribute( - self::equalTo( - $value, $delta, $maxDepth, $canonicalize, $ignoreCase - ), - $attributeName - ); - } - - /** - * Returns a PHPUnit_Framework_Constraint_IsEmpty matcher object. - * - * @return PHPUnit_Framework_Constraint_IsEmpty - * @since Method available since Release 3.5.0 - */ - public static function isEmpty() - { - return new PHPUnit_Framework_Constraint_IsEmpty; - } - /** - * Returns a PHPUnit_Framework_Constraint_FileExists matcher object. - * - * @return PHPUnit_Framework_Constraint_FileExists - * @since Method available since Release 3.0.0 - */ - public static function fileExists() - { - return new PHPUnit_Framework_Constraint_FileExists; - } - - /** - * Returns a PHPUnit_Framework_Constraint_GreaterThan matcher object. - * - * @param mixed $value - * @return PHPUnit_Framework_Constraint_GreaterThan - * @since Method available since Release 3.0.0 - */ - public static function greaterThan($value) - { - return new PHPUnit_Framework_Constraint_GreaterThan($value); - } - - /** - * Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps - * a PHPUnit_Framework_Constraint_IsEqual and a - * PHPUnit_Framework_Constraint_GreaterThan matcher object. - * - * @param mixed $value - * @return PHPUnit_Framework_Constraint_Or - * @since Method available since Release 3.1.0 - */ - public static function greaterThanOrEqual($value) - { - return self::logicalOr( - new PHPUnit_Framework_Constraint_IsEqual($value), - new PHPUnit_Framework_Constraint_GreaterThan($value) - ); - } - - /** - * Returns a PHPUnit_Framework_Constraint_ClassHasAttribute matcher object. - * - * @param string $attributeName - * @return PHPUnit_Framework_Constraint_ClassHasAttribute - * @since Method available since Release 3.1.0 - */ - public static function classHasAttribute($attributeName) - { - return new PHPUnit_Framework_Constraint_ClassHasAttribute( - $attributeName - ); - } - - /** - * Returns a PHPUnit_Framework_Constraint_ClassHasStaticAttribute matcher - * object. - * - * @param string $attributeName - * @return PHPUnit_Framework_Constraint_ClassHasStaticAttribute - * @since Method available since Release 3.1.0 - */ - public static function classHasStaticAttribute($attributeName) - { - return new PHPUnit_Framework_Constraint_ClassHasStaticAttribute( - $attributeName - ); - } - - /** - * Returns a PHPUnit_Framework_Constraint_ObjectHasAttribute matcher object. - * - * @param string $attributeName - * @return PHPUnit_Framework_Constraint_ObjectHasAttribute - * @since Method available since Release 3.0.0 - */ - public static function objectHasAttribute($attributeName) - { - return new PHPUnit_Framework_Constraint_ObjectHasAttribute( - $attributeName - ); - } - - /** - * Returns a PHPUnit_Framework_Constraint_IsIdentical matcher object. - * - * @param mixed $value - * @return PHPUnit_Framework_Constraint_IsIdentical - * @since Method available since Release 3.0.0 - */ - public static function identicalTo($value) - { - return new PHPUnit_Framework_Constraint_IsIdentical($value); - } - - /** - * Returns a PHPUnit_Framework_Constraint_IsInstanceOf matcher object. - * - * @param string $className - * @return PHPUnit_Framework_Constraint_IsInstanceOf - * @since Method available since Release 3.0.0 - */ - public static function isInstanceOf($className) - { - return new PHPUnit_Framework_Constraint_IsInstanceOf($className); - } - - /** - * Returns a PHPUnit_Framework_Constraint_IsType matcher object. - * - * @param string $type - * @return PHPUnit_Framework_Constraint_IsType - * @since Method available since Release 3.0.0 - */ - public static function isType($type) - { - return new PHPUnit_Framework_Constraint_IsType($type); - } - - /** - * Returns a PHPUnit_Framework_Constraint_LessThan matcher object. - * - * @param mixed $value - * @return PHPUnit_Framework_Constraint_LessThan - * @since Method available since Release 3.0.0 - */ - public static function lessThan($value) - { - return new PHPUnit_Framework_Constraint_LessThan($value); - } - - /** - * Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps - * a PHPUnit_Framework_Constraint_IsEqual and a - * PHPUnit_Framework_Constraint_LessThan matcher object. - * - * @param mixed $value - * @return PHPUnit_Framework_Constraint_Or - * @since Method available since Release 3.1.0 - */ - public static function lessThanOrEqual($value) - { - return self::logicalOr( - new PHPUnit_Framework_Constraint_IsEqual($value), - new PHPUnit_Framework_Constraint_LessThan($value) - ); - } - - /** - * Returns a PHPUnit_Framework_Constraint_PCREMatch matcher object. - * - * @param string $pattern - * @return PHPUnit_Framework_Constraint_PCREMatch - * @since Method available since Release 3.0.0 - */ - public static function matchesRegularExpression($pattern) - { - return new PHPUnit_Framework_Constraint_PCREMatch($pattern); - } - - /** - * Returns a PHPUnit_Framework_Constraint_StringMatches matcher object. - * - * @param string $string - * @return PHPUnit_Framework_Constraint_StringMatches - * @since Method available since Release 3.5.0 - */ - public static function matches($string) - { - return new PHPUnit_Framework_Constraint_StringMatches($string); - } - - /** - * Returns a PHPUnit_Framework_Constraint_StringStartsWith matcher object. - * - * @param mixed $prefix - * @return PHPUnit_Framework_Constraint_StringStartsWith - * @since Method available since Release 3.4.0 - */ - public static function stringStartsWith($prefix) - { - return new PHPUnit_Framework_Constraint_StringStartsWith($prefix); - } - - /** - * Returns a PHPUnit_Framework_Constraint_StringContains matcher object. - * - * @param string $string - * @param boolean $case - * @return PHPUnit_Framework_Constraint_StringContains - * @since Method available since Release 3.0.0 - */ - public static function stringContains($string, $case = TRUE) - { - return new PHPUnit_Framework_Constraint_StringContains($string, $case); - } - - /** - * Returns a PHPUnit_Framework_Constraint_StringEndsWith matcher object. - * - * @param mixed $suffix - * @return PHPUnit_Framework_Constraint_StringEndsWith - * @since Method available since Release 3.4.0 - */ - public static function stringEndsWith($suffix) - { - return new PHPUnit_Framework_Constraint_StringEndsWith($suffix); - } - - /** - * Fails a test with the given message. - * - * @param string $message - * @throws PHPUnit_Framework_AssertionFailedError - */ - public static function fail($message = '') - { - throw new PHPUnit_Framework_AssertionFailedError($message); - } - - /** - * Fails a test with a synthetic error. - * - * @param string $message - * @param string $file - * @param integer $line - * @param array $trace - * @throws PHPUnit_Framework_SyntheticError - */ - public static function syntheticFail($message = '', $file = '', $line = 0, $trace = array()) - { - throw new PHPUnit_Framework_SyntheticError($message, 0, $file, $line, $trace); - } - - /** - * Returns the value of an attribute of a class or an object. - * This also works for attributes that are declared protected or private. - * - * @param mixed $classOrObject - * @param string $attributeName - * @return mixed - * @throws InvalidArgumentException - */ - public static function readAttribute($classOrObject, $attributeName) - { - if (!is_string($attributeName)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } - - if (is_string($classOrObject)) { - if (!class_exists($classOrObject)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 1, 'class name' - ); - } - - return PHPUnit_Util_Class::getStaticAttribute( - $classOrObject, - $attributeName - ); - } - - else if (is_object($classOrObject)) { - return PHPUnit_Util_Class::getObjectAttribute( - $classOrObject, - $attributeName - ); - } - - else { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 1, 'class name or object' - ); - } - } - - /** - * Mark the test as incomplete. - * - * @param string $message - * @throws PHPUnit_Framework_IncompleteTestError - * @since Method available since Release 3.0.0 - */ - public static function markTestIncomplete($message = '') - { - throw new PHPUnit_Framework_IncompleteTestError($message); - } - - /** - * Mark the test as skipped. - * - * @param string $message - * @throws PHPUnit_Framework_SkippedTestError - * @since Method available since Release 3.0.0 - */ - public static function markTestSkipped($message = '') - { - throw new PHPUnit_Framework_SkippedTestError($message); - } - - /** - * Return the current assertion count. - * - * @return integer - * @since Method available since Release 3.3.3 - */ - public static function getCount() - { - return self::$count; - } - - /** - * Reset the assertion counter. - * - * @since Method available since Release 3.3.3 - */ - public static function resetCount() - { - self::$count = 0; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/AssertionFailedError.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/AssertionFailedError.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/AssertionFailedError.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/AssertionFailedError.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * Thrown when an assertion failed. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -class PHPUnit_Framework_AssertionFailedError extends Exception implements PHPUnit_Framework_SelfDescribing -{ - /** - * Wrapper for getMessage() which is declared as final. - * - * @return string - */ - public function toString() - { - return $this->getMessage(); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Array.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Array.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Array.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Array.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_ComparisonFailure - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Thrown when an assertion for array equality failed. - * - * @package PHPUnit - * @subpackage Framework_ComparisonFailure - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_ComparisonFailure_Array extends PHPUnit_Framework_ComparisonFailure -{ - /** - * Returns a string describing the difference between the expected and the - * actual array. - * - * @return string - */ - public function toString() - { - ksort($this->expected); - ksort($this->actual); - - $diff = PHPUnit_Util_Diff::diff( - print_r($this->expected, TRUE), - print_r($this->actual, TRUE) - ); - - if ($diff !== FALSE) { - return trim($diff); - } - - // Fallback: Either diff is not available or the print_r() output for - // the expected and the actual array are equal (but the arrays are not). - - $expectedOnly = array(); - $actualOnly = array(); - $diff = ''; - - foreach ($this->expected as $expectedKey => $expectedValue) { - if (!array_key_exists($expectedKey, $this->actual)) { - $expectedOnly[] = $expectedKey; - continue; - } - - if ($expectedValue === $this->actual[$expectedKey]) { - continue; - } - - $diffObject = PHPUnit_Framework_ComparisonFailure::diffIdentical( - $expectedValue, - $this->actual[$expectedKey], - sprintf( - '%sarray key %s: ', - - $this->message, - PHPUnit_Util_Type::toString($expectedKey) - ) - ); - - $diff .= $diffObject->toString() . "\n"; - } - - foreach ($this->actual as $actualKey => $actualValue) { - if (!array_key_exists($actualKey, $this->expected)) { - $actualOnly[] = $actualKey; - continue; - } - } - - foreach ($expectedOnly as $expectedKey) { - $diff .= sprintf( - "array key %s: only in expected %s\n", - - PHPUnit_Util_Type::toString($expectedKey), - PHPUnit_Util_Type::toString($this->expected[$expectedKey]) - ); - } - - foreach ($actualOnly as $actualKey) { - $diff .= sprintf( - "array key %s: only in actual %s\n", - - PHPUnit_Util_Type::toString($actualKey), - PHPUnit_Util_Type::toString($this->actual[$actualKey]) - ); - } - - return $diff; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Object.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Object.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Object.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Object.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_ComparisonFailure - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Thrown when an assertion for object equality failed. - * - * @package PHPUnit - * @subpackage Framework_ComparisonFailure - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_ComparisonFailure_Object extends PHPUnit_Framework_ComparisonFailure -{ - /** - * Returns a string describing the difference between the expected and the - * actual object. - * - * @return string - */ - public function toString() - { - $diff = PHPUnit_Util_Diff::diff( - print_r($this->expected, TRUE), - print_r($this->actual, TRUE) - ); - - if ($diff !== FALSE) { - return trim($diff); - } - - // Fallback: Either diff is not available or the print_r() output for - // the expected and the actual object are equal (but the objects are - // not). - - $expectedClass = get_class($this->expected); - $actualClass = get_class($this->actual); - - if ($expectedClass !== $actualClass) { - return sprintf( - "%s%sexpected class <%s>\n" . - '%sgot class <%s>', - - $this->message, - ($this->message != '') ? ' ' : '', - $expectedClass, - ($this->message != '') ? str_repeat(' ', strlen($this->message) + 1) : '', - $actualClass - ); - } else { - $expectedReflection = new ReflectionClass($expectedClass); - $actualReflection = new ReflectionClass($actualClass); - - $diff = "in object of class <{$expectedClass}>:\n"; - $i = 0; - - foreach($expectedReflection->getProperties() as $expectedAttribute) { - if ($expectedAttribute->isPrivate() || - $expectedAttribute->isProtected()) { - continue; - } - - $actualAttribute = $actualReflection->getProperty( - $expectedAttribute->getName() - ); - $expectedValue = $expectedAttribute->getValue( - $this->expected - ); - $actualValue = $actualAttribute->getValue($this->actual); - - if ($expectedValue !== $actualValue) { - if ($i > 0) { - $diff .= "\n"; - } - - ++$i; - - $expectedType = gettype($expectedValue); - $actualType = gettype($actualValue); - - if ($expectedType !== $actualType) { - $diffObject = new PHPUnit_Framework_ComparisonFailure_Type( - $expectedValue, - $actualValue, - $this->message . 'attribute <' . - $expectedAttribute->getName() . '>: ' - ); - - $diff .= $diffObject->toString(); - } - - elseif (is_object($expectedValue)) { - if (get_class($expectedValue) !== get_class($actualValue)) { - $diffObject = new PHPUnit_Framework_ComparisonFailure_Type( - $expectedValue, - $actualValue, - $this->message . 'attribute <' . - $expectedAttribute->getName() . '>: ' - ); - - $diff .= $diffObject->toString(); - } else { - $diff .= 'attribute <' . - $expectedAttribute->getName() . - '> contains object <' . - get_class($expectedValue) . - '> with different attributes'; - } - } else { - $diffObject = PHPUnit_Framework_ComparisonFailure::diffIdentical( - $expectedValue, - $actualValue, - $this->message . 'attribute <' . - $expectedAttribute->getName() . '>: ' - ); - - $diff .= $diffObject->toString(); - } - } - } - - return $diff; - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Scalar.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Scalar.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Scalar.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Scalar.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_ComparisonFailure - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Thrown when an assertion for scalar equality failed. - * - * @package PHPUnit - * @subpackage Framework_ComparisonFailure - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_ComparisonFailure_Scalar extends PHPUnit_Framework_ComparisonFailure -{ - /** - * Returns a string describing the difference between the expected and the - * actual scalar value. - */ - public function toString() - { - return sprintf( - 'Failed asserting that %s %s %s.', - - PHPUnit_Util_Type::toString($this->actual), - $this->identical ? 'is identical to' : 'matches expected', - PHPUnit_Util_Type::toString($this->expected) - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/String.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/String.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/String.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/String.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_ComparisonFailure - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Thrown when an assertion for string equality failed. - * - * @package PHPUnit - * @subpackage Framework_ComparisonFailure - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_ComparisonFailure_String extends PHPUnit_Framework_ComparisonFailure -{ - /** - * Returns a string describing the difference between - * the expected and the actual string value. - */ - public function toString() - { - $expected = (string)$this->expected; - $actual = (string)$this->actual; - $diff = PHPUnit_Util_Diff::diff($expected, $actual); - - if ($diff === FALSE) { - $diff = ''; - } - - if (!empty($this->message)) { - $buffer = $this->message . "\n"; - } else { - $buffer = ''; - } - - return trim($buffer . $diff); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Type.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Type.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Type.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure/Type.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_ComparisonFailure - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Thrown when an assertion for type equality failed. - * - * @package PHPUnit - * @subpackage Framework_ComparisonFailure - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_ComparisonFailure_Type extends PHPUnit_Framework_ComparisonFailure -{ - /** - * Returns a string describing the type difference between the expected - * and the actual value. - */ - public function toString() - { - return sprintf( - '%s does not match expected type "%s".', - - PHPUnit_Util_Type::toString($this->actual), - gettype($this->expected) - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ComparisonFailure.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,208 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * Thrown when an assertion for string equality failed. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -abstract class PHPUnit_Framework_ComparisonFailure extends PHPUnit_Framework_AssertionFailedError -{ - /** - * Expected value of the retrieval which does not match $actual. - * @var mixed - */ - protected $expected; - - /** - * Actually retrieved value which does not match $expected. - * @var mixed - */ - protected $actual; - - /** - * @var boolean - */ - protected $identical; - - /** - * Optional message which is placed in front of the first line - * returned by toString(). - * @var string - */ - protected $message; - - /** - * Initialises with the expected value and the actual value. - * - * @param mixed $expected Expected value retrieved. - * @param mixed $actual Actual value retrieved. - * @param boolean $identical - * @param string $message A string which is prefixed on all returned lines - * in the difference output. - */ - public function __construct($expected, $actual, $identical = FALSE, $message = '') - { - $this->expected = $expected; - $this->actual = $actual; - $this->identical = $identical; - $this->message = $message; - } - - /** - * @return mixed - */ - public function getActual() - { - return $this->actual; - } - - /** - * @return mixed - */ - public function getExpected() - { - return $this->expected; - } - - /** - * @return boolean - */ - public function identical() - { - return $this->identical; - } - - /** - * Figures out which diff class to use for the input types then - * instantiates that class and returns the object. - * @note The diff is type sensitive, if the type differs only the types - * are shown. - * - * @param mixed $expected Expected value retrieved. - * @param mixed $actual Actual value retrieved. - * @param string $message A string which is prefixed on all returned lines - * in the difference output. - * @return PHPUnit_Framework_ComparisonFailure - */ - public static function diffIdentical($expected, $actual, $message = '') - { - if (gettype($expected) !== gettype($actual)) { - return new PHPUnit_Framework_ComparisonFailure_Type( - $expected, $actual, TRUE, $message - ); - } - - else if (is_array($expected) && is_array($actual)) { - return new PHPUnit_Framework_ComparisonFailure_Array( - $expected, $actual, TRUE, $message - ); - } - - else if (is_object($expected) && is_object($actual)) { - return new PHPUnit_Framework_ComparisonFailure_Object( - $expected, $actual, TRUE, $message - ); - } - - else if (is_string($expected) && !is_object($actual)) { - return new PHPUnit_Framework_ComparisonFailure_String( - $expected, $actual, TRUE, $message - ); - } - - else if (is_null($expected) || is_scalar($expected)) { - return new PHPUnit_Framework_ComparisonFailure_Scalar( - $expected, $actual, TRUE, $message - ); - } - } - - /** - * Figures out which diff class to use for the input types then - * instantiates that class and returns the object. - * @note The diff is not type sensitive, if the type differs the $actual - * value will be converted to the same type as the $expected. - * - * @param mixed $expected Expected value retrieved. - * @param mixed $actual Actual value retrieved. - * @param string $message A string which is prefixed on all returned lines - * in the difference output. - * @return PHPUnit_Framework_ComparisonFailure - */ - public static function diffEqual($expected, $actual, $message = '') - { - if (is_array($expected) && is_array($actual)) { - return new PHPUnit_Framework_ComparisonFailure_Array( - $expected, $actual, FALSE, $message - ); - } - - else if (is_object($expected) && is_object($actual)) { - return new PHPUnit_Framework_ComparisonFailure_Object( - $expected, $actual, FALSE, $message - ); - } - - else if (is_string($expected) && !is_object($actual)) { - return new PHPUnit_Framework_ComparisonFailure_String( - $expected, $actual, FALSE, $message - ); - } - - else if (is_null($expected) || is_scalar($expected)) { - return new PHPUnit_Framework_ComparisonFailure_Scalar( - $expected, $actual, FALSE, $message - ); - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/And.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/And.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/And.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/And.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Logical AND. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_And extends PHPUnit_Framework_Constraint -{ - /** - * @var PHPUnit_Framework_Constraint[] - */ - protected $constraints = array(); - - /** - * @var PHPUnit_Framework_Constraint - */ - protected $lastConstraint = NULL; - - /** - * @param PHPUnit_Framework_Constraint[] $constraints - */ - public function setConstraints(array $constraints) - { - $this->constraints = array(); - - foreach($constraints as $key => $constraint) { - if (!($constraint instanceof PHPUnit_Framework_Constraint)) { - throw new InvalidArgumentException( - 'All parameters to ' . __CLASS__ . - ' must be a constraint object.' - ); - } - - $this->constraints[] = $constraint; - } - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - $this->lastConstraint = NULL; - - foreach($this->constraints as $constraint) { - $this->lastConstraint = $constraint; - - if (!$constraint->evaluate($other)) { - return FALSE; - } - } - - return TRUE; - } - - /** - * @param mixed $other The value passed to evaluate() which failed the - * constraint check. - * @param string $description A string with extra description of what was - * going on while the evaluation failed. - * @param boolean $not Flag to indicate negation. - * @throws PHPUnit_Framework_ExpectationFailedException - */ - public function fail($other, $description, $not = FALSE) - { - $this->lastConstraint->fail($other, $description, $not); - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - $text = ''; - - foreach($this->constraints as $key => $constraint) { - if ($key > 0) { - $text .= ' and '; - } - - $text .= $constraint->toString(); - } - - return $text; - } - - /** - * Counts the number of constraint elements. - * - * @return integer - * @since Method available since Release 3.4.0 - */ - public function count() - { - $count = 0; - - foreach ($this->constraints as $constraint) { - $count += count($constraint); - } - - return $count; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ArrayHasKey.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ArrayHasKey.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ArrayHasKey.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ArrayHasKey.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Constraint that asserts that the array it is evaluated for has a given key. - * - * Uses array_key_exists() to check if the key is found in the input array, if - * not found the evaluaton fails. - * - * The array key is passed in the constructor. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_ArrayHasKey extends PHPUnit_Framework_Constraint -{ - /** - * @var integer|string - */ - protected $key; - - /** - * @param integer|string $key - */ - public function __construct($key) - { - $this->key = $key; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return array_key_exists($this->key, $other); - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return 'has the key ' . PHPUnit_Util_Type::toString($this->key); - } - - /** - * @param mixed $other - * @param string $description - * @param boolean $not - */ - protected function customFailureDescription($other, $description, $not) - { - return sprintf( - 'Failed asserting that an array %s.', - - $this->toString() - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Attribute.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Attribute.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Attribute.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Attribute.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,149 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.1.0 - */ - -/** - * - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.1.0 - */ - -class PHPUnit_Framework_Constraint_Attribute extends PHPUnit_Framework_Constraint -{ - /** - * @var string - */ - protected $attributeName; - - /** - * @var PHPUnit_Framework_Constraint - */ - protected $constraint; - - /** - * @param PHPUnit_Framework_Constraint $constraint - * @param string $attributeName - */ - public function __construct(PHPUnit_Framework_Constraint $constraint, $attributeName) - { - $this->attributeName = $attributeName; - $this->constraint = $constraint; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return $this->constraint->evaluate( - PHPUnit_Framework_Assert::readAttribute( - $other, $this->attributeName - ) - ); - } - - /** - * @param mixed $other The value passed to evaluate() which failed the - * constraint check. - * @param string $description A string with extra description of what was - * going on while the evaluation failed. - * @param boolean $not Flag to indicate negation. - * @throws PHPUnit_Framework_ExpectationFailedException - */ - public function fail($other, $description, $not = FALSE) - { - parent::fail( - PHPUnit_Framework_Assert::readAttribute( - $other, $this->attributeName - ), - $description, - $not - ); - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return 'attribute "' . $this->attributeName . '" ' . - $this->constraint->toString(); - } - - /** - * Counts the number of constraint elements. - * - * @return integer - * @since Method available since Release 3.4.0 - */ - public function count() - { - return count($this->constraint); - } - - /** - * @since Method available since Release 3.4.0 - */ - protected function customFailureDescription($other, $description, $not) - { - return sprintf( - 'Failed asserting that %s.', - - $this->toString() - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ClassHasAttribute.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ClassHasAttribute.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ClassHasAttribute.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ClassHasAttribute.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.1.0 - */ - -/** - * Constraint that asserts that the class it is evaluated for has a given - * attribute. - * - * The attribute name is passed in the constructor. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.1.0 - */ -class PHPUnit_Framework_Constraint_ClassHasAttribute extends PHPUnit_Framework_Constraint -{ - /** - * @var string - */ - protected $attributeName; - - /** - * @param string $attributeName - */ - public function __construct($attributeName) - { - $this->attributeName = $attributeName; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - $class = new ReflectionClass($other); - - return $class->hasProperty($this->attributeName); - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return sprintf( - 'has attribute "%s"', - - $this->attributeName - ); - } - - protected function customFailureDescription($other, $description, $not) - { - return sprintf( - 'Failed asserting that class "%s" %s.', $other, $this->toString() - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ClassHasStaticAttribute.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ClassHasStaticAttribute.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ClassHasStaticAttribute.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ClassHasStaticAttribute.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.1.0 - */ - -/** - * Constraint that asserts that the class it is evaluated for has a given - * static attribute. - * - * The attribute name is passed in the constructor. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.1.0 - */ -class PHPUnit_Framework_Constraint_ClassHasStaticAttribute extends PHPUnit_Framework_Constraint_ClassHasAttribute -{ - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - $class = new ReflectionClass($other); - - if ($class->hasProperty($this->attributeName)) { - $attribute = $class->getProperty($this->attributeName); - - return $attribute->isStatic(); - } else { - return FALSE; - } - } - - /** - * Returns a string representation of the constraint. - * - * @return string - * @since Method available since Release 3.3.0 - */ - public function toString() - { - return sprintf( - 'has static attribute "%s"', - - $this->attributeName - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/FileExists.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/FileExists.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/FileExists.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/FileExists.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Constraint that checks if the file(name) that it is evaluated for exists. - * - * The file path to check is passed as $other in evaluate(). - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_FileExists extends PHPUnit_Framework_Constraint -{ - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return file_exists($other); - } - - /** - * @param mixed $other The value passed to evaluate() which failed the - * constraint check. - * @param string $description A string with extra description of what was - * going on while the evaluation failed. - * @param boolean $not Flag to indicate negation. - * @throws PHPUnit_Framework_ExpectationFailedException - */ - public function fail($other, $description, $not = FALSE) - { - $failureDescription = sprintf( - 'Failed asserting that file "%s" exists.', - - $other - ); - - if ($not) { - $failureDescription = self::negate($failureDescription); - } - - if (!empty($description)) { - $failureDescription = $description . "\n" . $failureDescription; - } - - throw new PHPUnit_Framework_ExpectationFailedException( - $failureDescription - ); - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return 'file exists'; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/GreaterThan.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/GreaterThan.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/GreaterThan.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/GreaterThan.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Constraint that asserts that the value it is evaluated for is greater - * than a given value. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_GreaterThan extends PHPUnit_Framework_Constraint -{ - /** - * @var numeric - */ - protected $value; - - /** - * @param numeric $value - */ - public function __construct($value) - { - $this->value = $value; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return $this->value < $other; - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return 'is greater than ' . PHPUnit_Util_Type::toString($this->value); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsAnything.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsAnything.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsAnything.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsAnything.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Constraint that accepts any input value. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_IsAnything extends PHPUnit_Framework_Constraint -{ - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return TRUE; - } - - /** - * @param mixed $other The value passed to evaluate() which failed the - * constraint check. - * @param string $description A string with extra description of what was - * going on while the evaluation failed. - * @param boolean $not Flag to indicate negation. - */ - public function fail($other, $description, $not = FALSE) - { - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return 'is anything'; - } - - /** - * Counts the number of constraint elements. - * - * @return integer - * @since Method available since Release 3.5.0 - */ - public function count() - { - return 0; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsEmpty.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsEmpty.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsEmpty.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsEmpty.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.5.0 - */ - -/** - * Constraint that checks whether a variable is empty(). - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.5.0 - */ -class PHPUnit_Framework_Constraint_IsEmpty extends PHPUnit_Framework_Constraint -{ - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return empty($other); - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return 'is empty'; - } - - /** - * @param mixed $other - * @param string $description - * @param boolean $not - */ - protected function customFailureDescription($other, $description, $not) - { - $type = gettype($other); - - if ($type[0] == 'a' || $type[0] == 'o') { - $type = 'an ' . $type; - } else { - $type = 'a ' . $type; - } - - return sprintf( - 'Failed asserting that %s is empty.', - $type - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsEqual.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsEqual.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsEqual.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsEqual.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,386 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Kore Nordmann - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Constraint that checks if one value is equal to another. - * - * Equality is checked with PHP's == operator, the operator is explained in - * detail at {@url http://www.php.net/manual/en/types.comparisons.php}. - * Two values are equal if they have the same value disregarding type. - * - * The expected value is passed in the constructor. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Kore Nordmann - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_IsEqual extends PHPUnit_Framework_Constraint -{ - /** - * @var mixed - */ - protected $value; - - /** - * @var float - */ - protected $delta = 0; - - /** - * @var integer - */ - protected $maxDepth = 10; - - /** - * @var boolean - */ - protected $canonicalize = FALSE; - - /** - * @var boolean - */ - protected $ignoreCase = FALSE; - - /** - * @param mixed $value - * @param float $delta - * @param integer $maxDepth - * @param boolean $canonicalize - * @param boolean $ignoreCase - */ - public function __construct($value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) - { - if (!is_numeric($delta)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'numeric'); - } - - if (!is_int($maxDepth)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(3, 'integer'); - } - - if (!is_bool($canonicalize)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(4, 'boolean'); - } - - if (!is_bool($ignoreCase)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(5, 'boolean'); - } - - $this->value = $value; - $this->delta = $delta; - $this->maxDepth = $maxDepth; - $this->canonicalize = $canonicalize; - $this->ignoreCase = $ignoreCase; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return $this->recursiveComparison($this->value, $other); - } - - /** - * @param mixed $other The value passed to evaluate() which failed the - * constraint check. - * @param string $description A string with extra description of what was - * going on while the evaluation failed. - * @param boolean $not Flag to indicate negation. - * @throws PHPUnit_Framework_ExpectationFailedException - */ - public function fail($other, $description, $not = FALSE) - { - $failureDescription = $this->failureDescription( - $other, - $description, - $not - ); - - if (!$not) { - if ($this->value instanceof DOMDocument) { - $value = $this->domToText($this->value); - } else { - $value = $this->value; - } - - if ($other instanceof DOMDocument) { - $other = $this->domToText($other); - } - - throw new PHPUnit_Framework_ExpectationFailedException( - $failureDescription, - PHPUnit_Framework_ComparisonFailure::diffEqual($value, $other), - $description - ); - } else { - throw new PHPUnit_Framework_ExpectationFailedException( - $failureDescription, - NULL - ); - } - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - $delta = ''; - - if (is_string($this->value)) { - if (strpos($this->value, "\n") !== FALSE) { - return 'is equal to '; - } else { - return sprintf( - 'is equal to ', - - $this->value - ); - } - } else { - if ($this->delta != 0) { - $delta = sprintf( - ' with delta <%F>', - - $this->delta - ); - } - - return sprintf( - 'is equal to %s%s', - - PHPUnit_Util_Type::toString($this->value), - $delta - ); - } - } - - /** - * Perform the actual recursive comparision of two values - * - * @param mixed $a First value - * @param mixed $b Second value - * @param int $depth Depth - * @return bool - */ - protected function recursiveComparison($a, $b, $depth = 0) - { - if ($a === $b) { - return TRUE; - } - - if ($depth >= $this->maxDepth) { - return TRUE; - } - - if (is_numeric($a) XOR is_numeric($b)) { - return FALSE; - } - - if (is_array($a) XOR is_array($b)) { - return FALSE; - } - - if (is_object($a) XOR is_object($b)) { - return FALSE; - } - - if ($a instanceof SplObjectStorage XOR $b instanceof SplObjectStorage) { - return FALSE; - } - - if ($a instanceof SplObjectStorage) { - foreach ($a as $object) { - if (!$b->contains($object)) { - return FALSE; - } - } - - foreach ($b as $object) { - if (!$a->contains($object)) { - return FALSE; - } - } - - return TRUE; - } - - if ($a instanceof DOMDocument || $b instanceof DOMDocument) { - if (!$a instanceof DOMDocument) { - $_a = new DOMDocument; - $_a->preserveWhiteSpace = FALSE; - $_a->loadXML($a); - $a = $_a; - unset($_a); - } - - if (!$b instanceof DOMDocument) { - $_b = new DOMDocument; - $_b->preserveWhiteSpace = FALSE; - $_b->loadXML($b); - $b = $_b; - unset($_b); - } - - return $a->C14N() == $b->C14N(); - } - - if (is_object($a) && is_object($b) && - (get_class($a) !== get_class($b))) { - return FALSE; - } - - // Normal comparision for scalar values. - if ((!is_array($a) && !is_object($a)) || - (!is_array($b) && !is_object($b))) { - if (is_numeric($a) && is_numeric($b)) { - // Optionally apply delta on numeric values. - return $this->numericComparison($a, $b); - } - - if (is_string($a) && is_string($b)) { - if ($this->canonicalize && PHP_EOL != "\n") { - $a = str_replace(PHP_EOL, "\n", $a); - $b = str_replace(PHP_EOL, "\n", $b); - } - - if ($this->ignoreCase) { - $a = strtolower($a); - $b = strtolower($b); - } - } - - return ($a == $b); - } - - if (is_object($a)) { - $isMock = $a instanceof PHPUnit_Framework_MockObject_MockObject; - $a = (array)$a; - $b = (array)$b; - - if ($isMock) { - unset($a["\0*\0invocationMocker"]); - - if (isset($b["\0*\0invocationMocker"])) { - unset($b["\0*\0invocationMocker"]); - } - } - } - - if ($this->canonicalize) { - sort($a); - sort($b); - } - - $keysInB = array_flip(array_keys($b)); - - foreach ($a as $key => $v) { - if (!isset($keysInB[$key])) { - // Abort on missing key in $b. - return FALSE; - } - - if (!$this->recursiveComparison($a[$key], $b[$key], $depth + 1)) { - // FALSE, if child comparision fails. - return FALSE; - } - - // Unset key to check whether all keys of b are compared. - unset($b[$key]); - } - - if (count($b)) { - // There is something in $b, that is missing in $a. - return FALSE; - } - - return TRUE; - } - - /** - * Compares two numeric values - use delta if applicable. - * - * @param mixed $a - * @param mixed $b - * @return bool - */ - protected function numericComparison($a, $b) - { - if ($this->delta === FALSE) { - return ($a == $b); - } else { - return (abs($a - $b) <= $this->delta); - } - } - - /** - * Returns the normalized, whitespace-cleaned, and indented textual - * representation of a DOMDocument. - * - * @param DOMDocument $document - * @return string - */ - protected function domToText(DOMDocument $document) - { - $document->formatOutput = TRUE; - $document->normalizeDocument(); - - return $document->saveXML(); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsFalse.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsFalse.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsFalse.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsFalse.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * Constraint that accepts FALSE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Framework_Constraint_IsFalse extends PHPUnit_Framework_Constraint -{ - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return $other === FALSE; - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return 'is false'; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsIdentical.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsIdentical.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsIdentical.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsIdentical.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Constraint that asserts that one value is identical to another. - * - * Identical check is performed with PHP's === operator, the operator is - * explained in detail at - * {@url http://www.php.net/manual/en/types.comparisons.php}. - * Two values are identical if they have the same value and are of the same - * type. - * - * The expected value is passed in the constructor. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_IsIdentical extends PHPUnit_Framework_Constraint -{ - /** - * @var mixed - */ - protected $value; - - /** - * @param mixed $value - */ - public function __construct($value) - { - $this->value = $value; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return $this->value === $other; - } - - /** - * @param mixed $other The value passed to evaluate() which failed the - * constraint check. - * @param string $description A string with extra description of what was - * going on while the evaluation failed. - * @param boolean $not Flag to indicate negation. - * @throws PHPUnit_Framework_ExpectationFailedException - */ - public function fail($other, $description, $not = FALSE) - { - $failureDescription = $this->failureDescription( - $other, - $description, - $not - ); - - if (!$not) { - throw new PHPUnit_Framework_ExpectationFailedException( - $failureDescription, - PHPUnit_Framework_ComparisonFailure::diffIdentical( - $this->value, $other - ), - $description - ); - } else { - throw new PHPUnit_Framework_ExpectationFailedException( - $failureDescription, - NULL - ); - } - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - if (is_object($this->value)) { - return 'is identical to an object of class "' . - get_class($this->value) . '"'; - } else { - return 'is identical to ' . - PHPUnit_Util_Type::toString($this->value); - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsInstanceOf.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsInstanceOf.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsInstanceOf.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsInstanceOf.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Constraint that asserts that the object it is evaluated for is an instance - * of a given class. - * - * The expected class name is passed in the constructor. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_IsInstanceOf extends PHPUnit_Framework_Constraint -{ - /** - * @var string - */ - protected $className; - - /** - * @param string $className - */ - public function __construct($className) - { - $this->className = $className; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return ($other instanceof $this->className); - } - - /** - * Creates the appropriate exception for the constraint which can be caught - * by the unit test system. This can be called if a call to evaluate() - * fails. - * - * @param mixed $other The value passed to evaluate() which failed the - * constraint check. - * @param string $description A string with extra description of what was - * going on while the evaluation failed. - * @param boolean $not Flag to indicate negation. - * @throws PHPUnit_Framework_ExpectationFailedException - */ - public function fail($other, $description, $not = FALSE) - { - throw new PHPUnit_Framework_ExpectationFailedException( - sprintf( - '%sFailed asserting that %s is %san instance of class "%s".', - - !empty($description) ? $description . "\n" : '', - PHPUnit_Util_Type::toString($other, TRUE), - $not ? 'not ' : '', - $this->className - ), - NULL - ); - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return sprintf( - 'is instance of class "%s"', - - $this->className - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsNull.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsNull.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsNull.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsNull.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * Constraint that accepts NULL. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Framework_Constraint_IsNull extends PHPUnit_Framework_Constraint -{ - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return $other === NULL; - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return 'is null'; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsTrue.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsTrue.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsTrue.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsTrue.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * Constraint that accepts TRUE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Framework_Constraint_IsTrue extends PHPUnit_Framework_Constraint -{ - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return $other === TRUE; - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return 'is true'; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsType.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsType.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsType.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/IsType.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,183 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Constraint that asserts that the value it is evaluated for is of a - * specified type. - * - * The expected value is passed in the constructor. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_IsType extends PHPUnit_Framework_Constraint -{ - const TYPE_ARRAY = 'array'; - const TYPE_BOOL = 'bool'; - const TYPE_FLOAT = 'float'; - const TYPE_INT = 'int'; - const TYPE_NULL = 'null'; - const TYPE_NUMERIC = 'numeric'; - const TYPE_OBJECT = 'object'; - const TYPE_RESOURCE = 'resource'; - const TYPE_STRING = 'string'; - const TYPE_SCALAR = 'scalar'; - - /** - * @var array - */ - protected $types = array( - 'array' => TRUE, - 'boolean' => TRUE, - 'bool' => TRUE, - 'float' => TRUE, - 'integer' => TRUE, - 'int' => TRUE, - 'null' => TRUE, - 'numeric' => TRUE, - 'object' => TRUE, - 'resource' => TRUE, - 'string' => TRUE, - 'scalar' => TRUE - ); - - /** - * @var string - */ - protected $type; - - /** - * @param string $type - * @throws InvalidArgumentException - */ - public function __construct($type) - { - if (!isset($this->types[$type])) { - throw new InvalidArgumentException( - sprintf( - 'Type specified for PHPUnit_Framework_Constraint_IsType <%s> ' . - 'is not a valid type.', - $type - ) - ); - } - - $this->type = $type; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - switch ($this->type) { - case 'numeric': { - return is_numeric($other); - } - - case 'integer': - case 'int': { - return is_integer($other); - } - - case 'float': { - return is_float($other); - } - - case 'string': { - return is_string($other); - } - - case 'boolean': - case 'bool': { - return is_bool($other); - } - - case 'null': { - return is_null($other); - } - - case 'array': { - return is_array($other); - } - - case 'object': { - return is_object($other); - } - - case 'resource': { - return is_resource($other); - } - - case 'scalar': { - return is_scalar($other); - } - } - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return sprintf( - 'is of type "%s"', - - $this->type - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/LessThan.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/LessThan.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/LessThan.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/LessThan.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Constraint that asserts that the value it is evaluated for is less than - * a given value. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_LessThan extends PHPUnit_Framework_Constraint -{ - /** - * @var numeric - */ - protected $value; - - /** - * @param numeric $value - */ - public function __construct($value) - { - $this->value = $value; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return $this->value > $other; - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return 'is less than ' . PHPUnit_Util_Type::toString($this->value); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Not.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Not.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Not.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Not.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Logical NOT. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ - -class PHPUnit_Framework_Constraint_Not extends PHPUnit_Framework_Constraint -{ - /** - * @var PHPUnit_Framework_Constraint - */ - protected $constraint; - - /** - * @param PHPUnit_Framework_Constraint $constraint - */ - public function __construct($constraint) - { - if (!($constraint instanceof PHPUnit_Framework_Constraint)) { - $constraint = new PHPUnit_Framework_Constraint_IsEqual($constraint); - } - - $this->constraint = $constraint; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return !$this->constraint->evaluate($other); - } - - /** - * @param mixed $other The value passed to evaluate() which failed the - * constraint check. - * @param string $description A string with extra description of what was - * going on while the evaluation failed. - * @param boolean $not Flag to indicate negation. - * @throws PHPUnit_Framework_ExpectationFailedException - */ - public function fail($other, $description, $not = FALSE) - { - if (count($this->constraint) == 1 || - $this->constraint instanceof PHPUnit_Framework_Constraint_Attribute) { - $this->constraint->fail($other, $description, TRUE); - } else { - parent::fail($other, $description, !$not); - } - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - switch (get_class($this->constraint)) { - case 'PHPUnit_Framework_Constraint_And': - case 'PHPUnit_Framework_Constraint_Not': - case 'PHPUnit_Framework_Constraint_Or': { - return 'not( ' . $this->constraint->toString() . ' )'; - } - break; - - default: { - return PHPUnit_Framework_Constraint::negate( - $this->constraint->toString() - ); - } - } - } - - /** - * Counts the number of constraint elements. - * - * @return integer - * @since Method available since Release 3.4.0 - */ - public function count() - { - return count($this->constraint); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ObjectHasAttribute.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ObjectHasAttribute.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ObjectHasAttribute.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/ObjectHasAttribute.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Constraint that asserts that the object it is evaluated for has a given - * attribute. - * - * The attribute name is passed in the constructor. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_ObjectHasAttribute extends PHPUnit_Framework_Constraint_ClassHasAttribute -{ - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - $object = new ReflectionObject($other); - - return $object->hasProperty($this->attributeName); - } - - protected function customFailureDescription($other, $description, $not) - { - return sprintf( - 'Failed asserting that object of class "%s" %s.', - get_class($other), $this->toString() - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Or.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Or.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Or.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Or.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Logical OR. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_Or extends PHPUnit_Framework_Constraint -{ - /** - * @var PHPUnit_Framework_Constraint[] - */ - protected $constraints = array(); - - /** - * @param PHPUnit_Framework_Constraint[] $constraints - */ - public function setConstraints(array $constraints) - { - $this->constraints = array(); - - foreach($constraints as $key => $constraint) { - if (!($constraint instanceof PHPUnit_Framework_Constraint)) { - $constraint = new PHPUnit_Framework_Constraint_IsEqual( - $constraint - ); - } - - $this->constraints[] = $constraint; - } - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - foreach($this->constraints as $constraint) { - if ($constraint->evaluate($other)) { - return TRUE; - } - } - - return FALSE; - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - $text = ''; - - foreach($this->constraints as $key => $constraint) { - if ($key > 0) { - $text .= ' or '; - } - - $text .= $constraint->toString(); - } - - return $text; - } - - /** - * Counts the number of constraint elements. - * - * @return integer - * @since Method available since Release 3.4.0 - */ - public function count() - { - $count = 0; - - foreach ($this->constraints as $constraint) { - $count += count($constraint); - } - - return $count; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/PCREMatch.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/PCREMatch.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/PCREMatch.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/PCREMatch.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Constraint that asserts that the string it is evaluated for matches - * a regular expression. - * - * Checks a given value using the Perl Compatible Regular Expression extension - * in PHP. The pattern is matched by executing preg_match(). - * - * The pattern string passed in the constructor. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_PCREMatch extends PHPUnit_Framework_Constraint -{ - /** - * @var string - */ - protected $pattern; - - /** - * @param string $pattern - */ - public function __construct($pattern) - { - $this->pattern = $pattern; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return preg_match($this->pattern, $other) > 0; - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return sprintf( - 'matches PCRE pattern "%s"', - - $this->pattern - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringContains.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringContains.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringContains.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringContains.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Constraint that asserts that the string it is evaluated for contains - * a given string. - * - * Uses strpos() to find the position of the string in the input, if not found - * the evaluaton fails. - * - * The sub-string is passed in the constructor. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_StringContains extends PHPUnit_Framework_Constraint -{ - /** - * @var string - */ - protected $string; - - /** - * @var boolean - */ - protected $ignoreCase; - - /** - * @param string $string - * @param boolean $ignoreCase - */ - public function __construct($string, $ignoreCase = FALSE) - { - $this->string = $string; - $this->ignoreCase = $ignoreCase; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - if ($this->ignoreCase) { - return stripos($other, $this->string) !== FALSE; - } else { - return strpos($other, $this->string) !== FALSE; - } - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - if ($this->ignoreCase) { - $string = strtolower($this->string); - } else { - $string = $this->string; - } - - return sprintf( - 'contains "%s"', - - $string - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringEndsWith.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringEndsWith.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringEndsWith.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringEndsWith.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.4.0 - */ - -/** - * Constraint that asserts that the string it is evaluated for ends with a given - * suffix. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.4.0 - */ -class PHPUnit_Framework_Constraint_StringEndsWith extends PHPUnit_Framework_Constraint -{ - /** - * @var string - */ - protected $suffix; - - /** - * @param string $suffix - */ - public function __construct($suffix) - { - $this->suffix = $suffix; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return substr($other, 0 - strlen($this->suffix)) == $this->suffix; - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return 'ends with "' . $this->suffix . '"'; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringMatches.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringMatches.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringMatches.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringMatches.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.5.0 - */ - -/** - * ... - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.5.0 - */ -class PHPUnit_Framework_Constraint_StringMatches extends PHPUnit_Framework_Constraint_PCREMatch -{ - /** - * @var string - */ - protected $string; - - /** - * @param string $string - */ - public function __construct($string) - { - $this->pattern = preg_quote(preg_replace('/\r\n/', "\n", $string), '/'); - $this->pattern = str_replace( - array( - '%e', - '%s', - '%S', - '%a', - '%A', - '%w', - '%i', - '%d', - '%x', - '%f', - '%c' - ), - array( - '\\' . DIRECTORY_SEPARATOR, - '[^\r\n]+', - '[^\r\n]*', - '.+', - '.*', - '\s*', - '[+-]?\d+', - '\d+', - '[0-9a-fA-F]+', - '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', - '.' - ), - $this->pattern - ); - - $this->pattern = '/^' . $this->pattern . '$/s'; - $this->string = $string; - } - - /** - * Creates the appropriate exception for the constraint which can be caught - * by the unit test system. This can be called if a call to evaluate() - * fails. - * - * @param mixed $other The value passed to evaluate() which failed the - * constraint check. - * @param string $description A string with extra description of what was - * going on while the evaluation failed. - * @param boolean $not Flag to indicate negation. - * @throws PHPUnit_Framework_ExpectationFailedException - */ - public function fail($other, $description, $not = FALSE) - { - $failureDescription = $this->failureDescription( - $other, - $description, - $not - ); - - if (!$not) { - throw new PHPUnit_Framework_ExpectationFailedException( - $failureDescription, - PHPUnit_Framework_ComparisonFailure::diffEqual( - $this->string, $other - ), - $description - ); - } else { - throw new PHPUnit_Framework_ExpectationFailedException( - $failureDescription, - NULL - ); - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringStartsWith.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringStartsWith.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringStartsWith.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/StringStartsWith.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.4.0 - */ - -/** - * Constraint that asserts that the string it is evaluated for begins with a - * given prefix. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.4.0 - */ -class PHPUnit_Framework_Constraint_StringStartsWith extends PHPUnit_Framework_Constraint -{ - /** - * @var string - */ - protected $prefix; - - /** - * @param string $prefix - */ - public function __construct($prefix) - { - $this->prefix = $prefix; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - return strpos($other, $this->prefix) === 0; - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return 'starts with "' . $this->prefix . '"'; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/TraversableContains.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/TraversableContains.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/TraversableContains.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/TraversableContains.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Constraint that asserts that the Traversable it is applied to contains - * a given value. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_TraversableContains extends PHPUnit_Framework_Constraint -{ - /** - * @var mixed - */ - protected $value; - - /** - * @param mixed $value - */ - public function __construct($value) - { - $this->value = $value; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - if ($other instanceof SplObjectStorage) { - return $other->contains($this->value); - } - - if (is_object($this->value)) { - foreach ($other as $element) { - if ($element === $this->value) { - return TRUE; - } - } - } else { - foreach ($other as $element) { - if ($element == $this->value) { - return TRUE; - } - } - } - - return FALSE; - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - if (is_string($this->value) && strpos($this->value, "\n") !== FALSE) { - return 'contains "' . $this->value . '"'; - } else { - return 'contains ' . PHPUnit_Util_Type::toString($this->value); - } - } - - protected function customFailureDescription($other, $description, $not) - { - return sprintf( - 'Failed asserting that an %s %s.', - - is_array($other) ? 'array' : 'iterator', - $this->toString() - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/TraversableContainsOnly.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/TraversableContainsOnly.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/TraversableContainsOnly.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/TraversableContainsOnly.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.1.4 - */ - -/** - * Constraint that asserts that the Traversable it is applied to contains - * only values of a given type. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.1.4 - */ -class PHPUnit_Framework_Constraint_TraversableContainsOnly extends PHPUnit_Framework_Constraint -{ - /** - * @var PHPUnit_Framework_Constraint - */ - protected $constraint; - - /** - * @var string - */ - protected $type; - - /** - * @param string $type - * @param boolean $isNativeType - */ - public function __construct($type, $isNativeType = TRUE) - { - if ($isNativeType) { - $this->constraint = new PHPUnit_Framework_Constraint_IsType($type); - } else { - $this->constraint = new PHPUnit_Framework_Constraint_IsInstanceOf( - $type - ); - } - - $this->type = $type; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - foreach ($other as $item) { - if (!$this->constraint->evaluate($item)) { - return FALSE; - } - } - - return TRUE; - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - return 'contains only values of type "' . $this->type . '"'; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Xor.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Xor.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Xor.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint/Xor.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Logical XOR. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_Constraint_Xor extends PHPUnit_Framework_Constraint -{ - /** - * @var PHPUnit_Framework_Constraint[] - */ - protected $constraints = array(); - - /** - * @param PHPUnit_Framework_Constraint[] $constraints - */ - public function setConstraints(array $constraints) - { - $this->constraints = array(); - - foreach($constraints as $key => $constraint) { - if (!($constraint instanceof PHPUnit_Framework_Constraint)) { - $constraint = new PHPUnit_Framework_Constraint_IsEqual( - $constraint - ); - } - - $this->constraints[] = $constraint; - } - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - public function evaluate($other) - { - $result = FALSE; - - foreach($this->constraints as $constraint) { - if ($constraint->evaluate($other)) { - if ( $result ) - { - return FALSE; - } - - $result = TRUE; - } - } - - return $result; - } - - /** - * Returns a string representation of the constraint. - * - * @return string - */ - public function toString() - { - $text = ''; - - foreach($this->constraints as $key => $constraint) { - if ($key > 0) { - $text .= ' xor '; - } - - $text .= $constraint->toString(); - } - - return $text; - } - - /** - * Counts the number of constraint elements. - * - * @return integer - * @since Method available since Release 3.4.0 - */ - public function count() - { - $count = 0; - - foreach ($this->constraints as $constraint) { - $count += count($constraint); - } - - return $count; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Constraint.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Constraint.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Abstract base class for constraints. which are placed upon any value. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Interface available since Release 3.0.0 - */ -abstract class PHPUnit_Framework_Constraint implements Countable, PHPUnit_Framework_SelfDescribing -{ - /** - * Counts the number of constraint elements. - * - * @return integer - * @since Method available since Release 3.4.0 - */ - public function count() - { - return 1; - } - - /** - * Creates the appropriate exception for the constraint which can be caught - * by the unit test system. This can be called if a call to evaluate() - * fails. - * - * @param mixed $other The value passed to evaluate() which failed the - * constraint check. - * @param string $description A string with extra description of what was - * going on while the evaluation failed. - * @param boolean $not Flag to indicate negation. - * @throws PHPUnit_Framework_ExpectationFailedException - */ - public function fail($other, $description, $not = FALSE) - { - throw new PHPUnit_Framework_ExpectationFailedException( - $this->failureDescription($other, $description, $not), - NULL - ); - } - - /** - * @param mixed $other - * @param string $description - * @param boolean $not - */ - protected function failureDescription($other, $description, $not) - { - $failureDescription = $this->customFailureDescription( - $other, $description, $not - ); - - if ($failureDescription === NULL) { - $failureDescription = sprintf( - 'Failed asserting that %s %s.', - - PHPUnit_Util_Type::toString($other), - $this->toString() - ); - } - - if ($not) { - $failureDescription = self::negate($failureDescription); - } - - if (!empty($description)) { - $failureDescription = $description . "\n" . $failureDescription; - } - - return $failureDescription; - } - - /** - * @param mixed $other - * @param string $description - * @param boolean $not - */ - protected function customFailureDescription($other, $description, $not) - { - } - - /** - * @param string $string - * @return string - */ - public static function negate($string) - { - return str_replace( - array( - 'contains ', - 'exists', - 'has ', - 'is ', - 'matches ', - 'starts with ', - 'ends with ', - 'not not ' - ), - array( - 'does not contain ', - 'does not exist', - 'does not have ', - 'is not ', - 'does not match ', - 'starts not with ', - 'ends not with ', - 'not ' - ), - $string - ); - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other Value or object to evaluate. - * @return bool - */ - abstract public function evaluate($other); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Error/Notice.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Error/Notice.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Error/Notice.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Error/Notice.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Error - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * Wrapper for PHP notices. - * You can disable notice-to-exception conversion by setting - * - * - * PHPUnit_Framework_Error_Notice::$enabled = FALSE; - * - * - * @package PHPUnit - * @subpackage Framework_Error - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Framework_Error_Notice extends PHPUnit_Framework_Error -{ - public static $enabled = TRUE; -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Error/Warning.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Error/Warning.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Error/Warning.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Error/Warning.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Error - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * Wrapper for PHP warnings. - * You can disable notice-to-exception conversion by setting - * - * - * PHPUnit_Framework_Error_Warning::$enabled = FALSE; - * - * - * @package PHPUnit - * @subpackage Framework_Error - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Framework_Error_Warning extends PHPUnit_Framework_Error -{ - public static $enabled = TRUE; -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Error.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Error.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Error.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Error.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.2.0 - */ - -/** - * Wrapper for PHP errors. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.2.0 - */ -class PHPUnit_Framework_Error extends Exception -{ - /** - * Constructor. - * - * @param string $message - * @param integer $code - * @param string $file - * @param integer $line - * @param array $trace - */ - public function __construct($message, $code, $file, $line, $trace) - { - parent::__construct($message, $code); - - $this->file = $file; - $this->line = $line; - $this->trace = $trace; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Exception.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Exception.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Exception.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Exception.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.4.0 - */ - -/** - * Exception for PHPUnit runtime errors. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.4.0 - */ -class PHPUnit_Framework_Exception extends RuntimeException -{ -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ExpectationFailedException.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ExpectationFailedException.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/ExpectationFailedException.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/ExpectationFailedException.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Exception for expectations which failed their check. - * - * The exception contains the error message and optionally a - * PHPUnit_Framework_ComparisonFailure which is used to - * generate diff output of the failed expectations. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_ExpectationFailedException extends PHPUnit_Framework_AssertionFailedError -{ - /** - * @var PHPUnit_Framework_ComparisonFailure - */ - protected $comparisonFailure; - - /** - * @var string - */ - protected $description; - - /** - * @var string - */ - protected $customMessage; - - public function __construct($description, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL, $message = '') - { - $this->description = $description; - $this->comparisonFailure = $comparisonFailure; - $this->customMessage = $message; - - if (!empty($message)) { - $description .= "\n" . $message; - } - - parent::__construct($description); - } - - /** - * @return PHPUnit_Framework_ComparisonFailure - */ - public function getComparisonFailure() - { - return $this->comparisonFailure; - } - - /** - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * @return string - */ - public function getCustomMessage() - { - return $this->customMessage; - } - - /** - * @param string $customMessage - * @since Method available since Release 3.4.0 - */ - public function setCustomMessage($customMessage) - { - $this->customMessage = $customMessage; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/IncompleteTest.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/IncompleteTest.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/IncompleteTest.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/IncompleteTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * A marker interface for marking any exception/error as result of an unit - * test as incomplete implementation or currently not implemented. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Interface available since Release 2.0.0 - */ -interface PHPUnit_Framework_IncompleteTest -{ -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/IncompleteTestError.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/IncompleteTestError.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/IncompleteTestError.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/IncompleteTestError.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * Extension to PHPUnit_Framework_AssertionFailedError to mark the special - * case of an incomplete test. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -class PHPUnit_Framework_IncompleteTestError extends PHPUnit_Framework_AssertionFailedError implements PHPUnit_Framework_IncompleteTest -{ -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Process/TestCaseMethod.tpl.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Process/TestCaseMethod.tpl.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Process/TestCaseMethod.tpl.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Process/TestCaseMethod.tpl.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -collectRawCodeCoverageInformation({collectCodeCoverageInformation}); - $result->strictMode({strict}); - - $test = new {className}('{methodName}', unserialize('{data}'), '{dataName}'); - $test->setDependencyInput(unserialize('{dependencyInput}')); - $test->setInIsolation(TRUE); - - ob_end_clean(); - ob_start(); - $test->run($result); - $output = ob_get_clean(); - - print serialize( - array( - 'testResult' => $test->getResult(), - 'numAssertions' => $test->getNumAssertions(), - 'result' => $result, - 'output' => $output - ) - ); - - ob_start(); -} - -{globals} - -if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP'])) { - require_once $GLOBALS['__PHPUNIT_BOOTSTRAP']; - unset($GLOBALS['__PHPUNIT_BOOTSTRAP']); -} - -{constants} -{included_files} - -__phpunit_run_isolated_test(); -ob_end_clean(); -?> diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/SelfDescribing.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/SelfDescribing.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/SelfDescribing.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/SelfDescribing.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Interface for classes that can return a description of itself. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Interface available since Release 3.0.0 - */ -interface PHPUnit_Framework_SelfDescribing -{ - /** - * Returns a string representation of the object. - * - * @return string - */ - public function toString(); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/SkippedTest.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/SkippedTest.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/SkippedTest.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/SkippedTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * A marker interface for marking a unit test as being skipped. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Interface available since Release 3.0.0 - */ -interface PHPUnit_Framework_SkippedTest -{ -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/SkippedTestError.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/SkippedTestError.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/SkippedTestError.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/SkippedTestError.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Extension to PHPUnit_Framework_AssertionFailedError to mark the special - * case of a skipped test. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Framework_SkippedTestError extends PHPUnit_Framework_AssertionFailedError implements PHPUnit_Framework_SkippedTest -{ -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/SkippedTestSuiteError.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/SkippedTestSuiteError.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/SkippedTestSuiteError.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/SkippedTestSuiteError.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.1.0 - */ - -/** - * Extension to PHPUnit_Framework_AssertionFailedError to mark the special - * case of a skipped test suite. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.1.0 - */ -class PHPUnit_Framework_SkippedTestSuiteError extends PHPUnit_Framework_AssertionFailedError implements PHPUnit_Framework_SkippedTest -{ -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/SyntheticError.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/SyntheticError.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/SyntheticError.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/SyntheticError.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.5.0 - */ - -/** - * Creates a synthetic failed assertion. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.5.0 - */ -class PHPUnit_Framework_SyntheticError extends PHPUnit_Framework_AssertionFailedError -{ - /** - * The synthetic file. - * - * @var string - */ - protected $syntheticFile = ''; - - /** - * The synthetic line number. - * - * @var integer - */ - protected $syntheticLine = 0; - - /** - * The synthetic trace. - * - * @var array - */ - protected $syntheticTrace = array(); - - /** - * Constructor. - * - * @param string $message - * @param integer $code - * @param string $file - * @param integer $line - * @param array $trace - */ - public function __construct($message, $code, $file, $line, $trace) - { - parent::__construct($message, $code); - - $this->syntheticFile = $file; - $this->syntheticLine = $line; - $this->syntheticTrace = $trace; - } - - /** - * @return string - */ - public function getSyntheticFile() - { - return $this->syntheticFile; - } - - /** - * @return integer - */ - public function getSyntheticLine() - { - return $this->syntheticLine; - } - - /** - * @return array - */ - public function getSyntheticTrace() - { - return $this->syntheticTrace; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Test.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Test.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Test.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Test.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * A Test can be run and collect its results. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Interface available since Release 2.0.0 - */ -interface PHPUnit_Framework_Test extends Countable -{ - /** - * Runs a test and collects its result in a TestResult instance. - * - * @param PHPUnit_Framework_TestResult $result - * @return PHPUnit_Framework_TestResult - */ - public function run(PHPUnit_Framework_TestResult $result = NULL); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/TestCase.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/TestCase.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/TestCase.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/TestCase.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,1503 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -require_once 'Text/Template.php'; - -/** - * A TestCase defines the fixture to run multiple tests. - * - * To define a TestCase - * - * 1) Implement a subclass of PHPUnit_Framework_TestCase. - * 2) Define instance variables that store the state of the fixture. - * 3) Initialize the fixture state by overriding setUp(). - * 4) Clean-up after a test by overriding tearDown(). - * - * Each test runs in its own fixture so there can be no side effects - * among test runs. - * - * Here is an example: - * - * - * value1 = 2; - * $this->value2 = 3; - * } - * } - * ?> - * - * - * For each test implement a method which interacts with the fixture. - * Verify the expected results with assertions specified by calling - * assert with a boolean. - * - * - * assertTrue($this->value1 + $this->value2 == 5); - * } - * ?> - * - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -abstract class PHPUnit_Framework_TestCase extends PHPUnit_Framework_Assert implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing -{ - /** - * Enable or disable the backup and restoration of the $GLOBALS array. - * Overwrite this attribute in a child class of TestCase. - * Setting this attribute in setUp() has no effect! - * - * @var boolean - */ - protected $backupGlobals = NULL; - - /** - * @var array - */ - protected $backupGlobalsBlacklist = array(); - - /** - * Enable or disable the backup and restoration of static attributes. - * Overwrite this attribute in a child class of TestCase. - * Setting this attribute in setUp() has no effect! - * - * @var boolean - */ - protected $backupStaticAttributes = NULL; - - /** - * @var array - */ - protected $backupStaticAttributesBlacklist = array(); - - /** - * Whether or not this test is to be run in a separate PHP process. - * - * @var boolean - */ - protected $runTestInSeparateProcess = NULL; - - /** - * Whether or not this test should preserve the global state when - * running in a separate PHP process. - * - * @var boolean - */ - protected $preserveGlobalState = TRUE; - - /** - * Whether or not this test is running in a separate PHP process. - * - * @var boolean - */ - protected $inIsolation = FALSE; - - /** - * @var array - */ - protected $data = array(); - - /** - * @var string - */ - protected $dataName = ''; - - /** - * @var boolean - */ - protected $useErrorHandler = NULL; - - /** - * @var boolean - */ - protected $useOutputBuffering = NULL; - - /** - * The name of the expected Exception. - * - * @var mixed - */ - protected $expectedException = NULL; - - /** - * The message of the expected Exception. - * - * @var string - */ - protected $expectedExceptionMessage = ''; - - /** - * The code of the expected Exception. - * - * @var integer - */ - protected $expectedExceptionCode; - - /** - * The stack trace to where the expected exception was set. - * - * @var array - */ - protected $expectedExceptionTrace = array(); - - /** - * The name of the test case. - * - * @var string - */ - protected $name = NULL; - - /** - * @var array - */ - protected $dependencies = array(); - - /** - * @var array - */ - protected $dependencyInput = array(); - - /** - * @var string - */ - protected $exceptionMessage = NULL; - - /** - * @var integer - */ - protected $exceptionCode = 0; - - /** - * @var Array - */ - protected $iniSettings = array(); - - /** - * @var Array - */ - protected $locale = array(); - - /** - * @var Array - */ - protected $mockObjects = array(); - - /** - * @var integer - */ - protected $status; - - /** - * @var string - */ - protected $statusMessage = ''; - - /** - * @var integer - */ - protected $numAssertions = 0; - - /** - * @var PHPUnit_Framework_TestResult - */ - protected $result; - - /** - * @var mixed - */ - protected $testResult; - - /** - * Constructs a test case with the given name. - * - * @param string $name - * @param array $data - * @param string $dataName - */ - public function __construct($name = NULL, array $data = array(), $dataName = '') - { - if ($name !== NULL) { - $this->setName($name); - } - - $this->data = $data; - $this->dataName = $dataName; - } - - /** - * Returns a string representation of the test case. - * - * @return string - */ - public function toString() - { - $class = new ReflectionClass($this); - - $buffer = sprintf( - '%s::%s', - - $class->name, - $this->getName(FALSE) - ); - - return $buffer . $this->getDataSetAsString(); - } - - /** - * Counts the number of test cases executed by run(TestResult result). - * - * @return integer - */ - public function count() - { - return 1; - } - - /** - * Returns the annotations for this test. - * - * @return array - * @since Method available since Release 3.4.0 - */ - public function getAnnotations() - { - return PHPUnit_Util_Test::parseTestMethodAnnotations( - get_class($this), $this->name - ); - } - - /** - * Gets the name of a TestCase. - * - * @param boolean $withDataSet - * @return string - */ - public function getName($withDataSet = TRUE) - { - if ($withDataSet) { - return $this->name . $this->getDataSetAsString(FALSE); - } else { - return $this->name; - } - } - - /** - * @return string - * @since Method available since Release 3.2.0 - */ - public function getExpectedException() - { - return $this->expectedException; - } - - /** - * @param mixed $exceptionName - * @param string $exceptionMessage - * @param integer $exceptionCode - * @since Method available since Release 3.2.0 - */ - public function setExpectedException($exceptionName, $exceptionMessage = '', $exceptionCode = 0) - { - $this->expectedException = $exceptionName; - $this->expectedExceptionMessage = $exceptionMessage; - $this->expectedExceptionCode = $exceptionCode; - $this->expectedExceptionTrace = debug_backtrace(); - } - - /** - * @since Method available since Release 3.4.0 - */ - protected function setExpectedExceptionFromAnnotation() - { - try { - $expectedException = PHPUnit_Util_Test::getExpectedException( - get_class($this), $this->name - ); - - if ($expectedException !== FALSE) { - $this->setExpectedException( - $expectedException['class'], - $expectedException['message'], - $expectedException['code'] - ); - } - } - - catch (ReflectionException $e) { - } - } - - /** - * @param boolean $useErrorHandler - * @since Method available since Release 3.4.0 - */ - public function setUseErrorHandler($useErrorHandler) - { - $this->useErrorHandler = $useErrorHandler; - } - - /** - * @since Method available since Release 3.4.0 - */ - protected function setUseErrorHandlerFromAnnotation() - { - try { - $useErrorHandler = PHPUnit_Util_Test::getErrorHandlerSettings( - get_class($this), $this->name - ); - - if ($useErrorHandler !== NULL) { - $this->setUseErrorHandler($useErrorHandler); - } - } - - catch (ReflectionException $e) { - } - } - - /** - * @param boolean $useOutputBuffering - * @since Method available since Release 3.4.0 - */ - public function setUseOutputBuffering($useOutputBuffering) - { - $this->useOutputBuffering = $useOutputBuffering; - } - - /** - * @since Method available since Release 3.4.0 - */ - protected function setUseOutputBufferingFromAnnotation() - { - try { - $useOutputBuffering = PHPUnit_Util_Test::getOutputBufferingSettings( - get_class($this), $this->name - ); - - if ($useOutputBuffering !== NULL) { - $this->setUseOutputBuffering($useOutputBuffering); - } - } - - catch (ReflectionException $e) { - } - } - - /** - * Returns the status of this test. - * - * @return integer - * @since Method available since Release 3.1.0 - */ - public function getStatus() - { - return $this->status; - } - - /** - * Returns the status message of this test. - * - * @return string - * @since Method available since Release 3.3.0 - */ - public function getStatusMessage() - { - return $this->statusMessage; - } - - /** - * Returns whether or not this test has failed. - * - * @return boolean - * @since Method available since Release 3.0.0 - */ - public function hasFailed() - { - $status = $this->getStatus(); - - return $status == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE || - $status == PHPUnit_Runner_BaseTestRunner::STATUS_ERROR; - } - - /** - * Runs the test case and collects the results in a TestResult object. - * If no TestResult object is passed a new one will be created. - * - * @param PHPUnit_Framework_TestResult $result - * @return PHPUnit_Framework_TestResult - * @throws InvalidArgumentException - */ - public function run(PHPUnit_Framework_TestResult $result = NULL) - { - if ($result === NULL) { - $result = $this->createResult(); - } - - $this->result = $result; - - $this->setExpectedExceptionFromAnnotation(); - $this->setUseErrorHandlerFromAnnotation(); - $this->setUseOutputBufferingFromAnnotation(); - - if ($this->useErrorHandler !== NULL) { - $oldErrorHandlerSetting = $result->getConvertErrorsToExceptions(); - $result->convertErrorsToExceptions($this->useErrorHandler); - } - - if (!$this->handleDependencies()) { - return; - } - - if ($this->runTestInSeparateProcess === TRUE && - $this->inIsolation !== TRUE && - !$this instanceof PHPUnit_Extensions_SeleniumTestCase && - !$this instanceof PHPUnit_Extensions_PhptTestCase) { - $class = new ReflectionClass($this); - - $template = new Text_Template( - sprintf( - '%s%sProcess%sTestCaseMethod.tpl', - - dirname(__FILE__), - DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR - ) - ); - - if ($this->preserveGlobalState) { - $constants = PHPUnit_Util_GlobalState::getConstantsAsString(); - $globals = PHPUnit_Util_GlobalState::getGlobalsAsString(); - $includedFiles = PHPUnit_Util_GlobalState::getIncludedFilesAsString(); - } else { - $constants = ''; - $globals = ''; - $includedFiles = ''; - } - - if ($result->getCollectCodeCoverageInformation()) { - $coverage = 'TRUE'; - } else { - $coverage = 'FALSE'; - } - - if ($result->isStrict()) { - $strict = 'TRUE'; - } else { - $strict = 'FALSE'; - } - - $data = addcslashes(serialize($this->data), "'"); - $dependencyInput = addcslashes( - serialize($this->dependencyInput), "'" - ); - $includePath = addslashes(get_include_path()); - - $template->setVar( - array( - 'filename' => $class->getFileName(), - 'className' => $class->getName(), - 'methodName' => $this->name, - 'collectCodeCoverageInformation' => $coverage, - 'data' => $data, - 'dataName' => $this->dataName, - 'dependencyInput' => $dependencyInput, - 'constants' => $constants, - 'globals' => $globals, - 'include_path' => $includePath, - 'included_files' => $includedFiles, - 'strict' => $strict - ) - ); - - $this->prepareTemplate($template); - - PHPUnit_Util_PHP::runJob($template->render(), $this, $result); - } else { - $result->run($this); - } - - if ($this->useErrorHandler !== NULL) { - $result->convertErrorsToExceptions($oldErrorHandlerSetting); - } - - $this->result = NULL; - - return $result; - } - - /** - * Runs the bare test sequence. - */ - public function runBare() - { - $this->numAssertions = 0; - - // Backup the $GLOBALS array and static attributes. - if ($this->runTestInSeparateProcess !== TRUE && - $this->inIsolation !== TRUE) { - if ($this->backupGlobals === NULL || - $this->backupGlobals === TRUE) { - PHPUnit_Util_GlobalState::backupGlobals( - $this->backupGlobalsBlacklist - ); - } - - if (version_compare(PHP_VERSION, '5.3', '>') && - $this->backupStaticAttributes === TRUE) { - PHPUnit_Util_GlobalState::backupStaticAttributes( - $this->backupStaticAttributesBlacklist - ); - } - } - - // Start output buffering. - if ($this->useOutputBuffering === TRUE) { - ob_start(); - } - - // Clean up stat cache. - clearstatcache(); - - try { - if ($this->inIsolation) { - $this->setUpBeforeClass(); - } - - $this->setUp(); - $this->assertPreConditions(); - $this->testResult = $this->runTest(); - $this->verifyMockObjects(); - $this->assertPostConditions(); - $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_PASSED; - } - - catch (PHPUnit_Framework_IncompleteTest $e) { - $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE; - $this->statusMessage = $e->getMessage(); - } - - catch (PHPUnit_Framework_SkippedTest $e) { - $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED; - $this->statusMessage = $e->getMessage(); - } - - catch (PHPUnit_Framework_AssertionFailedError $e) { - $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE; - $this->statusMessage = $e->getMessage(); - } - - catch (Exception $e) { - $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_ERROR; - $this->statusMessage = $e->getMessage(); - } - - // Tear down the fixture. An exception raised in tearDown() will be - // caught and passed on when no exception was raised before. - try { - $this->tearDown(); - - if ($this->inIsolation) { - $this->tearDownAfterClass(); - } - } - - catch (Exception $_e) { - if (!isset($e)) { - $e = $_e; - } - } - - // Stop output buffering. - if ($this->useOutputBuffering === TRUE) { - ob_end_clean(); - } - - // Clean up stat cache. - clearstatcache(); - - // Restore the $GLOBALS array and static attributes. - if ($this->runTestInSeparateProcess !== TRUE && - $this->inIsolation !== TRUE) { - if ($this->backupGlobals === NULL || - $this->backupGlobals === TRUE) { - PHPUnit_Util_GlobalState::restoreGlobals( - $this->backupGlobalsBlacklist - ); - } - - if (version_compare(PHP_VERSION, '5.3', '>') && - $this->backupStaticAttributes === TRUE) { - PHPUnit_Util_GlobalState::restoreStaticAttributes(); - } - } - - // Clean up INI settings. - foreach ($this->iniSettings as $varName => $oldValue) { - ini_set($varName, $oldValue); - } - - $this->iniSettings = array(); - - // Clean up locale settings. - foreach ($this->locale as $category => $locale) { - setlocale($category, $locale); - } - - // Workaround for missing "finally". - if (isset($e)) { - $this->onNotSuccessfulTest($e); - } - } - - /** - * Override to run the test and assert its state. - * - * @return mixed - * @throws RuntimeException - */ - protected function runTest() - { - if ($this->name === NULL) { - throw new PHPUnit_Framework_Exception( - 'PHPUnit_Framework_TestCase::$name must not be NULL.' - ); - } - - try { - $class = new ReflectionClass($this); - $method = $class->getMethod($this->name); - } - - catch (ReflectionException $e) { - $this->fail($e->getMessage()); - } - - try { - $testResult = $method->invokeArgs( - $this, array_merge($this->data, $this->dependencyInput) - ); - } - - catch (Exception $e) { - if (!$e instanceof PHPUnit_Framework_IncompleteTest && - !$e instanceof PHPUnit_Framework_SkippedTest && - is_string($this->expectedException) && - $e instanceof $this->expectedException) { - if (is_string($this->expectedExceptionMessage) && - !empty($this->expectedExceptionMessage)) { - $this->assertContains( - $this->expectedExceptionMessage, - $e->getMessage() - ); - } - - if (is_int($this->expectedExceptionCode) && - $this->expectedExceptionCode !== 0) { - $this->assertEquals( - $this->expectedExceptionCode, $e->getCode() - ); - } - - $this->numAssertions++; - - return; - } else { - throw $e; - } - } - - if ($this->expectedException !== NULL) { - $this->numAssertions++; - - $this->syntheticFail( - 'Expected exception ' . $this->expectedException, - '', - 0, - $this->expectedExceptionTrace - ); - } - - return $testResult; - } - - /** - * Verifies the mock object expectations. - * - * @since Method available since Release 3.5.0 - */ - protected function verifyMockObjects() - { - foreach ($this->mockObjects as $mockObject) { - $this->numAssertions++; - $mockObject->__phpunit_verify(); - $mockObject->__phpunit_cleanup(); - } - - $this->mockObjects = array(); - } - - /** - * Sets the name of a TestCase. - * - * @param string - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * Sets the dependencies of a TestCase. - * - * @param array $dependencies - * @since Method available since Release 3.4.0 - */ - public function setDependencies(array $dependencies) - { - $this->dependencies = $dependencies; - } - - /** - * Sets - * - * @param array $dependencyInput - * @since Method available since Release 3.4.0 - */ - public function setDependencyInput(array $dependencyInput) - { - $this->dependencyInput = $dependencyInput; - } - - /** - * Calling this method in setUp() has no effect! - * - * @param boolean $backupGlobals - * @since Method available since Release 3.3.0 - */ - public function setBackupGlobals($backupGlobals) - { - if (is_null($this->backupGlobals) && is_bool($backupGlobals)) { - $this->backupGlobals = $backupGlobals; - } - } - - /** - * Calling this method in setUp() has no effect! - * - * @param boolean $backupStaticAttributes - * @since Method available since Release 3.4.0 - */ - public function setBackupStaticAttributes($backupStaticAttributes) - { - if (is_null($this->backupStaticAttributes) && - is_bool($backupStaticAttributes)) { - $this->backupStaticAttributes = $backupStaticAttributes; - } - } - - /** - * @param boolean $runTestInSeparateProcess - * @throws InvalidArgumentException - * @since Method available since Release 3.4.0 - */ - public function setRunTestInSeparateProcess($runTestInSeparateProcess) - { - if (is_bool($runTestInSeparateProcess)) { - if ($this->runTestInSeparateProcess === NULL) { - $this->runTestInSeparateProcess = $runTestInSeparateProcess; - } - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); - } - } - - /** - * @param boolean $preserveGlobalState - * @throws InvalidArgumentException - * @since Method available since Release 3.4.0 - */ - public function setPreserveGlobalState($preserveGlobalState) - { - if (is_bool($preserveGlobalState)) { - $this->preserveGlobalState = $preserveGlobalState; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); - } - } - - /** - * @param boolean $inIsolation - * @throws InvalidArgumentException - * @since Method available since Release 3.4.0 - */ - public function setInIsolation($inIsolation) - { - if (is_bool($inIsolation)) { - $this->inIsolation = $inIsolation; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); - } - } - - /** - * @return mixed - * @since Method available since Release 3.4.0 - */ - public function getResult() - { - return $this->testResult; - } - - /** - * @param mixed $result - * @since Method available since Release 3.4.0 - */ - public function setResult($result) - { - $this->testResult = $result; - } - - /** - * This method is a wrapper for the ini_set() function that automatically - * resets the modified php.ini setting to its original value after the - * test is run. - * - * @param string $varName - * @param string $newValue - * @throws InvalidArgumentException - * @throws RuntimeException - * @since Method available since Release 3.0.0 - */ - protected function iniSet($varName, $newValue) - { - if (!is_string($varName)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - $currentValue = ini_set($varName, $newValue); - - if ($currentValue !== FALSE) { - $this->iniSettings[$varName] = $currentValue; - } else { - throw new PHPUnit_Framework_Exception( - sprintf( - 'INI setting "%s" could not be set to "%s".', - $varName, - $newValue - ) - ); - } - } - - /** - * This method is a wrapper for the setlocale() function that automatically - * resets the locale to its original value after the test is run. - * - * @param integer $category - * @param string $locale - * @throws InvalidArgumentException - * @throws RuntimeException - * @since Method available since Release 3.1.0 - */ - protected function setLocale() - { - $args = func_get_args(); - - if (count($args) < 2) { - throw new InvalidArgumentException; - } - - $category = $args[0]; - $locale = $args[1]; - - $categories = array( - LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME - ); - - if (defined('LC_MESSAGES')) { - $categories[] = LC_MESSAGES; - } - - if (!in_array($category, $categories)) { - throw new InvalidArgumentException; - } - - if (!is_array($locale) && !is_string($locale)) { - throw new InvalidArgumentException; - } - - $this->locale[$category] = setlocale($category, NULL); - - $result = call_user_func_array( 'setlocale', $args ); - - if ($result === FALSE) { - throw new PHPUnit_Framework_Exception( - 'The locale functionality is not implemented on your platform, ' . - 'the specified locale does not exist or the category name is ' . - 'invalid.' - ); - } - } - - /** - * Returns a mock object for the specified class. - * - * @param string $originalClassName - * @param array $methods - * @param array $arguments - * @param string $mockClassName - * @param boolean $callOriginalConstructor - * @param boolean $callOriginalClone - * @param boolean $callAutoload - * @return PHPUnit_Framework_MockObject_MockObject - * @throws InvalidArgumentException - * @since Method available since Release 3.0.0 - */ - public function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE) - { - $mockObject = PHPUnit_Framework_MockObject_Generator::getMock( - $originalClassName, - $methods, - $arguments, - $mockClassName, - $callOriginalConstructor, - $callOriginalClone, - $callAutoload - ); - - $this->mockObjects[] = $mockObject; - - return $mockObject; - } - - /** - * Returns a builder object to create mock objects using a fluent interface. - * - * @param string $className - * @return PHPUnit_Framework_MockObject_MockBuilder - * @since Method available since Release 3.5.0 - */ - public function getMockBuilder($className) - { - return new PHPUnit_Framework_MockObject_MockBuilder( - $this, $className - ); - } - - /** - * Mocks the specified class and returns the name of the mocked class. - * - * @param string $originalClassName - * @param array $methods - * @param array $arguments - * @param string $mockClassName - * @param boolean $callOriginalConstructor - * @param boolean $callOriginalClone - * @param boolean $callAutoload - * @return string - * @throws InvalidArgumentException - * @since Method available since Release 3.5.0 - */ - protected function getMockClass($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = FALSE, $callOriginalClone = TRUE, $callAutoload = TRUE) - { - $mock = $this->getMock( - $originalClassName, - $methods, - $arguments, - $mockClassName, - $callOriginalConstructor, - $callOriginalClone, - $callAutoload - ); - - return get_class($mock); - } - - /** - * Returns a mock object for the specified abstract class with all abstract - * methods of the class mocked. Concrete methods are not mocked. - * - * @param string $originalClassName - * @param array $arguments - * @param string $mockClassName - * @param boolean $callOriginalConstructor - * @param boolean $callOriginalClone - * @param boolean $callAutoload - * @return PHPUnit_Framework_MockObject_MockObject - * @since Method available since Release 3.4.0 - * @throws InvalidArgumentException - */ - public function getMockForAbstractClass($originalClassName, array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE) - { - $mockObject = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass( - $originalClassName, - $arguments, - $mockClassName, - $callOriginalConstructor, - $callOriginalClone, - $callAutoload - ); - - $this->mockObjects[] = $mockObject; - - return $mockObject; - } - - /** - * Returns a mock object based on the given WSDL file. - * - * @param string $wsdlFile - * @param string $originalClassName - * @param string $mockClassName - * @param array $methods - * @param boolean $callOriginalConstructor - * @return PHPUnit_Framework_MockObject_MockObject - * @since Method available since Release 3.4.0 - */ - protected function getMockFromWsdl($wsdlFile, $originalClassName = '', $mockClassName = '', array $methods = array(), $callOriginalConstructor = TRUE) - { - if ($originalClassName === '') { - $originalClassName = str_replace( - '.wsdl', '', basename($wsdlFile) - ); - } - - eval( - PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl( - $wsdlFile, $originalClassName, $methods - ) - ); - - return $this->getMock( - $originalClassName, - $methods, - array('', array()), - $mockClassName, - $callOriginalConstructor, - FALSE, - FALSE - ); - } - - /** - * Adds a value to the assertion counter. - * - * @param integer $count - * @since Method available since Release 3.3.3 - */ - public function addToAssertionCount($count) - { - $this->numAssertions += $count; - } - - /** - * Returns the number of assertions performed by this test. - * - * @return integer - * @since Method available since Release 3.3.0 - */ - public function getNumAssertions() - { - return $this->numAssertions; - } - - /** - * Returns a matcher that matches when the method it is evaluated for - * is executed zero or more times. - * - * @return PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount - * @since Method available since Release 3.0.0 - */ - public static function any() - { - return new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount; - } - - /** - * Returns a matcher that matches when the method it is evaluated for - * is never executed. - * - * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount - * @since Method available since Release 3.0.0 - */ - public static function never() - { - return new PHPUnit_Framework_MockObject_Matcher_InvokedCount(0); - } - - /** - * Returns a matcher that matches when the method it is evaluated for - * is executed at least once. - * - * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce - * @since Method available since Release 3.0.0 - */ - public static function atLeastOnce() - { - return new PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce; - } - - /** - * Returns a matcher that matches when the method it is evaluated for - * is executed exactly once. - * - * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount - * @since Method available since Release 3.0.0 - */ - public static function once() - { - return new PHPUnit_Framework_MockObject_Matcher_InvokedCount(1); - } - - /** - * Returns a matcher that matches when the method it is evaluated for - * is executed exactly $count times. - * - * @param integer $count - * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount - * @since Method available since Release 3.0.0 - */ - public static function exactly($count) - { - return new PHPUnit_Framework_MockObject_Matcher_InvokedCount($count); - } - - /** - * Returns a matcher that matches when the method it is evaluated for - * is invoked at the given $index. - * - * @param integer $index - * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex - * @since Method available since Release 3.0.0 - */ - public static function at($index) - { - return new PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex($index); - } - - /** - * - * - * @param mixed $value - * @return PHPUnit_Framework_MockObject_Stub_Return - * @since Method available since Release 3.0.0 - */ - public static function returnValue($value) - { - return new PHPUnit_Framework_MockObject_Stub_Return($value); - } - - /** - * - * - * @param integer $argumentIndex - * @return PHPUnit_Framework_MockObject_Stub_ReturnArgument - * @since Method available since Release 3.3.0 - */ - public static function returnArgument($argumentIndex) - { - return new PHPUnit_Framework_MockObject_Stub_ReturnArgument( - $argumentIndex - ); - } - - /** - * - * - * @param mixed $callback - * @return PHPUnit_Framework_MockObject_Stub_ReturnCallback - * @since Method available since Release 3.3.0 - */ - public static function returnCallback($callback) - { - return new PHPUnit_Framework_MockObject_Stub_ReturnCallback($callback); - } - - /** - * - * - * @param Exception $exception - * @return PHPUnit_Framework_MockObject_Stub_Exception - * @since Method available since Release 3.1.0 - */ - public static function throwException(Exception $exception) - { - return new PHPUnit_Framework_MockObject_Stub_Exception($exception); - } - - /** - * - * - * @param mixed $value, ... - * @return PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls - * @since Method available since Release 3.0.0 - */ - public static function onConsecutiveCalls() - { - $args = func_get_args(); - - return new PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls($args); - } - - /** - * @param mixed $data - * @return string - * @since Method available since Release 3.2.1 - */ - protected function dataToString($data) - { - $result = array(); - - foreach ($data as $_data) { - if (is_array($_data)) { - $result[] = 'array(' . $this->dataToString($_data) . ')'; - } - - else if (is_object($_data)) { - $object = new ReflectionObject($_data); - - if ($object->hasMethod('__toString')) { - $result[] = (string)$_data; - } else { - $result[] = get_class($_data); - } - } - - else if (is_resource($_data)) { - $result[] = ''; - } - - else { - $result[] = var_export($_data, TRUE); - } - } - - return join(', ', $result); - } - - /** - * Gets the data set description of a TestCase. - * - * @param boolean $includeData - * @return string - * @since Method available since Release 3.3.0 - */ - protected function getDataSetAsString($includeData = TRUE) - { - $buffer = ''; - - if (!empty($this->data)) { - if (is_int($this->dataName)) { - $buffer .= sprintf(' with data set #%d', $this->dataName); - } else { - $buffer .= sprintf(' with data set "%s"', $this->dataName); - } - - if ($includeData) { - $buffer .= sprintf(' (%s)', $this->dataToString($this->data)); - } - } - - return $buffer; - } - - /** - * Creates a default TestResult object. - * - * @return PHPUnit_Framework_TestResult - */ - protected function createResult() - { - return new PHPUnit_Framework_TestResult; - } - - /** - * @since Method available since Release 3.5.4 - */ - protected function handleDependencies() - { - if (!empty($this->dependencies) && !$this->inIsolation) { - $className = get_class($this); - $passed = $this->result->passed(); - $passedKeys = array_keys($passed); - $numKeys = count($passedKeys); - - for ($i = 0; $i < $numKeys; $i++) { - $pos = strpos($passedKeys[$i], ' with data set'); - - if ($pos !== FALSE) { - $passedKeys[$i] = substr($passedKeys[$i], 0, $pos); - } - } - - $passedKeys = array_flip(array_unique($passedKeys)); - - foreach ($this->dependencies as $dependency) { - if (strpos($dependency, '::') === FALSE) { - $dependency = $className . '::' . $dependency; - } - - if (!isset($passedKeys[$dependency])) { - $this->result->addError( - $this, - new PHPUnit_Framework_SkippedTestError( - sprintf( - 'This test depends on "%s" to pass.', $dependency - ) - ), - 0 - ); - - return FALSE; - } else { - if (isset($passed[$dependency])) { - $this->dependencyInput[] = $passed[$dependency]; - } else { - $this->dependencyInput[] = NULL; - } - } - } - } - - return TRUE; - } - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - */ - protected function setUp() - { - } - - /** - * Performs assertions shared by all tests of a test case. - * - * This method is called before the execution of a test starts - * and after setUp() is called. - * - * @since Method available since Release 3.2.8 - */ - protected function assertPreConditions() - { - } - - /** - * Performs assertions shared by all tests of a test case. - * - * This method is called before the execution of a test ends - * and before tearDown() is called. - * - * @since Method available since Release 3.2.8 - */ - protected function assertPostConditions() - { - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } - - /** - * This method is called after the last test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function tearDownAfterClass() - { - } - - /** - * This method is called when a test method did not execute successfully. - * - * @param Exception $e - * @since Method available since Release 3.4.0 - */ - protected function onNotSuccessfulTest(Exception $e) - { - throw $e; - } - - /** - * Performs custom preparations on the process isolation template. - * - * @param Text_Template $template - * @since Method available since Release 3.4.0 - */ - protected function prepareTemplate(Text_Template $template) - { - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/TestFailure.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/TestFailure.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/TestFailure.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/TestFailure.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,228 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * A TestFailure collects a failed test together with the caught exception. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -class PHPUnit_Framework_TestFailure -{ - /** - * @var PHPUnit_Framework_Test - */ - protected $failedTest; - - /** - * @var Exception - */ - protected $thrownException; - - /** - * Constructs a TestFailure with the given test and exception. - * - * @param PHPUnit_Framework_Test $failedTest - * @param Exception $thrownException - */ - public function __construct(PHPUnit_Framework_Test $failedTest, Exception $thrownException) - { - $this->failedTest = $failedTest; - $this->thrownException = $thrownException; - } - - /** - * Returns a short description of the failure. - * - * @return string - */ - public function toString() - { - return sprintf( - '%s: %s', - - $this->failedTest, - $this->thrownException->getMessage() - ); - } - - /** - * Returns a description for the thrown exception. - * - * @return string - * @since Method available since Release 3.4.0 - */ - public function getExceptionAsString() - { - return self::exceptionToString($this->thrownException); - } - - /** - * Returns a description for an exception. - * - * @param Exception $e - * @return string - * @since Method available since Release 3.2.0 - */ - public static function exceptionToString(Exception $e) - { - if ($e instanceof PHPUnit_Framework_SelfDescribing) { - if ($e instanceof PHPUnit_Framework_ExpectationFailedException) { - $comparisonFailure = $e->getComparisonFailure(); - $description = $e->getDescription(); - $message = $e->getCustomMessage(); - - if ($message == '') { - $buffer = ''; - } else { - $buffer = $message . "\n"; - } - - if ($comparisonFailure !== NULL) { - if ($comparisonFailure->identical()) { - if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Object) { - $buffer .= 'Failed asserting that two variables ' . - "reference the same object.\n"; - } else { - $buffer .= $comparisonFailure->toString() . "\n"; - } - } else { - if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Scalar) { - $buffer .= $comparisonFailure->toString() . "\n"; - } - - else if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Array || - $comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Object || - $comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_String) { - $buffer .= sprintf( - "Failed asserting that two %ss are equal.\n%s\n", - - strtolower( - substr(get_class($comparisonFailure), 36) - ), - $comparisonFailure->toString() - ); - } - } - } else { - $buffer .= $e->toString(); - - if (!empty($buffer)) { - $buffer .= "\n"; - } - - if (strpos($buffer, $description) === FALSE) { - $buffer .= $description . "\n"; - } - } - } - - else { - $buffer = $e->toString(); - - if (!empty($buffer)) { - $buffer .= "\n"; - } - } - } - - else if ($e instanceof PHPUnit_Framework_Error) { - $buffer = $e->getMessage() . "\n"; - } - - else { - $buffer = get_class($e) . ': ' . $e->getMessage() . "\n"; - } - - return $buffer; - } - - /** - * Gets the failed test. - * - * @return Test - */ - public function failedTest() - { - return $this->failedTest; - } - - /** - * Gets the thrown exception. - * - * @return Exception - */ - public function thrownException() - { - return $this->thrownException; - } - - /** - * Returns the exception's message. - * - * @return string - */ - public function exceptionMessage() - { - return $this->thrownException()->getMessage(); - } - - /** - * Returns TRUE if the thrown exception - * is of type AssertionFailedError. - * - * @return boolean - */ - public function isFailure() - { - return ($this->thrownException() instanceof PHPUnit_Framework_AssertionFailedError); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/TestListener.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/TestListener.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/TestListener.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/TestListener.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * A Listener for test progress. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Interface available since Release 2.0.0 - */ -interface PHPUnit_Framework_TestListener -{ - /** - * An error occurred. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time); - - /** - * A failure occurred. - * - * @param PHPUnit_Framework_Test $test - * @param PHPUnit_Framework_AssertionFailedError $e - * @param float $time - */ - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time); - - /** - * Incomplete test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time); - - /** - * Skipped test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - * @since Method available since Release 3.0.0 - */ - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time); - - /** - * A test suite started. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit_Framework_TestSuite $suite); - - /** - * A test suite ended. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit_Framework_TestSuite $suite); - - /** - * A test started. - * - * @param PHPUnit_Framework_Test $test - */ - public function startTest(PHPUnit_Framework_Test $test); - - /** - * A test ended. - * - * @param PHPUnit_Framework_Test $test - * @param float $time - */ - public function endTest(PHPUnit_Framework_Test $test, $time); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/TestResult.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/TestResult.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/TestResult.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/TestResult.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,867 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -require_once 'PHP/CodeCoverage.php'; -require_once 'PHP/Timer.php'; - -/** - * A TestResult collects the results of executing a test case. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -class PHPUnit_Framework_TestResult implements Countable -{ - /** - * @var boolean - */ - protected static $xdebugLoaded = NULL; - - /** - * @var boolean - */ - protected static $useXdebug = NULL; - - /** - * @var array - */ - protected $passed = array(); - - /** - * @var array - */ - protected $errors = array(); - - /** - * @var array - */ - protected $failures = array(); - - /** - * @var array - */ - protected $notImplemented = array(); - - /** - * @var array - */ - protected $skipped = array(); - - /** - * @var array - */ - protected $listeners = array(); - - /** - * @var integer - */ - protected $runTests = 0; - - /** - * @var float - */ - protected $time = 0; - - /** - * @var PHPUnit_Framework_TestSuite - */ - protected $topTestSuite = NULL; - - /** - * Code Coverage information. - * - * @var array - */ - protected $codeCoverage; - - /** - * @var boolean - */ - protected $collectCodeCoverageInformation = FALSE; - - /** - * @var boolean - */ - protected $collectRawCodeCoverageInformation = FALSE; - - /** - * @var array - */ - protected $rawCodeCoverageInformation = array(); - - /** - * @var boolean - */ - protected $convertErrorsToExceptions = TRUE; - - /** - * @var boolean - */ - protected $stop = FALSE; - - /** - * @var boolean - */ - protected $stopOnError = FALSE; - - /** - * @var boolean - */ - protected $stopOnFailure = FALSE; - - /** - * @var boolean - */ - protected $strictMode = FALSE; - - /** - * @var boolean - */ - protected $stopOnIncomplete = FALSE; - - /** - * @var boolean - */ - protected $stopOnSkipped = FALSE; - - /** - * @var boolean - */ - protected $lastTestFailed = FALSE; - - /** - * @param PHP_CodeCoverage $codeCoverage - */ - public function __construct(PHP_CodeCoverage $codeCoverage = NULL) - { - if ($codeCoverage === NULL) { - $codeCoverage = PHP_CodeCoverage::getInstance(); - } - - $this->codeCoverage = $codeCoverage; - } - - /** - * Registers a TestListener. - * - * @param PHPUnit_Framework_TestListener - */ - public function addListener(PHPUnit_Framework_TestListener $listener) - { - $this->listeners[] = $listener; - } - - /** - * Unregisters a TestListener. - * - * @param PHPUnit_Framework_TestListener $listener - */ - public function removeListener(PHPUnit_Framework_TestListener $listener) - { - foreach ($this->listeners as $key => $_listener) { - if ($listener === $_listener) { - unset($this->listeners[$key]); - } - } - } - - /** - * Flushes all flushable TestListeners. - * - * @since Method available since Release 3.0.0 - */ - public function flushListeners() - { - foreach ($this->listeners as $listener) { - if ($listener instanceof PHPUnit_Util_Printer) { - $listener->flush(); - } - } - } - - /** - * Adds an error to the list of errors. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - if ($e instanceof PHPUnit_Framework_IncompleteTest) { - $this->notImplemented[] = new PHPUnit_Framework_TestFailure( - $test, $e - ); - - $notifyMethod = 'addIncompleteTest'; - - if ($this->stopOnIncomplete) { - $this->stop(); - } - } - - else if ($e instanceof PHPUnit_Framework_SkippedTest) { - $this->skipped[] = new PHPUnit_Framework_TestFailure($test, $e); - $notifyMethod = 'addSkippedTest'; - - if ($this->stopOnSkipped) { - $this->stop(); - } - } - - else { - $this->errors[] = new PHPUnit_Framework_TestFailure($test, $e); - $notifyMethod = 'addError'; - - if ($this->stopOnError || $this->stopOnFailure) { - $this->stop(); - } - } - - foreach ($this->listeners as $listener) { - $listener->$notifyMethod($test, $e, $time); - } - - $this->lastTestFailed = TRUE; - $this->time += $time; - } - - /** - * Adds a failure to the list of failures. - * The passed in exception caused the failure. - * - * @param PHPUnit_Framework_Test $test - * @param PHPUnit_Framework_AssertionFailedError $e - * @param float $time - */ - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) - { - if ($e instanceof PHPUnit_Framework_IncompleteTest) { - $this->notImplemented[] = new PHPUnit_Framework_TestFailure( - $test, $e - ); - - $notifyMethod = 'addIncompleteTest'; - - if ($this->stopOnIncomplete) { - $this->stop(); - } - } - - else if ($e instanceof PHPUnit_Framework_SkippedTest) { - $this->skipped[] = new PHPUnit_Framework_TestFailure($test, $e); - $notifyMethod = 'addSkippedTest'; - - if ($this->stopOnSkipped) { - $this->stop(); - } - } - - else { - $this->failures[] = new PHPUnit_Framework_TestFailure($test, $e); - $notifyMethod = 'addFailure'; - - if ($this->stopOnFailure) { - $this->stop(); - } - } - - foreach ($this->listeners as $listener) { - $listener->$notifyMethod($test, $e, $time); - } - - $this->lastTestFailed = TRUE; - $this->time += $time; - } - - /** - * Informs the result that a testsuite will be started. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - if ($this->topTestSuite === NULL) { - $this->topTestSuite = $suite; - } - - foreach ($this->listeners as $listener) { - $listener->startTestSuite($suite); - } - } - - /** - * Informs the result that a testsuite was completed. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - foreach ($this->listeners as $listener) { - $listener->endTestSuite($suite); - } - } - - /** - * Informs the result that a test will be started. - * - * @param PHPUnit_Framework_Test $test - */ - public function startTest(PHPUnit_Framework_Test $test) - { - $this->lastTestFailed = FALSE; - $this->runTests += count($test); - - foreach ($this->listeners as $listener) { - $listener->startTest($test); - } - } - - /** - * Informs the result that a test was completed. - * - * @param PHPUnit_Framework_Test $test - * @param float $time - */ - public function endTest(PHPUnit_Framework_Test $test, $time) - { - foreach ($this->listeners as $listener) { - $listener->endTest($test, $time); - } - - if (!$this->lastTestFailed && $test instanceof PHPUnit_Framework_TestCase) { - $this->passed[get_class($test) . '::' . $test->getName()] = $test->getResult(); - $this->time += $time; - } - } - - /** - * Returns TRUE if no incomplete test occured. - * - * @return boolean - */ - public function allCompletlyImplemented() - { - return $this->notImplementedCount() == 0; - } - - /** - * Gets the number of incomplete tests. - * - * @return integer - */ - public function notImplementedCount() - { - return count($this->notImplemented); - } - - /** - * Returns an Enumeration for the incomplete tests. - * - * @return array - */ - public function notImplemented() - { - return $this->notImplemented; - } - - /** - * Returns TRUE if no test has been skipped. - * - * @return boolean - * @since Method available since Release 3.0.0 - */ - public function noneSkipped() - { - return $this->skippedCount() == 0; - } - - /** - * Gets the number of skipped tests. - * - * @return integer - * @since Method available since Release 3.0.0 - */ - public function skippedCount() - { - return count($this->skipped); - } - - /** - * Returns an Enumeration for the skipped tests. - * - * @return array - * @since Method available since Release 3.0.0 - */ - public function skipped() - { - return $this->skipped; - } - - /** - * Gets the number of detected errors. - * - * @return integer - */ - public function errorCount() - { - return count($this->errors); - } - - /** - * Returns an Enumeration for the errors. - * - * @return array - */ - public function errors() - { - return $this->errors; - } - - /** - * Gets the number of detected failures. - * - * @return integer - */ - public function failureCount() - { - return count($this->failures); - } - - /** - * Returns an Enumeration for the failures. - * - * @return array - */ - public function failures() - { - return $this->failures; - } - - /** - * Returns the names of the tests that have passed. - * - * @return array - * @since Method available since Release 3.4.0 - */ - public function passed() - { - return $this->passed; - } - - /** - * Returns the (top) test suite. - * - * @return PHPUnit_Framework_TestSuite - * @since Method available since Release 3.0.0 - */ - public function topTestSuite() - { - return $this->topTestSuite; - } - - /** - * Enables or disables the collection of Code Coverage information. - * - * @param boolean $flag - * @throws InvalidArgumentException - * @since Method available since Release 2.3.0 - */ - public function collectCodeCoverageInformation($flag) - { - if (is_bool($flag)) { - $this->collectCodeCoverageInformation = $flag; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); - } - } - - /** - * Enables or disables the collection of raw Code Coverage information. - * - * @param boolean $flag - * @throws InvalidArgumentException - * @since Method available since Release 3.4.0 - */ - public function collectRawCodeCoverageInformation($flag) - { - if (is_bool($flag)) { - $this->collectRawCodeCoverageInformation = $flag; - - if ($flag === TRUE) { - $this->collectCodeCoverageInformation = $flag; - } - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); - } - } - - /** - * Returns whether code coverage information should be collected. - * - * @return boolean If code coverage should be collected - * @since Method available since Release 3.2.0 - */ - public function getCollectCodeCoverageInformation() - { - return $this->collectCodeCoverageInformation; - } - - /** - * Returns the raw Code Coverage information. - * - * @return array - * @since Method available since Release 3.4.0 - */ - public function getRawCodeCoverageInformation() - { - return $this->rawCodeCoverageInformation; - } - - /** - * Returns the strict mode configuration option - * - * @return boolean - */ - public function isStrict() - { - return $this->strictMode; - } - - /** - * Runs a TestCase. - * - * @param PHPUnit_Framework_Test $test - */ - public function run(PHPUnit_Framework_Test $test) - { - PHPUnit_Framework_Assert::resetCount(); - - $error = FALSE; - $failure = FALSE; - $incomplete = FALSE; - $skipped = FALSE; - - $this->startTest($test); - - $errorHandlerSet = FALSE; - - if ($this->convertErrorsToExceptions) { - $oldErrorHandler = set_error_handler( - array('PHPUnit_Util_ErrorHandler', 'handleError'), - E_ALL | E_STRICT - ); - - if ($oldErrorHandler === NULL) { - $errorHandlerSet = TRUE; - } else { - restore_error_handler(); - } - } - - if (self::$xdebugLoaded === NULL) { - self::$xdebugLoaded = extension_loaded('xdebug'); - self::$useXdebug = self::$xdebugLoaded; - } - - $useXdebug = self::$useXdebug && - $this->collectCodeCoverageInformation && - !$test instanceof PHPUnit_Extensions_SeleniumTestCase && - !$test instanceof PHPUnit_Framework_Warning; - - if ($useXdebug) { - $this->codeCoverage->start($test); - } - - PHP_Timer::start(); - - try { - $test->runBare(); - } - - catch (PHPUnit_Framework_AssertionFailedError $e) { - $failure = TRUE; - - if ($e instanceof PHPUnit_Framework_IncompleteTestError) { - $incomplete = TRUE; - } - - else if ($e instanceof PHPUnit_Framework_SkippedTestError) { - $skipped = TRUE; - } - } - - catch (Exception $e) { - $error = TRUE; - } - - $time = PHP_Timer::stop(); - - if ($useXdebug) { - $data = $this->codeCoverage->stop(FALSE); - - if (!$this->strictMode || (!$incomplete && !$skipped)) { - if ($this->collectRawCodeCoverageInformation) { - $this->rawCodeCoverageInformation[] = $data; - } else { - $filterGroups = array('DEFAULT', 'TESTS'); - - if (!defined('PHPUNIT_TESTSUITE')) { - $filterGroups[] = 'PHPUNIT'; - } - - $this->codeCoverage->append($data, $test, $filterGroups); - } - } - - unset($data); - } - - if ($errorHandlerSet === TRUE) { - restore_error_handler(); - } - - $test->addToAssertionCount(PHPUnit_Framework_Assert::getCount()); - - if ($error === TRUE) { - $this->addError($test, $e, $time); - } - - else if ($failure === TRUE) { - $this->addFailure($test, $e, $time); - } - - else if ($this->strictMode && $test->getNumAssertions() == 0) { - $this->addFailure( - $test, - new PHPUnit_Framework_IncompleteTestError( - 'This test did not perform any assertions' - ), - $time - ); - } - - $this->endTest($test, $time); - } - - /** - * Gets the number of run tests. - * - * @return integer - */ - public function count() - { - return $this->runTests; - } - - /** - * Checks whether the test run should stop. - * - * @return boolean - */ - public function shouldStop() - { - return $this->stop; - } - - /** - * Marks that the test run should stop. - * - */ - public function stop() - { - $this->stop = TRUE; - } - - /** - * Returns the PHP_CodeCoverage object. - * - * @return PHP_CodeCoverage - * @since Method available since Release 3.5.0 - */ - public function getCodeCoverage() - { - return $this->codeCoverage; - } - - /** - * Enables or disables the error-to-exception conversion. - * - * @param boolean $flag - * @throws InvalidArgumentException - * @since Method available since Release 3.2.14 - */ - public function convertErrorsToExceptions($flag) - { - if (is_bool($flag)) { - $this->convertErrorsToExceptions = $flag; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); - } - } - - /** - * Returns the error-to-exception conversion setting. - * - * @return boolean - * @since Method available since Release 3.4.0 - */ - public function getConvertErrorsToExceptions() - { - return $this->convertErrorsToExceptions; - } - - /** - * Enables or disables the stopping when an error occurs. - * - * @param boolean $flag - * @throws InvalidArgumentException - * @since Method available since Release 3.5.0 - */ - public function stopOnError($flag) - { - if (is_bool($flag)) { - $this->stopOnError = $flag; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); - } - } - - /** - * Enables or disables the stopping when a failure occurs. - * - * @param boolean $flag - * @throws InvalidArgumentException - * @since Method available since Release 3.1.0 - */ - public function stopOnFailure($flag) - { - if (is_bool($flag)) { - $this->stopOnFailure = $flag; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); - } - } - - /** - * Enables or disables the strict mode. - * - * When active - * * Tests that do not assert anything will be marked as incomplete. - * * Tests that are incomplete or skipped yield no code coverage. - * - * @param boolean $flag - * @throws InvalidArgumentException - * @since Method available since Release 3.5.2 - */ - public function strictMode($flag) - { - if (is_bool($flag)) { - $this->strictMode = $flag; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); - } - } - - /** - * Enables or disables the stopping for incomplete tests. - * - * @param boolean $flag - * @throws InvalidArgumentException - * @since Method available since Release 3.5.0 - */ - public function stopOnIncomplete($flag) - { - if (is_bool($flag)) { - $this->stopOnIncomplete = $flag; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); - } - } - - /** - * Enables or disables the stopping for skipped tests. - * - * @param boolean $flag - * @throws InvalidArgumentException - * @since Method available since Release 3.1.0 - */ - public function stopOnSkipped($flag) - { - if (is_bool($flag)) { - $this->stopOnSkipped = $flag; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); - } - } - - /** - * Returns the time spent running the tests. - * - * @return float - */ - public function time() - { - return $this->time; - } - - /** - * Returns whether the entire test was successful or not. - * - * @return boolean - */ - public function wasSuccessful() - { - return empty($this->errors) && empty($this->failures); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/TestSuite/DataProvider.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/TestSuite/DataProvider.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/TestSuite/DataProvider.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/TestSuite/DataProvider.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_TestSuite - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.4.0 - */ - -/** - * - * - * @package PHPUnit - * @subpackage Framework_TestSuite - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.4.0 - */ -class PHPUnit_Framework_TestSuite_DataProvider extends PHPUnit_Framework_TestSuite -{ - /** - * Sets the dependencies of a TestCase. - * - * @param array $dependencies - */ - public function setDependencies(array $dependencies) - { - foreach ($this->tests as $test) { - $test->setDependencies($dependencies); - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/TestSuite.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/TestSuite.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/TestSuite.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/TestSuite.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,941 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -require_once 'PHP/CodeCoverage.php'; - -/** - * A TestSuite is a composite of Tests. It runs a collection of test cases. - * - * Here is an example using the dynamic test definition. - * - * - * addTest(new MathTest('testPass')); - * ?> - * - * - * Alternatively, a TestSuite can extract the tests to be run automatically. - * To do so you pass a ReflectionClass instance for your - * PHPUnit_Framework_TestCase class to the PHPUnit_Framework_TestSuite - * constructor. - * - * - * - * - * - * This constructor creates a suite with all the methods starting with - * "test" that take no arguments. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -class PHPUnit_Framework_TestSuite implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing, IteratorAggregate -{ - /** - * Enable or disable the backup and restoration of the $GLOBALS array. - * - * @var boolean - */ - protected $backupGlobals = NULL; - - /** - * Enable or disable the backup and restoration of static attributes. - * - * @var boolean - */ - protected $backupStaticAttributes = NULL; - - /** - * The name of the test suite. - * - * @var string - */ - protected $name = ''; - - /** - * The test groups of the test suite. - * - * @var array - */ - protected $groups = array(); - - /** - * The tests in the test suite. - * - * @var array - */ - protected $tests = array(); - - /** - * The number of tests in the test suite. - * - * @var integer - */ - protected $numTests = -1; - - /** - * @var boolean - */ - protected $testCase = FALSE; - - /** - * Constructs a new TestSuite: - * - * - PHPUnit_Framework_TestSuite() constructs an empty TestSuite. - * - * - PHPUnit_Framework_TestSuite(ReflectionClass) constructs a - * TestSuite from the given class. - * - * - PHPUnit_Framework_TestSuite(ReflectionClass, String) - * constructs a TestSuite from the given class with the given - * name. - * - * - PHPUnit_Framework_TestSuite(String) either constructs a - * TestSuite from the given class (if the passed string is the - * name of an existing class) or constructs an empty TestSuite - * with the given name. - * - * @param mixed $theClass - * @param string $name - * @throws InvalidArgumentException - */ - public function __construct($theClass = '', $name = '') - { - $argumentsValid = FALSE; - - if (is_object($theClass) && - $theClass instanceof ReflectionClass) { - $argumentsValid = TRUE; - } - - else if (is_string($theClass) && - $theClass !== '' && - class_exists($theClass, FALSE)) { - $argumentsValid = TRUE; - - if ($name == '') { - $name = $theClass; - } - - $theClass = new ReflectionClass($theClass); - } - - else if (is_string($theClass)) { - $this->setName($theClass); - return; - } - - if (!$argumentsValid) { - throw new InvalidArgumentException; - } - - if (!$theClass->isSubclassOf('PHPUnit_Framework_TestCase')) { - throw new InvalidArgumentException( - 'Class does not extend PHPUnit_Framework_TestCase.' - ); - } - - $filename = $theClass->getFilename(); - - if (strpos($filename, 'eval()') === FALSE) { - PHP_CodeCoverage::getInstance()->filter()->addFileToBlacklist( - realpath($filename), 'TESTS' - ); - } - - if ($name != '') { - $this->setName($name); - } else { - $this->setName($theClass->getName()); - } - - $constructor = $theClass->getConstructor(); - - if ($constructor !== NULL && - !$constructor->isPublic()) { - $this->addTest( - self::warning( - sprintf( - 'Class "%s" has no public constructor.', - - $theClass->getName() - ) - ) - ); - - return; - } - - foreach ($theClass->getMethods() as $method) { - if (strpos($method->getDeclaringClass()->getName(), 'PHPUnit_') !== 0) { - $this->addTestMethod($theClass, $method); - } - } - - if (empty($this->tests)) { - $this->addTest( - self::warning( - sprintf( - 'No tests found in class "%s".', - - $theClass->getName() - ) - ) - ); - } - - $this->testCase = TRUE; - } - - /** - * Returns a string representation of the test suite. - * - * @return string - */ - public function toString() - { - return $this->getName(); - } - - /** - * Adds a test to the suite. - * - * @param PHPUnit_Framework_Test $test - * @param array $groups - */ - public function addTest(PHPUnit_Framework_Test $test, $groups = array()) - { - $class = new ReflectionClass($test); - - if (!$class->isAbstract()) { - $this->tests[] = $test; - $this->numTests = -1; - - if ($test instanceof PHPUnit_Framework_TestSuite && - empty($groups)) { - $groups = $test->getGroups(); - } - - if (empty($groups)) { - $groups = array('__nogroup__'); - } - - foreach ($groups as $group) { - if (!isset($this->groups[$group])) { - $this->groups[$group] = array($test); - } else { - $this->groups[$group][] = $test; - } - } - } - } - - /** - * Adds the tests from the given class to the suite. - * - * @param mixed $testClass - * @throws InvalidArgumentException - */ - public function addTestSuite($testClass) - { - if (is_string($testClass) && class_exists($testClass)) { - $testClass = new ReflectionClass($testClass); - } - - if (!is_object($testClass)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 1, 'class name or object' - ); - } - - if ($testClass instanceof PHPUnit_Framework_TestSuite) { - $this->addTest($testClass); - } - - else if ($testClass instanceof ReflectionClass) { - $suiteMethod = FALSE; - - if (!$testClass->isAbstract()) { - if ($testClass->hasMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME)) { - $method = $testClass->getMethod( - PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME - ); - - if ($method->isStatic()) { - $this->addTest( - $method->invoke(NULL, $testClass->getName()) - ); - - $suiteMethod = TRUE; - } - } - } - - if (!$suiteMethod && !$testClass->isAbstract()) { - $this->addTest(new PHPUnit_Framework_TestSuite($testClass)); - } - } - - else { - throw new InvalidArgumentException; - } - } - - /** - * Wraps both addTest() and addTestSuite - * as well as the separate import statements for the user's convenience. - * - * If the named file cannot be read or there are no new tests that can be - * added, a PHPUnit_Framework_Warning will be created instead, - * leaving the current test run untouched. - * - * @param string $filename - * @param boolean $syntaxCheck - * @param array $phptOptions Array with ini settings for the php instance - * run, key being the name if the setting, - * value the ini value. - * @throws InvalidArgumentException - * @since Method available since Release 2.3.0 - * @author Stefano F. Rausch - */ - public function addTestFile($filename, $syntaxCheck = FALSE, $phptOptions = array()) - { - if (!is_string($filename)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (file_exists($filename) && substr($filename, -5) == '.phpt') { - $this->addTest( - new PHPUnit_Extensions_PhptTestCase($filename, $phptOptions) - ); - - return; - } - - if (!file_exists($filename)) { - $includePaths = explode(PATH_SEPARATOR, get_include_path()); - - foreach ($includePaths as $includePath) { - $file = $includePath . DIRECTORY_SEPARATOR . $filename; - - if (file_exists($file)) { - $filename = $file; - break; - } - } - } - - PHPUnit_Util_Class::collectStart(); - PHPUnit_Util_Fileloader::checkAndLoad($filename, $syntaxCheck); - $newClasses = PHPUnit_Util_Class::collectEnd(); - $baseName = str_replace('.php', '', basename($filename)); - - foreach ($newClasses as $className) { - if (substr($className, 0 - strlen($baseName)) == $baseName) { - $newClasses = array($className); - break; - } - } - - $testsFound = FALSE; - - foreach ($newClasses as $className) { - $class = new ReflectionClass($className); - - if (!$class->isAbstract()) { - if ($class->hasMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME)) { - $method = $class->getMethod( - PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME - ); - - if ($method->isStatic()) { - $this->addTest($method->invoke(NULL, $className)); - - $testsFound = TRUE; - } - } - - else if ($class->implementsInterface('PHPUnit_Framework_Test')) { - $this->addTestSuite($class); - - $testsFound = TRUE; - } - } - } - - $this->numTests = -1; - } - - /** - * Wrapper for addTestFile() that adds multiple test files. - * - * @param array|Iterator $filenames - * @throws InvalidArgumentException - * @since Method available since Release 2.3.0 - */ - public function addTestFiles($filenames, $syntaxCheck = FALSE) - { - if (!(is_array($filenames) || - (is_object($filenames) && $filenames instanceof Iterator))) { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 1, 'array or iterator' - ); - } - - foreach ($filenames as $filename) { - $this->addTestFile((string)$filename, $syntaxCheck); - } - } - - /** - * Counts the number of test cases that will be run by this test. - * - * @return integer - */ - public function count() - { - if ($this->numTests > -1) { - return $this->numTests; - } - - $this->numTests = 0; - - foreach ($this->tests as $test) { - $this->numTests += count($test); - } - - return $this->numTests; - } - - /** - * @param ReflectionClass $theClass - * @param string $name - * @return PHPUnit_Framework_Test - * @throws RuntimeException - */ - public static function createTest(ReflectionClass $theClass, $name) - { - $className = $theClass->getName(); - - if (!$theClass->isInstantiable()) { - return self::warning( - sprintf('Cannot instantiate class "%s".', $className) - ); - } - - $backupSettings = PHPUnit_Util_Test::getBackupSettings( - $className, $name - ); - $preserveGlobalState = PHPUnit_Util_Test::getPreserveGlobalStateSettings( - $className, $name - ); - $runTestInSeparateProcess = PHPUnit_Util_Test::getProcessIsolationSettings( - $className, $name - ); - - $constructor = $theClass->getConstructor(); - - if ($constructor !== NULL) { - $parameters = $constructor->getParameters(); - - // TestCase() or TestCase($name) - if (count($parameters) < 2) { - $test = new $className; - } - - // TestCase($name, $data) - else { - try { - $data = PHPUnit_Util_Test::getProvidedData( - $className, $name - ); - } - - catch (Exception $e) { - $message = sprintf( - 'The data provider specified for %s::%s is invalid.', - $className, - $name - ); - - $_message = $e->getMessage(); - - if (!empty($_message)) { - $message .= "\n" . $_message; - } - - $data = self::warning($message); - } - - // Test method with @dataProvider. - if (isset($data)) { - $test = new PHPUnit_Framework_TestSuite_DataProvider( - $className . '::' . $name - ); - - if (empty($data)) { - $data = self::warning( - sprintf( - 'No tests found in suite "%s".', - $test->getName() - ) - ); - } - - if ($data instanceof PHPUnit_Framework_Warning) { - $test->addTest($data); - } - - else { - $groups = PHPUnit_Util_Test::getGroups($className, $name); - - foreach ($data as $_dataName => $_data) { - $_test = new $className($name, $_data, $_dataName); - - if ($runTestInSeparateProcess) { - $_test->setRunTestInSeparateProcess(TRUE); - - if ($preserveGlobalState !== NULL) { - $_test->setPreserveGlobalState($preserveGlobalState); - } - } - - if ($backupSettings['backupGlobals'] !== NULL) { - $_test->setBackupGlobals( - $backupSettings['backupGlobals'] - ); - } - - if ($backupSettings['backupStaticAttributes'] !== NULL) { - $_test->setBackupStaticAttributes( - $backupSettings['backupStaticAttributes'] - ); - } - - $test->addTest($_test, $groups); - } - } - } - - else { - $test = new $className; - } - } - } - - if (!isset($test)) { - throw new RuntimeException('No valid test provided.'); - } - - if ($test instanceof PHPUnit_Framework_TestCase) { - $test->setName($name); - - if ($runTestInSeparateProcess) { - $test->setRunTestInSeparateProcess(TRUE); - - if ($preserveGlobalState !== NULL) { - $test->setPreserveGlobalState($preserveGlobalState); - } - } - - if ($backupSettings['backupGlobals'] !== NULL) { - $test->setBackupGlobals($backupSettings['backupGlobals']); - } - - if ($backupSettings['backupStaticAttributes'] !== NULL) { - $test->setBackupStaticAttributes( - $backupSettings['backupStaticAttributes'] - ); - } - } - - return $test; - } - - /** - * Creates a default TestResult object. - * - * @return PHPUnit_Framework_TestResult - */ - protected function createResult() - { - return new PHPUnit_Framework_TestResult; - } - - /** - * Returns the name of the suite. - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Returns the test groups of the suite. - * - * @return array - * @since Method available since Release 3.2.0 - */ - public function getGroups() - { - return array_keys($this->groups); - } - - /** - * Runs the tests and collects their result in a TestResult. - * - * @param PHPUnit_Framework_TestResult $result - * @param mixed $filter - * @param array $groups - * @param array $excludeGroups - * @param boolean $processIsolation - * @return PHPUnit_Framework_TestResult - * @throws InvalidArgumentException - */ - public function run(PHPUnit_Framework_TestResult $result = NULL, $filter = FALSE, array $groups = array(), array $excludeGroups = array(), $processIsolation = FALSE) - { - if ($result === NULL) { - $result = $this->createResult(); - } - - $result->startTestSuite($this); - - try { - $this->setUp(); - - if ($this->testCase && - method_exists($this->name, 'setUpBeforeClass')) { - call_user_func(array($this->name, 'setUpBeforeClass')); - } - } - - catch (PHPUnit_Framework_SkippedTestSuiteError $e) { - $numTests = count($this); - - for ($i = 0; $i < $numTests; $i++) { - $result->addFailure($this, $e, 0); - } - - return $result; - } - - if (empty($groups)) { - $tests = $this->tests; - } else { - $tests = new SplObjectStorage; - - foreach ($groups as $group) { - if (isset($this->groups[$group])) { - foreach ($this->groups[$group] as $test) { - $tests->attach($test); - } - } - } - } - - foreach ($tests as $test) { - if ($result->shouldStop()) { - break; - } - - if ($test instanceof PHPUnit_Framework_TestSuite) { - $test->setBackupGlobals($this->backupGlobals); - $test->setBackupStaticAttributes($this->backupStaticAttributes); - - $test->run( - $result, $filter, $groups, $excludeGroups, $processIsolation - ); - } else { - $runTest = TRUE; - - if ($filter !== FALSE ) { - $tmp = PHPUnit_Util_Test::describe($test, FALSE); - - if ($tmp[0] != '') { - $name = join('::', $tmp); - } else { - $name = $tmp[1]; - } - - if (preg_match($filter, $name) == 0) { - $runTest = FALSE; - } - } - - if ($runTest && !empty($excludeGroups)) { - foreach ($this->groups as $_group => $_tests) { - if (in_array($_group, $excludeGroups)) { - foreach ($_tests as $_test) { - if ($test === $_test) { - $runTest = FALSE; - break 2; - } - } - } - } - } - - if ($runTest) { - if ($test instanceof PHPUnit_Framework_TestCase) { - $test->setBackupGlobals($this->backupGlobals); - $test->setBackupStaticAttributes( - $this->backupStaticAttributes - ); - $test->setRunTestInSeparateProcess($processIsolation); - } - - $this->runTest($test, $result); - } - } - } - - if ($this->testCase && - method_exists($this->name, 'tearDownAfterClass')) { - call_user_func(array($this->name, 'tearDownAfterClass')); - } - - $this->tearDown(); - $result->endTestSuite($this); - - return $result; - } - - /** - * Runs a test. - * - * @param PHPUnit_Framework_Test $test - * @param PHPUnit_Framework_TestResult $testResult - */ - public function runTest(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result) - { - $test->run($result); - } - - /** - * Sets the name of the suite. - * - * @param string - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * Returns the test at the given index. - * - * @param integer - * @return PHPUnit_Framework_Test - */ - public function testAt($index) - { - if (isset($this->tests[$index])) { - return $this->tests[$index]; - } else { - return FALSE; - } - } - - /** - * Returns the tests as an enumeration. - * - * @return array - */ - public function tests() - { - return $this->tests; - } - - /** - * Mark the test suite as skipped. - * - * @param string $message - * @throws PHPUnit_Framework_SkippedTestSuiteError - * @since Method available since Release 3.0.0 - */ - public function markTestSuiteSkipped($message = '') - { - throw new PHPUnit_Framework_SkippedTestSuiteError($message); - } - - /** - * @param ReflectionClass $class - * @param ReflectionMethod $method - */ - protected function addTestMethod(ReflectionClass $class, ReflectionMethod $method) - { - $name = $method->getName(); - - if ($this->isPublicTestMethod($method)) { - $test = self::createTest($class, $name); - - if ($test instanceof PHPUnit_Framework_TestCase || - $test instanceof PHPUnit_Framework_TestSuite_DataProvider) { - $test->setDependencies( - PHPUnit_Util_Test::getDependencies($class->getName(), $name) - ); - } - - $this->addTest($test, PHPUnit_Util_Test::getGroups( - $class->getName(), $name) - ); - } - - else if ($this->isTestMethod($method)) { - $this->addTest( - self::warning( - sprintf( - 'Test method "%s" is not public.', - - $name - ) - ) - ); - } - } - - /** - * @param ReflectionMethod $method - * @return boolean - */ - public static function isPublicTestMethod(ReflectionMethod $method) - { - return (self::isTestMethod($method) && $method->isPublic()); - } - - /** - * @param ReflectionMethod $method - * @return boolean - */ - public static function isTestMethod(ReflectionMethod $method) - { - if (strpos($method->name, 'test') === 0) { - return TRUE; - } - - // @scenario on TestCase::testMethod() - // @test on TestCase::testMethod() - return strpos($method->getDocComment(), '@test') !== FALSE || - strpos($method->getDocComment(), '@scenario') !== FALSE; - } - - /** - * @param string $message - * @return PHPUnit_Framework_Warning - */ - protected static function warning($message) - { - return new PHPUnit_Framework_Warning($message); - } - - /** - * @param boolean $backupGlobals - * @since Method available since Release 3.3.0 - */ - public function setBackupGlobals($backupGlobals) - { - if (is_null($this->backupGlobals) && is_bool($backupGlobals)) { - $this->backupGlobals = $backupGlobals; - } - } - - /** - * @param boolean $backupStaticAttributes - * @since Method available since Release 3.4.0 - */ - public function setBackupStaticAttributes($backupStaticAttributes) - { - if (is_null($this->backupStaticAttributes) && - is_bool($backupStaticAttributes)) { - $this->backupStaticAttributes = $backupStaticAttributes; - } - } - - /** - * Returns an iterator for this test suite. - * - * @return RecursiveIteratorIterator - * @since Method available since Release 3.1.0 - */ - public function getIterator() - { - return new RecursiveIteratorIterator( - new PHPUnit_Util_TestSuiteIterator($this) - ); - } - - /** - * Template Method that is called before the tests - * of this test suite are run. - * - * @since Method available since Release 3.1.0 - */ - protected function setUp() - { - } - - /** - * Template Method that is called after the tests - * of this test suite have finished running. - * - * @since Method available since Release 3.1.0 - */ - protected function tearDown() - { - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Warning.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Warning.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework/Warning.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework/Warning.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * A warning. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -class PHPUnit_Framework_Warning extends PHPUnit_Framework_TestCase -{ - /** - * @var string - */ - protected $message = ''; - - /** - * @var boolean - */ - protected $backupGlobals = FALSE; - - /** - * @var boolean - */ - protected $backupStaticAttributes = FALSE; - - /** - * @var boolean - */ - protected $runTestInSeparateProcess = FALSE; - - /** - * @var boolean - */ - protected $useErrorHandler = FALSE; - - /** - * @var boolean - */ - protected $useOutputBuffering = FALSE; - - /** - * @param string $message - */ - public function __construct($message = '') - { - $this->message = $message; - parent::__construct('Warning'); - } - - /** - * @throws RuntimeException - */ - protected function runTest() - { - $this->fail($this->message); - } - - /** - * @return string - * @since Method available since Release 3.0.0 - */ - public function getMessage() - { - return $this->message; - } - - /** - * Returns a string representation of the test case. - * - * @return string - * @since Method available since Release 3.4.0 - */ - public function toString() - { - return 'Warning'; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Framework.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Framework.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -require_once 'PHP/CodeCoverage/Filter.php'; -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'PHPUNIT'); - -trigger_error( - 'Please no longer include "PHPUnit/Framework.php".', E_USER_NOTICE -); diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Runner/BaseTestRunner.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Runner/BaseTestRunner.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Runner/BaseTestRunner.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Runner/BaseTestRunner.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,190 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Runner - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * Base class for all test runners. - * - * @package PHPUnit - * @subpackage Runner - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -abstract class PHPUnit_Runner_BaseTestRunner -{ - const STATUS_PASSED = 0; - const STATUS_SKIPPED = 1; - const STATUS_INCOMPLETE = 2; - const STATUS_FAILURE = 3; - const STATUS_ERROR = 4; - const SUITE_METHODNAME = 'suite'; - - /** - * Returns the loader to be used. - * - * @return PHPUnit_Runner_TestSuiteLoader - */ - public function getLoader() - { - return new PHPUnit_Runner_StandardTestSuiteLoader; - } - - /** - * Returns the Test corresponding to the given suite. - * This is a template method, subclasses override - * the runFailed() and clearStatus() methods. - * - * @param string $suiteClassName - * @param string $suiteClassFile - * @param boolean $syntaxCheck - * @return PHPUnit_Framework_Test - */ - public function getTest($suiteClassName, $suiteClassFile = '', $syntaxCheck = FALSE) - { - if (is_dir($suiteClassName) && - !is_file($suiteClassName . '.php') && empty($suiteClassFile)) { - $testCollector = new PHPUnit_Runner_IncludePathTestCollector( - array($suiteClassName) - ); - - $suite = new PHPUnit_Framework_TestSuite($suiteClassName); - $suite->addTestFiles($testCollector->collectTests(), $syntaxCheck); - - return $suite; - } - - try { - $testClass = $this->loadSuiteClass( - $suiteClassName, $suiteClassFile, $syntaxCheck - ); - } - - catch (Exception $e) { - $this->runFailed($e->getMessage()); - return NULL; - } - - try { - $suiteMethod = $testClass->getMethod(self::SUITE_METHODNAME); - - if (!$suiteMethod->isStatic()) { - $this->runFailed( - 'suite() method must be static.' - ); - - return NULL; - } - - try { - $test = $suiteMethod->invoke(NULL, $testClass->getName()); - } - - catch (ReflectionException $e) { - $this->runFailed( - sprintf( - "Failed to invoke suite() method.\n%s", - - $e->getMessage() - ) - ); - - return NULL; - } - } - - catch (ReflectionException $e) { - try { - $test = new PHPUnit_Framework_TestSuite($testClass); - } - - catch (InvalidArgumentException $e) { - $test = new PHPUnit_Framework_TestSuite; - $test->setName($suiteClassName); - } - } - - $this->clearStatus(); - - return $test; - } - - /** - * Returns the loaded ReflectionClass for a suite name. - * - * @param string $suiteClassName - * @param string $suiteClassFile - * @param boolean $syntaxCheck - * @return ReflectionClass - */ - protected function loadSuiteClass($suiteClassName, $suiteClassFile = '', $syntaxCheck = FALSE) - { - $loader = $this->getLoader(); - - if ($loader instanceof PHPUnit_Runner_StandardTestSuiteLoader) { - return $loader->load($suiteClassName, $suiteClassFile, $syntaxCheck); - } else { - return $loader->load($suiteClassName, $suiteClassFile); - } - } - - /** - * Clears the status message. - * - */ - protected function clearStatus() - { - } - - /** - * Override to define how to handle a failed loading of - * a test suite. - * - * @param string $message - */ - abstract protected function runFailed($message); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Runner/IncludePathTestCollector.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Runner/IncludePathTestCollector.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Runner/IncludePathTestCollector.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Runner/IncludePathTestCollector.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Runner - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.1.0 - */ - -require_once 'File/Iterator/Factory.php'; - -/** - * A test collector that collects tests from one or more directories - * recursively. If no directories are specified, the include_path is searched. - * - * - * $testCollector = new PHPUnit_Runner_IncludePathTestCollector( - * array('/path/to/*Test.php files') - * ); - * - * $suite = new PHPUnit_Framework_TestSuite('My Test Suite'); - * $suite->addTestFiles($testCollector->collectTests()); - * - * - * @package PHPUnit - * @subpackage Runner - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.1.0 - */ -class PHPUnit_Runner_IncludePathTestCollector implements PHPUnit_Runner_TestCollector -{ - /** - * @var string - */ - protected $filterIterator; - - /** - * @var array - */ - protected $paths; - - /** - * @var mixed - */ - protected $suffixes; - - /** - * @var mixed - */ - protected $prefixes; - - /** - * @param array $paths - * @param mixed $suffixes - * @param mixed $prefixes - */ - public function __construct(array $paths = array(), $suffixes = array('Test.php', '.phpt'), $prefixes = array()) - { - if (!empty($paths)) { - $this->paths = $paths; - } else { - $this->paths = explode(PATH_SEPARATOR, get_include_path()); - } - - $this->suffixes = $suffixes; - $this->prefixes = $prefixes; - } - - /** - * @return File_Iterator - */ - public function collectTests() - { - $iterator = File_Iterator_Factory::getFileIterator( - $this->paths, $this->suffixes, $this->prefixes - ); - - if ($this->filterIterator !== NULL) { - $class = new ReflectionClass($this->filterIterator); - $iterator = $class->newInstance($iterator); - } - - return $iterator; - } - - /** - * Adds a FilterIterator to filter the source files to be collected. - * - * @param string $filterIterator - * @throws InvalidArgumentException - */ - public function setFilterIterator($filterIterator) - { - if (is_string($filterIterator) && class_exists($filterIterator)) { - $class = new ReflectionClass($filterIterator); - - if ($class->isSubclassOf('FilterIterator')) { - $this->filterIterator = $filterIterator; - } - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class name'); - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Runner/StandardTestSuiteLoader.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Runner/StandardTestSuiteLoader.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Runner/StandardTestSuiteLoader.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Runner/StandardTestSuiteLoader.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,167 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Runner - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * The standard test suite loader. - * - * @package PHPUnit - * @subpackage Runner - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -class PHPUnit_Runner_StandardTestSuiteLoader implements PHPUnit_Runner_TestSuiteLoader -{ - /** - * @param string $suiteClassName - * @param string $suiteClassFile - * @param boolean $syntaxCheck - * @return ReflectionClass - * @throws RuntimeException - */ - public function load($suiteClassName, $suiteClassFile = '', $syntaxCheck = FALSE) - { - $suiteClassName = str_replace('.php', '', $suiteClassName); - - if (empty($suiteClassFile)) { - $suiteClassFile = PHPUnit_Util_Filesystem::classNameToFilename( - $suiteClassName - ); - } - - if (!class_exists($suiteClassName, FALSE)) { - if (!file_exists($suiteClassFile)) { - $includePaths = explode(PATH_SEPARATOR, get_include_path()); - - foreach ($includePaths as $includePath) { - $file = $includePath . DIRECTORY_SEPARATOR . - $suiteClassFile; - - if (file_exists($file)) { - $suiteClassFile = $file; - break; - } - } - } - - PHPUnit_Util_Class::collectStart(); - PHPUnit_Util_Fileloader::checkAndLoad($suiteClassFile, $syntaxCheck); - $loadedClasses = PHPUnit_Util_Class::collectEnd(); - } - - if (!class_exists($suiteClassName, FALSE) && !empty($loadedClasses)) { - $offset = 0 - strlen($suiteClassName); - - foreach ($loadedClasses as $loadedClass) { - if (substr($loadedClass, $offset) === $suiteClassName) { - $suiteClassName = $loadedClass; - break; - } - } - } - - if (!class_exists($suiteClassName, FALSE) && !empty($loadedClasses)) { - $testCaseClass = 'PHPUnit_Framework_TestCase'; - - foreach ($loadedClasses as $loadedClass) { - $class = new ReflectionClass($loadedClass); - $classFile = $class->getFileName(); - - if ($class->isSubclassOf($testCaseClass) && - !$class->isAbstract()) { - $suiteClassName = $loadedClass; - $testCaseClass = $loadedClass; - - if ($classFile == realpath($suiteClassFile)) { - break; - } - } - - if ($class->hasMethod('suite')) { - $method = $class->getMethod('suite'); - - if (!$method->isAbstract() && - $method->isPublic() && - $method->isStatic()) { - $suiteClassName = $loadedClass; - - if ($classFile == realpath($suiteClassFile)) { - break; - } - } - } - } - } - - if (class_exists($suiteClassName, FALSE)) { - $class = new ReflectionClass($suiteClassName); - - if ($class->getFileName() == realpath($suiteClassFile)) { - return $class; - } - } - - throw new PHPUnit_Framework_Exception( - sprintf( - 'Class %s could not be found in %s.', - - $suiteClassName, - $suiteClassFile - ) - ); - } - - /** - * @param ReflectionClass $aClass - * @return ReflectionClass - */ - public function reload(ReflectionClass $aClass) - { - return $aClass; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Runner/TestCollector.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Runner/TestCollector.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Runner/TestCollector.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Runner/TestCollector.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Runner - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * Collects Test class names to be presented - * by the TestSelector. - * - * @package PHPUnit - * @subpackage Runner - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Interface available since Release 2.0.0 - */ -interface PHPUnit_Runner_TestCollector -{ - /** - * @return array - */ - public function collectTests(); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Runner/TestSuiteLoader.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Runner/TestSuiteLoader.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Runner/TestSuiteLoader.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Runner/TestSuiteLoader.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Runner - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * An interface to define how a test suite should be loaded. - * - * @package PHPUnit - * @subpackage Runner - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Interface available since Release 2.0.0 - */ -interface PHPUnit_Runner_TestSuiteLoader -{ - /** - * @param string $suiteClassName - * @param string $suiteClassFile - * @return ReflectionClass - */ - public function load($suiteClassName, $suiteClassFile = ''); - - /** - * @param ReflectionClass $aClass - * @return ReflectionClass - */ - public function reload(ReflectionClass $aClass); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Runner/Version.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Runner/Version.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Runner/Version.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Runner/Version.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Runner - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * This class defines the current version of PHPUnit. - * - * @package PHPUnit - * @subpackage Runner - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -class PHPUnit_Runner_Version -{ - /** - * Returns the current version of PHPUnit. - * - * @return string - */ - public static function id() - { - return '3.5.5'; - } - - /** - * @return string - */ - public static function getVersionString() - { - return 'PHPUnit 3.5.5 by Sebastian Bergmann.'; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/TextUI/Command.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/TextUI/Command.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/TextUI/Command.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/TextUI/Command.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,877 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage TextUI - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * A TestRunner for the Command Line Interface (CLI) - * PHP SAPI Module. - * - * @package PHPUnit - * @subpackage TextUI - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_TextUI_Command -{ - /** - * @var array - */ - protected $arguments = array( - 'listGroups' => FALSE, - 'loader' => NULL, - 'syntaxCheck' => FALSE, - 'useDefaultConfiguration' => TRUE - ); - - /** - * @var array - */ - protected $options = array(); - - /** - * @var array - */ - protected $longOptions = array( - 'colors' => NULL, - 'bootstrap=' => NULL, - 'configuration=' => NULL, - 'coverage-html=' => NULL, - 'coverage-clover=' => NULL, - 'debug' => NULL, - 'exclude-group=' => NULL, - 'filter=' => NULL, - 'group=' => NULL, - 'help' => NULL, - 'include-path=' => NULL, - 'list-groups' => NULL, - 'loader=' => NULL, - 'log-dbus' => NULL, - 'log-json=' => NULL, - 'log-junit=' => NULL, - 'log-tap=' => NULL, - 'process-isolation' => NULL, - 'repeat=' => NULL, - 'skeleton-class' => NULL, - 'skeleton-test' => NULL, - 'stderr' => NULL, - 'stop-on-error' => NULL, - 'stop-on-failure' => NULL, - 'stop-on-incomplete' => NULL, - 'stop-on-skipped' => NULL, - 'story' => NULL, - 'story-html=' => NULL, - 'story-text=' => NULL, - 'strict' => NULL, - 'syntax-check' => NULL, - 'tap' => NULL, - 'testdox' => NULL, - 'testdox-html=' => NULL, - 'testdox-text=' => NULL, - 'no-configuration' => NULL, - 'no-globals-backup' => NULL, - 'static-backup' => NULL, - 'verbose' => NULL, - 'version' => NULL, - 'wait' => NULL - ); - - /** - * @param boolean $exit - */ - public static function main($exit = TRUE) - { - $command = new PHPUnit_TextUI_Command; - $command->run($_SERVER['argv'], $exit); - } - - /** - * @param array $argv - * @param boolean $exit - */ - public function run(array $argv, $exit = TRUE) - { - $this->handleArguments($argv); - - $runner = new PHPUnit_TextUI_TestRunner($this->arguments['loader']); - - if (is_object($this->arguments['test']) && - $this->arguments['test'] instanceof PHPUnit_Framework_Test) { - $suite = $this->arguments['test']; - } else { - $suite = $runner->getTest( - $this->arguments['test'], - $this->arguments['testFile'], - $this->arguments['syntaxCheck'] - ); - } - - if (count($suite) == 0) { - $skeleton = new PHPUnit_Util_Skeleton_Test( - $suite->getName(), - $this->arguments['testFile'] - ); - - $result = $skeleton->generate(TRUE); - - if (!$result['incomplete']) { - eval(str_replace(array(''), '', $result['code'])); - $suite = new PHPUnit_Framework_TestSuite( - $this->arguments['test'] . 'Test' - ); - } - } - - if ($this->arguments['listGroups']) { - PHPUnit_TextUI_TestRunner::printVersionString(); - - print "Available test group(s):\n"; - - $groups = $suite->getGroups(); - sort($groups); - - foreach ($groups as $group) { - print " - $group\n"; - } - - exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); - } - - unset($this->arguments['test']); - unset($this->arguments['testFile']); - - try { - $result = $runner->doRun($suite, $this->arguments); - } - - catch (PHPUnit_Framework_Exception $e) { - print $e->getMessage() . "\n"; - } - - if ($exit) { - if (isset($result) && $result->wasSuccessful()) { - exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); - } - - else if (!isset($result) || $result->errorCount() > 0) { - exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); - } - - else { - exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); - } - } - } - - /** - * Handles the command-line arguments. - * - * A child class of PHPUnit_TextUI_Command can hook into the argument - * parsing by adding the switch(es) to the $longOptions array and point to a - * callback method that handles the switch(es) in the child class like this - * - * - * longOptions['--my-switch'] = 'myHandler'; - * } - * - * // --my-switch foo -> myHandler('foo') - * protected function myHandler($value) - * { - * } - * } - * - * - * @param array $argv - */ - protected function handleArguments(array $argv) - { - try { - $this->options = PHPUnit_Util_Getopt::getopt( - $argv, - 'd:c:', - array_keys($this->longOptions) - ); - } - - catch (RuntimeException $e) { - PHPUnit_TextUI_TestRunner::showError($e->getMessage()); - } - - $skeletonClass = FALSE; - $skeletonTest = FALSE; - - foreach ($this->options[0] as $option) { - switch ($option[0]) { - case '--colors': { - $this->arguments['colors'] = TRUE; - } - break; - - case '--bootstrap': { - $this->arguments['bootstrap'] = $option[1]; - } - break; - - case 'c': - case '--configuration': { - $this->arguments['configuration'] = $option[1]; - } - break; - - case '--coverage-clover': { - if (extension_loaded('tokenizer') && - extension_loaded('xdebug')) { - $this->arguments['coverageClover'] = $option[1]; - } else { - if (!extension_loaded('tokenizer')) { - $this->showMessage( - 'The tokenizer extension is not loaded.' - ); - } else { - $this->showMessage( - 'The Xdebug extension is not loaded.' - ); - } - } - } - break; - - case '--coverage-html': { - if (extension_loaded('tokenizer') && - extension_loaded('xdebug')) { - $this->arguments['reportDirectory'] = $option[1]; - } else { - if (!extension_loaded('tokenizer')) { - $this->showMessage( - 'The tokenizer extension is not loaded.' - ); - } else { - $this->showMessage( - 'The Xdebug extension is not loaded.' - ); - } - } - } - break; - - case 'd': { - $ini = explode('=', $option[1]); - - if (isset($ini[0])) { - if (isset($ini[1])) { - ini_set($ini[0], $ini[1]); - } else { - ini_set($ini[0], TRUE); - } - } - } - break; - - case '--debug': { - $this->arguments['debug'] = TRUE; - } - break; - - case '--help': { - $this->showHelp(); - exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); - } - break; - - case '--filter': { - $this->arguments['filter'] = $option[1]; - } - break; - - case '--group': { - $this->arguments['groups'] = explode(',', $option[1]); - } - break; - - case '--exclude-group': { - $this->arguments['excludeGroups'] = explode( - ',', $option[1] - ); - } - break; - - case '--include-path': { - $includePath = $option[1]; - } - break; - - case '--list-groups': { - $this->arguments['listGroups'] = TRUE; - } - break; - - case '--loader': { - $this->arguments['loader'] = $option[1]; - } - break; - - case '--log-dbus': { - $this->arguments['logDbus'] = TRUE; - } - break; - - case '--log-json': { - $this->arguments['jsonLogfile'] = $option[1]; - } - break; - - case '--log-junit': { - $this->arguments['junitLogfile'] = $option[1]; - } - break; - - case '--log-tap': { - $this->arguments['tapLogfile'] = $option[1]; - } - break; - - case '--process-isolation': { - $this->arguments['processIsolation'] = TRUE; - $this->arguments['syntaxCheck'] = FALSE; - } - break; - - case '--repeat': { - $this->arguments['repeat'] = (int)$option[1]; - } - break; - - case '--stderr': { - $this->arguments['printer'] = new PHPUnit_TextUI_ResultPrinter( - 'php://stderr', - isset($this->arguments['verbose']) ? $this->arguments['verbose'] : FALSE - ); - } - break; - - case '--stop-on-error': { - $this->arguments['stopOnError'] = TRUE; - } - break; - - case '--stop-on-failure': { - $this->arguments['stopOnFailure'] = TRUE; - } - break; - - case '--stop-on-incomplete': { - $this->arguments['stopOnIncomplete'] = TRUE; - } - break; - - case '--stop-on-skipped': { - $this->arguments['stopOnSkipped'] = TRUE; - } - break; - - case '--skeleton-test': { - $skeletonTest = TRUE; - $skeletonClass = FALSE; - } - break; - - case '--skeleton-class': { - $skeletonClass = TRUE; - $skeletonTest = FALSE; - } - break; - - case '--tap': { - $this->arguments['printer'] = new PHPUnit_Util_Log_TAP; - } - break; - - case '--story': { - $this->showMessage( - 'The --story functionality is deprecated and ' . - 'will be removed in the future.', - FALSE - ); - - $this->arguments['printer'] = new PHPUnit_Extensions_Story_ResultPrinter_Text; - } - break; - - case '--story-html': { - $this->showMessage( - 'The --story-html functionality is deprecated and ' . - 'will be removed in the future.', - FALSE - ); - - $this->arguments['storyHTMLFile'] = $option[1]; - } - break; - - case '--story-text': { - $this->showMessage( - 'The --story-text functionality is deprecated and ' . - 'will be removed in the future.', - FALSE - ); - - $this->arguments['storyTextFile'] = $option[1]; - } - break; - - case '--syntax-check': { - $this->arguments['syntaxCheck'] = TRUE; - } - break; - - case '--testdox': { - $this->arguments['printer'] = new PHPUnit_Util_TestDox_ResultPrinter_Text; - } - break; - - case '--testdox-html': { - $this->arguments['testdoxHTMLFile'] = $option[1]; - } - break; - - case '--testdox-text': { - $this->arguments['testdoxTextFile'] = $option[1]; - } - break; - - case '--no-configuration': { - $this->arguments['useDefaultConfiguration'] = FALSE; - } - break; - - case '--no-globals-backup': { - $this->arguments['backupGlobals'] = FALSE; - } - break; - - case '--static-backup': { - $this->arguments['backupStaticAttributes'] = TRUE; - } - break; - - case '--verbose': { - $this->arguments['verbose'] = TRUE; - } - break; - - case '--version': { - PHPUnit_TextUI_TestRunner::printVersionString(); - exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); - } - break; - - case '--wait': { - $this->arguments['wait'] = TRUE; - } - break; - - case '--strict': { - $this->arguments['strict'] = TRUE; - } - break; - - default: { - $optionName = str_replace('--', '', $option[0]); - - if (isset($this->longOptions[$optionName])) { - $handler = $this->longOptions[$optionName]; - } - - else if (isset($this->longOptions[$optionName . '='])) { - $handler = $this->longOptions[$optionName . '=']; - } - - if (isset($handler) && is_callable(array($this, $handler))) { - $this->$handler($option[1]); - } - } - } - } - - if (isset($this->arguments['printer']) && - $this->arguments['printer'] instanceof PHPUnit_Extensions_Story_ResultPrinter_Text && - isset($this->arguments['processIsolation']) && - $this->arguments['processIsolation']) { - $this->showMessage( - 'The story result printer cannot be used in process isolation.' - ); - } - - $this->handleCustomTestSuite(); - - if (!isset($this->arguments['test'])) { - if (isset($this->options[1][0])) { - $this->arguments['test'] = $this->options[1][0]; - } - - if (isset($this->options[1][1])) { - $this->arguments['testFile'] = $this->options[1][1]; - } else { - $this->arguments['testFile'] = ''; - } - - if (isset($this->arguments['test']) && is_file($this->arguments['test'])) { - $this->arguments['testFile'] = realpath($this->arguments['test']); - $this->arguments['test'] = substr($this->arguments['test'], 0, strrpos($this->arguments['test'], '.')); - } - } - - if (isset($includePath)) { - ini_set( - 'include_path', - $includePath . PATH_SEPARATOR . ini_get('include_path') - ); - } - - if (isset($this->arguments['bootstrap'])) { - $this->handleBootstrap($this->arguments['bootstrap'], $this->arguments['syntaxCheck']); - } - - if ($this->arguments['loader'] !== NULL) { - $this->arguments['loader'] = $this->handleLoader($this->arguments['loader']); - } - - if (isset($this->arguments['configuration']) && - is_dir($this->arguments['configuration'])) { - $configurationFile = $this->arguments['configuration'] . - '/phpunit.xml'; - - if (file_exists($configurationFile)) { - $this->arguments['configuration'] = realpath( - $configurationFile - ); - } - - else if (file_exists($configurationFile . '.dist')) { - $this->arguments['configuration'] = realpath( - $configurationFile . '.dist' - ); - } - } - - else if (!isset($this->arguments['configuration']) && - $this->arguments['useDefaultConfiguration']) { - if (file_exists('phpunit.xml')) { - $this->arguments['configuration'] = realpath('phpunit.xml'); - } else if (file_exists('phpunit.xml.dist')) { - $this->arguments['configuration'] = realpath( - 'phpunit.xml.dist' - ); - } - } - - if (isset($this->arguments['configuration'])) { - $configuration = PHPUnit_Util_Configuration::getInstance( - $this->arguments['configuration'] - ); - - $phpunit = $configuration->getPHPUnitConfiguration(); - - if (isset($phpunit['syntaxCheck'])) { - $this->arguments['syntaxCheck'] = $phpunit['syntaxCheck']; - } - - if (isset($phpunit['testSuiteLoaderClass'])) { - if (isset($phpunit['testSuiteLoaderFile'])) { - $file = $phpunit['testSuiteLoaderFile']; - } else { - $file = ''; - } - - $this->arguments['loader'] = $this->handleLoader( - $phpunit['testSuiteLoaderClass'], $file - ); - } - - $configuration->handlePHPConfiguration(); - - if (!isset($this->arguments['bootstrap'])) { - $phpunitConfiguration = $configuration->getPHPUnitConfiguration(); - - if (isset($phpunitConfiguration['bootstrap'])) { - $this->handleBootstrap($phpunitConfiguration['bootstrap'], $this->arguments['syntaxCheck']); - } - } - - $browsers = $configuration->getSeleniumBrowserConfiguration(); - - if (!empty($browsers)) { - PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers; - } - - if (!isset($this->arguments['test'])) { - $testSuite = $configuration->getTestSuiteConfiguration( - $this->arguments['syntaxCheck'] - ); - - if ($testSuite !== NULL) { - $this->arguments['test'] = $testSuite; - } - } - } - - if (isset($this->arguments['test']) && is_string($this->arguments['test']) && substr($this->arguments['test'], -5, 5) == '.phpt') { - $test = new PHPUnit_Extensions_PhptTestCase($this->arguments['test']); - - $this->arguments['test'] = new PHPUnit_Framework_TestSuite; - $this->arguments['test']->addTest($test); - } - - if (!isset($this->arguments['test']) || - (isset($this->arguments['testDatabaseLogRevision']) && !isset($this->arguments['testDatabaseDSN']))) { - $this->showHelp(); - exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); - } - - if (!isset($this->arguments['syntaxCheck'])) { - $this->arguments['syntaxCheck'] = FALSE; - } - - if ($skeletonClass || $skeletonTest) { - if (isset($this->arguments['test']) && $this->arguments['test'] !== FALSE) { - PHPUnit_TextUI_TestRunner::printVersionString(); - - if ($skeletonClass) { - $class = 'PHPUnit_Util_Skeleton_Class'; - } else { - $class = 'PHPUnit_Util_Skeleton_Test'; - } - - try { - $args = array(); - $reflector = new ReflectionClass($class); - - for ($i = 0; $i <= 3; $i++) { - if (isset($this->options[1][$i])) { - $args[] = $this->options[1][$i]; - } - } - - $skeleton = $reflector->newInstanceArgs($args); - $skeleton->write(); - } - - catch (Exception $e) { - print $e->getMessage() . "\n"; - exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); - } - - printf( - 'Wrote skeleton for "%s" to "%s".' . "\n", - $skeleton->getOutClassName(), - $skeleton->getOutSourceFile() - ); - - exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); - } else { - $this->showHelp(); - exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); - } - } - } - - /** - * Handles the loading of the PHPUnit_Runner_TestSuiteLoader implementation. - * - * @param string $loaderClass - * @param string $loaderFile - */ - protected function handleLoader($loaderClass, $loaderFile = '') - { - if (!class_exists($loaderClass, FALSE)) { - if ($loaderFile == '') { - $loaderFile = PHPUnit_Util_Filesystem::classNameToFilename( - $loaderClass - ); - } - - $loaderFile = PHPUnit_Util_Filesystem::fileExistsInIncludePath( - $loaderFile - ); - - if ($loaderFile !== FALSE) { - require $loaderFile; - } - } - - if (class_exists($loaderClass, FALSE)) { - $class = new ReflectionClass($loaderClass); - - if ($class->implementsInterface('PHPUnit_Runner_TestSuiteLoader') && - $class->isInstantiable()) { - $loader = $class->newInstance(); - } - } - - if (!isset($loader)) { - PHPUnit_TextUI_TestRunner::showError( - sprintf( - 'Could not use "%s" as loader.', - - $loaderClass - ) - ); - } - - return $loader; - } - - /** - * Loads a bootstrap file. - * - * @param string $filename - * @param boolean $syntaxCheck - */ - protected function handleBootstrap($filename, $syntaxCheck = FALSE) - { - try { - PHPUnit_Util_Fileloader::checkAndLoad($filename, $syntaxCheck); - } - - catch (RuntimeException $e) { - PHPUnit_TextUI_TestRunner::showError($e->getMessage()); - } - } - - /** - * Shows a message. - * - * @param string $message - * @param boolean $exit - */ - protected function showMessage($message, $exit = TRUE) - { - PHPUnit_TextUI_TestRunner::printVersionString(); - print $message . "\n"; - - if ($exit) { - exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); - } else { - print "\n"; - } - } - - /** - * Show the help message. - */ - protected function showHelp() - { - PHPUnit_TextUI_TestRunner::printVersionString(); - - print << - - --log-junit Log test execution in JUnit XML format to file. - --log-tap Log test execution in TAP format to file. - --log-dbus Log test execution to DBUS. - --log-json Log test execution in JSON format. - - --coverage-html Generate code coverage report in HTML format. - --coverage-clover Write code coverage data in Clover XML format. - - --testdox-html Write agile documentation in HTML format to file. - --testdox-text Write agile documentation in Text format to file. - - --filter Filter which tests to run. - --group ... Only runs tests from the specified group(s). - --exclude-group ... Exclude tests from the specified group(s). - --list-groups List available test groups. - - --loader TestSuiteLoader implementation to use. - --repeat Runs the test(s) repeatedly. - - --tap Report test execution progress in TAP format. - --testdox Report test execution progress in TestDox format. - - --colors Use colors in output. - --stderr Write to STDERR instead of STDOUT. - --stop-on-error Stop execution upon first error. - --stop-on-failure Stop execution upon first error or failure. - --stop-on-skipped Stop execution upon first skipped test. - --stop-on-incomplete Stop execution upon first incomplete test. - --strict Mark a test as incomplete if no assertions are made. - --verbose Output more verbose information. - --wait Waits for a keystroke after each test. - - --skeleton-class Generate Unit class for UnitTest in UnitTest.php. - --skeleton-test Generate UnitTest class for Unit in Unit.php. - - --process-isolation Run each test in a separate PHP process. - --no-globals-backup Do not backup and restore \$GLOBALS for each test. - --static-backup Backup and restore static attributes for each test. - --syntax-check Try to check source files for syntax errors. - - --bootstrap A "bootstrap" PHP file that is run before the tests. - --configuration Read configuration from XML file. - --no-configuration Ignore default configuration file (phpunit.xml). - --include-path Prepend PHP's include_path with given path(s). - -d key[=value] Sets a php.ini value. - - --help Prints this usage information. - --version Prints the version and exits. - -EOT; - } - - /** - * Custom callback for test suite discovery. - */ - protected function handleCustomTestSuite() - { - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/TextUI/ResultPrinter.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/TextUI/ResultPrinter.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/TextUI/ResultPrinter.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/TextUI/ResultPrinter.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,639 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage TextUI - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -require_once 'PHP/Timer.php'; - -/** - * Prints the result of a TextUI TestRunner run. - * - * @package PHPUnit - * @subpackage TextUI - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -class PHPUnit_TextUI_ResultPrinter extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener -{ - const EVENT_TEST_START = 0; - const EVENT_TEST_END = 1; - const EVENT_TESTSUITE_START = 2; - const EVENT_TESTSUITE_END = 3; - - /** - * @var integer - */ - protected $column = 0; - - /** - * @var integer - */ - protected $indent = 0; - - /** - * @var integer - */ - protected $lastEvent = -1; - - /** - * @var boolean - */ - protected $lastTestFailed = FALSE; - - /** - * @var integer - */ - protected $numAssertions = 0; - - /** - * @var integer - */ - protected $numTests = -1; - - /** - * @var integer - */ - protected $numTestsRun = 0; - - /** - * @var integer - */ - protected $numTestsWidth; - - /** - * @var boolean - */ - protected $colors = FALSE; - - /** - * @var boolean - */ - protected $debug = FALSE; - - /** - * @var boolean - */ - protected $verbose = FALSE; - - /** - * Constructor. - * - * @param mixed $out - * @param boolean $verbose - * @param boolean $colors - * @param boolean $debug - * @throws InvalidArgumentException - * @since Method available since Release 3.0.0 - */ - public function __construct($out = NULL, $verbose = FALSE, $colors = FALSE, $debug = FALSE) - { - parent::__construct($out); - - if (is_bool($verbose)) { - $this->verbose = $verbose; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'boolean'); - } - - if (is_bool($colors)) { - $this->colors = $colors; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(3, 'boolean'); - } - - if (is_bool($debug)) { - $this->debug = $debug; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(4, 'boolean'); - } - } - - /** - * @param PHPUnit_Framework_TestResult $result - */ - public function printResult(PHPUnit_Framework_TestResult $result) - { - $this->printHeader(); - - if ($result->errorCount() > 0) { - $this->printErrors($result); - } - - if ($result->failureCount() > 0) { - if ($result->errorCount() > 0) { - print "\n--\n\n"; - } - - $this->printFailures($result); - } - - if ($this->verbose) { - if ($result->notImplementedCount() > 0) { - if ($result->failureCount() > 0) { - print "\n--\n\n"; - } - - $this->printIncompletes($result); - } - - if ($result->skippedCount() > 0) { - if ($result->notImplementedCount() > 0) { - print "\n--\n\n"; - } - - $this->printSkipped($result); - } - } - - $this->printFooter($result); - } - - /** - * @param array $defects - * @param integer $count - * @param string $type - */ - protected function printDefects(array $defects, $count, $type) - { - static $called = FALSE; - - if ($count == 0) { - return; - } - - $this->write( - sprintf( - "%sThere %s %d %s%s:\n", - - $called ? "\n" : '', - ($count == 1) ? 'was' : 'were', - $count, - $type, - ($count == 1) ? '' : 's' - ) - ); - - $i = 1; - - foreach ($defects as $defect) { - $this->printDefect($defect, $i++); - } - - $called = TRUE; - } - - /** - * @param PHPUnit_Framework_TestFailure $defect - * @param integer $count - */ - protected function printDefect(PHPUnit_Framework_TestFailure $defect, $count) - { - $this->printDefectHeader($defect, $count); - $this->printDefectTrace($defect); - } - - /** - * @param PHPUnit_Framework_TestFailure $defect - * @param integer $count - */ - protected function printDefectHeader(PHPUnit_Framework_TestFailure $defect, $count) - { - $failedTest = $defect->failedTest(); - - if ($failedTest instanceof PHPUnit_Framework_SelfDescribing) { - $testName = $failedTest->toString(); - } else { - $testName = get_class($failedTest); - } - - $this->write( - sprintf( - "\n%d) %s\n", - - $count, - $testName - ) - ); - } - - /** - * @param PHPUnit_Framework_TestFailure $defect - */ - protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) - { - $this->write( - $defect->getExceptionAsString() . "\n" . - PHPUnit_Util_Filter::getFilteredStacktrace( - $defect->thrownException(), - FALSE - ) - ); - } - - /** - * @param PHPUnit_Framework_TestResult $result - */ - protected function printErrors(PHPUnit_Framework_TestResult $result) - { - $this->printDefects($result->errors(), $result->errorCount(), 'error'); - } - - /** - * @param PHPUnit_Framework_TestResult $result - */ - protected function printFailures(PHPUnit_Framework_TestResult $result) - { - $this->printDefects( - $result->failures(), - $result->failureCount(), - 'failure' - ); - } - - /** - * @param PHPUnit_Framework_TestResult $result - */ - protected function printIncompletes(PHPUnit_Framework_TestResult $result) - { - $this->printDefects( - $result->notImplemented(), - $result->notImplementedCount(), - 'incomplete test' - ); - } - - /** - * @param PHPUnit_Framework_TestResult $result - * @since Method available since Release 3.0.0 - */ - protected function printSkipped(PHPUnit_Framework_TestResult $result) - { - $this->printDefects( - $result->skipped(), - $result->skippedCount(), - 'skipped test' - ); - } - - protected function printHeader() - { - $this->write($this->verbose ? "\n" : "\n\n"); - $this->write(PHP_Timer::resourceUsage() . "\n\n"); - } - - /** - * @param PHPUnit_Framework_TestResult $result - */ - protected function printFooter(PHPUnit_Framework_TestResult $result) - { - if ($result->wasSuccessful() && - $result->allCompletlyImplemented() && - $result->noneSkipped()) { - if ($this->colors) { - $this->write("\x1b[30;42m\x1b[2K"); - } - - $this->write( - sprintf( - "OK (%d test%s, %d assertion%s)\n", - - count($result), - (count($result) == 1) ? '' : 's', - $this->numAssertions, - ($this->numAssertions == 1) ? '' : 's' - ) - ); - - if ($this->colors) { - $this->write("\x1b[0m\x1b[2K"); - } - } - - else if ((!$result->allCompletlyImplemented() || - !$result->noneSkipped())&& - $result->wasSuccessful()) { - if ($this->colors) { - $this->write( - "\x1b[30;43m\x1b[2KOK, but incomplete or skipped tests!\n" . - "\x1b[0m\x1b[30;43m\x1b[2K" - ); - } else { - $this->write("OK, but incomplete or skipped tests!\n"); - } - - $this->write( - sprintf( - "Tests: %d, Assertions: %d%s%s.\n", - - count($result), - $this->numAssertions, - $this->getCountString( - $result->notImplementedCount(), 'Incomplete' - ), - $this->getCountString( - $result->skippedCount(), 'Skipped' - ) - ) - ); - - if ($this->colors) { - $this->write("\x1b[0m\x1b[2K"); - } - } - - else { - $this->write("\n"); - - if ($this->colors) { - $this->write( - "\x1b[37;41m\x1b[2KFAILURES!\n\x1b[0m\x1b[37;41m\x1b[2K" - ); - } else { - $this->write("FAILURES!\n"); - } - - $this->write( - sprintf( - "Tests: %d, Assertions: %s%s%s%s%s.\n", - - count($result), - $this->numAssertions, - $this->getCountString($result->failureCount(), 'Failures'), - $this->getCountString($result->errorCount(), 'Errors'), - $this->getCountString( - $result->notImplementedCount(), 'Incomplete' - ), - $this->getCountString($result->skippedCount(), 'Skipped') - ) - ); - - if ($this->colors) { - $this->write("\x1b[0m\x1b[2K"); - } - } - } - - /** - * @param integer $count - * @param string $name - * @return string - * @since Method available since Release 3.0.0 - */ - protected function getCountString($count, $name) - { - $string = ''; - - if ($count > 0) { - $string = sprintf( - ', %s: %d', - - $name, - $count - ); - } - - return $string; - } - - /** - */ - public function printWaitPrompt() - { - $this->write("\n to continue\n"); - } - - /** - * An error occurred. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - $this->writeProgress('E'); - $this->lastTestFailed = TRUE; - } - - /** - * A failure occurred. - * - * @param PHPUnit_Framework_Test $test - * @param PHPUnit_Framework_AssertionFailedError $e - * @param float $time - */ - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) - { - $this->writeProgress('F'); - $this->lastTestFailed = TRUE; - } - - /** - * Incomplete test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - $this->writeProgress('I'); - $this->lastTestFailed = TRUE; - } - - /** - * Skipped test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - * @since Method available since Release 3.0.0 - */ - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - $this->writeProgress('S'); - $this->lastTestFailed = TRUE; - } - - /** - * A testsuite started. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - if ($this->numTests == -1) { - $this->numTests = count($suite); - $this->numTestsWidth = strlen((string)$this->numTests); - } else { - $this->indent++; - } - - if ($this->verbose) { - $name = $suite->getName(); - - if (empty($name)) { - $name = 'Test Suite'; - } else { - $name = preg_replace( '(^.*::(.*?)$)', '\\1', $name ); - } - - $this->write( - sprintf( - "%s%s%s", - - $this->lastEvent == self::EVENT_TESTSUITE_END || - $suite instanceof PHPUnit_Framework_TestSuite_DataProvider ? - "\n" : - '', - str_repeat(' ', $this->indent), - $name - ) - ); - - $this->writeNewLine(); - } - - $this->lastEvent = self::EVENT_TESTSUITE_START; - } - - /** - * A testsuite ended. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $this->indent--; - - if ($this->verbose) { - if ($this->lastEvent != self::EVENT_TESTSUITE_END) { - $this->writeNewLine(); - } - } - - $this->lastEvent = self::EVENT_TESTSUITE_END; - } - - /** - * A test started. - * - * @param PHPUnit_Framework_Test $test - */ - public function startTest(PHPUnit_Framework_Test $test) - { - $this->lastEvent = self::EVENT_TEST_START; - - if ($this->debug) { - $this->write( - sprintf( - "\nStarting test '%s'.\n", PHPUnit_Util_Test::describe($test) - ) - ); - } - } - - /** - * A test ended. - * - * @param PHPUnit_Framework_Test $test - * @param float $time - */ - public function endTest(PHPUnit_Framework_Test $test, $time) - { - if (!$this->lastTestFailed) { - $this->writeProgress('.'); - } - - if ($test instanceof PHPUnit_Framework_TestCase) { - $this->numAssertions += $test->getNumAssertions(); - } - - $this->lastEvent = self::EVENT_TEST_END; - $this->lastTestFailed = FALSE; - } - - /** - * @param string $progress - */ - protected function writeProgress($progress) - { - $this->write($progress); - $this->column++; - $this->numTestsRun++; - - if ($this->column == 60) { - if (!$this->verbose) { - $this->write( - sprintf( - ' %' . $this->numTestsWidth . 'd / %' . - $this->numTestsWidth . "d", - - $this->numTestsRun, - $this->numTests - ) - ); - } - - $this->writeNewLine(); - } - } - - protected function writeNewLine() - { - $this->write("\n"); - - if ($this->verbose) { - $this->column = $this->indent; - $this->write(str_repeat(' ', max(0, $this->indent))); - } else { - $this->column = 0; - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/TextUI/TestRunner.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/TextUI/TestRunner.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/TextUI/TestRunner.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/TextUI/TestRunner.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,774 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage TextUI - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * A TestRunner for the Command Line Interface (CLI) - * PHP SAPI Module. - * - * @package PHPUnit - * @subpackage TextUI - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -class PHPUnit_TextUI_TestRunner extends PHPUnit_Runner_BaseTestRunner -{ - const SUCCESS_EXIT = 0; - const FAILURE_EXIT = 1; - const EXCEPTION_EXIT = 2; - - /** - * @var PHPUnit_Runner_TestSuiteLoader - */ - protected $loader = NULL; - - /** - * @var PHPUnit_TextUI_ResultPrinter - */ - protected $printer = NULL; - - /** - * @var boolean - */ - protected static $versionStringPrinted = FALSE; - - /** - * @param PHPUnit_Runner_TestSuiteLoader $loader - * @since Method available since Release 3.4.0 - */ - public function __construct(PHPUnit_Runner_TestSuiteLoader $loader = NULL) - { - $this->loader = $loader; - } - - /** - * @param mixed $test - * @param array $arguments - * @throws InvalidArgumentException - */ - public static function run($test, array $arguments = array()) - { - if ($test instanceof ReflectionClass) { - $test = new PHPUnit_Framework_TestSuite($test); - } - - if ($test instanceof PHPUnit_Framework_Test) { - $aTestRunner = new PHPUnit_TextUI_TestRunner; - - return $aTestRunner->doRun( - $test, - $arguments - ); - } else { - throw new InvalidArgumentException( - 'No test case or test suite found.' - ); - } - } - - /** - * Runs a single test and waits until the user types RETURN. - * - * @param PHPUnit_Framework_Test $suite - */ - public static function runAndWait(PHPUnit_Framework_Test $suite) - { - $aTestRunner = new PHPUnit_TextUI_TestRunner; - - $aTestRunner->doRun( - $suite, - array( - 'wait' => TRUE - ) - ); - - } - - /** - * @return PHPUnit_Framework_TestResult - */ - protected function createTestResult() - { - return new PHPUnit_Framework_TestResult; - } - - /** - * @param PHPUnit_Framework_Test $suite - * @param array $arguments - * @return PHPUnit_Framework_TestResult - */ - public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) - { - $this->handleConfiguration($arguments); - - if (isset($arguments['bootstrap'])) { - $bootstrap = PHPUnit_Util_Fileloader::load($arguments['bootstrap']); - - if ($bootstrap) { - $GLOBALS['__PHPUNIT_BOOTSTRAP'] = $bootstrap; - } - } - - if ($arguments['backupGlobals'] === FALSE) { - $suite->setBackupGlobals(FALSE); - } - - if ($arguments['backupStaticAttributes'] === TRUE) { - $suite->setBackupStaticAttributes(TRUE); - } - - if (is_integer($arguments['repeat'])) { - $suite = new PHPUnit_Extensions_RepeatedTest( - $suite, - $arguments['repeat'], - $arguments['filter'], - $arguments['groups'], - $arguments['excludeGroups'], - $arguments['processIsolation'] - ); - } - - $result = $this->createTestResult(); - - if (!$arguments['convertErrorsToExceptions']) { - $result->convertErrorsToExceptions(FALSE); - } - - if (!$arguments['convertNoticesToExceptions']) { - PHPUnit_Framework_Error_Notice::$enabled = FALSE; - } - - if (!$arguments['convertWarningsToExceptions']) { - PHPUnit_Framework_Error_Warning::$enabled = FALSE; - } - - if ($arguments['stopOnError']) { - $result->stopOnError(TRUE); - } - - if ($arguments['stopOnFailure']) { - $result->stopOnFailure(TRUE); - } - - if ($arguments['stopOnIncomplete']) { - $result->stopOnIncomplete(TRUE); - } - - if ($arguments['stopOnSkipped']) { - $result->stopOnSkipped(TRUE); - } - - if ($this->printer === NULL) { - if (isset($arguments['printer']) && - $arguments['printer'] instanceof PHPUnit_Util_Printer) { - $this->printer = $arguments['printer']; - } else { - $this->printer = new PHPUnit_TextUI_ResultPrinter( - NULL, - $arguments['verbose'], - $arguments['colors'], - $arguments['debug'] - ); - } - } - - if (!$this->printer instanceof PHPUnit_Util_Log_TAP && - !self::$versionStringPrinted) { - $this->printer->write( - PHPUnit_Runner_Version::getVersionString() . "\n\n" - ); - } - - foreach ($arguments['listeners'] as $listener) { - $result->addListener($listener); - } - - $result->addListener($this->printer); - - if (isset($arguments['storyHTMLFile'])) { - $result->addListener( - new PHPUnit_Extensions_Story_ResultPrinter_HTML( - $arguments['storyHTMLFile'] - ) - ); - } - - if (isset($arguments['storyTextFile'])) { - $result->addListener( - new PHPUnit_Extensions_Story_ResultPrinter_Text( - $arguments['storyTextFile'] - ) - ); - } - - if (isset($arguments['testdoxHTMLFile'])) { - $result->addListener( - new PHPUnit_Util_TestDox_ResultPrinter_HTML( - $arguments['testdoxHTMLFile'] - ) - ); - } - - if (isset($arguments['testdoxTextFile'])) { - $result->addListener( - new PHPUnit_Util_TestDox_ResultPrinter_Text( - $arguments['testdoxTextFile'] - ) - ); - } - - if ((isset($arguments['coverageClover']) || - isset($arguments['reportDirectory'])) && - extension_loaded('xdebug')) { - $result->collectCodeCoverageInformation(TRUE); - } - - if (isset($arguments['logDbus'])) { - $result->addListener(new PHPUnit_Util_Log_DBUS); - } - - if (isset($arguments['jsonLogfile'])) { - $result->addListener( - new PHPUnit_Util_Log_JSON($arguments['jsonLogfile']) - ); - } - - if (isset($arguments['tapLogfile'])) { - $result->addListener( - new PHPUnit_Util_Log_TAP($arguments['tapLogfile']) - ); - } - - if (isset($arguments['junitLogfile'])) { - $result->addListener( - new PHPUnit_Util_Log_JUnit( - $arguments['junitLogfile'], $arguments['logIncompleteSkipped'] - ) - ); - } - - if ($arguments['strict']) { - $result->strictMode(TRUE); - } - - $suite->run( - $result, - $arguments['filter'], - $arguments['groups'], - $arguments['excludeGroups'], - $arguments['processIsolation'] - ); - - unset($suite); - $result->flushListeners(); - - if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) { - $this->printer->printResult($result); - } - - if (extension_loaded('tokenizer') && extension_loaded('xdebug')) { - if (isset($arguments['coverageClover'])) { - $this->printer->write( - "\nWriting code coverage data to XML file, this may take " . - 'a moment.' - ); - - require_once 'PHP/CodeCoverage/Report/Clover.php'; - - $writer = new PHP_CodeCoverage_Report_Clover; - $writer->process( - $result->getCodeCoverage(), $arguments['coverageClover'] - ); - - $this->printer->write("\n"); - unset($writer); - } - - if (isset($arguments['reportDirectory'])) { - $this->printer->write( - "\nGenerating code coverage report, this may take a moment." - ); - - $title = ''; - - if (isset($arguments['configuration'])) { - $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration(); - - if (isset($loggingConfiguration['title'])) { - $title = $loggingConfiguration['title']; - } - } - - require_once 'PHP/CodeCoverage/Report/HTML.php'; - - $writer = new PHP_CodeCoverage_Report_HTML( - array( - 'title' => $title, - 'charset' => $arguments['reportCharset'], - 'yui' => $arguments['reportYUI'], - 'highlight' => $arguments['reportHighlight'], - 'lowUpperBound' => $arguments['reportLowUpperBound'], - 'highLowerBound' => $arguments['reportHighLowerBound'], - 'generator' => ' and PHPUnit ' . PHPUnit_Runner_Version::id() - ) - ); - - $writer->process( - $result->getCodeCoverage(), $arguments['reportDirectory'] - ); - - $this->printer->write("\n"); - unset($writer); - } - } - - $this->pause($arguments['wait']); - - return $result; - } - - /** - * @param boolean $wait - */ - protected function pause($wait) - { - if (!$wait) { - return; - } - - if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) { - $this->printer->printWaitPrompt(); - } - - fgets(STDIN); - } - - /** - * @param PHPUnit_TextUI_ResultPrinter $resultPrinter - */ - public function setPrinter(PHPUnit_TextUI_ResultPrinter $resultPrinter) - { - $this->printer = $resultPrinter; - } - - /** - * Override to define how to handle a failed loading of - * a test suite. - * - * @param string $message - */ - protected function runFailed($message) - { - self::printVersionString(); - self::write($message); - exit(self::FAILURE_EXIT); - } - - /** - * @param string $buffer - * @since Method available since Release 3.1.0 - */ - protected static function write($buffer) - { - if (PHP_SAPI != 'cli') { - $buffer = htmlspecialchars($buffer); - } - - print $buffer; - } - - /** - * Returns the loader to be used. - * - * @return PHPUnit_Runner_TestSuiteLoader - * @since Method available since Release 2.2.0 - */ - public function getLoader() - { - if ($this->loader === NULL) { - $this->loader = new PHPUnit_Runner_StandardTestSuiteLoader; - } - - return $this->loader; - } - - /** - */ - public static function showError($message) - { - self::printVersionString(); - self::write($message . "\n"); - - exit(self::FAILURE_EXIT); - } - - /** - */ - public static function printVersionString() - { - if (!self::$versionStringPrinted) { - self::write(PHPUnit_Runner_Version::getVersionString() . "\n\n"); - self::$versionStringPrinted = TRUE; - } - } - - /** - * @param array $arguments - * @since Method available since Release 3.2.1 - */ - protected function handleConfiguration(array &$arguments) - { - if (isset($arguments['configuration']) && - !$arguments['configuration'] instanceof PHPUnit_Util_Configuration) { - $arguments['configuration'] = PHPUnit_Util_Configuration::getInstance( - $arguments['configuration'] - ); - } - - $arguments['debug'] = isset($arguments['debug']) ? $arguments['debug'] : FALSE; - $arguments['filter'] = isset($arguments['filter']) ? $arguments['filter'] : FALSE; - $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array(); - $arguments['wait'] = isset($arguments['wait']) ? $arguments['wait'] : FALSE; - - if (isset($arguments['configuration'])) { - $arguments['configuration']->handlePHPConfiguration(); - - $phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration(); - - if (isset($phpunitConfiguration['backupGlobals']) && - !isset($arguments['backupGlobals'])) { - $arguments['backupGlobals'] = $phpunitConfiguration['backupGlobals']; - } - - if (isset($phpunitConfiguration['backupStaticAttributes']) && - !isset($arguments['backupStaticAttributes'])) { - $arguments['backupStaticAttributes'] = $phpunitConfiguration['backupStaticAttributes']; - } - - if (isset($phpunitConfiguration['bootstrap']) && - !isset($arguments['bootstrap'])) { - $arguments['bootstrap'] = $phpunitConfiguration['bootstrap']; - } - - if (isset($phpunitConfiguration['colors']) && - !isset($arguments['colors'])) { - $arguments['colors'] = $phpunitConfiguration['colors']; - } - - if (isset($phpunitConfiguration['convertErrorsToExceptions']) && - !isset($arguments['convertErrorsToExceptions'])) { - $arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions']; - } - - if (isset($phpunitConfiguration['convertNoticesToExceptions']) && - !isset($arguments['convertNoticesToExceptions'])) { - $arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions']; - } - - if (isset($phpunitConfiguration['convertWarningsToExceptions']) && - !isset($arguments['convertWarningsToExceptions'])) { - $arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions']; - } - - if (isset($phpunitConfiguration['processIsolation']) && - !isset($arguments['processIsolation'])) { - $arguments['processIsolation'] = $phpunitConfiguration['processIsolation']; - } - - if (isset($phpunitConfiguration['stopOnFailure']) && - !isset($arguments['stopOnFailure'])) { - $arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure']; - } - - if (isset($phpunitConfiguration['strict']) && - !isset($arguments['strict'])) { - $arguments['strict'] = $phpunitConfiguration['strict']; - } - - if (isset($phpunitConfiguration['verbose']) && - !isset($arguments['verbose'])) { - $arguments['verbose'] = $phpunitConfiguration['verbose']; - } - - if (isset($phpunitConfiguration['forceCoversAnnotation']) && - !isset($arguments['forceCoversAnnotation'])) { - $arguments['forceCoversAnnotation'] = $phpunitConfiguration['forceCoversAnnotation']; - } - - if (isset($phpunitConfiguration['mapTestClassNameToCoveredClassName']) && - !isset($arguments['mapTestClassNameToCoveredClassName'])) { - $arguments['mapTestClassNameToCoveredClassName'] = $phpunitConfiguration['mapTestClassNameToCoveredClassName']; - } - - $groupConfiguration = $arguments['configuration']->getGroupConfiguration(); - - if (!empty($groupConfiguration['include']) && - !isset($arguments['groups'])) { - $arguments['groups'] = $groupConfiguration['include']; - } - - if (!empty($groupConfiguration['exclude']) && - !isset($arguments['excludeGroups'])) { - $arguments['excludeGroups'] = $groupConfiguration['exclude']; - } - - foreach ($arguments['configuration']->getListenerConfiguration() as $listener) { - if (!class_exists($listener['class'], FALSE) && - $listener['file'] !== '') { - $file = PHPUnit_Util_Filesystem::fileExistsInIncludePath( - $listener['file'] - ); - - if ($file !== FALSE) { - require $file; - } - } - - if (class_exists($listener['class'], FALSE)) { - if (count($listener['arguments']) == 0) { - $listener = new $listener['class']; - } else { - $listenerClass = new ReflectionClass( - $listener['class'] - ); - $listener = $listenerClass->newInstanceArgs( - $listener['arguments'] - ); - } - - if ($listener instanceof PHPUnit_Framework_TestListener) { - $arguments['listeners'][] = $listener; - } - } - } - - $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration(); - - if (isset($loggingConfiguration['coverage-html']) && - !isset($arguments['reportDirectory'])) { - if (isset($loggingConfiguration['charset']) && - !isset($arguments['reportCharset'])) { - $arguments['reportCharset'] = $loggingConfiguration['charset']; - } - - if (isset($loggingConfiguration['yui']) && - !isset($arguments['reportYUI'])) { - $arguments['reportYUI'] = $loggingConfiguration['yui']; - } - - if (isset($loggingConfiguration['highlight']) && - !isset($arguments['reportHighlight'])) { - $arguments['reportHighlight'] = $loggingConfiguration['highlight']; - } - - if (isset($loggingConfiguration['lowUpperBound']) && - !isset($arguments['reportLowUpperBound'])) { - $arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound']; - } - - if (isset($loggingConfiguration['highLowerBound']) && - !isset($arguments['reportHighLowerBound'])) { - $arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound']; - } - - $arguments['reportDirectory'] = $loggingConfiguration['coverage-html']; - } - - if (isset($loggingConfiguration['coverage-clover']) && - !isset($arguments['coverageClover'])) { - $arguments['coverageClover'] = $loggingConfiguration['coverage-clover']; - } - - if (isset($loggingConfiguration['json']) && - !isset($arguments['jsonLogfile'])) { - $arguments['jsonLogfile'] = $loggingConfiguration['json']; - } - - if (isset($loggingConfiguration['plain'])) { - $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter( - $loggingConfiguration['plain'], TRUE - ); - } - - if (isset($loggingConfiguration['tap']) && - !isset($arguments['tapLogfile'])) { - $arguments['tapLogfile'] = $loggingConfiguration['tap']; - } - - if (isset($loggingConfiguration['junit']) && - !isset($arguments['junitLogfile'])) { - $arguments['junitLogfile'] = $loggingConfiguration['junit']; - - if (isset($loggingConfiguration['logIncompleteSkipped']) && - !isset($arguments['logIncompleteSkipped'])) { - $arguments['logIncompleteSkipped'] = $loggingConfiguration['logIncompleteSkipped']; - } - } - - if (isset($loggingConfiguration['story-html']) && - !isset($arguments['storyHTMLFile'])) { - $arguments['storyHTMLFile'] = $loggingConfiguration['story-html']; - } - - if (isset($loggingConfiguration['story-text']) && - !isset($arguments['storyTextFile'])) { - $arguments['storsTextFile'] = $loggingConfiguration['story-text']; - } - - if (isset($loggingConfiguration['testdox-html']) && - !isset($arguments['testdoxHTMLFile'])) { - $arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html']; - } - - if (isset($loggingConfiguration['testdox-text']) && - !isset($arguments['testdoxTextFile'])) { - $arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text']; - } - } - - if (isset($arguments['configuration'])) { - $filterConfiguration = $arguments['configuration']->getFilterConfiguration(); - - $filter = PHP_CodeCoverage_Filter::getInstance(); - - foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) { - $filter->addDirectoryToBlacklist( - $dir['path'], $dir['suffix'], $dir['prefix'], $dir['group'] - ); - } - - foreach ($filterConfiguration['blacklist']['include']['file'] as $file) { - $filter->addFileToBlacklist($file); - } - - foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) { - $filter->removeDirectoryFromBlacklist( - $dir['path'], $dir['suffix'], $dir['prefix'], $dir['group'] - ); - } - - foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) { - $filter->removeFileFromBlacklist($file); - } - - if ((isset($arguments['coverageClover']) || - isset($arguments['reportDirectory'])) && - extension_loaded('xdebug')) { - $coverage = PHP_CodeCoverage::getInstance(); - - $coverage->setProcessUncoveredFilesFromWhitelist( - $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist'] - ); - - if (isset($arguments['forceCoversAnnotation'])) { - $coverage->setForceCoversAnnotation( - $arguments['forceCoversAnnotation'] - ); - } - - if (isset($arguments['mapTestClassNameToCoveredClassName'])) { - $coverage->setMapTestClassNameToCoveredClassName( - $arguments['mapTestClassNameToCoveredClassName'] - ); - } - - foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) { - $filter->addDirectoryToWhitelist( - $dir['path'], $dir['suffix'], $dir['prefix'] - ); - } - - foreach ($filterConfiguration['whitelist']['include']['file'] as $file) { - $filter->addFileToWhitelist($file); - } - - foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) { - $filter->removeDirectoryFromWhitelist( - $dir['path'], $dir['suffix'], $dir['prefix'] - ); - } - - foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) { - $filter->removeFileFromWhitelist($file); - } - } - } - - $arguments['backupGlobals'] = isset($arguments['backupGlobals']) ? $arguments['backupGlobals'] : NULL; - $arguments['backupStaticAttributes'] = isset($arguments['backupStaticAttributes']) ? $arguments['backupStaticAttributes'] : NULL; - $arguments['colors'] = isset($arguments['colors']) ? $arguments['colors'] : FALSE; - $arguments['convertErrorsToExceptions'] = isset($arguments['convertErrorsToExceptions']) ? $arguments['convertErrorsToExceptions'] : TRUE; - $arguments['convertNoticesToExceptions'] = isset($arguments['convertNoticesToExceptions']) ? $arguments['convertNoticesToExceptions'] : TRUE; - $arguments['convertWarningsToExceptions'] = isset($arguments['convertWarningsToExceptions']) ? $arguments['convertWarningsToExceptions'] : TRUE; - $arguments['excludeGroups'] = isset($arguments['excludeGroups']) ? $arguments['excludeGroups'] : array(); - $arguments['groups'] = isset($arguments['groups']) ? $arguments['groups'] : array(); - $arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : FALSE; - $arguments['processIsolation'] = isset($arguments['processIsolation']) ? $arguments['processIsolation'] : FALSE; - $arguments['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : FALSE; - $arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'UTF-8'; - $arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE; - $arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70; - $arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35; - $arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : TRUE; - $arguments['stopOnError'] = isset($arguments['stopOnError']) ? $arguments['stopOnError'] : FALSE; - $arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE; - $arguments['stopOnIncomplete'] = isset($arguments['stopOnIncomplete']) ? $arguments['stopOnIncomplete'] : FALSE; - $arguments['stopOnSkipped'] = isset($arguments['stopOnSkipped']) ? $arguments['stopOnSkipped'] : FALSE; - $arguments['strict'] = isset($arguments['strict']) ? $arguments['strict'] : FALSE; - $arguments['verbose'] = isset($arguments['verbose']) ? $arguments['verbose'] : FALSE; - - if ($arguments['filter'] !== FALSE && - preg_match('/^[a-zA-Z0-9_]/', $arguments['filter'])) { - // Escape delimiters in regular expression. Do NOT use preg_quote, - // to keep magic characters. - $arguments['filter'] = '/' . str_replace( - '/', '\\/', $arguments['filter'] - ) . '/'; - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Class.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Class.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Class.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Class.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,403 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.1.0 - */ - -if (!defined('T_NAMESPACE')) { - define('T_NAMESPACE', 377); -} - -/** - * Class helpers. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.1.0 - */ -class PHPUnit_Util_Class -{ - protected static $buffer = array(); - - /** - * Starts the collection of loaded classes. - * - */ - public static function collectStart() - { - self::$buffer = get_declared_classes(); - } - - /** - * Stops the collection of loaded classes and - * returns the names of the loaded classes. - * - * @return array - */ - public static function collectEnd() - { - return array_values( - array_diff(get_declared_classes(), self::$buffer) - ); - } - - /** - * Returns the class hierarchy for a given class. - * - * @param string $className - * @param boolean $asReflectionObjects - * @return array - */ - public static function getHierarchy($className, $asReflectionObjects = FALSE) - { - if ($asReflectionObjects) { - $classes = array(new ReflectionClass($className)); - } else { - $classes = array($className); - } - - $done = FALSE; - - while (!$done) { - if ($asReflectionObjects) { - $class = new ReflectionClass( - $classes[count($classes)-1]->getName() - ); - } else { - $class = new ReflectionClass($classes[count($classes)-1]); - } - - $parent = $class->getParentClass(); - - if ($parent !== FALSE) { - if ($asReflectionObjects) { - $classes[] = $parent; - } else { - $classes[] = $parent->getName(); - } - } else { - $done = TRUE; - } - } - - return $classes; - } - - /** - * Returns the parameters of a function or method. - * - * @param ReflectionFunction|ReflectionMethod $method - * @param boolean $forCall - * @return string - * @since Method available since Release 3.2.0 - */ - public static function getMethodParameters($method, $forCall = FALSE) - { - $parameters = array(); - - foreach ($method->getParameters() as $i => $parameter) { - $name = '$' . $parameter->getName(); - - if ($name === '$') { - $name .= 'arg' . $i; - } - - $default = ''; - $typeHint = ''; - - if (!$forCall) { - if ($parameter->isArray()) { - $typeHint = 'array '; - } else { - try { - $class = $parameter->getClass(); - } - - catch (ReflectionException $e) { - $class = FALSE; - } - - if ($class) { - $typeHint = $class->getName() . ' '; - } - } - - if ($parameter->isDefaultValueAvailable()) { - $value = $parameter->getDefaultValue(); - $default = ' = ' . var_export($value, TRUE); - } - - else if ($parameter->isOptional()) { - $default = ' = null'; - } - } - - $ref = ''; - - if ($parameter->isPassedByReference()) { - $ref = '&'; - } - - $parameters[] = $typeHint . $ref . $name . $default; - } - - return join(', ', $parameters); - } - - /** - * Returns the package information of a user-defined class. - * - * @param string $className - * @param string $docComment - * @return array - */ - public static function getPackageInformation($className, $docComment) - { - $result = array( - 'namespace' => '', - 'fullPackage' => '', - 'category' => '', - 'package' => '', - 'subpackage' => '' - ); - - if (strpos($className, '\\') !== FALSE) { - $result['namespace'] = self::arrayToName( - explode('\\', $className) - ); - } - - if (preg_match('/@category[\s]+([\.\w]+)/', $docComment, $matches)) { - $result['category'] = $matches[1]; - } - - if (preg_match('/@package[\s]+([\.\w]+)/', $docComment, $matches)) { - $result['package'] = $matches[1]; - $result['fullPackage'] = $matches[1]; - } - - if (preg_match('/@subpackage[\s]+([\.\w]+)/', $docComment, $matches)) { - $result['subpackage'] = $matches[1]; - $result['fullPackage'] .= '.' . $matches[1]; - } - - if (empty($result['fullPackage'])) { - $result['fullPackage'] = self::arrayToName( - explode('_', str_replace('\\', '_', $className)), '.' - ); - } - - return $result; - } - - /** - * Returns the value of a static attribute. - * This also works for attributes that are declared protected or private. - * - * @param string $className - * @param string $attributeName - * @return mixed - * @throws InvalidArgumentException - * @since Method available since Release 3.4.0 - */ - public static function getStaticAttribute($className, $attributeName) - { - if (!is_string($className)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - if (!class_exists($className)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class name'); - } - - if (!is_string($attributeName)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } - - $class = new ReflectionClass($className); - - while ($class) { - $attributes = $class->getStaticProperties(); - - if (array_key_exists($attributeName, $attributes)) { - return $attributes[$attributeName]; - } - - $class = $class->getParentClass(); - } - - throw new PHPUnit_Framework_Exception( - sprintf( - 'Attribute "%s" not found in class.', - - $attributeName - ) - ); - } - - /** - * Returns the value of an object's attribute. - * This also works for attributes that are declared protected or private. - * - * @param object $object - * @param string $attributeName - * @return mixed - * @throws InvalidArgumentException - * @since Method available since Release 3.4.0 - */ - public static function getObjectAttribute($object, $attributeName) - { - if (!is_object($object)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'object'); - } - - if (!is_string($attributeName)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); - } - - PHPUnit_Framework_Assert::assertObjectHasAttribute( - $attributeName, $object - ); - - try { - $attribute = new ReflectionProperty($object, $attributeName); - } - - catch (ReflectionException $e) { - $reflector = new ReflectionObject($object); - - while ($reflector = $reflector->getParentClass()) { - try { - $attribute = $reflector->getProperty($attributeName); - break; - } - - catch(ReflectionException $e) { - } - } - } - - if ($attribute->isPublic()) { - return $object->$attributeName; - } else { - $array = (array)$object; - $protectedName = "\0*\0" . $attributeName; - - if (array_key_exists($protectedName, $array)) { - return $array[$protectedName]; - } else { - $classes = self::getHierarchy(get_class($object)); - - foreach ($classes as $class) { - $privateName = sprintf( - "\0%s\0%s", - - $class, - $attributeName - ); - - if (array_key_exists($privateName, $array)) { - return $array[$privateName]; - } - } - } - } - - throw new PHPUnit_Framework_Exception( - sprintf( - 'Attribute "%s" not found in object.', - - $attributeName - ) - ); - } - - /** - * - * - * @param string $className - * @return array - * @since Method available since Release 3.4.0 - */ - public static function parseFullyQualifiedClassName($className) - { - $result = array( - 'namespace' => '', - 'className' => $className, - 'fullyQualifiedClassName' => $className - ); - - if (strpos($className, '\\') !== FALSE) { - $tmp = explode('\\', $className); - $result['className'] = $tmp[count($tmp)-1]; - $result['namespace'] = self::arrayToName($tmp); - } - - return $result; - } - - /** - * Returns the package information of a user-defined class. - * - * @param array $parts - * @param string $join - * @return string - * @since Method available since Release 3.2.12 - */ - protected static function arrayToName(array $parts, $join = '\\') - { - $result = ''; - - if (count($parts) > 1) { - array_pop($parts); - - $result = join($join, $parts); - } - - return $result; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Configuration.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Configuration.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Configuration.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Configuration.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,868 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.2.0 - */ - -/** - * Wrapper for the PHPUnit XML configuration file. - * - * Example XML configuration file: - * - * - * - * - * - * - * /path/to/files - * /path/to/MyTest.php - * - * - * - * - * - * name - * - * - * name - * - * - * - * - * - * /path/to/files - * /path/to/file - * - * /path/to/files - * /path/to/file - * - * - * - * /path/to/files - * /path/to/file - * - * /path/to/files - * /path/to/file - * - * - * - * - * - * - * - * - * - * Sebastian - * - * - * 22 - * April - * 19.78 - * - * - * MyRelativeFile.php - * MyRelativeDir - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * . - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.2.0 - */ -class PHPUnit_Util_Configuration -{ - private static $instances = array(); - - protected $document; - protected $xpath; - protected $filename; - - /** - * Loads a PHPUnit configuration file. - * - * @param string $filename - */ - protected function __construct($filename) - { - $this->filename = $filename; - $this->document = PHPUnit_Util_XML::loadFile($filename); - $this->xpath = new DOMXPath($this->document); - } - - /** - * @since Method available since Release 3.4.0 - */ - private final function __clone() - { - } - - /** - * Returns a PHPUnit configuration object. - * - * @param string $filename - * @return PHPUnit_Util_Configuration - * @since Method available since Release 3.4.0 - */ - public static function getInstance($filename) - { - $realpath = realpath($filename); - - if ($realpath === FALSE) { - throw new PHPUnit_Framework_Exception( - sprintf( - 'Could not read "%s".', - $filename - ) - ); - } - - if (!isset(self::$instances[$realpath])) { - self::$instances[$realpath] = new PHPUnit_Util_Configuration($realpath); - } - - return self::$instances[$realpath]; - } - - /** - * Returns the configuration for SUT filtering. - * - * @return array - * @since Method available since Release 3.2.1 - */ - public function getFilterConfiguration() - { - $addUncoveredFilesFromWhitelist = TRUE; - - $tmp = $this->xpath->query('filter/whitelist'); - - if ($tmp->length == 1 && - $tmp->item(0)->hasAttribute('addUncoveredFilesFromWhitelist')) { - $addUncoveredFilesFromWhitelist = $this->getBoolean( - (string)$tmp->item(0)->getAttribute('addUncoveredFilesFromWhitelist'), - TRUE - ); - } - - return array( - 'blacklist' => array( - 'include' => array( - 'directory' => $this->readFilterDirectories( - 'filter/blacklist/directory' - ), - 'file' => $this->readFilterFiles( - 'filter/blacklist/file' - ) - ), - 'exclude' => array( - 'directory' => $this->readFilterDirectories( - 'filter/blacklist/exclude/directory' - ), - 'file' => $this->readFilterFiles( - 'filter/blacklist/exclude/file' - ) - ) - ), - 'whitelist' => array( - 'addUncoveredFilesFromWhitelist' => $addUncoveredFilesFromWhitelist, - 'include' => array( - 'directory' => $this->readFilterDirectories( - 'filter/whitelist/directory' - ), - 'file' => $this->readFilterFiles( - 'filter/whitelist/file' - ) - ), - 'exclude' => array( - 'directory' => $this->readFilterDirectories( - 'filter/whitelist/exclude/directory' - ), - 'file' => $this->readFilterFiles( - 'filter/whitelist/exclude/file' - ) - ) - ) - ); - } - - /** - * Returns the configuration for groups. - * - * @return array - * @since Method available since Release 3.2.1 - */ - public function getGroupConfiguration() - { - $groups = array( - 'include' => array(), - 'exclude' => array() - ); - - foreach ($this->xpath->query('groups/include/group') as $group) { - $groups['include'][] = (string)$group->nodeValue; - } - - foreach ($this->xpath->query('groups/exclude/group') as $group) { - $groups['exclude'][] = (string)$group->nodeValue; - } - - return $groups; - } - - /** - * Returns the configuration for listeners. - * - * @return array - * @since Method available since Release 3.4.0 - */ - public function getListenerConfiguration() - { - $result = array(); - - foreach ($this->xpath->query('listeners/listener') as $listener) { - $class = (string)$listener->getAttribute('class'); - $file = ''; - $arguments = array(); - - if ($listener->hasAttribute('file')) { - $file = $this->toAbsolutePath((string)$listener->getAttribute('file')); - } - - if ($listener->childNodes->item(1) instanceof DOMElement && - $listener->childNodes->item(1)->tagName == 'arguments') { - foreach ($listener->childNodes->item(1)->childNodes as $argument) { - if ($argument instanceof DOMElement) { - if($argument->tagName == 'file' || $argument->tagName == 'directory') { - $arguments[] = $this->toAbsolutePath((string)$argument->nodeValue); - } else { - $arguments[] = PHPUnit_Util_XML::xmlToVariable($argument); - } - } - } - } - - $result[] = array( - 'class' => $class, - 'file' => $file, - 'arguments' => $arguments - ); - } - - return $result; - } - - /** - * Returns the logging configuration. - * - * @return array - */ - public function getLoggingConfiguration() - { - $result = array(); - - foreach ($this->xpath->query('logging/log') as $log) { - $type = (string)$log->getAttribute('type'); - $target = $this->toAbsolutePath((string)$log->getAttribute('target')); - - if ($type == 'coverage-html') { - if ($log->hasAttribute('title')) { - $result['title'] = (string)$log->getAttribute('title'); - } - - if ($log->hasAttribute('charset')) { - $result['charset'] = (string)$log->getAttribute('charset'); - } - - if ($log->hasAttribute('lowUpperBound')) { - $result['lowUpperBound'] = (string)$log->getAttribute('lowUpperBound'); - } - - if ($log->hasAttribute('highLowerBound')) { - $result['highLowerBound'] = (string)$log->getAttribute('highLowerBound'); - } - - if ($log->hasAttribute('yui')) { - $result['yui'] = $this->getBoolean( - (string)$log->getAttribute('yui'), - FALSE - ); - } - - if ($log->hasAttribute('highlight')) { - $result['highlight'] = $this->getBoolean( - (string)$log->getAttribute('highlight'), - FALSE - ); - } - } - - else if ($type == 'junit') { - if ($log->hasAttribute('logIncompleteSkipped')) { - $result['logIncompleteSkipped'] = $this->getBoolean( - (string)$log->getAttribute('logIncompleteSkipped'), - FALSE - ); - } - } - - $result[$type] = $target; - } - - return $result; - } - - /** - * Returns the PHP configuration. - * - * @return array - * @since Method available since Release 3.2.1 - */ - public function getPHPConfiguration() - { - $result = array( - 'include_path' => '', - 'ini' => array(), - 'const' => array(), - 'var' => array(), - 'env' => array(), - 'post' => array(), - 'get' => array(), - 'cookie' => array(), - 'server' => array(), - 'files' => array(), - 'request' => array() - ); - - $nl = $this->xpath->query('php/includePath'); - - if ($nl->length == 1) { - $result['include_path'] = $this->toAbsolutePath((string)$nl->item(0)->nodeValue); - } - - foreach ($this->xpath->query('php/ini') as $ini) { - $name = (string)$ini->getAttribute('name'); - $value = (string)$ini->getAttribute('value'); - - $result['ini'][$name] = $value; - } - - foreach ($this->xpath->query('php/const') as $const) { - $name = (string)$const->getAttribute('name'); - $value = (string)$const->getAttribute('value'); - - $result['const'][$name] = $this->getBoolean($value, $value); - } - - foreach (array('var', 'env', 'post', 'get', 'cookie', 'server', 'files', 'request') as $array) { - foreach ($this->xpath->query('php/' . $array) as $var) { - $name = (string)$var->getAttribute('name'); - $value = (string)$var->getAttribute('value'); - - $result[$array][$name] = $this->getBoolean($value, $value); - } - } - - return $result; - } - - /** - * Handles the PHP configuration. - * - * @since Method available since Release 3.2.20 - */ - public function handlePHPConfiguration() - { - $configuration = $this->getPHPConfiguration(); - - if ($configuration['include_path'] != '') { - ini_set( - 'include_path', - $configuration['include_path'] . PATH_SEPARATOR . - ini_get('include_path') - ); - } - - foreach ($configuration['ini'] as $name => $value) { - if (defined($value)) { - $value = constant($value); - } - - ini_set($name, $value); - } - - foreach ($configuration['const'] as $name => $value) { - if (!defined($name)) { - define($name, $value); - } - } - - foreach (array('var', 'env', 'post', 'get', 'cookie', 'server', 'files', 'request') as $array) { - if ($array == 'var') { - $target = &$GLOBALS; - } else { - $target = &$GLOBALS['_' . strtoupper($array)]; - } - - foreach ($configuration[$array] as $name => $value) { - $target[$name] = $value; - } - } - } - - /** - * Returns the PHPUnit configuration. - * - * @return array - * @since Method available since Release 3.2.14 - */ - public function getPHPUnitConfiguration() - { - $result = array(); - $root = $this->document->documentElement; - - if ($root->hasAttribute('colors')) { - $result['colors'] = $this->getBoolean( - (string)$root->getAttribute('colors'), FALSE - ); - } - - else if ($root->hasAttribute('ansi')) { - $result['colors'] = $this->getBoolean( - (string)$root->getAttribute('ansi'), FALSE - ); - } - - if ($root->hasAttribute('backupGlobals')) { - $result['backupGlobals'] = $this->getBoolean( - (string)$root->getAttribute('backupGlobals'), TRUE - ); - } - - if ($root->hasAttribute('backupStaticAttributes')) { - $result['backupStaticAttributes'] = $this->getBoolean( - (string)$root->getAttribute('backupStaticAttributes'), FALSE - ); - } - - if ($root->hasAttribute('bootstrap')) { - $result['bootstrap'] = $this->toAbsolutePath( - (string)$root->getAttribute('bootstrap') - ); - } - - if ($root->hasAttribute('convertErrorsToExceptions')) { - $result['convertErrorsToExceptions'] = $this->getBoolean( - (string)$root->getAttribute('convertErrorsToExceptions'), TRUE - ); - } - - if ($root->hasAttribute('convertNoticesToExceptions')) { - $result['convertNoticesToExceptions'] = $this->getBoolean( - (string)$root->getAttribute('convertNoticesToExceptions'), TRUE - ); - } - - if ($root->hasAttribute('convertWarningsToExceptions')) { - $result['convertWarningsToExceptions'] = $this->getBoolean( - (string)$root->getAttribute('convertWarningsToExceptions'), TRUE - ); - } - - if ($root->hasAttribute('forceCoversAnnotation')) { - $result['forceCoversAnnotation'] = $this->getBoolean( - (string)$root->getAttribute('forceCoversAnnotation'), FALSE - ); - } - - if ($root->hasAttribute('mapTestClassNameToCoveredClassName')) { - $result['mapTestClassNameToCoveredClassName'] = $this->getBoolean( - (string)$root->getAttribute('mapTestClassNameToCoveredClassName'), - FALSE - ); - } - - if ($root->hasAttribute('processIsolation')) { - $result['processIsolation'] = $this->getBoolean( - (string)$root->getAttribute('processIsolation'), FALSE - ); - } - - if ($root->hasAttribute('stopOnError')) { - $result['stopOnError'] = $this->getBoolean( - (string)$root->getAttribute('stopOnError'), FALSE - ); - } - - if ($root->hasAttribute('stopOnFailure')) { - $result['stopOnFailure'] = $this->getBoolean( - (string)$root->getAttribute('stopOnFailure'), FALSE - ); - } - - if ($root->hasAttribute('stopOnIncomplete')) { - $result['stopOnIncomplete'] = $this->getBoolean( - (string)$root->getAttribute('stopOnIncomplete'), FALSE - ); - } - - if ($root->hasAttribute('stopOnSkipped')) { - $result['stopOnSkipped'] = $this->getBoolean( - (string)$root->getAttribute('stopOnSkipped'), FALSE - ); - } - - if ($root->hasAttribute('syntaxCheck')) { - $result['syntaxCheck'] = $this->getBoolean( - (string)$root->getAttribute('syntaxCheck'), FALSE - ); - } - - if ($root->hasAttribute('testSuiteLoaderClass')) { - $result['testSuiteLoaderClass'] = (string)$root->getAttribute( - 'testSuiteLoaderClass' - ); - } - - if ($root->hasAttribute('testSuiteLoaderFile')) { - $result['testSuiteLoaderFile'] = (string)$root->getAttribute( - 'testSuiteLoaderFile' - ); - } - - if ($root->hasAttribute('strict')) { - $result['strict'] = $this->getBoolean( - (string)$root->getAttribute('strict'), FALSE - ); - } - - if ($root->hasAttribute('verbose')) { - $result['verbose'] = $this->getBoolean( - (string)$root->getAttribute('verbose'), FALSE - ); - } - - return $result; - } - - /** - * Returns the SeleniumTestCase browser configuration. - * - * @return array - * @since Method available since Release 3.2.9 - */ - public function getSeleniumBrowserConfiguration() - { - $result = array(); - - foreach ($this->xpath->query('selenium/browser') as $config) { - $name = (string)$config->getAttribute('name'); - $browser = (string)$config->getAttribute('browser'); - - if ($config->hasAttribute('host')) { - $host = (string)$config->getAttribute('host'); - } else { - $host = 'localhost'; - } - - if ($config->hasAttribute('port')) { - $port = (int)$config->getAttribute('port'); - } else { - $port = 4444; - } - - if ($config->hasAttribute('timeout')) { - $timeout = (int)$config->getAttribute('timeout'); - } else { - $timeout = 30000; - } - - $result[] = array( - 'name' => $name, - 'browser' => $browser, - 'host' => $host, - 'port' => $port, - 'timeout' => $timeout - ); - } - - return $result; - } - - /** - * Returns the test suite configuration. - * - * @param boolean $syntaxCheck - * @return PHPUnit_Framework_TestSuite - * @since Method available since Release 3.2.1 - */ - public function getTestSuiteConfiguration($syntaxCheck = FALSE) - { - $testSuiteNodes = $this->xpath->query('testsuites/testsuite'); - - if ($testSuiteNodes->length == 0) { - $testSuiteNodes = $this->xpath->query('testsuite'); - } - - if ($testSuiteNodes->length == 1) { - return $this->getTestSuite($testSuiteNodes->item(0), $syntaxCheck); - } - - if ($testSuiteNodes->length > 1) { - $suite = new PHPUnit_Framework_TestSuite; - - foreach ($testSuiteNodes as $testSuiteNode) { - $suite->addTestSuite( - $this->getTestSuite($testSuiteNode, $syntaxCheck) - ); - } - - return $suite; - } - } - - /** - * @param DOMElement $testSuiteNode - * @param boolean $syntaxCheck - * @return PHPUnit_Framework_TestSuite - * @since Method available since Release 3.4.0 - */ - protected function getTestSuite(DOMElement $testSuiteNode, $syntaxCheck) - { - if ($testSuiteNode->hasAttribute('name')) { - $suite = new PHPUnit_Framework_TestSuite( - (string)$testSuiteNode->getAttribute('name') - ); - } else { - $suite = new PHPUnit_Framework_TestSuite; - } - - foreach ($testSuiteNode->getElementsByTagName('directory') as $directoryNode) { - $directory = (string)$directoryNode->nodeValue; - - if (empty($directory)) { - continue; - } - - if ($directoryNode->hasAttribute('prefix')) { - $prefix = (string)$directoryNode->getAttribute('prefix'); - } else { - $prefix = ''; - } - - if ($directoryNode->hasAttribute('suffix')) { - $suffix = (string)$directoryNode->getAttribute('suffix'); - } else { - $suffix = 'Test.php'; - } - - $testCollector = new PHPUnit_Runner_IncludePathTestCollector( - array($this->toAbsolutePath($directory)), $suffix, $prefix - ); - - $suite->addTestFiles($testCollector->collectTests(), $syntaxCheck); - } - - foreach ($testSuiteNode->getElementsByTagName('file') as $fileNode) { - $file = (string)$fileNode->nodeValue; - - if (empty($file)) { - continue; - } - - $suite->addTestFile($file, $syntaxCheck); - } - - return $suite; - } - - /** - * @param string $value - * @param boolean $default - * @return boolean - * @since Method available since Release 3.2.3 - */ - protected function getBoolean($value, $default) - { - if (strtolower($value) == 'false') { - return FALSE; - } - - else if (strtolower($value) == 'true') { - return TRUE; - } - - return $default; - } - - /** - * @param string $query - * @return array - * @since Method available since Release 3.2.3 - */ - protected function readFilterDirectories($query) - { - $directories = array(); - - foreach ($this->xpath->query($query) as $directory) { - if ($directory->hasAttribute('prefix')) { - $prefix = (string)$directory->getAttribute('prefix'); - } else { - $prefix = ''; - } - - if ($directory->hasAttribute('suffix')) { - $suffix = (string)$directory->getAttribute('suffix'); - } else { - $suffix = '.php'; - } - - if ($directory->hasAttribute('group')) { - $group = (string)$directory->getAttribute('group'); - } else { - $group = 'DEFAULT'; - } - - $directories[] = array( - 'path' => $this->toAbsolutePath((string)$directory->nodeValue), - 'prefix' => $prefix, - 'suffix' => $suffix, - 'group' => $group - ); - } - - return $directories; - } - - /** - * @param string $query - * @return array - * @since Method available since Release 3.2.3 - */ - protected function readFilterFiles($query) - { - $files = array(); - - foreach ($this->xpath->query($query) as $file) { - $files[] = $this->toAbsolutePath((string)$file->nodeValue); - } - - return $files; - } - - /** - * @param string $path - * @return string - * @since Method available since Release 3.5.0 - */ - protected function toAbsolutePath($path) - { - // is the path already an absolute path? - if ($path[0] === '/' || $path[0] === '\\' || - (strlen($path) > 3 && ctype_alpha($path[0]) && - $path[1] === ':' && ($path[2] === '\\' || $path[2] === '/'))) { - return $path; - } - - return dirname($this->filename) . DIRECTORY_SEPARATOR . $path; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Diff.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Diff.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Diff.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Diff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,261 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @author Kore Nordmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.4.0 - */ - -/** - * Diff implementation. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @author Kore Nordmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.4.0 - */ -class PHPUnit_Util_Diff -{ - /** - * Returns the diff between two arrays or strings. - * - * @param array|string $from - * @param array|string $to - * @return string - */ - public static function diff($from, $to) - { - if (is_string($from)) { - $from = preg_split('(\r\n|\r|\n)', $from); - } - - if (is_string($to)) { - $to = preg_split('(\r\n|\r|\n)', $to); - } - - $buffer = "--- Expected\n+++ Actual\n"; - $start = array(); - $end = array(); - $fromLength = count($from); - $toLength = count($to); - $length = min($fromLength, $toLength); - - for ($i = 0; $i < $length; ++$i) { - if ($from[$i] === $to[$i]) { - $start[] = $from[$i]; - unset($from[$i], $to[$i]); - } else { - break; - } - } - - $length -= $i; - - for ($i = 1; $i < $length; ++$i) { - if ($from[$fromLength - $i] === $to[$toLength - $i]) { - array_unshift($end, $from[$fromLength - $i]); - unset($from[$fromLength - $i], $to[$toLength - $i]); - } else { - break; - } - } - - $common = self::longestCommonSubsequence( - array_values($from), array_values($to) - ); - - $diff = array(); - $line = 0; - - foreach ($start as $token) { - $diff[] = array($token, 0 /* OLD */); - } - - reset($from); - reset($to); - - foreach ($common as $token) { - while ((($fromToken = reset($from)) !== $token)) { - $diff[] = array(array_shift($from), 2 /* REMOVED */); - } - - while ((($toToken = reset($to)) !== $token)) { - $diff[] = array(array_shift($to), 1 /* ADDED */); - } - - $diff[] = array($token, 0 /* OLD */); - - array_shift($from); - array_shift($to); - } - - while (($token = array_shift($from)) !== NULL) { - $diff[] = array($token, 2 /* REMOVED */); - } - - while (($token = array_shift($to)) !== NULL) { - $diff[] = array($token, 1 /* ADDED */); - } - - foreach ($end as $token) { - $diff[] = array($token, 0 /* OLD */); - } - - $inOld = FALSE; - $i = 0; - $old = array(); - - foreach ($diff as $line) { - if ($line[1] === 0 /* OLD */) { - if ($inOld === FALSE) { - $inOld = $i; - } - } - - else if ($inOld !== FALSE) { - if (($i - $inOld) > 5) { - $old[$inOld] = $i - 1; - } - - $inOld = FALSE; - } - - ++$i; - } - - $start = isset($old[0]) ? $old[0] : 0; - $end = count($diff); - $i = 0; - - if ($tmp = array_search($end, $old)) { - $end = $tmp; - } - - $newChunk = TRUE; - - for ($i = $start; $i < $end; $i++) { - if (isset($old[$i])) { - $buffer .= "\n"; - $newChunk = TRUE; - $i = $old[$i]; - } - - if ($newChunk) { - // TODO: Implement chunk range information. - $buffer .= "@@ @@\n"; - $newChunk = FALSE; - } - - if ($diff[$i][1] === 1 /* ADDED */) { - $buffer .= '+' . $diff[$i][0] . "\n"; - } - - else if ($diff[$i][1] === 2 /* REMOVED */) { - $buffer .= '-' . $diff[$i][0] . "\n"; - } - - else { - $buffer .= ' ' . $diff[$i][0] . "\n"; - } - } - - return $buffer; - } - - /** - * Calculates the longest common subsequence of two arrays. - * - * @param array $from - * @param array $to - * @return array - */ - protected static function longestCommonSubsequence(array $from, array $to) - { - $common = array(); - $matrix = array(); - $fromLength = count($from); - $toLength = count($to); - - for ($i = 0; $i <= $fromLength; ++$i) { - $matrix[$i][0] = 0; - } - - for ($j = 0; $j <= $toLength; ++$j) { - $matrix[0][$j] = 0; - } - - for ($i = 1; $i <= $fromLength; ++$i) { - for ($j = 1; $j <= $toLength; ++$j) { - $matrix[$i][$j] = max( - $matrix[$i-1][$j], - $matrix[$i][$j-1], - $from[$i-1] === $to[$j-1] ? $matrix[$i-1][$j-1] + 1 : 0 - ); - } - } - - $i = $fromLength; - $j = $toLength; - - while ($i > 0 && $j > 0) { - if ($from[$i-1] === $to[$j-1]) { - array_unshift($common, $from[$i-1]); - --$i; - --$j; - } - - else if ($matrix[$i][$j-1] > $matrix[$i-1][$j]) { - --$j; - } - - else { - --$i; - } - } - - return $common; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/ErrorHandler.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/ErrorHandler.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/ErrorHandler.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/ErrorHandler.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.3.0 - */ - -/** - * Error handler that converts PHP errors and warnings to exceptions. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Util_ErrorHandler -{ - protected static $errorStack = array(); - - /** - * Returns the error stack. - * - * @return array - */ - public static function getErrorStack() - { - return self::$errorStack; - } - - /** - * @param integer $errno - * @param string $errstr - * @param string $errfile - * @param integer $errline - * @throws PHPUnit_Framework_Error - */ - public static function handleError($errno, $errstr, $errfile, $errline) - { - if (!($errno & error_reporting())) { - return FALSE; - } - - self::$errorStack[] = array($errno, $errstr, $errfile, $errline); - - $trace = debug_backtrace(FALSE); - array_shift($trace); - - foreach ($trace as $frame) { - if ($frame['function'] == '__toString') { - return FALSE; - } - } - - if ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_STRICT) { - if (PHPUnit_Framework_Error_Notice::$enabled !== TRUE) { - return FALSE; - } - - $exception = 'PHPUnit_Framework_Error_Notice'; - } - - else if ($errno == E_WARNING || $errno == E_USER_WARNING) { - if (PHPUnit_Framework_Error_Warning::$enabled !== TRUE) { - return FALSE; - } - - $exception = 'PHPUnit_Framework_Error_Warning'; - } - - else { - $exception = 'PHPUnit_Framework_Error'; - } - - throw new $exception($errstr, $errno, $errfile, $errline, $trace); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/File.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/File.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/File.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/File.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,310 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.4.0 - */ - -if (!defined('T_NAMESPACE')) { - define('T_NAMESPACE', 377); -} - -/** - * File helpers. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.4.0 - */ -class PHPUnit_Util_File -{ - /** - * @var array - */ - protected static $cache = array(); - - /** - * Returns information on the classes declared in a sourcefile. - * - * @param string $filename - * @return array - */ - public static function getClassesInFile($filename) - { - if (!isset(self::$cache[$filename])) { - self::$cache[$filename] = self::parseFile($filename); - } - - return self::$cache[$filename]; - } - - /** - * Parses a file for class and method information. - * - * @param string $filename - * @return array - */ - protected static function parseFile($filename) - { - $result = array(); - - $tokens = token_get_all( - file_get_contents($filename) - ); - $numTokens = count($tokens); - $blocks = array(); - $line = 1; - $currentBlock = FALSE; - $currentNamespace = FALSE; - $currentClass = FALSE; - $currentFunction = FALSE; - $currentFunctionStartLine = FALSE; - $currentFunctionTokens = array(); - $currentDocComment = FALSE; - $currentSignature = FALSE; - $currentSignatureStartToken = FALSE; - - for ($i = 0; $i < $numTokens; $i++) { - if ($currentFunction !== FALSE) { - $currentFunctionTokens[] = $tokens[$i]; - } - - if (is_string($tokens[$i])) { - if ($tokens[$i] == '{') { - if ($currentBlock == T_CLASS) { - $block = $currentClass; - } - - else if ($currentBlock == T_FUNCTION) { - $currentSignature = ''; - - for ($j = $currentSignatureStartToken; $j < $i; $j++) { - if (is_string($tokens[$j])) { - $currentSignature .= $tokens[$j]; - } else { - $currentSignature .= $tokens[$j][1]; - } - } - - $currentSignature = trim($currentSignature); - - $block = $currentFunction; - $currentSignatureStartToken = FALSE; - } - - else { - $block = FALSE; - } - - array_push($blocks, $block); - - $currentBlock = FALSE; - } - - else if ($tokens[$i] == '}') { - $block = array_pop($blocks); - - if ($block !== FALSE && $block !== NULL) { - if ($block == $currentFunction) { - if ($currentDocComment !== FALSE) { - $docComment = $currentDocComment; - $currentDocComment = FALSE; - } else { - $docComment = ''; - } - - $tmp = array( - 'docComment' => $docComment, - 'signature' => $currentSignature, - 'startLine' => $currentFunctionStartLine, - 'endLine' => $line, - 'tokens' => $currentFunctionTokens - ); - - if ($currentClass !== FALSE) { - $result[$currentClass]['methods'][$currentFunction] = $tmp; - } - - $currentFunction = FALSE; - $currentFunctionStartLine = FALSE; - $currentFunctionTokens = array(); - $currentSignature = FALSE; - } - - else if ($block == $currentClass) { - $result[$currentClass]['endLine'] = $line; - - $currentClass = FALSE; - $currentClassStartLine = FALSE; - } - } - } - - continue; - } - - switch ($tokens[$i][0]) { - case T_HALT_COMPILER: { - return; - } - break; - - case T_NAMESPACE: { - $currentNamespace = $tokens[$i+2][1]; - - for ($j = $i+3; $j < $numTokens; $j += 2) { - if ($tokens[$j][0] == T_NS_SEPARATOR) { - $currentNamespace .= '\\' . $tokens[$j+1][1]; - } else { - break; - } - } - } - break; - - case T_CURLY_OPEN: { - $currentBlock = T_CURLY_OPEN; - array_push($blocks, $currentBlock); - } - break; - - case T_DOLLAR_OPEN_CURLY_BRACES: { - $currentBlock = T_DOLLAR_OPEN_CURLY_BRACES; - array_push($blocks, $currentBlock); - } - break; - - case T_CLASS: { - $currentBlock = T_CLASS; - - if ($currentNamespace === FALSE) { - $currentClass = $tokens[$i+2][1]; - } else { - $currentClass = $currentNamespace . '\\' . - $tokens[$i+2][1]; - } - - if ($currentDocComment !== FALSE) { - $docComment = $currentDocComment; - $currentDocComment = FALSE; - } else { - $docComment = ''; - } - - $result[$currentClass] = array( - 'methods' => array(), - 'docComment' => $docComment, - 'startLine' => $line - ); - } - break; - - case T_FUNCTION: { - if (!((is_array($tokens[$i+2]) && - $tokens[$i+2][0] == T_STRING) || - (is_string($tokens[$i+2]) && - $tokens[$i+2] == '&' && - is_array($tokens[$i+3]) && - $tokens[$i+3][0] == T_STRING))) { - continue; - } - - $currentBlock = T_FUNCTION; - $currentFunctionStartLine = $line; - - $done = FALSE; - $currentSignatureStartToken = $i - 1; - - do { - switch ($tokens[$currentSignatureStartToken][0]) { - case T_ABSTRACT: - case T_FINAL: - case T_PRIVATE: - case T_PUBLIC: - case T_PROTECTED: - case T_STATIC: - case T_WHITESPACE: { - $currentSignatureStartToken--; - } - break; - - default: { - $currentSignatureStartToken++; - $done = TRUE; - } - } - } - while (!$done); - - if (isset($tokens[$i+2][1])) { - $functionName = $tokens[$i+2][1]; - } - - else if (isset($tokens[$i+3][1])) { - $functionName = $tokens[$i+3][1]; - } - - if ($currentNamespace === FALSE) { - $currentFunction = $functionName; - } else { - $currentFunction = $currentNamespace . '\\' . - $functionName; - } - } - break; - - case T_DOC_COMMENT: { - $currentDocComment = $tokens[$i][1]; - } - break; - } - - $line += substr_count($tokens[$i][1], "\n"); - } - - return $result; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Fileloader.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Fileloader.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Fileloader.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Fileloader.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.3.0 - */ - -/** - * Utility methods to load PHP sourcefiles. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://www.phpunit.de/ - * @since Class available since Release 2.3.0 - */ -class PHPUnit_Util_Fileloader -{ - /** - * Checks if a PHP sourcefile is readable and is optionally checked for - * syntax errors through the syntaxCheck() method. The sourcefile is - * loaded through the load() method. - * - * @param string $filename - * @param boolean $syntaxCheck - * @throws RuntimeException - */ - public static function checkAndLoad($filename, $syntaxCheck = FALSE) - { - if (!is_readable($filename)) { - $filename = './' . $filename; - } - - if (!is_readable($filename)) { - throw new RuntimeException( - sprintf('Cannot open file "%s".' . "\n", $filename) - ); - } - - if ($syntaxCheck) { - self::syntaxCheck($filename); - } - - self::load($filename); - } - - /** - * Loads a PHP sourcefile. - * - * @param string $filename - * @return mixed - * @since Method available since Release 3.0.0 - */ - public static function load($filename) - { - $filename = PHPUnit_Util_Filesystem::fileExistsInIncludePath( - $filename - ); - - $oldVariableNames = array_keys(get_defined_vars()); - - include_once $filename; - - $newVariables = get_defined_vars(); - $newVariableNames = array_diff( - array_keys($newVariables), $oldVariableNames - ); - - foreach ($newVariableNames as $variableName) { - if ($variableName != 'oldVariableNames') { - $GLOBALS[$variableName] = $newVariables[$variableName]; - } - } - - return $filename; - } - - /** - * Uses a separate process to perform a syntax check on a PHP sourcefile. - * - * @param string $filename - * @throws RuntimeException - * @since Method available since Release 3.0.0 - */ - protected static function syntaxCheck($filename) - { - $command = PHPUnit_Util_PHP::getPhpBinary(); - - if (DIRECTORY_SEPARATOR == '\\') { - $command = escapeshellarg($command); - } - - $command .= ' -l ' . escapeshellarg($filename); - $output = shell_exec($command); - - if (strpos($output, 'Errors parsing') !== FALSE) { - throw new RuntimeException($output); - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Filesystem.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Filesystem.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Filesystem.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Filesystem.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,149 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Filesystem helpers. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Util_Filesystem -{ - /** - * @var array - */ - protected static $buffer = array(); - - /** - * Maps class names to source file names: - * - PEAR CS: Foo_Bar_Baz -> Foo/Bar/Baz.php - * - Namespace: Foo\Bar\Baz -> Foo/Bar/Baz.php - * - * @param string $className - * @return string - * @since Method available since Release 3.4.0 - */ - public static function classNameToFilename($className) - { - return str_replace( - array('_', '\\'), - DIRECTORY_SEPARATOR, - $className - ) . '.php'; - } - - /** - * Starts the collection of loaded files. - * - * @since Method available since Release 3.3.0 - */ - public static function collectStart() - { - self::$buffer = get_included_files(); - } - - /** - * Stops the collection of loaded files and - * returns the names of the loaded files. - * - * @return array - * @since Method available since Release 3.3.0 - */ - public static function collectEnd() - { - return array_values( - array_diff(get_included_files(), self::$buffer) - ); - } - - /** - * Stops the collection of loaded files and adds - * the names of the loaded files to the blacklist. - * - * @return array - * @since Method available since Release 3.4.6 - */ - public static function collectEndAndAddToBlacklist() - { - foreach (self::collectEnd() as $blacklistedFile) { - PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist( - $blacklistedFile, 'PHPUNIT' - ); - } - } - - /** - * Wrapper for file_exists() that searches the include_path. - * - * @param string $file - * @return mixed - * @author Mattis Stordalen Flister - * @since Method available since Release 3.2.9 - */ - public static function fileExistsInIncludePath($file) - { - if (file_exists($file)) { - return realpath($file); - } - - $paths = explode(PATH_SEPARATOR, get_include_path()); - - foreach ($paths as $path) { - $fullpath = $path . DIRECTORY_SEPARATOR . $file; - - if (file_exists($fullpath)) { - return realpath($fullpath); - } - } - - return FALSE; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Filter.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Filter.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Filter.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Filter.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -require_once 'File/Iterator/Factory.php'; - -/** - * Utility class for code filtering. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -class PHPUnit_Util_Filter -{ - /** - * Filters stack frames from PHPUnit classes. - * - * @param Exception $e - * @param boolean $filterTests - * @param boolean $asString - * @return string - */ - public static function getFilteredStacktrace(Exception $e, $filterTests = TRUE, $asString = TRUE) - { - if ($asString === TRUE) { - $filteredStacktrace = ''; - } else { - $filteredStacktrace = array(); - } - - $groups = array('DEFAULT'); - - if (!defined('PHPUNIT_TESTSUITE')) { - $groups[] = 'PHPUNIT'; - } - - if ($filterTests) { - $groups[] = 'TESTS'; - } - - if ($e instanceof PHPUnit_Framework_SyntheticError) { - $eTrace = $e->getSyntheticTrace(); - } else { - $eTrace = $e->getTrace(); - } - - if (!self::frameExists($eTrace, $e->getFile(), $e->getLine())) { - array_unshift( - $eTrace, array('file' => $e->getFile(), 'line' => $e->getLine()) - ); - } - - foreach ($eTrace as $frame) { - if (isset($frame['file']) && is_file($frame['file']) && - !PHP_CodeCoverage::getInstance()->filter()->isFiltered( - $frame['file'], $groups, TRUE)) { - if ($asString === TRUE) { - $filteredStacktrace .= sprintf( - "%s:%s\n", - - $frame['file'], - isset($frame['line']) ? $frame['line'] : '?' - ); - } else { - $filteredStacktrace[] = $frame; - } - } - } - - return $filteredStacktrace; - } - - /** - * @param array $trace - * @param string $file - * @param int $line - * @return boolean - * @since Method available since Release 3.3.2 - */ - public static function frameExists(array $trace, $file, $line) - { - foreach ($trace as $frame) { - if (isset($frame['file']) && $frame['file'] == $file && - isset($frame['line']) && $frame['line'] == $line) { - return TRUE; - } - } - - return FALSE; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Getopt.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Getopt.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Getopt.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Getopt.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,208 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Command-line options parsing class. - * - * @package PHPUnit - * @subpackage Util - * @author Andrei Zmievski - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Util_Getopt -{ - public static function getopt(array $args, $short_options, $long_options = NULL) - { - if (empty($args)) { - return array(array(), array()); - } - - $opts = array(); - $non_opts = array(); - - if ($long_options) { - sort($long_options); - } - - if (isset($args[0][0]) && $args[0][0] != '-') { - array_shift($args); - } - - reset($args); - array_map('trim', $args); - - while (list($i, $arg) = each($args)) { - if ($arg == '') { - continue; - } - - if ($arg == '--') { - $non_opts = array_merge($non_opts, array_slice($args, $i + 1)); - break; - } - - if ($arg[0] != '-' || - (strlen($arg) > 1 && $arg[1] == '-' && !$long_options)) { - $non_opts = array_merge($non_opts, array_slice($args, $i)); - break; - } - - elseif (strlen($arg) > 1 && $arg[1] == '-') { - self::parseLongOption( - substr($arg, 2), $long_options, $opts, $args - ); - } - - else { - self::parseShortOption( - substr($arg, 1), $short_options, $opts, $args - ); - } - } - - return array($opts, $non_opts); - } - - protected static function parseShortOption($arg, $short_options, &$opts, &$args) - { - $argLen = strlen($arg); - - for ($i = 0; $i < $argLen; $i++) { - $opt = $arg[$i]; - $opt_arg = NULL; - - if (($spec = strstr($short_options, $opt)) === FALSE || - $arg[$i] == ':') { - throw new PHPUnit_Framework_Exception( - "unrecognized option -- $opt" - ); - } - - if (strlen($spec) > 1 && $spec[1] == ':') { - if (strlen($spec) > 2 && $spec[2] == ':') { - if ($i + 1 < $argLen) { - $opts[] = array($opt, substr($arg, $i + 1)); - break; - } - } else { - if ($i + 1 < $argLen) { - $opts[] = array($opt, substr($arg, $i + 1)); - break; - } - - else if (list(, $opt_arg) = each($args)) { - } - - else { - throw new PHPUnit_Framework_Exception( - "option requires an argument -- $opt" - ); - } - } - } - - $opts[] = array($opt, $opt_arg); - } - } - - protected static function parseLongOption($arg, $long_options, &$opts, &$args) - { - $count = count($long_options); - $list = explode('=', $arg); - $opt = $list[0]; - $opt_arg = NULL; - - if (count($list) > 1) { - $opt_arg = $list[1]; - } - - $opt_len = strlen($opt); - - for ($i = 0; $i < $count; $i++) { - $long_opt = $long_options[$i]; - $opt_start = substr($long_opt, 0, $opt_len); - - if ($opt_start != $opt) { - continue; - } - - $opt_rest = substr($long_opt, $opt_len); - - if ($opt_rest != '' && $opt[0] != '=' && $i + 1 < $count && - $opt == substr($long_options[$i+1], 0, $opt_len)) { - throw new PHPUnit_Framework_Exception( - "option --$opt is ambiguous" - ); - } - - if (substr($long_opt, -1) == '=') { - if (substr($long_opt, -2) != '==') { - if (!strlen($opt_arg) && - !(list(, $opt_arg) = each($args))) { - throw new PHPUnit_Framework_Exception( - "option --$opt requires an argument" - ); - } - } - } - - else if ($opt_arg) { - throw new PHPUnit_Framework_Exception( - "option --$opt doesn't allow an argument" - ); - } - - $opts[] = array('--' . $opt, $opt_arg); - return; - } - - throw new PHPUnit_Framework_Exception("unrecognized option --$opt"); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/GlobalState.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/GlobalState.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/GlobalState.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/GlobalState.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,348 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.4.0 - */ - -/** - * - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.4.0 - */ -class PHPUnit_Util_GlobalState -{ - /** - * @var array - */ - protected static $globals = array(); - - /** - * @var array - */ - protected static $staticAttributes = array(); - - /** - * @var array - */ - protected static $superGlobalArrays = array( - '_ENV', - '_POST', - '_GET', - '_COOKIE', - '_SERVER', - '_FILES', - '_REQUEST' - ); - - /** - * @var array - */ - protected static $superGlobalArraysLong = array( - 'HTTP_ENV_VARS', - 'HTTP_POST_VARS', - 'HTTP_GET_VARS', - 'HTTP_COOKIE_VARS', - 'HTTP_SERVER_VARS', - 'HTTP_POST_FILES' - ); - - public static function backupGlobals(array $blacklist) - { - self::$globals = array(); - $superGlobalArrays = self::getSuperGlobalArrays(); - - foreach ($superGlobalArrays as $superGlobalArray) { - if (!in_array($superGlobalArray, $blacklist)) { - self::backupSuperGlobalArray($superGlobalArray); - } - } - - foreach (array_keys($GLOBALS) as $key) { - if ($key != 'GLOBALS' && - !in_array($key, $superGlobalArrays) && - !in_array($key, $blacklist)) { - self::$globals['GLOBALS'][$key] = serialize($GLOBALS[$key]); - } - } - } - - public static function restoreGlobals(array $blacklist) - { - if (ini_get('register_long_arrays') == '1') { - $superGlobalArrays = array_merge( - self::$superGlobalArrays, self::$superGlobalArraysLong - ); - } else { - $superGlobalArrays = self::$superGlobalArrays; - } - - foreach ($superGlobalArrays as $superGlobalArray) { - if (!in_array($superGlobalArray, $blacklist)) { - self::restoreSuperGlobalArray($superGlobalArray); - } - } - - foreach (array_keys($GLOBALS) as $key) { - if ($key != 'GLOBALS' && - !in_array($key, $superGlobalArrays) && - !in_array($key, $blacklist)) { - if (isset(self::$globals['GLOBALS'][$key])) { - $GLOBALS[$key] = unserialize( - self::$globals['GLOBALS'][$key] - ); - } else { - unset($GLOBALS[$key]); - } - } - } - - self::$globals = array(); - } - - protected static function backupSuperGlobalArray($superGlobalArray) - { - self::$globals[$superGlobalArray] = array(); - - if (isset($GLOBALS[$superGlobalArray]) && - is_array($GLOBALS[$superGlobalArray])) { - foreach ($GLOBALS[$superGlobalArray] as $key => $value) { - self::$globals[$superGlobalArray][$key] = serialize($value); - } - } - } - - protected static function restoreSuperGlobalArray($superGlobalArray) - { - if (isset($GLOBALS[$superGlobalArray]) && - is_array($GLOBALS[$superGlobalArray]) && - isset(self::$globals[$superGlobalArray])) { - $keys = array_keys( - array_merge( - $GLOBALS[$superGlobalArray], self::$globals[$superGlobalArray] - ) - ); - - foreach ($keys as $key) { - if (isset(self::$globals[$superGlobalArray][$key])) { - $GLOBALS[$superGlobalArray][$key] = unserialize( - self::$globals[$superGlobalArray][$key] - ); - } else { - unset($GLOBALS[$superGlobalArray][$key]); - } - } - } - - self::$globals[$superGlobalArray] = array(); - } - - public static function getIncludedFilesAsString() - { - $blacklist = PHP_CodeCoverage::getInstance()->filter()->getBlacklist(); - $blacklist = array_flip($blacklist['PHPUNIT']); - $files = get_included_files(); - $result = ''; - - for ($i = count($files) - 1; $i > 0; $i--) { - if (!isset($blacklist[$files[$i]]) && is_file($files[$i])) { - $result = 'require_once \'' . $files[$i] . "';\n" . $result; - } - } - - return $result; - } - - public static function getConstantsAsString() - { - $constants = get_defined_constants(TRUE); - $result = ''; - - if (isset($constants['user'])) { - foreach ($constants['user'] as $name => $value) { - $result .= sprintf( - 'if (!defined(\'%s\')) define(\'%s\', %s);' . "\n", - $name, - $name, - self::exportVariable($value) - ); - } - } - - return $result; - } - - public static function getGlobalsAsString() - { - $result = ''; - $superGlobalArrays = self::getSuperGlobalArrays(); - - foreach ($superGlobalArrays as $superGlobalArray) { - if (isset($GLOBALS[$superGlobalArray]) && - is_array($GLOBALS[$superGlobalArray])) { - foreach (array_keys($GLOBALS[$superGlobalArray]) as $key) { - $result .= sprintf( - '$GLOBALS[\'%s\'][\'%s\'] = %s;' . "\n", - $superGlobalArray, - $key, - self::exportVariable($GLOBALS[$superGlobalArray][$key]) - ); - } - } - } - - $blacklist = $superGlobalArrays; - $blacklist[] = 'GLOBALS'; - $blacklist[] = '_PEAR_Config_instance'; - - foreach (array_keys($GLOBALS) as $key) { - if (!in_array($key, $blacklist)) { - $result .= sprintf( - '$GLOBALS[\'%s\'] = %s;' . "\n", - $key, - self::exportVariable($GLOBALS[$key]) - ); - } - } - - return $result; - } - - protected static function getSuperGlobalArrays() - { - if (ini_get('register_long_arrays') == '1') { - return array_merge( - self::$superGlobalArrays, self::$superGlobalArraysLong - ); - } else { - return self::$superGlobalArrays; - } - } - - public static function backupStaticAttributes(array $blacklist) - { - self::$staticAttributes = array(); - $declaredClasses = get_declared_classes(); - $declaredClassesNum = count($declaredClasses); - - for ($i = $declaredClassesNum - 1; $i >= 0; $i--) { - if (strpos($declaredClasses[$i], 'PHPUnit') !== 0 && - !$declaredClasses[$i] instanceof PHPUnit_Framework_Test) { - $class = new ReflectionClass($declaredClasses[$i]); - - if (!$class->isUserDefined()) { - break; - } - - $backup = array(); - - foreach ($class->getProperties() as $attribute) { - if ($attribute->isStatic()) { - $name = $attribute->getName(); - - if (!isset($blacklist[$declaredClasses[$i]]) || - !in_array($name, $blacklist[$declaredClasses[$i]])) { - $attribute->setAccessible(TRUE); - $backup[$name] = serialize($attribute->getValue()); - } - } - } - - if (!empty($backup)) { - self::$staticAttributes[$declaredClasses[$i]] = $backup; - } - } - } - } - - public static function restoreStaticAttributes() - { - foreach (self::$staticAttributes as $className => $staticAttributes) { - foreach ($staticAttributes as $name => $value) { - $reflector = new ReflectionProperty($className, $name); - $reflector->setAccessible(TRUE); - $reflector->setValue(unserialize($value)); - } - } - - self::$staticAttributes = array(); - } - - protected static function exportVariable($variable) - { - if (is_scalar($variable) || is_null($variable) || - (is_array($variable) && self::arrayOnlyContainsScalars($variable))) { - return var_export($variable, TRUE); - } - - return 'unserialize(\'' . - str_replace("'", "\'", serialize($variable)) . - '\')'; - } - - protected static function arrayOnlyContainsScalars(array $array) - { - $result = TRUE; - - foreach ($array as $element) { - if (is_array($element)) { - $result = self::arrayOnlyContainsScalars($element); - } - - else if (!is_scalar($element) && !is_null($element)) { - $result = FALSE; - } - - if ($result === FALSE) { - break; - } - } - - return $result; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/InvalidArgumentHelper.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/InvalidArgumentHelper.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/InvalidArgumentHelper.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/InvalidArgumentHelper.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.4.0 - */ - -/** - * Factory for InvalidArgumentException objects. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.4.0 - */ -class PHPUnit_Util_InvalidArgumentHelper -{ - /** - * @param integer $argument - * @param string $type - * @param mixed $value - */ - public static function factory($argument, $type, $value = NULL) - { - $stack = debug_backtrace(FALSE); - - return new InvalidArgumentException( - sprintf( - 'Argument #%d%sof %s::%s() must be a %s', - $argument, - $value !== NULL ? ' (' . $value . ')' : ' ', - $stack[1]['class'], - $stack[1]['function'], - $type - ) - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Log/DBUS.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Log/DBUS.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Log/DBUS.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Log/DBUS.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,226 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util_Log - * @author Benjamin Eberlei - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.5.0 - */ - -/** - * A TestListener that integrates with DBUS. - * - * @package PHPUnit - * @subpackage Util_Log - * @author Benjamin Eberlei - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.5.0 - */ -class PHPUnit_Util_Log_DBUS implements PHPUnit_Framework_TestListener -{ - /** - * @var integer - */ - protected $errors = 0; - - /** - * @var integer - */ - protected $failures = 0; - - /** - * @var integer - */ - protected $startTime = NULL; - - /** - * @var string - */ - protected $suiteName = ''; - - /** - * @var integer - */ - protected $tests = 0; - - /** - * @var integer - */ - protected $startedSuites = 0; - - /** - * @var integer - */ - protected $endedSuites = 0; - - /** - * An error occurred. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - $this->errors++; - } - - /** - * A failure occurred. - * - * @param PHPUnit_Framework_Test $test - * @param PHPUnit_Framework_AssertionFailedError $e - * @param float $time - */ - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) - { - $this->failures++; - } - - /** - * Incomplete test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - } - - /** - * Skipped test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - * @since Method available since Release 3.0.0 - */ - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - } - - /** - * A test suite started. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - if($this->startedSuites == 0) { - $this->startTime = time(); - $this->suiteName = $suite->getName(); - } - - $this->startedSuites++; - } - - /** - * A test suite ended. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $this->endedSuites++; - - if($this->startedSuites <= $this->endedSuites) { - $this->notify(); - } - } - - /** - * A test started. - * - * @param PHPUnit_Framework_Test $test - */ - public function startTest(PHPUnit_Framework_Test $test) - { - $this->tests++; - } - - /** - * A test ended. - * - * @param PHPUnit_Framework_Test $test - * @param float $time - */ - public function endTest(PHPUnit_Framework_Test $test, $time) - { - } - - /** - * - */ - protected function notify() - { - $d = new Dbus(Dbus::BUS_SESSION); - - $n = $d->createProxy( - 'org.freedesktop.Notifications', - '/org/freedesktop/Notifications', - 'org.freedesktop.Notifications' - ); - - $n->Notify( - 'PHPUnit_Util_Log_DBUS', - new DBusUInt32(0), - 'phpunit', - 'PHPUnit Test Report', - sprintf( - "Suite: %s\n%d tests run in %s minutes.\n%d errors, %d failures", - $this->suiteName, - $this->tests, - (date('i:s', time() - $this->startTime)), - $this->errors, - $this->failures - ), - new DBusArray(DBus::STRING, array()), - new DBusDict(DBus::VARIANT, array()), - 1000 - ); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Log/JSON.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Log/JSON.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Log/JSON.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Log/JSON.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,240 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util_Log - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * A TestListener that generates JSON messages. - * - * @package PHPUnit - * @subpackage Util_Log - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Util_Log_JSON extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener -{ - /** - * @var string - */ - protected $currentTestSuiteName = ''; - - /** - * @var string - */ - protected $currentTestName = ''; - - /** - * @var boolean - * @access private - */ - protected $currentTestPass = TRUE; - - /** - * An error occurred. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - $this->writeCase( - 'error', - $time, - PHPUnit_Util_Filter::getFilteredStacktrace( - $e, - TRUE, - FALSE - ), - $e->getMessage() - ); - - $this->currentTestPass = FALSE; - } - - /** - * A failure occurred. - * - * @param PHPUnit_Framework_Test $test - * @param PHPUnit_Framework_AssertionFailedError $e - * @param float $time - */ - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) - { - $this->writeCase( - 'fail', - $time, - PHPUnit_Util_Filter::getFilteredStacktrace( - $e, - TRUE, - FALSE - ), - $e->getMessage() - ); - - $this->currentTestPass = FALSE; - } - - /** - * Incomplete test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - $this->writeCase('error', $time, array(), 'Incomplete Test'); - - $this->currentTestPass = FALSE; - } - - /** - * Skipped test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - $this->writeCase('error', $time, array(), 'Skipped Test'); - - $this->currentTestPass = FALSE; - } - - /** - * A testsuite started. - * - * @param PHPUnit_Framework_TestSuite $suite - */ - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $this->currentTestSuiteName = $suite->getName(); - $this->currentTestName = ''; - - $this->write( - array( - 'event' => 'suiteStart', - 'suite' => $this->currentTestSuiteName, - 'tests' => count($suite) - ) - ); - } - - /** - * A testsuite ended. - * - * @param PHPUnit_Framework_TestSuite $suite - */ - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $this->currentTestSuiteName = ''; - $this->currentTestName = ''; - } - - /** - * A test started. - * - * @param PHPUnit_Framework_Test $test - */ - public function startTest(PHPUnit_Framework_Test $test) - { - $this->currentTestName = PHPUnit_Util_Test::describe($test); - $this->currentTestPass = TRUE; - - $this->write( - array( - 'event' => 'testStart', - 'suite' => $this->currentTestSuiteName, - 'test' => $this->currentTestName - ) - ); - } - - /** - * A test ended. - * - * @param PHPUnit_Framework_Test $test - * @param float $time - */ - public function endTest(PHPUnit_Framework_Test $test, $time) - { - if ($this->currentTestPass) { - $this->writeCase('pass', $time); - } - } - - /** - * @param string $status - * @param float $time - * @param array $trace - * @param string $message - */ - protected function writeCase($status, $time, array $trace = array(), $message = '') - { - $this->write( - array( - 'event' => 'test', - 'suite' => $this->currentTestSuiteName, - 'test' => $this->currentTestName, - 'status' => $status, - 'time' => $time, - 'trace' => $trace, - 'message' => $message - ) - ); - } - - /** - * @param string $buffer - */ - public function write($buffer) - { - parent::write(json_encode($buffer)); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Log/JUnit.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Log/JUnit.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Log/JUnit.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Log/JUnit.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,485 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util_Log - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.3.0 - */ - -/** - * A TestListener that generates a logfile of the test execution in XML markup. - * - * The XML markup used is the same as the one that is used by the JUnit Ant task. - * - * @package PHPUnit - * @subpackage Util_Log - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.1.0 - */ -class PHPUnit_Util_Log_JUnit extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener -{ - /** - * @var DOMDocument - */ - protected $document; - - /** - * @var DOMElement - */ - protected $root; - - /** - * @var boolean - */ - protected $logIncompleteSkipped = FALSE; - - /** - * @var boolean - */ - protected $writeDocument = TRUE; - - /** - * @var DOMElement[] - */ - protected $testSuites = array(); - - /** - * @var integer[] - */ - protected $testSuiteTests = array(0); - - /** - * @var integer[] - */ - protected $testSuiteAssertions = array(0); - - /** - * @var integer[] - */ - protected $testSuiteErrors = array(0); - - /** - * @var integer[] - */ - protected $testSuiteFailures = array(0); - - /** - * @var integer[] - */ - protected $testSuiteTimes = array(0); - - /** - * @var integer - */ - protected $testSuiteLevel = 0; - - /** - * @var DOMElement - */ - protected $currentTestCase = NULL; - - /** - * @var boolean - */ - protected $attachCurrentTestCase = TRUE; - - /** - * Constructor. - * - * @param mixed $out - * @param boolean $logIncompleteSkipped - */ - public function __construct($out = NULL, $logIncompleteSkipped = FALSE) - { - $this->document = new DOMDocument('1.0', 'UTF-8'); - $this->document->formatOutput = TRUE; - - $this->root = $this->document->createElement('testsuites'); - $this->document->appendChild($this->root); - - parent::__construct($out); - - $this->logIncompleteSkipped = $logIncompleteSkipped; - } - - /** - * Flush buffer and close output. - * - */ - public function flush() - { - if ($this->writeDocument === TRUE) { - $this->write($this->getXML()); - } - - parent::flush(); - } - - /** - * An error occurred. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - if ($this->currentTestCase !== NULL) { - if ($test instanceof PHPUnit_Framework_SelfDescribing) { - $buffer = $test->toString() . "\n"; - } else { - $buffer = ''; - } - - $buffer .= PHPUnit_Framework_TestFailure::exceptionToString($e) . - "\n" . - PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE); - - $error = $this->document->createElement( - 'error', PHPUnit_Util_XML::prepareString($buffer) - ); - - $error->setAttribute('type', get_class($e)); - - $this->currentTestCase->appendChild($error); - - $this->testSuiteErrors[$this->testSuiteLevel]++; - } - } - - /** - * A failure occurred. - * - * @param PHPUnit_Framework_Test $test - * @param PHPUnit_Framework_AssertionFailedError $e - * @param float $time - */ - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) - { - if ($this->currentTestCase !== NULL) { - if (!$test instanceof PHPUnit_Framework_Warning) { - if ($test instanceof PHPUnit_Framework_SelfDescribing) { - $buffer = $test->toString() . "\n"; - } else { - $buffer = ''; - } - - $buffer .= PHPUnit_Framework_TestFailure::exceptionToString($e). - "\n" . - PHPUnit_Util_Filter::getFilteredStacktrace( - $e, FALSE - ); - - $failure = $this->document->createElement( - 'failure', PHPUnit_Util_XML::prepareString($buffer) - ); - - $failure->setAttribute('type', get_class($e)); - - $this->currentTestCase->appendChild($failure); - - $this->testSuiteFailures[$this->testSuiteLevel]++; - } - } - } - - /** - * Incomplete test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - if ($this->logIncompleteSkipped && $this->currentTestCase !== NULL) { - $error = $this->document->createElement( - 'error', - PHPUnit_Util_XML::prepareString( - "Incomplete Test\n" . - PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE) - ) - ); - - $error->setAttribute('type', get_class($e)); - - $this->currentTestCase->appendChild($error); - - $this->testSuiteErrors[$this->testSuiteLevel]++; - } else { - $this->attachCurrentTestCase = FALSE; - } - } - - /** - * Skipped test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - * @since Method available since Release 3.0.0 - */ - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - if ($this->logIncompleteSkipped && $this->currentTestCase !== NULL) { - $error = $this->document->createElement( - 'error', - PHPUnit_Util_XML::prepareString( - "Skipped Test\n" . - PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE) - ) - ); - - $error->setAttribute('type', get_class($e)); - - $this->currentTestCase->appendChild($error); - - $this->testSuiteErrors[$this->testSuiteLevel]++; - } else { - $this->attachCurrentTestCase = FALSE; - } - } - - /** - * A testsuite started. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $testSuite = $this->document->createElement('testsuite'); - $testSuite->setAttribute('name', $suite->getName()); - - if (class_exists($suite->getName(), FALSE)) { - try { - $class = new ReflectionClass($suite->getName()); - - $testSuite->setAttribute('file', $class->getFileName()); - - $packageInformation = PHPUnit_Util_Class::getPackageInformation( - $suite->getName(), $class->getDocComment() - ); - - if (!empty($packageInformation['namespace'])) { - $testSuite->setAttribute( - 'namespace', $packageInformation['namespace'] - ); - } - - if (!empty($packageInformation['fullPackage'])) { - $testSuite->setAttribute( - 'fullPackage', $packageInformation['fullPackage'] - ); - } - - if (!empty($packageInformation['category'])) { - $testSuite->setAttribute( - 'category', $packageInformation['category'] - ); - } - - if (!empty($packageInformation['package'])) { - $testSuite->setAttribute( - 'package', $packageInformation['package'] - ); - } - - if (!empty($packageInformation['subpackage'])) { - $testSuite->setAttribute( - 'subpackage', $packageInformation['subpackage'] - ); - } - } - - catch (ReflectionException $e) { - } - } - - if ($this->testSuiteLevel > 0) { - $this->testSuites[$this->testSuiteLevel]->appendChild($testSuite); - } else { - $this->root->appendChild($testSuite); - } - - $this->testSuiteLevel++; - $this->testSuites[$this->testSuiteLevel] = $testSuite; - $this->testSuiteTests[$this->testSuiteLevel] = 0; - $this->testSuiteAssertions[$this->testSuiteLevel] = 0; - $this->testSuiteErrors[$this->testSuiteLevel] = 0; - $this->testSuiteFailures[$this->testSuiteLevel] = 0; - $this->testSuiteTimes[$this->testSuiteLevel] = 0; - } - - /** - * A testsuite ended. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $this->testSuites[$this->testSuiteLevel]->setAttribute( - 'tests', $this->testSuiteTests[$this->testSuiteLevel] - ); - - $this->testSuites[$this->testSuiteLevel]->setAttribute( - 'assertions', $this->testSuiteAssertions[$this->testSuiteLevel] - ); - - $this->testSuites[$this->testSuiteLevel]->setAttribute( - 'failures', $this->testSuiteFailures[$this->testSuiteLevel] - ); - - $this->testSuites[$this->testSuiteLevel]->setAttribute( - 'errors', $this->testSuiteErrors[$this->testSuiteLevel] - ); - - $this->testSuites[$this->testSuiteLevel]->setAttribute( - 'time', sprintf('%F', $this->testSuiteTimes[$this->testSuiteLevel]) - ); - - if ($this->testSuiteLevel > 1) { - $this->testSuiteTests[$this->testSuiteLevel - 1] += $this->testSuiteTests[$this->testSuiteLevel]; - $this->testSuiteAssertions[$this->testSuiteLevel - 1] += $this->testSuiteAssertions[$this->testSuiteLevel]; - $this->testSuiteErrors[$this->testSuiteLevel - 1] += $this->testSuiteErrors[$this->testSuiteLevel]; - $this->testSuiteFailures[$this->testSuiteLevel - 1] += $this->testSuiteFailures[$this->testSuiteLevel]; - $this->testSuiteTimes[$this->testSuiteLevel - 1] += $this->testSuiteTimes[$this->testSuiteLevel]; - } - - $this->testSuiteLevel--; - } - - /** - * A test started. - * - * @param PHPUnit_Framework_Test $test - */ - public function startTest(PHPUnit_Framework_Test $test) - { - if (!$test instanceof PHPUnit_Framework_Warning) { - $testCase = $this->document->createElement('testcase'); - $testCase->setAttribute('name', $test->getName()); - - if ($test instanceof PHPUnit_Framework_TestCase) { - $class = new ReflectionClass($test); - $methodName = $test->getName(); - - if ($class->hasMethod($methodName)) { - $method = $class->getMethod($test->getName()); - - $testCase->setAttribute('class', $class->getName()); - $testCase->setAttribute('file', $class->getFileName()); - $testCase->setAttribute('line', $method->getStartLine()); - } - } - - $this->currentTestCase = $testCase; - } - } - - /** - * A test ended. - * - * @param PHPUnit_Framework_Test $test - * @param float $time - */ - public function endTest(PHPUnit_Framework_Test $test, $time) - { - if (!$test instanceof PHPUnit_Framework_Warning) { - if ($this->attachCurrentTestCase) { - if ($test instanceof PHPUnit_Framework_TestCase) { - $numAssertions = $test->getNumAssertions(); - $this->testSuiteAssertions[$this->testSuiteLevel] += $numAssertions; - - $this->currentTestCase->setAttribute( - 'assertions', $numAssertions - ); - } - - $this->currentTestCase->setAttribute( - 'time', sprintf('%F', $time) - ); - - $this->testSuites[$this->testSuiteLevel]->appendChild( - $this->currentTestCase - ); - - $this->testSuiteTests[$this->testSuiteLevel]++; - $this->testSuiteTimes[$this->testSuiteLevel] += $time; - } - } - - $this->attachCurrentTestCase = TRUE; - $this->currentTestCase = NULL; - } - - /** - * Returns the XML as a string. - * - * @return string - * @since Method available since Release 2.2.0 - */ - public function getXML() - { - return $this->document->saveXML(); - } - - /** - * Enables or disables the writing of the document - * in flush(). - * - * This is a "hack" needed for the integration of - * PHPUnit with Phing. - * - * @return string - * @since Method available since Release 2.2.0 - */ - public function setWriteDocument($flag) - { - if (is_bool($flag)) { - $this->writeDocument = $flag; - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Log/TAP.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Log/TAP.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Log/TAP.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Log/TAP.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,253 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util_Log - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -require_once 'SymfonyComponents/YAML/sfYamlDumper.php'; - -/** - * A TestListener that generates a logfile of the - * test execution using the Test Anything Protocol (TAP). - * - * @package PHPUnit - * @subpackage Util_Log - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Util_Log_TAP extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener -{ - /** - * @var integer - */ - protected $testNumber = 0; - - /** - * @var integer - */ - protected $testSuiteLevel = 0; - - /** - * @var boolean - */ - protected $testSuccessful = TRUE; - - /** - * Constructor. - * - * @param mixed $out - * @throws InvalidArgumentException - * @since Method available since Release 3.3.4 - */ - public function __construct($out = NULL) - { - parent::__construct($out); - $this->write("TAP version 13\n"); - } - - /** - * An error occurred. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - $this->writeNotOk($test, 'Error'); - } - - /** - * A failure occurred. - * - * @param PHPUnit_Framework_Test $test - * @param PHPUnit_Framework_AssertionFailedError $e - * @param float $time - */ - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) - { - $this->writeNotOk($test, 'Failure'); - - $message = explode( - "\n", PHPUnit_Framework_TestFailure::exceptionToString($e) - ); - - $diagnostic = array( - 'message' => $message[0], - 'severity' => 'fail' - ); - - if ($e instanceof PHPUnit_Framework_ExpectationFailedException) { - $cf = $e->getComparisonFailure(); - - if ($cf !== NULL) { - $diagnostic['data'] = array( - 'got' => $cf->getActual(), - 'expected' => $cf->getExpected() - ); - } - } - - $yaml = new sfYamlDumper(); - - $this->write( - sprintf( - " ---\n%s ...\n", - $yaml->dump($diagnostic, 2, 2) - ) - ); - } - - /** - * Incomplete test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - $this->writeNotOk($test, '', 'TODO Incomplete Test'); - } - - /** - * Skipped test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - * @since Method available since Release 3.0.0 - */ - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - $this->write( - sprintf( - "ok %d - # SKIP%s\n", - - $this->testNumber, - $e->getMessage() != '' ? ' ' . $e->getMessage() : '' - ) - ); - - $this->testSuccessful = FALSE; - } - - /** - * A testsuite started. - * - * @param PHPUnit_Framework_TestSuite $suite - */ - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $this->testSuiteLevel++; - } - - /** - * A testsuite ended. - * - * @param PHPUnit_Framework_TestSuite $suite - */ - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $this->testSuiteLevel--; - - if ($this->testSuiteLevel == 0) { - $this->write(sprintf("1..%d\n", $this->testNumber)); - } - } - - /** - * A test started. - * - * @param PHPUnit_Framework_Test $test - */ - public function startTest(PHPUnit_Framework_Test $test) - { - $this->testNumber++; - $this->testSuccessful = TRUE; - } - - /** - * A test ended. - * - * @param PHPUnit_Framework_Test $test - * @param float $time - */ - public function endTest(PHPUnit_Framework_Test $test, $time) - { - if ($this->testSuccessful === TRUE) { - $this->write( - sprintf( - "ok %d - %s\n", - - $this->testNumber, - PHPUnit_Util_Test::describe($test) - ) - ); - } - } - - /** - * @param PHPUnit_Framework_Test $test - * @param string $prefix - * @param string $directive - */ - protected function writeNotOk(PHPUnit_Framework_Test $test, $prefix = '', $directive = '') - { - $this->write( - sprintf( - "not ok %d - %s%s%s\n", - - $this->testNumber, - $prefix != '' ? $prefix . ': ' : '', - PHPUnit_Util_Test::describe($test), - $directive != '' ? ' # ' . $directive : '' - ) - ); - - $this->testSuccessful = FALSE; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Log/XHProf.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Log/XHProf.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Log/XHProf.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Log/XHProf.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,252 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util_Log - * @author Benjamin Eberlei - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.5.0 - */ - -/** - * A TestListener that integrates with XHProf. - * - * Here is an example XML configuration for activating this listener: - * - * - * - * - * - * - * - * /var/www/xhprof_lib/utils/xhprof_lib.php - * - * - * /var/www/xhprof_lib/utils/xhprof_runs.php - * - * - * http://localhost/xhprof_html/index.php - * - * - * Doctrine2 - * - * - * XHPROF_FLAGS_CPU,XHPROF_FLAGS_MEMORY - * - * - * - * - * - * - * - * @package PHPUnit - * @subpackage Util_Log - * @author Benjamin Eberlei - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.5.0 - */ -class PHPUnit_Util_Log_XHProf implements PHPUnit_Framework_TestListener -{ - /** - * @var array - */ - protected $runs = array(); - - /** - * @var array - */ - protected $options = array(); - - /** - * @var integer - */ - protected $suites = 0; - - /** - * Constructor. - * - * @param array $options - */ - public function __construct(array $options = array()) - { - if (!extension_loaded('xhprof')) { - throw new RuntimeException( - 'The XHProf extension is required for this listener to work.' - ); - } - - if (!isset($options['appNamespace'])) { - throw new InvalidArgumentException( - 'The "appNamespace" option is not set.' - ); - } - - if (!isset($options['xhprofLibFile']) || - !file_exists($options['xhprofLibFile'])) { - throw new InvalidArgumentException( - 'The "xhprofLibFile" option is not set or the configured file does not exist' - ); - } - - if (!isset($options['xhprofRunsFile']) || - !file_exists($options['xhprofRunsFile'])) { - throw new InvalidArgumentException( - 'The "xhprofRunsFile" option is not set or the configured file does not exist' - ); - } - - require_once $options['xhprofLibFile']; - require_once $options['xhprofRunsFile']; - - $this->options = $options; - } - - /** - * An error occurred. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - } - - /** - * A failure occurred. - * - * @param PHPUnit_Framework_Test $test - * @param PHPUnit_Framework_AssertionFailedError $e - * @param float $time - */ - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) - { - } - - /** - * Incomplete test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - } - - /** - * Skipped test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - } - - /** - * A test started. - * - * @param PHPUnit_Framework_Test $test - */ - public function startTest(PHPUnit_Framework_Test $test) - { - if (!isset($this->options['xhprofFlags'])) { - $flags = XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY; - } else { - $flags = 0; - - foreach (explode(',', $this->options['xhprofFlags']) as $flag) { - $flags += constant($flag); - } - } - - xhprof_enable($flags); - } - - /** - * A test ended. - * - * @param PHPUnit_Framework_Test $test - * @param float $time - */ - public function endTest(PHPUnit_Framework_Test $test, $time) - { - $data = xhprof_disable(); - $runs = new XHProfRuns_Default; - $run = $runs->save_run($data, $this->options['appNamespace']); - $this->runs[] = $this->options['xhprofWeb'] . '?run=' . $run . - '&source=' . $this->options['appNamespace']; - } - - /** - * A test suite started. - * - * @param PHPUnit_Framework_TestSuite $suite - */ - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $this->suites++; - } - - /** - * A test suite ended. - * - * @param PHPUnit_Framework_TestSuite $suite - */ - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $this->suites--; - - if ($this->suites == 0) { - print "\n\nXHProf runs: " . count($this->runs) . "\n"; - - foreach ($this->runs as $run) { - print ' * ' . $run . "\n"; - } - - print "\n"; - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/PHP.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/PHP.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/PHP.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/PHP.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,254 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.4.0 - */ - -/** - * Utility methods for PHP sub-processes. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://www.phpunit.de/ - * @since Class available since Release 3.4.0 - */ -class PHPUnit_Util_PHP -{ - /** - * Path to the PHP interpreter that is to be used. - * - * @var string $phpBinary - */ - protected static $phpBinary = NULL; - - /** - * Descriptor specification for proc_open(). - * - * @var array - */ - protected static $descriptorSpec = array( - 0 => array('pipe', 'r'), - 1 => array('pipe', 'w'), - 2 => array('pipe', 'w') - ); - - /** - * Returns the path to a PHP interpreter. - * - * PHPUnit_Util_PHP::$phpBinary contains the path to the PHP - * interpreter. - * - * When not set, the following assumptions will be made: - * - * 1. When the PHP CLI/CGI binary configured with the PEAR Installer - * (php_bin configuration value) is readable, it will be used. - * - * 2. When PHPUnit is run using the CLI SAPI and the $_SERVER['_'] - * variable does not contain the string "PHPUnit", $_SERVER['_'] - * is assumed to contain the path to the current PHP interpreter - * and that will be used. - * - * 3. When PHPUnit is run using the CLI SAPI and the $_SERVER['_'] - * variable contains the string "PHPUnit", the file that $_SERVER['_'] - * points to is assumed to be the PHPUnit TextUI CLI wrapper script - * "phpunit" and the binary set up using #! on that file's first - * line of code is assumed to contain the path to the current PHP - * interpreter and that will be used. - * - * 4. The current PHP interpreter is assumed to be in the $PATH and - * to be invokable through "php". - * - * @return string - */ - public static function getPhpBinary() - { - if (self::$phpBinary === NULL) { - if (is_readable('@php_bin@')) { - self::$phpBinary = '@php_bin@'; - } - - else if (PHP_SAPI == 'cli' && isset($_SERVER['_']) && - strpos($_SERVER['_'], 'phpunit') !== FALSE) { - $file = file($_SERVER['_']); - $tmp = explode(' ', $file[0]); - self::$phpBinary = trim($tmp[1]); - } - - if (!is_readable(self::$phpBinary)) { - self::$phpBinary = 'php'; - } else { - self::$phpBinary = escapeshellarg(self::$phpBinary); - } - } - - return self::$phpBinary; - } - - /** - * Runs a single job (PHP code) using a separate PHP process. - * - * @param string $job - * @param PHPUnit_Framework_TestCase $test - * @param PHPUnit_Framework_TestResult $result - * @return array|null - */ - public static function runJob($job, PHPUnit_Framework_Test $test = NULL, PHPUnit_Framework_TestResult $result = NULL) - { - $process = proc_open( - self::getPhpBinary(), self::$descriptorSpec, $pipes - ); - - // Workaround for http://bugs.php.net/bug.php?id=52911 - if (DIRECTORY_SEPARATOR == '\\') { - sleep(2); - } - - if (is_resource($process)) { - if ($result !== NULL) { - $result->startTest($test); - } - - fwrite($pipes[0], $job); - fclose($pipes[0]); - - $stdout = stream_get_contents($pipes[1]); - fclose($pipes[1]); - - $stderr = stream_get_contents($pipes[2]); - fclose($pipes[2]); - - proc_close($process); - - if ($result !== NULL) { - self::processChildResult($test, $result, $stdout, $stderr); - } else { - return array('stdout' => $stdout, 'stderr' => $stderr); - } - } - } - - /** - * Runs a single job (PHP code) using a separate PHP process. - * - * @param PHPUnit_Framework_TestCase $test - * @param PHPUnit_Framework_TestResult $result - * @param string $stdout - * @param string $stderr - * @since Method available since Release 3.5.0 - */ - protected static function processChildResult(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result, $stdout, $stderr) - { - if (!empty($stderr)) { - $time = 0; - $result->addError( - $test, - new RuntimeException(trim($stderr)), $time - ); - } else { - $childResult = @unserialize($stdout); - - if ($childResult !== FALSE) { - if (!empty($childResult['output'])) { - print $childResult['output']; - } - - $test->setResult($childResult['testResult']); - $test->addToAssertionCount($childResult['numAssertions']); - - $childResult = $childResult['result']; - - if ($result->getCollectCodeCoverageInformation()) { - $codeCoverageInformation = $childResult->getRawCodeCoverageInformation(); - - if (isset($codeCoverageInformation[0]) && - is_array($codeCoverageInformation[0])) { - $result->getCodeCoverage()->append( - $codeCoverageInformation[0], $test - ); - } - } - - $time = $childResult->time(); - $notImplemented = $childResult->notImplemented(); - $skipped = $childResult->skipped(); - $errors = $childResult->errors(); - $failures = $childResult->failures(); - - if (!empty($notImplemented)) { - $result->addError( - $test, $notImplemented[0]->thrownException(), $time - ); - } - - else if (!empty($skipped)) { - $result->addError( - $test, $skipped[0]->thrownException(), $time - ); - } - - else if (!empty($errors)) { - $result->addError( - $test, $errors[0]->thrownException(), $time - ); - } - - else if (!empty($failures)) { - $result->addFailure( - $test, $failures[0]->thrownException(), $time - ); - } - } else { - $time = 0; - - $result->addError( - $test, new RuntimeException(trim($stdout)), $time - ); - } - } - - $result->endTest($test, $time); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Printer.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Printer.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Printer.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Printer.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,203 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.0.0 - */ - -/** - * Utility class that can print to STDOUT or write to a file. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.0.0 - */ -abstract class PHPUnit_Util_Printer -{ - /** - * If TRUE, flush output after every write. - * - * @var boolean - */ - protected $autoFlush = FALSE; - - /** - * @var resource - */ - protected $out; - - /** - * @var string - */ - protected $outTarget; - - /** - * @var boolean - */ - protected $printsHTML = FALSE; - - /** - * Constructor. - * - * @param mixed $out - * @throws InvalidArgumentException - */ - public function __construct($out = NULL) - { - if ($out !== NULL) { - if (is_string($out)) { - if (strpos($out, 'socket://') === 0) { - $out = explode(':', str_replace('socket://', '', $out)); - - if (sizeof($out) != 2) { - throw new InvalidArgumentException; - } - - $this->out = fsockopen($out[0], $out[1]); - } else { - $this->out = fopen($out, 'wt'); - } - - $this->outTarget = $out; - } else { - $this->out = $out; - } - } - } - - /** - * Flush buffer, optionally tidy up HTML, and close output. - */ - public function flush() - { - if ($this->out !== NULL && $this->outTarget !== 'php://stderr') { - fclose($this->out); - } - - if ($this->printsHTML === TRUE && $this->outTarget !== NULL && - strpos($this->outTarget, 'php://') !== 0 && - strpos($this->outTarget, 'socket://') !== 0 && - extension_loaded('tidy')) { - file_put_contents( - $this->outTarget, - tidy_repair_file( - $this->outTarget, array('indent' => TRUE, 'wrap' => 0), 'utf8' - ) - ); - } - } - - /** - * Performs a safe, incremental flush. - * - * Do not confuse this function with the flush() function of this class, - * since the flush() function may close the file being written to, rendering - * the current object no longer usable. - * - * @since Method available since Release 3.3.0 - */ - public function incrementalFlush() - { - if ($this->out !== NULL) { - fflush($this->out); - } else { - flush(); - } - } - - /** - * @param string $buffer - */ - public function write($buffer) - { - if ($this->out !== NULL) { - fwrite($this->out, $buffer); - - if ($this->autoFlush) { - $this->incrementalFlush(); - } - } else { - if (PHP_SAPI != 'cli') { - $buffer = htmlspecialchars($buffer); - } - - print $buffer; - - if ($this->autoFlush) { - $this->incrementalFlush(); - } - } - } - - /** - * Check auto-flush mode. - * - * @return boolean - * @since Method available since Release 3.3.0 - */ - public function getAutoFlush() - { - return $this->autoFlush; - } - - /** - * Set auto-flushing mode. - * - * If set, *incremental* flushes will be done after each write. This should - * not be confused with the different effects of this class' flush() method. - * - * @param boolean $autoFlush - * @since Method available since Release 3.3.0 - */ - public function setAutoFlush($autoFlush) - { - if (is_bool($autoFlush)) { - $this->autoFlush = $autoFlush; - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Class.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Class.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Class.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Class.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,327 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util_Skeleton - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -require_once 'Text/Template.php'; - -/** - * Generator for class skeletons from test classes. - * - * @package PHPUnit - * @subpackage Util_Skeleton - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Util_Skeleton_Class extends PHPUnit_Util_Skeleton -{ - /** - * Constructor. - * - * @param string $inClassName - * @param string $inSourceFile - * @param string $outClassName - * @param string $outSourceFile - * @throws RuntimeException - */ - public function __construct($inClassName, $inSourceFile = '', $outClassName = '', $outSourceFile = '') - { - if (empty($inSourceFile)) { - $inSourceFile = $inClassName . '.php'; - } - - if (!is_file($inSourceFile)) { - throw new PHPUnit_Framework_Exception( - sprintf( - '"%s" could not be opened.', - - $inSourceFile - ) - ); - } - - if (empty($outClassName)) { - $outClassName = substr($inClassName, 0, strlen($inClassName) - 4); - } - - if (empty($outSourceFile)) { - $outSourceFile = dirname($inSourceFile) . DIRECTORY_SEPARATOR . - $outClassName . '.php'; - } - - parent::__construct( - $inClassName, $inSourceFile, $outClassName, $outSourceFile - ); - } - - /** - * Generates the class' source. - * - * @return mixed - */ - public function generate() - { - $methods = ''; - - foreach ($this->findTestedMethods() as $method) { - $methodTemplate = new Text_Template( - sprintf( - '%s%sTemplate%sMethod.tpl', - - dirname(__FILE__), - DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR - ) - ); - - $methodTemplate->setVar( - array( - 'methodName' => $method, - ) - ); - - $methods .= $methodTemplate->render(); - } - - $classTemplate = new Text_Template( - sprintf( - '%s%sTemplate%sClass.tpl', - - dirname(__FILE__), - DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR - ) - ); - - $classTemplate->setVar( - array( - 'className' => $this->outClassName['fullyQualifiedClassName'], - 'methods' => $methods, - 'date' => date('Y-m-d'), - 'time' => date('H:i:s') - ) - ); - - return $classTemplate->render(); - } - - /** - * Returns the methods of the class under test - * that are called from the test methods. - * - * @return array - */ - protected function findTestedMethods() - { - $setUpVariables = array(); - $testedMethods = array(); - $classes = PHPUnit_Util_File::getClassesInFile( - $this->inSourceFile - ); - $testMethods = $classes[$this->inClassName['fullyQualifiedClassName']]['methods']; - unset($classes); - - foreach ($testMethods as $name => $testMethod) { - if (strtolower($name) == 'setup') { - $setUpVariables = $this->findVariablesThatReferenceClass( - $testMethod['tokens'] - ); - - break; - } - } - - foreach ($testMethods as $name => $testMethod) { - $argVariables = array(); - - if (strtolower($name) == 'setup') { - continue; - } - - $start = strpos($testMethod['signature'], '(') + 1; - $end = strlen($testMethod['signature']) - $start - 1; - $args = substr($testMethod['signature'], $start, $end); - - foreach (explode(',', $args) as $arg) { - $arg = explode(' ', trim($arg)); - - if (count($arg) == 2) { - $type = $arg[0]; - $var = $arg[1]; - } else { - $type = NULL; - $var = $arg[0]; - } - - if ($type == $this->outClassName['fullyQualifiedClassName']) { - $argVariables[] = $var; - } - } - - $variables = array_unique( - array_merge( - $setUpVariables, - $argVariables, - $this->findVariablesThatReferenceClass($testMethod['tokens']) - ) - ); - - foreach ($testMethod['tokens'] as $i => $token) { - // Class::method() - if (is_array($token) && $token[0] == T_DOUBLE_COLON && - is_array($testMethod['tokens'][$i-1]) && - $testMethod['tokens'][$i-1][0] == T_STRING && - $testMethod['tokens'][$i-1][1] == $this->outClassName['fullyQualifiedClassName'] && - is_array($testMethod['tokens'][$i+1]) && - $testMethod['tokens'][$i+1][0] == T_STRING && - $testMethod['tokens'][$i+2] == '(') { - $testedMethods[] = $testMethod['tokens'][$i+1][1]; - } - - // $this->object->method() - else if (is_array($token) && $token[0] == T_OBJECT_OPERATOR && - in_array($this->findVariableName($testMethod['tokens'], $i), $variables) && - is_array($testMethod['tokens'][$i+2]) && - $testMethod['tokens'][$i+2][0] == T_OBJECT_OPERATOR && - is_array($testMethod['tokens'][$i+3]) && - $testMethod['tokens'][$i+3][0] == T_STRING && - $testMethod['tokens'][$i+4] == '(') { - $testedMethods[] = $testMethod['tokens'][$i+3][1]; - } - - // $object->method() - else if (is_array($token) && $token[0] == T_OBJECT_OPERATOR && - in_array($this->findVariableName($testMethod['tokens'], $i), $variables) && - is_array($testMethod['tokens'][$i+1]) && - $testMethod['tokens'][$i+1][0] == T_STRING && - $testMethod['tokens'][$i+2] == '(') { - $testedMethods[] = $testMethod['tokens'][$i+1][1]; - } - } - } - - $testedMethods = array_unique($testedMethods); - sort($testedMethods); - - return $testedMethods; - } - - /** - * Returns the variables used in test methods - * that reference the class under test. - * - * @param array $tokens - * @return array - */ - protected function findVariablesThatReferenceClass(array $tokens) - { - $inNew = FALSE; - $variables = array(); - - foreach ($tokens as $i => $token) { - if (is_string($token)) { - if (trim($token) == ';') { - $inNew = FALSE; - } - - continue; - } - - list ($token, $value) = $token; - - switch ($token) { - case T_NEW: { - $inNew = TRUE; - } - break; - - case T_STRING: { - if ($inNew) { - if ($value == $this->outClassName['fullyQualifiedClassName']) { - $variables[] = $this->findVariableName( - $tokens, $i - ); - } - } - - $inNew = FALSE; - } - break; - } - } - - return $variables; - } - - /** - * Finds the variable name of the object for the method call - * that is currently being processed. - * - * @param array $tokens - * @param integer $start - * @return mixed - */ - protected function findVariableName(array $tokens, $start) - { - for ($i = $start - 1; $i >= 0; $i--) { - if (is_array($tokens[$i]) && $tokens[$i][0] == T_VARIABLE) { - $variable = $tokens[$i][1]; - - if (is_array($tokens[$i+1]) && - $tokens[$i+1][0] == T_OBJECT_OPERATOR && - $tokens[$i+2] != '(' && - $tokens[$i+3] != '(') { - $variable .= '->' . $tokens[$i+2][1]; - } - - return $variable; - } - } - - return FALSE; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/Class.tpl.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/Class.tpl.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/Class.tpl.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/Class.tpl.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/IncompleteTestMethod.tpl.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/IncompleteTestMethod.tpl.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/IncompleteTestMethod.tpl.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/IncompleteTestMethod.tpl.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ - - /** - * @todo Implement test{methodName}(). - */ - public function test{methodName}() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/Method.tpl.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/Method.tpl.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/Method.tpl.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/Method.tpl.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ - - /** - * @todo Implement {methodName}(). - */ - public function {methodName}() - { - // Remove the following line when you implement this method. - throw new RuntimeException('Not yet implemented.'); - } diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestClass.tpl.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestClass.tpl.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestClass.tpl.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestClass.tpl.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -object = new {className}; - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } -{methods}} -?> diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethod.tpl.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethod.tpl.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethod.tpl.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethod.tpl.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ - - /** - * Generated from @assert {annotation}. - */ - public function test{methodName}() - { - $this->assert{assertion}( - {expected}, - $this->object->{origMethodName}({arguments}) - ); - } diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodBool.tpl.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodBool.tpl.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodBool.tpl.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodBool.tpl.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ - - /** - * Generated from @assert {annotation}. - */ - public function test{methodName}() - { - $this->assert{assertion}( - $this->object->{origMethodName}({arguments}) - ); - } diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodBoolStatic.tpl.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodBoolStatic.tpl.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodBoolStatic.tpl.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodBoolStatic.tpl.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ - - /** - * Generated from @assert {annotation}. - */ - public function test{methodName}() - { - $this->assert{assertion}( - {className}::{origMethodName}({arguments}) - ); - } diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodException.tpl.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodException.tpl.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodException.tpl.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodException.tpl.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ - - /** - * Generated from @assert {annotation}. - * @expectedException {expected} - */ - public function test{methodName}() - { - $this->object->{origMethodName}({arguments}); - } diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodExceptionStatic.tpl.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodExceptionStatic.tpl.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodExceptionStatic.tpl.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodExceptionStatic.tpl.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ - - /** - * Generated from @assert {annotation}. - * @expectedException {expected} - */ - public function test{methodName}() - { - {className}::{origMethodName}({arguments}); - } diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodStatic.tpl.dist phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodStatic.tpl.dist --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodStatic.tpl.dist 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Template/TestMethodStatic.tpl.dist 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ - - /** - * Generated from @assert {annotation}. - */ - public function test{methodName}() - { - $this->assert{assertion}( - {expected}, - {className}::{origMethodName}({arguments}) - ); - } diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Test.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Test.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Test.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton/Test.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,379 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util_Skeleton - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -require_once 'Text/Template.php'; - -/** - * Generator for test class skeletons from classes. - * - * @package PHPUnit - * @subpackage Util_Skeleton - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Util_Skeleton_Test extends PHPUnit_Util_Skeleton -{ - /** - * @var array - */ - protected $methodNameCounter = array(); - - /** - * Constructor. - * - * @param string $inClassName - * @param string $inSourceFile - * @param string $outClassName - * @param string $outSourceFile - * @throws RuntimeException - */ - public function __construct($inClassName, $inSourceFile = '', $outClassName = '', $outSourceFile = '') - { - if (class_exists($inClassName)) { - $reflector = new ReflectionClass($inClassName); - $inSourceFile = $reflector->getFileName(); - - if ($inSourceFile === FALSE) { - $inSourceFile = ''; - } - - unset($reflector); - } else { - if (empty($inSourceFile)) { - $possibleFilenames = array( - $inClassName . '.php', - PHPUnit_Util_Filesystem::classNameToFilename($inClassName) - ); - - foreach ($possibleFilenames as $possibleFilename) { - if (is_file($possibleFilename)) { - $inSourceFile = $possibleFilename; - } - } - } - - if (empty($inSourceFile)) { - throw new PHPUnit_Framework_Exception( - sprintf( - 'Neither "%s" nor "%s" could be opened.', - $possibleFilenames[0], - $possibleFilenames[1] - ) - ); - } - - if (!is_file($inSourceFile)) { - throw new PHPUnit_Framework_Exception( - sprintf( - '"%s" could not be opened.', - - $inSourceFile - ) - ); - } - - $inSourceFile = realpath($inSourceFile); - include_once $inSourceFile; - - if (!class_exists($inClassName)) { - throw new PHPUnit_Framework_Exception( - sprintf( - 'Could not find class "%s" in "%s".', - - $inClassName, - $inSourceFile - ) - ); - } - } - - if (empty($outClassName)) { - $outClassName = $inClassName . 'Test'; - } - - if (empty($outSourceFile)) { - $outSourceFile = dirname($inSourceFile) . DIRECTORY_SEPARATOR . $outClassName . '.php'; - } - - parent::__construct( - $inClassName, $inSourceFile, $outClassName, $outSourceFile - ); - } - - /** - * Generates the test class' source. - * - * @param boolean $verbose - * @return mixed - */ - public function generate($verbose = FALSE) - { - $class = new ReflectionClass( - $this->inClassName['fullyQualifiedClassName'] - ); - $methods = ''; - $incompleteMethods = ''; - - foreach ($class->getMethods() as $method) { - if (!$method->isConstructor() && - !$method->isAbstract() && - $method->isPublic() && - $method->getDeclaringClass()->getName() == $this->inClassName['fullyQualifiedClassName']) { - $assertAnnotationFound = FALSE; - - if (preg_match_all('/@assert(.*)$/Um', $method->getDocComment(), $annotations)) { - foreach ($annotations[1] as $annotation) { - if (preg_match('/\((.*)\)\s+([^\s]*)\s+(.*)/', $annotation, $matches)) { - switch ($matches[2]) { - case '==': { - $assertion = 'Equals'; - } - break; - - case '!=': { - $assertion = 'NotEquals'; - } - break; - - case '===': { - $assertion = 'Same'; - } - break; - - case '!==': { - $assertion = 'NotSame'; - } - break; - - case '>': { - $assertion = 'GreaterThan'; - } - break; - - case '>=': { - $assertion = 'GreaterThanOrEqual'; - } - break; - - case '<': { - $assertion = 'LessThan'; - } - break; - - case '<=': { - $assertion = 'LessThanOrEqual'; - } - break; - - case 'throws': { - $assertion = 'exception'; - } - break; - - default: { - throw new PHPUnit_Framework_Exception( - sprintf( - 'Token "%s" could not be parsed in @assert annotation.', - $matches[2] - ) - ); - } - } - - if ($assertion == 'exception') { - $template = 'TestMethodException'; - } - - else if ($assertion == 'Equals' && - strtolower($matches[3]) == 'true') { - $assertion = 'True'; - $template = 'TestMethodBool'; - } - - else if ($assertion == 'NotEquals' && - strtolower($matches[3]) == 'true') { - $assertion = 'False'; - $template = 'TestMethodBool'; - } - - else if ($assertion == 'Equals' && - strtolower($matches[3]) == 'false') { - $assertion = 'False'; - $template = 'TestMethodBool'; - } - - else if ($assertion == 'NotEquals' && - strtolower($matches[3]) == 'false') { - $assertion = 'True'; - $template = 'TestMethodBool'; - } - - else { - $template = 'TestMethod'; - } - - if ($method->isStatic()) { - $template .= 'Static'; - } - - $methodTemplate = new Text_Template( - sprintf( - '%s%sTemplate%s%s.tpl', - - dirname(__FILE__), - DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR, - $template - ) - ); - - $origMethodName = $method->getName(); - $methodName = ucfirst($origMethodName); - - if (isset($this->methodNameCounter[$methodName])) { - $this->methodNameCounter[$methodName]++; - } else { - $this->methodNameCounter[$methodName] = 1; - } - - if ($this->methodNameCounter[$methodName] > 1) { - $methodName .= $this->methodNameCounter[$methodName]; - } - - $methodTemplate->setVar( - array( - 'annotation' => trim($annotation), - 'arguments' => $matches[1], - 'assertion' => isset($assertion) ? $assertion : '', - 'expected' => $matches[3], - 'origMethodName' => $origMethodName, - 'className' => $this->inClassName['fullyQualifiedClassName'], - 'methodName' => $methodName - ) - ); - - $methods .= $methodTemplate->render(); - - $assertAnnotationFound = TRUE; - } - } - } - - if (!$assertAnnotationFound) { - $methodTemplate = new Text_Template( - sprintf( - '%s%sTemplate%sIncompleteTestMethod.tpl', - - dirname(__FILE__), - DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR - ) - ); - - $methodTemplate->setVar( - array( - 'methodName' => ucfirst($method->getName()) - ) - ); - - $incompleteMethods .= $methodTemplate->render(); - } - } - } - - $classTemplate = new Text_Template( - sprintf( - '%s%sTemplate%sTestClass.tpl', - - dirname(__FILE__), - DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR - ) - ); - - if ($this->inSourceFile != '') { - $requireClassFile = sprintf( - "\n\nrequire_once '%s';", - - $this->inSourceFile - ); - } else { - $requireClassFile = ''; - } - - if ($this->outClassName['namespace'] != '') { - $namespace = "\nnamespace " . - $this->outClassName['namespace'] . ";\n"; - } else { - $namespace = ''; - } - - $classTemplate->setVar( - array( - 'namespace' => $namespace, - 'namespaceSeparator' => !empty($namespace) ? '\\' : '', - 'className' => $this->inClassName['className'], - 'testClassName' => $this->outClassName['className'], - 'requireClassFile' => $requireClassFile, - 'methods' => $methods . $incompleteMethods, - 'date' => date('Y-m-d'), - 'time' => date('H:i:s') - ) - ); - - if (!$verbose) { - return $classTemplate->render(); - } else { - return array( - 'code' => $classTemplate->render(), - 'incomplete' => empty($methods) - ); - } - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Skeleton.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Skeleton.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.1.0 - */ - -/** - * Generator for skeletons. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.1.0 - */ -abstract class PHPUnit_Util_Skeleton -{ - /** - * @var array - */ - protected $inClassName; - - /** - * @var string - */ - protected $inSourceFile; - - /** - * @var array - */ - protected $outClassName; - - /** - * @var string - */ - protected $outSourceFile; - - /** - * Constructor. - * - * @param string $inClassName - * @param string $inSourceFile - * @param string $outClassName - * @param string $outSourceFile - * @since Method available since Release 3.4.0 - */ - public function __construct($inClassName, $inSourceFile = '', $outClassName = '', $outSourceFile = '') - { - $this->inClassName = PHPUnit_Util_Class::parseFullyQualifiedClassName( - $inClassName - ); - - $this->outClassName = PHPUnit_Util_Class::parseFullyQualifiedClassName( - $outClassName - ); - - $this->inSourceFile = str_replace( - $this->inClassName['fullyQualifiedClassName'], - $this->inClassName['className'], - $inSourceFile - ); - - $this->outSourceFile = str_replace( - $this->outClassName['fullyQualifiedClassName'], - $this->outClassName['className'], - $outSourceFile - ); - } - - /** - * @return string - */ - public function getOutClassName() - { - return $this->outClassName['fullyQualifiedClassName']; - } - - /** - * @return string - */ - public function getOutSourceFile() - { - return $this->outSourceFile; - } - - /** - * Generates the code and writes it to a source file. - * - * @param string $file - */ - public function write($file = '') - { - if ($file == '') { - $file = $this->outSourceFile; - } - - if ($fp = @fopen($file, 'wt')) { - @fwrite($fp, $this->generate()); - @fclose($fp); - } - } - - abstract public function generate(); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Test.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Test.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Test.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Test.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,473 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Test helpers. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Util_Test -{ - const REGEX_DATA_PROVIDER = '/@dataProvider\s+([a-zA-Z0-9._:-\\\\x7f-\xff]+)/'; - const REGEX_EXPECTED_EXCEPTION = '(@expectedException\s+([:.\w\\\\x7f-\xff]+)(?:[\t ]+(\S*))?(?:[\t ]+(\S*))?\s*$)m'; - - private static $annotationCache = array(); - - protected static $templateMethods = array( - 'setUp', 'assertPreConditions', 'assertPostConditions', 'tearDown' - ); - - /** - * @param PHPUnit_Framework_Test $test - * @param boolean $asString - * @return mixed - */ - public static function describe(PHPUnit_Framework_Test $test, $asString = TRUE) - { - if ($asString) { - if ($test instanceof PHPUnit_Framework_SelfDescribing) { - return $test->toString(); - } else { - return get_class($test); - } - } else { - if ($test instanceof PHPUnit_Framework_TestCase) { - return array( - get_class($test), $test->getName() - ); - } - - else if ($test instanceof PHPUnit_Framework_SelfDescribing) { - return array('', $test->toString()); - } - - else { - return array('', get_class($test)); - } - } - } - - /** - * Returns the expected exception for a test. - * - * @param string $className - * @param string $methodName - * @return array - * @since Method available since Release 3.3.6 - */ - public static function getExpectedException($className, $methodName) - { - $reflector = new ReflectionMethod($className, $methodName); - $docComment = $reflector->getDocComment(); - - if (preg_match(self::REGEX_EXPECTED_EXCEPTION, $docComment, $matches)) { - $annotations = self::parseTestMethodAnnotations( - $className, $methodName - ); - - $class = $matches[1]; - $code = 0; - $message = ''; - - if (isset($matches[2])) { - $message = trim($matches[2]); - } - - else if (isset($annotations['method']['expectedExceptionMessage'])) { - $message = $annotations['method']['expectedExceptionMessage'][0]; - } - - if (isset($matches[3])) { - $code = (int)$matches[3]; - } - - else if (isset($annotations['method']['expectedExceptionCode'])) { - $code = (int)$annotations['method']['expectedExceptionCode'][0]; - } - - return array( - 'class' => $class, 'code' => $code, 'message' => $message - ); - } - - return FALSE; - } - - /** - * Returns the provided data for a method. - * - * @param string $className - * @param string $methodName - * @param string $docComment - * @return mixed array|Iterator when a data provider is specified and exists - * false when a data provider is specified and does not exist - * null when no data provider is specified - * @since Method available since Release 3.2.0 - */ - public static function getProvidedData($className, $methodName) - { - $reflector = new ReflectionMethod($className, $methodName); - $docComment = $reflector->getDocComment(); - $data = NULL; - - if (preg_match(self::REGEX_DATA_PROVIDER, $docComment, $matches)) { - $dataProviderMethodNameNamespace = explode('\\', $matches[1]); - $leaf = explode('::', array_pop($dataProviderMethodNameNamespace)); - $dataProviderMethodName = array_pop($leaf); - - if (!empty($dataProviderMethodNameNamespace)) { - $dataProviderMethodNameNamespace = join('\\', $dataProviderMethodNameNamespace) . '\\'; - } else { - $dataProviderMethodNameNamespace = ''; - } - - if (!empty($leaf)) { - $dataProviderClassName = $dataProviderMethodNameNamespace . array_pop($leaf); - } else { - $dataProviderClassName = $className; - } - - $dataProviderClass = new ReflectionClass($dataProviderClassName); - $dataProviderMethod = $dataProviderClass->getMethod( - $dataProviderMethodName - ); - - if ($dataProviderMethod->isStatic()) { - $object = NULL; - } else { - $object = $dataProviderClass->newInstance(); - } - - if ($dataProviderMethod->getNumberOfParameters() == 0) { - $data = $dataProviderMethod->invoke($object); - } else { - $data = $dataProviderMethod->invoke($object, $methodName); - } - } - - if ($data !== NULL) { - foreach ($data as $key => $value) { - if (!is_array($value)) { - throw new InvalidArgumentException( - sprintf( - 'Data set %s is invalid.', - is_int($key) ? '#' . $key : '"' . $key . '"' - ) - ); - } - } - } - - return $data; - } - - /** - * @param string $className - * @param string $methodName - * @return array - * @throws ReflectionException - * @since Method available since Release 3.4.0 - */ - public static function parseTestMethodAnnotations($className, $methodName = '') - { - if (!isset(self::$annotationCache[$className])) { - $class = new ReflectionClass($className); - self::$annotationCache[$className] = self::parseAnnotations($class->getDocComment()); - } - - if (!empty($methodName) && !isset(self::$annotationCache[$className . '::' . $methodName])) { - $method = new ReflectionMethod($className, $methodName); - self::$annotationCache[$className . '::' . $methodName] = self::parseAnnotations($method->getDocComment()); - } - - return array( - 'class' => self::$annotationCache[$className], - 'method' => !empty($methodName) ? self::$annotationCache[$className . '::' . $methodName] : array() - ); - } - - /** - * @param string $docblock - * @return array - * @since Method available since Release 3.4.0 - */ - private static function parseAnnotations($docblock) - { - $annotations = array(); - - if (preg_match_all('/@(?P[A-Za-z_-]+)(?:[ \t]+(?P.*?))?[ \t]*\r?$/m', $docblock, $matches)) { - $numMatches = count($matches[0]); - - for ($i = 0; $i < $numMatches; ++$i) { - $annotations[$matches['name'][$i]][] = $matches['value'][$i]; - } - } - - return $annotations; - } - - /** - * Returns the backup settings for a test. - * - * @param string $className - * @param string $methodName - * @return array - * @since Method available since Release 3.4.0 - */ - public static function getBackupSettings($className, $methodName) - { - return array( - 'backupGlobals' => self::getBooleanAnnotationSetting( - $className, $methodName, 'backupGlobals' - ), - 'backupStaticAttributes' => self::getBooleanAnnotationSetting( - $className, $methodName, 'backupStaticAttributes' - ) - ); - } - - /** - * Returns the dependencies for a test class or method. - * - * @param string $className - * @param string $methodName - * @return array - * @since Method available since Release 3.4.0 - */ - public static function getDependencies($className, $methodName) - { - $annotations = self::parseTestMethodAnnotations( - $className, $methodName - ); - - $dependencies = array(); - - if (isset($annotations['class']['depends'])) { - $dependencies = $annotations['class']['depends']; - } - - if (isset($annotations['method']['depends'])) { - $dependencies = array_merge( - $dependencies, $annotations['method']['depends'] - ); - } - - return array_unique($dependencies); - } - - /** - * Returns the error handler settings for a test. - * - * @param string $className - * @param string $methodName - * @return boolean - * @since Method available since Release 3.4.0 - */ - public static function getErrorHandlerSettings($className, $methodName) - { - return self::getBooleanAnnotationSetting( - $className, $methodName, 'errorHandler' - ); - } - - /** - * Returns the groups for a test class or method. - * - * @param string $className - * @param string $methodName - * @return array - * @since Method available since Release 3.2.0 - */ - public static function getGroups($className, $methodName = '') - { - $annotations = self::parseTestMethodAnnotations( - $className, $methodName - ); - - $groups = array(); - - if (isset($annotations['method']['author'])) { - $groups = $annotations['method']['author']; - } - - else if (isset($annotations['class']['author'])) { - $groups = $annotations['class']['author']; - } - - if (isset($annotations['class']['group'])) { - $groups = array_merge($groups, $annotations['class']['group']); - } - - if (isset($annotations['method']['group'])) { - $groups = array_merge($groups, $annotations['method']['group']); - } - - return array_unique($groups); - } - - /** - * Returns the tickets for a test class or method. - * - * @param string $className - * @param string $methodName - * @return array - * @since Method available since Release 3.4.0 - */ - public static function getTickets($className, $methodName) - { - $annotations = self::parseTestMethodAnnotations( - $className, $methodName - ); - - $tickets = array(); - - if (isset($annotations['class']['ticket'])) { - $tickets = $annotations['class']['ticket']; - } - - if (isset($annotations['method']['ticket'])) { - $tickets = array_merge($tickets, $annotations['method']['ticket']); - } - - return array_unique($tickets); - } - - /** - * Returns the output buffering settings for a test. - * - * @param string $className - * @param string $methodName - * @return boolean - * @since Method available since Release 3.4.0 - */ - public static function getOutputBufferingSettings($className, $methodName) - { - return self::getBooleanAnnotationSetting( - $className, $methodName, 'outputBuffering' - ); - } - - /** - * Returns the process isolation settings for a test. - * - * @param string $className - * @param string $methodName - * @return boolean - * @since Method available since Release 3.4.1 - */ - public static function getProcessIsolationSettings($className, $methodName) - { - $annotations = self::parseTestMethodAnnotations( - $className, $methodName - ); - - if (isset($annotations['class']['runTestsInSeparateProcesses']) || - isset($annotations['method']['runInSeparateProcess'])) { - return TRUE; - } else { - return FALSE; - } - } - - /** - * Returns the preserve global state settings for a test. - * - * @param string $className - * @param string $methodName - * @return boolean - * @since Method available since Release 3.4.0 - */ - public static function getPreserveGlobalStateSettings($className, $methodName) - { - return self::getBooleanAnnotationSetting( - $className, $methodName, 'preserveGlobalState' - ); - } - - /** - * @param string $className - * @param string $methodName - * @param string $settingName - * @return boolean - * @since Method available since Release 3.4.0 - */ - private static function getBooleanAnnotationSetting($className, $methodName, $settingName) - { - $annotations = self::parseTestMethodAnnotations( - $className, $methodName - ); - - $result = NULL; - - if (isset($annotations['class'][$settingName])) { - if ($annotations['class'][$settingName][0] == 'enabled') { - $result = TRUE; - } - - else if ($annotations['class'][$settingName][0] == 'disabled') { - $result = FALSE; - } - } - - if (isset($annotations['method'][$settingName])) { - if ($annotations['method'][$settingName][0] == 'enabled') { - $result = TRUE; - } - - else if ($annotations['method'][$settingName][0] == 'disabled') { - $result = FALSE; - } - } - - return $result; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/TestDox/NamePrettifier.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/TestDox/NamePrettifier.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/TestDox/NamePrettifier.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/TestDox/NamePrettifier.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,178 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util_TestDox - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.3.0 - */ - -/** - * Prettifies class and method names for use in TestDox documentation. - * - * @package PHPUnit - * @subpackage Util_TestDox - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.1.0 - */ -class PHPUnit_Util_TestDox_NamePrettifier -{ - /** - * @var string - */ - protected $prefix = 'Test'; - - /** - * @var string - */ - protected $suffix = 'Test'; - - /** - * @var array - */ - protected $strings = array(); - - /** - * Prettifies the name of a test class. - * - * @param string $name - * @return string - */ - public function prettifyTestClass($name) - { - $title = $name; - - if ($this->suffix !== NULL && - $this->suffix == substr($name, -1 * strlen($this->suffix))) { - $title = substr($title, 0, strripos($title, $this->suffix)); - } - - if ($this->prefix !== NULL && - $this->prefix == substr($name, 0, strlen($this->prefix))) { - $title = substr($title, strlen($this->prefix)); - } - - return $title; - } - - /** - * Prettifies the name of a test method. - * - * @param string $name - * @return string - */ - public function prettifyTestMethod($name) - { - $buffer = ''; - - if (!is_string($name) || strlen($name) == 0) { - return $buffer; - } - - $string = preg_replace('#\d+$#', '', $name); - - if (in_array($string, $this->strings)) { - $name = $string; - } else { - $this->strings[] = $string; - } - - if (strpos($name, '_') !== FALSE) { - return str_replace('_', ' ', $name); - } - - $max = strlen($name); - - if (substr($name, 0, 4) == 'test') { - $offset = 4; - } else { - $offset = 0; - $name[0] = strtoupper($name[0]); - } - - $wasNumeric = FALSE; - - for ($i = $offset; $i < $max; $i++) { - if ($i > $offset && - ord($name[$i]) >= 65 && - ord($name[$i]) <= 90) { - $buffer .= ' ' . strtolower($name[$i]); - } else { - $isNumeric = is_numeric($name[$i]); - - if (!$wasNumeric && $isNumeric) { - $buffer .= ' '; - $wasNumeric = TRUE; - } - - if ($wasNumeric && !$isNumeric) { - $wasNumeric = FALSE; - } - - $buffer .= $name[$i]; - } - } - - return $buffer; - } - - /** - * Sets the prefix of test names. - * - * @param string $prefix - */ - public function setPrefix($prefix) - { - $this->prefix = $prefix; - } - - /** - * Sets the suffix of test names. - * - * @param string $prefix - */ - public function setSuffix($suffix) - { - $this->suffix = $suffix; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/TestDox/ResultPrinter/HTML.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/TestDox/ResultPrinter/HTML.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/TestDox/ResultPrinter/HTML.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/TestDox/ResultPrinter/HTML.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util_TestDox - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.3.0 - */ - -/** - * Prints TestDox documentation in HTML format. - * - * @package PHPUnit - * @subpackage Util_TestDox - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.1.0 - */ -class PHPUnit_Util_TestDox_ResultPrinter_HTML extends PHPUnit_Util_TestDox_ResultPrinter -{ - /** - * @var boolean - */ - protected $printsHTML = TRUE; - - /** - * Handler for 'start run' event. - * - */ - protected function startRun() - { - $this->write(''); - } - - /** - * Handler for 'start class' event. - * - * @param string $name - */ - protected function startClass($name) - { - $this->write( - '

' . $this->currentTestClassPrettified . - '

    ' - ); - } - - /** - * Handler for 'on test' event. - * - * @param string $name - * @param boolean $success - */ - protected function onTest($name, $success = TRUE) - { - if (!$success) { - $strikeOpen = ''; - $strikeClose = ''; - } else { - $strikeOpen = ''; - $strikeClose = ''; - } - - $this->write('
  • ' . $strikeOpen . $name . $strikeClose . '
  • '); - } - - /** - * Handler for 'end class' event. - * - * @param string $name - */ - protected function endClass($name) - { - $this->write('
'); - } - - /** - * Handler for 'end run' event. - * - */ - protected function endRun() - { - $this->write(''); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/TestDox/ResultPrinter/Text.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/TestDox/ResultPrinter/Text.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/TestDox/ResultPrinter/Text.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/TestDox/ResultPrinter/Text.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util_TestDox - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.3.0 - */ - -/** - * Prints TestDox documentation in text format. - * - * @package PHPUnit - * @subpackage Util_TestDox - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.1.0 - */ -class PHPUnit_Util_TestDox_ResultPrinter_Text extends PHPUnit_Util_TestDox_ResultPrinter -{ - /** - * Handler for 'start class' event. - * - * @param string $name - */ - protected function startClass($name) - { - $this->write($this->currentTestClassPrettified . "\n"); - } - - /** - * Handler for 'on test' event. - * - * @param string $name - * @param boolean $success - */ - protected function onTest($name, $success = TRUE) - { - if ($success) { - $this->write(' [x] '); - } else { - $this->write(' [ ] '); - } - - $this->write($name . "\n"); - } - - /** - * Handler for 'end class' event. - * - * @param string $name - */ - protected function endClass($name) - { - $this->write("\n"); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/TestDox/ResultPrinter.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/TestDox/ResultPrinter.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/TestDox/ResultPrinter.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/TestDox/ResultPrinter.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,348 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util_TestDox - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.3.0 - */ - -/** - * Base class for printers of TestDox documentation. - * - * @package PHPUnit - * @subpackage Util_TestDox - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.1.0 - */ -abstract class PHPUnit_Util_TestDox_ResultPrinter extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener -{ - /** - * @var PHPUnit_Util_TestDox_NamePrettifier - */ - protected $prettifier; - - /** - * @var string - */ - protected $testClass = ''; - - /** - * @var integer - */ - protected $testStatus = FALSE; - - /** - * @var array - */ - protected $tests = array(); - - /** - * @var integer - */ - protected $successful = 0; - - /** - * @var integer - */ - protected $failed = 0; - - /** - * @var integer - */ - protected $skipped = 0; - - /** - * @var integer - */ - protected $incomplete = 0; - - /** - * @var string - */ - protected $testTypeOfInterest = 'PHPUnit_Framework_TestCase'; - - /** - * @var string - */ - protected $currentTestClassPrettified; - - /** - * @var string - */ - protected $currentTestMethodPrettified; - - /** - * Constructor. - * - * @param resource $out - */ - public function __construct($out = NULL) - { - parent::__construct($out); - - $this->prettifier = new PHPUnit_Util_TestDox_NamePrettifier; - $this->startRun(); - } - - /** - * Flush buffer and close output. - * - */ - public function flush() - { - $this->doEndClass(); - $this->endRun(); - - parent::flush(); - } - - /** - * An error occurred. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - if ($test instanceof $this->testTypeOfInterest) { - $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_ERROR; - $this->failed++; - } - } - - /** - * A failure occurred. - * - * @param PHPUnit_Framework_Test $test - * @param PHPUnit_Framework_AssertionFailedError $e - * @param float $time - */ - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) - { - if ($test instanceof $this->testTypeOfInterest) { - $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE; - $this->failed++; - } - } - - /** - * Incomplete test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - if ($test instanceof $this->testTypeOfInterest) { - $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE; - $this->incomplete++; - } - } - - /** - * Skipped test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - * @since Method available since Release 3.0.0 - */ - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - if ($test instanceof $this->testTypeOfInterest) { - $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED; - $this->skipped++; - } - } - - /** - * A testsuite started. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - } - - /** - * A testsuite ended. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - } - - /** - * A test started. - * - * @param PHPUnit_Framework_Test $test - */ - public function startTest(PHPUnit_Framework_Test $test) - { - if ($test instanceof $this->testTypeOfInterest) { - $class = get_class($test); - - if ($this->testClass != $class) { - if ($this->testClass != '') { - $this->doEndClass(); - } - - $this->currentTestClassPrettified = $this->prettifier->prettifyTestClass($class); - $this->startClass($class); - - $this->testClass = $class; - $this->tests = array(); - } - - $prettified = FALSE; - - if ($test instanceof PHPUnit_Framework_TestCase && - !$test instanceof PHPUnit_Framework_Warning) { - $annotations = $test->getAnnotations(); - - if (isset($annotations['method']['testdox'][0])) { - $this->currentTestMethodPrettified = $annotations['method']['testdox'][0]; - $prettified = TRUE; - } - } - - if (!$prettified) { - $this->currentTestMethodPrettified = $this->prettifier->prettifyTestMethod($test->getName(FALSE)); - } - - $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_PASSED; - } - } - - /** - * A test ended. - * - * @param PHPUnit_Framework_Test $test - * @param float $time - */ - public function endTest(PHPUnit_Framework_Test $test, $time) - { - if ($test instanceof $this->testTypeOfInterest) { - if (!isset($this->tests[$this->currentTestMethodPrettified])) { - if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) { - $this->tests[$this->currentTestMethodPrettified]['success'] = 1; - $this->tests[$this->currentTestMethodPrettified]['failure'] = 0; - } else { - $this->tests[$this->currentTestMethodPrettified]['success'] = 0; - $this->tests[$this->currentTestMethodPrettified]['failure'] = 1; - } - } else { - if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) { - $this->tests[$this->currentTestMethodPrettified]['success']++; - } else { - $this->tests[$this->currentTestMethodPrettified]['failure']++; - } - } - - $this->currentTestClassPrettified = NULL; - $this->currentTestMethodPrettified = NULL; - } - } - - /** - * @since Method available since Release 2.3.0 - */ - protected function doEndClass() - { - foreach ($this->tests as $name => $data) { - $this->onTest($name, $data['failure'] == 0); - } - - $this->endClass($this->testClass); - } - - /** - * Handler for 'start run' event. - * - */ - protected function startRun() - { - } - - /** - * Handler for 'start class' event. - * - * @param string $name - */ - protected function startClass($name) - { - } - - /** - * Handler for 'on test' event. - * - * @param string $name - * @param boolean $success - */ - protected function onTest($name, $success = TRUE) - { - } - - /** - * Handler for 'end class' event. - * - * @param string $name - */ - protected function endClass($name) - { - } - - /** - * Handler for 'end run' event. - * - */ - protected function endRun() - { - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/TestSuiteIterator.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/TestSuiteIterator.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/TestSuiteIterator.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/TestSuiteIterator.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,149 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.1.0 - */ - -/** - * Iterator for test suites. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.1.0 - */ -class PHPUnit_Util_TestSuiteIterator implements RecursiveIterator -{ - /** - * @var integer - */ - protected $position; - - /** - * @var PHPUnit_Framework_Test[] - */ - protected $tests; - - /** - * Constructor. - * - * @param PHPUnit_Framework_TestSuite $suite - */ - public function __construct(PHPUnit_Framework_TestSuite $testSuite) - { - $this->tests = $testSuite->tests(); - } - - /** - * Rewinds the Iterator to the first element. - * - */ - public function rewind() - { - $this->position = 0; - } - - /** - * Checks if there is a current element after calls to rewind() or next(). - * - * @return boolean - */ - public function valid() - { - return $this->position < count($this->tests); - } - - /** - * Returns the key of the current element. - * - * @return integer - */ - public function key() - { - return $this->position; - } - - /** - * Returns the current element. - * - * @return PHPUnit_Framework_Test - */ - public function current() - { - return $this->valid() ? $this->tests[$this->position] : NULL; - } - - /** - * Moves forward to next element. - * - */ - public function next() - { - $this->position++; - } - - /** - * Returns the sub iterator for the current element. - * - * @return PHPUnit_Util_TestSuiteIterator - */ - public function getChildren() - { - return new PHPUnit_Util_TestSuiteIterator( - $this->tests[$this->position] - ); - } - - /** - * Checks whether the current element has children. - * - * @return boolean - */ - public function hasChildren() - { - return $this->tests[$this->position] instanceof PHPUnit_Framework_TestSuite; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Type.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Type.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/Type.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/Type.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,192 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.0.0 - */ - -/** - * Utility class for textual type (and value) representation. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.0.0 - */ -class PHPUnit_Util_Type -{ - public static function isType($type) - { - return in_array( - $type, - array( - 'numeric', - 'integer', - 'int', - 'float', - 'string', - 'boolean', - 'bool', - 'null', - 'array', - 'object', - 'resource', - 'scalar' - ) - ); - } - - public static function shortenedExport($value) - { - if (is_string($value)) { - return self::shortenedString($value); - } - - elseif (is_array($value)) { - if (count($value) == 0) { - return 'array()'; - } - - $a1 = array_slice($value, 0, 1, TRUE); - $k1 = key($a1); - $v1 = $a1[$k1]; - - if (is_string($v1)) { - $v1 = self::shortenedString($v1); - } - - elseif (is_array($v1)) { - $v1 = 'array(...)'; - } else { - $v1 = self::toString($v1); - } - - $a2 = FALSE; - - if (count($value) > 1) { - $a2 = array_slice($value, -1, 1, TRUE); - $k2 = key($a2); - $v2 = $a2[$k2]; - - if (is_string($v2)) { - $v2 = self::shortenedString($v2); - } - - elseif (is_array($v2)) { - $v2 = 'array(...)'; - } else { - $v2 = self::toString($v2); - } - } - - $text = 'array( ' . self::toString($k1) . ' => ' . $v1; - - if ($a2 !== FALSE) { - $text .= ', ..., ' . self::toString($k2) . ' => ' . $v2 . ' )'; - } else { - $text .= ' )'; - } - - return $text; - } - - elseif (is_object($value)) { - return get_class($value) . '(...)'; - } - - return self::toString($value); - } - - public static function shortenedString($string) - { - $string = preg_replace('#\n|\r\n|\r#', ' ', $string); - - if (strlen($string) > 14) { - return PHPUnit_Util_Type::toString( - substr($string, 0, 7) . '...' . substr($string, -7) - ); - } else { - return PHPUnit_Util_Type::toString($string); - } - } - - public static function toString($value, $short = FALSE) - { - if (is_array($value) || is_object($value)) { - if (!$short) { - return "\n" . print_r($value, TRUE); - } else { - if (is_array($value)) { - return ''; - } else { - return '<' . get_class($value) . '>'; - } - } - } - - if (is_string($value) && strpos($value, "\n") !== FALSE) { - return ''; - } - - if (!is_null($value)) { - $type = gettype($value) . ':'; - } else { - $type = ''; - $value = 'null'; - } - - if (is_bool($value)) { - if ($value === TRUE) { - $value = 'true'; - } - - else if ($value === FALSE) { - $value = 'false'; - } - } - - return '<' . $type . $value . '>'; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/XML.php phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/XML.php --- phpunit-3.5.5/PHPUnit-3.5.5/PHPUnit/Util/XML.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/PHPUnit/Util/XML.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,958 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.2.0 - */ - -/** - * XML helpers. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.2.0 - */ -class PHPUnit_Util_XML -{ - /** - * @param string $string - * @return string - * @author Kore Nordmann - * @since Method available since Release 3.4.6 - */ - public static function prepareString($string) - { - return preg_replace( - '([\\x00-\\x04\\x0b\\x0c\\x0e-\\x1f\\x7f])e', - 'sprintf( "&#x%02x;", ord( "\\1" ) )', - htmlspecialchars( - self::convertToUtf8($string), ENT_COMPAT, 'UTF-8' - ) - ); - } - - /** - * Converts a string to UTF-8 encoding. - * - * @param string $string - * @return string - * @since Method available since Release 3.2.19 - */ - protected static function convertToUtf8($string) - { - if (!self::isUtf8($string)) { - if (function_exists('mb_convert_encoding')) { - $string = mb_convert_encoding($string, 'UTF-8'); - } else { - $string = utf8_encode($string); - } - } - - return $string; - } - - /** - * Checks a string for UTF-8 encoding. - * - * @param string $string - * @return boolean - * @since Method available since Release 3.3.0 - */ - protected static function isUtf8($string) - { - $length = strlen($string); - - for ($i = 0; $i < $length; $i++) { - if (ord($string[$i]) < 0x80) { - $n = 0; - } - - else if ((ord($string[$i]) & 0xE0) == 0xC0) { - $n = 1; - } - - else if ((ord($string[$i]) & 0xF0) == 0xE0) { - $n = 2; - } - - else if ((ord($string[$i]) & 0xF0) == 0xF0) { - $n = 3; - } - - else { - return FALSE; - } - - for ($j = 0; $j < $n; $j++) { - if ((++$i == $length) || ((ord($string[$i]) & 0xC0) != 0x80)) { - return FALSE; - } - } - } - - return TRUE; - } - - /** - * Loads an XML (or HTML) file into a DOMDocument object. - * - * @param string $filename - * @param boolean $isHtml - * @return DOMDocument - * @since Method available since Release 3.3.0 - */ - public static function loadFile($filename, $isHtml = FALSE) - { - $reporting = error_reporting(0); - $contents = file_get_contents($filename); - error_reporting($reporting); - - if ($contents === FALSE) { - throw new PHPUnit_Framework_Exception( - sprintf( - 'Could not read "%s".', - $filename - ) - ); - } - - return self::load($contents, $isHtml, $filename); - } - - /** - * Load an $actual document into a DOMDocument. This is called - * from the selector assertions. - * - * If $actual is already a DOMDocument, it is returned with - * no changes. Otherwise, $actual is loaded into a new DOMDocument - * as either HTML or XML, depending on the value of $isHtml. - * - * Note: prior to PHPUnit 3.3.0, this method loaded a file and - * not a string as it currently does. To load a file into a - * DOMDocument, use loadFile() instead. - * - * @param string|DOMDocument $actual - * @param boolean $isHtml - * @param string $filename - * @return DOMDocument - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ - public static function load($actual, $isHtml = FALSE, $filename = '') - { - if ($actual instanceof DOMDocument) { - return $actual; - } - - $internal = libxml_use_internal_errors(TRUE); - $reporting = error_reporting(0); - $dom = new DOMDocument; - - if ($isHtml) { - $loaded = $dom->loadHTML($actual); - } else { - $loaded = $dom->loadXML($actual); - } - - libxml_use_internal_errors($internal); - error_reporting($reporting); - - if ($loaded === FALSE) { - $message = ''; - - foreach (libxml_get_errors() as $error) { - $message .= $error->message; - } - - if ($filename != '') { - throw new PHPUnit_Framework_Exception( - sprintf( - 'Could not load "%s".%s', - - $filename, - $message != '' ? "\n" . $message : '' - ) - ); - } else { - throw new PHPUnit_Framework_Exception($message); - } - } - - return $dom; - } - - /** - * - * - * @param DOMNode $node - * @return string - * @since Method available since Release 3.4.0 - */ - public static function nodeToText(DOMNode $node) - { - if ($node->childNodes->length == 1) { - return $node->nodeValue; - } - - $result = ''; - - foreach ($node->childNodes as $childNode) { - $result .= $node->ownerDocument->saveXML($childNode); - } - - return $result; - } - - /** - * - * - * @param DOMNode $node - * @since Method available since Release 3.3.0 - * @author Mattis Stordalen Flister - */ - public static function removeCharacterDataNodes(DOMNode $node) - { - if ($node->hasChildNodes()) { - for ($i = $node->childNodes->length - 1; $i >= 0; $i--) { - if (($child = $node->childNodes->item($i)) instanceof DOMCharacterData) { - $node->removeChild($child); - } - } - } - } - - /** - * "Convert" a DOMElement object into a PHP variable. - * - * @param DOMElement $element - * @return mixed - * @since Method available since Release 3.4.0 - */ - public static function xmlToVariable(DOMElement $element) - { - $variable = NULL; - - switch ($element->tagName) { - case 'array': { - $variable = array(); - - foreach ($element->getElementsByTagName('element') as $element) { - $value = self::xmlToVariable($element->childNodes->item(1)); - - if ($element->hasAttribute('key')) { - $variable[(string)$element->getAttribute('key')] = $value; - } else { - $variable[] = $value; - } - } - } - break; - - case 'object': { - $className = $element->getAttribute('class'); - - if ($element->hasChildNodes()) { - $arguments = $element->childNodes->item(1)->childNodes; - $constructorArgs = array(); - - foreach ($arguments as $argument) { - if ($argument instanceof DOMElement) { - $constructorArgs[] = self::xmlToVariable($argument); - } - } - - $class = new ReflectionClass($className); - $variable = $class->newInstanceArgs($constructorArgs); - } else { - $variable = new $className; - } - } - break; - - case 'boolean': { - $variable = $element->nodeValue == 'true' ? TRUE : FALSE; - } - break; - - case 'integer': - case 'double': - case 'string': { - $variable = $element->nodeValue; - - settype($variable, $element->tagName); - } - break; - } - - return $variable; - } - - /** - * Validate list of keys in the associative array. - * - * @param array $hash - * @param array $validKeys - * @return array - * @throws InvalidArgumentException - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ - public static function assertValidKeys(array $hash, array $validKeys) - { - $valids = array(); - - // Normalize validation keys so that we can use both indexed and - // associative arrays. - foreach ($validKeys as $key => $val) { - is_int($key) ? $valids[$val] = NULL : $valids[$key] = $val; - } - - $validKeys = array_keys($valids); - - // Check for invalid keys. - foreach ($hash as $key => $value) { - if (!in_array($key, $validKeys)) { - $unknown[] = $key; - } - } - - if (!empty($unknown)) { - throw new InvalidArgumentException( - 'Unknown key(s): ' . implode(', ', $unknown) - ); - } - - // Add default values for any valid keys that are empty. - foreach ($valids as $key => $value) { - if (!isset($hash[$key])) { - $hash[$key] = $value; - } - } - - return $hash; - } - - /** - * Parse a CSS selector into an associative array suitable for - * use with findNodes(). - * - * @param string $selector - * @param mixed $content - * @return array - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ - public static function convertSelectToTag($selector, $content = TRUE) - { - $selector = trim(preg_replace("/\s+/", " ", $selector)); - - // substitute spaces within attribute value - while (preg_match('/\[[^\]]+"[^"]+\s[^"]+"\]/', $selector)) { - $selector = preg_replace( - '/(\[[^\]]+"[^"]+)\s([^"]+"\])/', "$1__SPACE__$2", $selector - ); - } - - if (strstr($selector, ' ')) { - $elements = explode(' ', $selector); - } else { - $elements = array($selector); - } - - $previousTag = array(); - - foreach (array_reverse($elements) as $element) { - $element = str_replace('__SPACE__', ' ', $element); - - // child selector - if ($element == '>') { - $previousTag = array('child' => $previousTag['descendant']); - continue; - } - - $tag = array(); - - // match element tag - preg_match("/^([^\.#\[]*)/", $element, $eltMatches); - - if (!empty($eltMatches[1])) { - $tag['tag'] = $eltMatches[1]; - } - - // match attributes (\[[^\]]*\]*), ids (#[^\.#\[]*), - // and classes (\.[^\.#\[]*)) - preg_match_all( - "/(\[[^\]]*\]*|#[^\.#\[]*|\.[^\.#\[]*)/", $element, $matches - ); - - if (!empty($matches[1])) { - $classes = array(); - $attrs = array(); - - foreach ($matches[1] as $match) { - // id matched - if (substr($match, 0, 1) == '#') { - $tag['id'] = substr($match, 1); - } - - // class matched - else if (substr($match, 0, 1) == '.') { - $classes[] = substr($match, 1); - } - - // attribute matched - else if (substr($match, 0, 1) == '[' && - substr($match, -1, 1) == ']') { - $attribute = substr($match, 1, strlen($match) - 2); - $attribute = str_replace('"', '', $attribute); - - // match single word - if (strstr($attribute, '~=')) { - list($key, $value) = explode('~=', $attribute); - $value = "regexp:/.*\b$value\b.*/"; - } - - // match substring - else if (strstr($attribute, '*=')) { - list($key, $value) = explode('*=', $attribute); - $value = "regexp:/.*$value.*/"; - } - - // exact match - else { - list($key, $value) = explode('=', $attribute); - } - - $attrs[$key] = $value; - } - } - - if ($classes) { - $tag['class'] = join(' ', $classes); - } - - if ($attrs) { - $tag['attributes'] = $attrs; - } - } - - // tag content - if (is_string($content)) { - $tag['content'] = $content; - } - - // determine previous child/descendants - if (!empty($previousTag['descendant'])) { - $tag['descendant'] = $previousTag['descendant']; - } - - else if (!empty($previousTag['child'])) { - $tag['child'] = $previousTag['child']; - } - - $previousTag = array('descendant' => $tag); - } - - return $tag; - } - - /** - * Parse an $actual document and return an array of DOMNodes - * matching the CSS $selector. If an error occurs, it will - * return FALSE. - * - * To only return nodes containing a certain content, give - * the $content to match as a string. Otherwise, setting - * $content to TRUE will return all nodes matching $selector. - * - * The $actual document may be a DOMDocument or a string - * containing XML or HTML, identified by $isHtml. - * - * @param array $selector - * @param string $content - * @param mixed $actual - * @param boolean $isHtml - * @return false|array - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - * @author Tobias Schlitt - */ - public static function cssSelect($selector, $content, $actual, $isHtml = TRUE) - { - $matcher = self::convertSelectToTag($selector, $content); - $dom = self::load($actual, $isHtml); - $tags = self::findNodes($dom, $matcher, $isHtml); - - return $tags; - } - - /** - * Parse out the options from the tag using DOM object tree. - * - * @param DOMDocument $dom - * @param array $options - * @param boolean $isHtml - * @return array - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - * @author Tobias Schlitt - */ - public static function findNodes(DOMDocument $dom, array $options, $isHtml = TRUE) - { - $valid = array( - 'id', 'class', 'tag', 'content', 'attributes', 'parent', - 'child', 'ancestor', 'descendant', 'children' - ); - - $filtered = array(); - $options = self::assertValidKeys($options, $valid); - - // find the element by id - if ($options['id']) { - $options['attributes']['id'] = $options['id']; - } - - if ($options['class']) { - $options['attributes']['class'] = $options['class']; - } - - // find the element by a tag type - if ($options['tag']) { - if ($isHtml) { - $elements = self::getElementsByCaseInsensitiveTagName( - $dom, $options['tag'] - ); - } else { - $elements = $dom->getElementsByTagName($options['tag']); - } - - foreach ($elements as $element) { - $nodes[] = $element; - } - - if (empty($nodes)) { - return FALSE; - } - } - - // no tag selected, get them all - else { - $tags = array( - 'a', 'abbr', 'acronym', 'address', 'area', 'b', 'base', 'bdo', - 'big', 'blockquote', 'body', 'br', 'button', 'caption', 'cite', - 'code', 'col', 'colgroup', 'dd', 'del', 'div', 'dfn', 'dl', - 'dt', 'em', 'fieldset', 'form', 'frame', 'frameset', 'h1', 'h2', - 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'html', 'i', 'iframe', - 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'link', - 'map', 'meta', 'noframes', 'noscript', 'object', 'ol', 'optgroup', - 'option', 'p', 'param', 'pre', 'q', 'samp', 'script', 'select', - 'small', 'span', 'strong', 'style', 'sub', 'sup', 'table', - 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title', - 'tr', 'tt', 'ul', 'var' - ); - - foreach ($tags as $tag) { - if ($isHtml) { - $elements = self::getElementsByCaseInsensitiveTagName( - $dom, $tag - ); - } else { - $elements = $dom->getElementsByTagName($tag); - } - - foreach ($elements as $element) { - $nodes[] = $element; - } - } - - if (empty($nodes)) { - return FALSE; - } - } - - // filter by attributes - if ($options['attributes']) { - foreach ($nodes as $node) { - $invalid = FALSE; - - foreach ($options['attributes'] as $name => $value) { - // match by regexp if like "regexp:/foo/i" - if (preg_match('/^regexp\s*:\s*(.*)/i', $value, $matches)) { - if (!preg_match($matches[1], $node->getAttribute($name))) { - $invalid = TRUE; - } - } - - // class can match only a part - else if ($name == 'class') { - // split to individual classes - $findClasses = explode( - ' ', preg_replace("/\s+/", " ", $value) - ); - - $allClasses = explode( - ' ', - preg_replace("/\s+/", " ", $node->getAttribute($name)) - ); - - // make sure each class given is in the actual node - foreach ($findClasses as $findClass) { - if (!in_array($findClass, $allClasses)) { - $invalid = TRUE; - } - } - } - - // match by exact string - else { - if ($node->getAttribute($name) != $value) { - $invalid = TRUE; - } - } - } - - // if every attribute given matched - if (!$invalid) { - $filtered[] = $node; - } - } - - $nodes = $filtered; - $filtered = array(); - - if (empty($nodes)) { - return FALSE; - } - } - - // filter by content - if ($options['content'] !== NULL) { - foreach ($nodes as $node) { - $invalid = FALSE; - - // match by regexp if like "regexp:/foo/i" - if (preg_match('/^regexp\s*:\s*(.*)/i', $options['content'], $matches)) { - if (!preg_match($matches[1], self::getNodeText($node))) { - $invalid = TRUE; - } - } - - // match by exact string - else if (strstr(self::getNodeText($node), $options['content']) === FALSE) { - $invalid = TRUE; - } - - if (!$invalid) { - $filtered[] = $node; - } - } - - $nodes = $filtered; - $filtered = array(); - - if (empty($nodes)) { - return FALSE; - } - } - - // filter by parent node - if ($options['parent']) { - $parentNodes = self::findNodes($dom, $options['parent'], $isHtml); - $parentNode = isset($parentNodes[0]) ? $parentNodes[0] : NULL; - - foreach ($nodes as $node) { - if ($parentNode !== $node->parentNode) { - break; - } - - $filtered[] = $node; - } - - $nodes = $filtered; - $filtered = array(); - - if (empty($nodes)) { - return FALSE; - } - } - - // filter by child node - if ($options['child']) { - $childNodes = self::findNodes($dom, $options['child'], $isHtml); - $childNodes = !empty($childNodes) ? $childNodes : array(); - - foreach ($nodes as $node) { - foreach ($node->childNodes as $child) { - foreach ($childNodes as $childNode) { - if ($childNode === $child) { - $filtered[] = $node; - } - } - } - } - - $nodes = $filtered; - $filtered = array(); - - if (empty($nodes)) { - return FALSE; - } - } - - // filter by ancestor - if ($options['ancestor']) { - $ancestorNodes = self::findNodes($dom, $options['ancestor'], $isHtml); - $ancestorNode = isset($ancestorNodes[0]) ? $ancestorNodes[0] : NULL; - - foreach ($nodes as $node) { - $parent = $node->parentNode; - - while ($parent->nodeType != XML_HTML_DOCUMENT_NODE) { - if ($parent === $ancestorNode) { - $filtered[] = $node; - } - - $parent = $parent->parentNode; - } - } - - $nodes = $filtered; - $filtered = array(); - - if (empty($nodes)) { - return FALSE; - } - } - - // filter by descendant - if ($options['descendant']) { - $descendantNodes = self::findNodes($dom, $options['descendant'], $isHtml); - $descendantNodes = !empty($descendantNodes) ? $descendantNodes : array(); - - foreach ($nodes as $node) { - foreach (self::getDescendants($node) as $descendant) { - foreach ($descendantNodes as $descendantNode) { - if ($descendantNode === $descendant) { - $filtered[] = $node; - } - } - } - } - - $nodes = $filtered; - $filtered = array(); - - if (empty($nodes)) { - return FALSE; - } - } - - // filter by children - if ($options['children']) { - $validChild = array('count', 'greater_than', 'less_than', 'only'); - $childOptions = self::assertValidKeys( - $options['children'], $validChild - ); - - foreach ($nodes as $node) { - $childNodes = $node->childNodes; - - foreach ($childNodes as $childNode) { - if ($childNode->nodeType !== XML_CDATA_SECTION_NODE && - $childNode->nodeType !== XML_TEXT_NODE) { - $children[] = $childNode; - } - } - - // we must have children to pass this filter - if (!empty($children)) { - // exact count of children - if ($childOptions['count'] !== NULL) { - if (count($children) !== $childOptions['count']) { - break; - } - } - - // range count of children - else if ($childOptions['less_than'] !== NULL && - $childOptions['greater_than'] !== NULL) { - if (count($children) >= $childOptions['less_than'] || - count($children) <= $childOptions['greater_than']) { - break; - } - } - - // less than a given count - else if ($childOptions['less_than'] !== NULL) { - if (count($children) >= $childOptions['less_than']) { - break; - } - } - - // more than a given count - else if ($childOptions['greater_than'] !== NULL) { - if (count($children) <= $childOptions['greater_than']) { - break; - } - } - - // match each child against a specific tag - if ($childOptions['only']) { - $onlyNodes = self::findNodes( - $dom, $childOptions['only'], $isHtml - ); - - // try to match each child to one of the 'only' nodes - foreach ($children as $child) { - $matched = FALSE; - - foreach ($onlyNodes as $onlyNode) { - if ($onlyNode === $child) { - $matched = TRUE; - } - } - - if (!$matched) { - break(2); - } - } - } - - $filtered[] = $node; - } - } - - $nodes = $filtered; - $filtered = array(); - - if (empty($nodes)) { - return; - } - } - - // return the first node that matches all criteria - return !empty($nodes) ? $nodes : array(); - } - - /** - * Recursively get flat array of all descendants of this node. - * - * @param DOMNode $node - * @return array - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ - protected static function getDescendants(DOMNode $node) - { - $allChildren = array(); - $childNodes = $node->childNodes ? $node->childNodes : array(); - - foreach ($childNodes as $child) { - if ($child->nodeType === XML_CDATA_SECTION_NODE || - $child->nodeType === XML_TEXT_NODE) { - continue; - } - - $children = self::getDescendants($child); - $allChildren = array_merge($allChildren, $children, array($child)); - } - - return isset($allChildren) ? $allChildren : array(); - } - - /** - * Gets elements by case insensitive tagname. - * - * @param DOMDocument $dom - * @param string $tag - * @return DOMNodeList - * @since Method available since Release 3.4.0 - */ - protected static function getElementsByCaseInsensitiveTagName(DOMDocument $dom, $tag) - { - $elements = $dom->getElementsByTagName(strtolower($tag)); - - if ($elements->length == 0) { - $elements = $dom->getElementsByTagName(strtoupper($tag)); - } - - return $elements; - } - - /** - * Get the text value of this node's child text node. - * - * @param DOMNode $node - * @return string - * @since Method available since Release 3.3.0 - * @author Mike Naberezny - * @author Derek DeVries - */ - protected static function getNodeText(DOMNode $node) - { - if (!$node->childNodes instanceof DOMNodeList) { - return ''; - } - - $result = ''; - - foreach ($node->childNodes as $childNode) { - if ($childNode->nodeType === XML_TEXT_NODE) { - $result .= trim($childNode->data) . ' '; - } else { - $result .= self::getNodeText($childNode); - } - } - - return str_replace(' ', ' ', $result); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/Samples/BankAccount/BankAccount.php phpunit-3.6.10/PHPUnit-3.5.5/Samples/BankAccount/BankAccount.php --- phpunit-3.5.5/PHPUnit-3.5.5/Samples/BankAccount/BankAccount.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/Samples/BankAccount/BankAccount.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.3.0 - */ - -class BankAccountException extends RuntimeException {} - -/** - * A bank account. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.3.0 - */ -class BankAccount -{ - /** - * The bank account's balance. - * - * @var float - */ - protected $balance = 0; - - /** - * Returns the bank account's balance. - * - * @return float - */ - public function getBalance() - { - return $this->balance; - } - - /** - * Sets the bank account's balance. - * - * @param float $balance - * @throws BankAccountException - */ - protected function setBalance($balance) - { - if ($balance >= 0) { - $this->balance = $balance; - } else { - throw new BankAccountException; - } - } - - /** - * Deposits an amount of money to the bank account. - * - * @param float $balance - * @throws BankAccountException - */ - public function depositMoney($balance) - { - $this->setBalance($this->getBalance() + $balance); - - return $this->getBalance(); - } - - /** - * Withdraws an amount of money from the bank account. - * - * @param float $balance - * @throws BankAccountException - */ - public function withdrawMoney($balance) - { - $this->setBalance($this->getBalance() - $balance); - - return $this->getBalance(); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/Samples/BankAccount/BankAccountTest.php phpunit-3.6.10/PHPUnit-3.5.5/Samples/BankAccount/BankAccountTest.php --- phpunit-3.5.5/PHPUnit-3.5.5/Samples/BankAccount/BankAccountTest.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/Samples/BankAccount/BankAccountTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,134 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.3.0 - */ - -require_once 'PHPUnit/Framework/TestCase.php'; -require_once 'BankAccount.php'; - -/** - * Tests for the BankAccount class. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.3.0 - */ -class BankAccountTest extends PHPUnit_Framework_TestCase -{ - protected $ba; - - protected function setUp() - { - $this->ba = new BankAccount; - } - - /** - * @covers BankAccount::getBalance - * @group balanceIsInitiallyZero - * @group specification - */ - public function testBalanceIsInitiallyZero() - { - $this->assertEquals(0, $this->ba->getBalance()); - } - - /** - * @covers BankAccount::withdrawMoney - * @group balanceCannotBecomeNegative - * @group specification - */ - public function testBalanceCannotBecomeNegative() - { - try { - $this->ba->withdrawMoney(1); - } - - catch (BankAccountException $e) { - $this->assertEquals(0, $this->ba->getBalance()); - - return; - } - - $this->fail(); - } - - /** - * @covers BankAccount::depositMoney - * @group balanceCannotBecomeNegative - * @group specification - */ - public function testBalanceCannotBecomeNegative2() - { - try { - $this->ba->depositMoney(-1); - } - - catch (BankAccountException $e) { - $this->assertEquals(0, $this->ba->getBalance()); - - return; - } - - $this->fail(); - } - - /** - * @covers BankAccount::getBalance - * @covers BankAccount::depositMoney - * @covers BankAccount::withdrawMoney - * @group balanceCannotBecomeNegative - */ -/* - public function testDepositingAndWithdrawingMoneyWorks() - { - $this->assertEquals(0, $this->ba->getBalance()); - $this->ba->depositMoney(1); - $this->assertEquals(1, $this->ba->getBalance()); - $this->ba->withdrawMoney(1); - $this->assertEquals(0, $this->ba->getBalance()); - } -*/ -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/Samples/BowlingGame/BowlingGame.php phpunit-3.6.10/PHPUnit-3.5.5/Samples/BowlingGame/BowlingGame.php --- phpunit-3.5.5/PHPUnit-3.5.5/Samples/BowlingGame/BowlingGame.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/Samples/BowlingGame/BowlingGame.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -class BowlingGame -{ - protected $rolls = array(); - - public function roll($pins) - { - $this->rolls[] = $pins; - } - - protected function isSpare($frameIndex) - { - return $this->sumOfPinsInFrame($frameIndex) == 10; - } - - protected function isStrike($frameIndex) - { - return $this->rolls[$frameIndex] == 10; - } - - protected function sumOfPinsInFrame($frameIndex) - { - return $this->rolls[$frameIndex] + - $this->rolls[$frameIndex + 1]; - } - - protected function spareBonus($frameIndex) - { - return $this->rolls[$frameIndex + 2]; - } - - protected function strikeBonus($frameIndex) - { - return $this->rolls[$frameIndex + 1] + - $this->rolls[$frameIndex + 2]; - } - - public function score() - { - $score = 0; - $frameIndex = 0; - - for ($frame = 0; $frame < 10; $frame++) { - if ($this->isStrike($frameIndex)) { - $score += 10 + $this->strikeBonus($frameIndex); - $frameIndex++; - } - - else if ($this->isSpare($frameIndex)) { - $score += 10 + $this->spareBonus($frameIndex); - $frameIndex += 2; - } - - else { - $score += $this->sumOfPinsInFrame($frameIndex); - $frameIndex += 2; - } - } - - return $score; - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/Samples/BowlingGame/BowlingGameSpec.php phpunit-3.6.10/PHPUnit-3.5.5/Samples/BowlingGame/BowlingGameSpec.php --- phpunit-3.5.5/PHPUnit-3.5.5/Samples/BowlingGame/BowlingGameSpec.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/Samples/BowlingGame/BowlingGameSpec.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,181 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -require_once 'PHPUnit/Extensions/Story/TestCase.php'; -require_once 'BowlingGame.php'; - -class BowlingGameSpec extends PHPUnit_Extensions_Story_TestCase -{ - /** - * @scenario - */ - public function scoreForGutterGameIs0() - { - $this->given('New game') - ->then('Score should be', 0); - } - - /** - * @scenario - */ - public function scoreForAllOnesIs20() - { - $this->given('New game') - ->when('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->and('Player rolls', 1) - ->then('Score should be', 20); - } - - /** - * @scenario - */ - public function scoreForOneSpareAnd3Is16() - { - $this->given('New game') - ->when('Player rolls', 5) - ->and('Player rolls', 5) - ->and('Player rolls', 3) - ->then('Score should be', 16); - } - - /** - * @scenario - */ - public function scoreForOneStrikeAnd3And4Is24() - { - $this->given('New game') - ->when('Player rolls', 10) - ->and('Player rolls', 3) - ->and('Player rolls', 4) - ->then('Score should be', 24); - } - - /** - * @scenario - */ - public function scoreForPerfectGameIs300() - { - $this->given('New game') - ->when('Player rolls', 10) - ->and('Player rolls', 10) - ->and('Player rolls', 10) - ->and('Player rolls', 10) - ->and('Player rolls', 10) - ->and('Player rolls', 10) - ->and('Player rolls', 10) - ->and('Player rolls', 10) - ->and('Player rolls', 10) - ->and('Player rolls', 10) - ->and('Player rolls', 10) - ->and('Player rolls', 10) - ->then('Score should be', 300); - } - - public function runGiven(&$world, $action, $arguments) - { - switch($action) { - case 'New game': { - $world['game'] = new BowlingGame; - $world['rolls'] = 0; - } - break; - - default: { - return $this->notImplemented($action); - } - } - } - - public function runWhen(&$world, $action, $arguments) - { - switch($action) { - case 'Player rolls': { - $world['game']->roll($arguments[0]); - $world['rolls']++; - } - break; - - default: { - return $this->notImplemented($action); - } - } - } - - public function runThen(&$world, $action, $arguments) - { - switch($action) { - case 'Score should be': { - for ($i = $world['rolls']; $i < 20; $i++) { - $world['game']->roll(0); - } - - $this->assertEquals($arguments[0], $world['game']->score()); - } - break; - - default: { - return $this->notImplemented($action); - } - } - } -} - diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/Samples/BowlingGame/BowlingGameTest.php phpunit-3.6.10/PHPUnit-3.5.5/Samples/BowlingGame/BowlingGameTest.php --- phpunit-3.5.5/PHPUnit-3.5.5/Samples/BowlingGame/BowlingGameTest.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/Samples/BowlingGame/BowlingGameTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -require_once 'BowlingGame.php'; - -class BowlingGameTest extends PHPUnit_Framework_TestCase -{ - protected $game; - - protected function setUp() - { - $this->game = new BowlingGame; - } - - public function testScoreForGutterGameIs0() - { - $this->rollMany(20, 0); - $this->assertEquals(0, $this->game->score()); - } - - public function testScoreForAllOnesIs20() - { - $this->rollMany(20, 1); - $this->assertEquals(20, $this->game->score()); - } - - public function testScoreForOneSpareAnd3Is16() - { - $this->rollSpare(); - $this->game->roll(3); - $this->rollMany(17, 0); - $this->assertEquals(16, $this->game->score()); - } - - public function testScoreForOneStrikeAnd3And4Is24() - { - $this->rollStrike(); - $this->game->roll(3); - $this->game->roll(4); - $this->rollMany(17, 0); - $this->assertEquals(24, $this->game->score()); - } - - public function testScoreForPerfectGameIs300() - { - $this->rollMany(12, 10); - $this->assertEquals(300, $this->game->score()); - } - - protected function rollMany($n, $pins) - { - for ($i = 0; $i < $n; $i++) { - $this->game->roll($pins); - } - } - - protected function rollSpare() - { - $this->game->roll(5); - $this->game->roll(5); - } - - protected function rollStrike() - { - $this->game->roll(10); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/Samples/Money/IMoney.php phpunit-3.6.10/PHPUnit-3.5.5/Samples/Money/IMoney.php --- phpunit-3.5.5/PHPUnit-3.5.5/Samples/Money/IMoney.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/Samples/Money/IMoney.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.3.0 - */ - -require_once 'Money.php'; -require_once 'MoneyBag.php'; - -/** - * Money Interface. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.3.0 - */ -interface IMoney -{ - public function add(IMoney $m); - public function addMoney(Money $m); - public function addMoneyBag(MoneyBag $s); - public function isZero(); - public function multiply($factor); - public function negate(); - public function subtract(IMoney $m); - public function appendTo(MoneyBag $m); -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/Samples/Money/Money.php phpunit-3.6.10/PHPUnit-3.5.5/Samples/Money/Money.php --- phpunit-3.5.5/PHPUnit-3.5.5/Samples/Money/Money.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/Samples/Money/Money.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,147 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.3.0 - */ - -require_once 'IMoney.php'; - -/** - * A Money. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.3.0 - */ -class Money implements IMoney -{ - protected $fAmount; - protected $fCurrency; - - public function __construct($amount, $currency) - { - $this->fAmount = $amount; - $this->fCurrency = $currency; - } - - public function add(IMoney $m) - { - return $m->addMoney($this); - } - - public function addMoney(Money $m) - { - if ($this->currency() == $m->currency()) { - return new Money($this->amount() + $m->amount(), $this->currency()); - } - - return MoneyBag::create($this, $m); - } - - public function addMoneyBag(MoneyBag $s) - { - return $s->addMoney($this); - } - - public function amount() - { - return $this->fAmount; - } - - public function currency() - { - return $this->fCurrency; - } - - public function equals($anObject) - { - if ($this->isZero() && - $anObject instanceof IMoney) { - return $anObject->isZero(); - } - - if ($anObject instanceof Money) { - return ($this->currency() == $anObject->currency() && - $this->amount() == $anObject->amount()); - } - - return FALSE; - } - - public function hashCode() - { - return crc32($this->fCurrency) + $this->fAmount; - } - - public function isZero() - { - return $this->amount() == 0; - } - - public function multiply($factor) - { - return new Money($this->amount() * $factor, $this->currency()); - } - - public function negate() - { - return new Money(-1 * $this->amount(), $this->currency()); - } - - public function subtract(IMoney $m) - { - return $this->add($m->negate()); - } - - public function toString() - { - return '[' . $this->amount() . ' ' . $this->currency() . ']'; - } - - public function appendTo(MoneyBag $m) - { - $m->appendMoney($this); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/Samples/Money/MoneyBag.php phpunit-3.6.10/PHPUnit-3.5.5/Samples/Money/MoneyBag.php --- phpunit-3.5.5/PHPUnit-3.5.5/Samples/Money/MoneyBag.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/Samples/Money/MoneyBag.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,246 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.3.0 - */ - -require_once 'IMoney.php'; -require_once 'Money.php'; - -/** - * A MoneyBag. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.3.0 - */ -class MoneyBag implements IMoney -{ - protected $fMonies = array(); - - public static function create(IMoney $m1, IMoney $m2) - { - $result = new MoneyBag; - $m1->appendTo($result); - $m2->appendTo($result); - - return $result->simplify(); - } - - public function add(IMoney $m) - { - return $m->addMoneyBag($this); - } - - public function addMoney(Money $m) - { - return MoneyBag::create($m, $this); - } - - public function addMoneyBag(MoneyBag $s) - { - return MoneyBag::create($s, $this); - } - - public function appendBag(MoneyBag $aBag) - { - foreach ($aBag->monies() as $aMoney) { - $this->appendMoney($aMoney); - } - } - - public function monies() - { - return $this->fMonies; - } - - public function appendMoney(Money $aMoney) - { - if ($aMoney->isZero()) { - return; - } - - $old = $this->findMoney($aMoney->currency()); - - if ($old == NULL) { - $this->fMonies[] = $aMoney; - return; - } - - $keys = array_keys($this->fMonies); - $max = count($keys); - - for ($i = 0; $i < $max; $i++) { - if ($this->fMonies[$keys[$i]] === $old) { - unset($this->fMonies[$keys[$i]]); - break; - } - } - - $sum = $old->add($aMoney); - - if ($sum->isZero()) { - return; - } - - $this->fMonies[] = $sum; - } - - public function equals($anObject) - { - if ($this->isZero() && - $anObject instanceof IMoney) { - return $anObject->isZero(); - } - - if ($anObject instanceof MoneyBag) { - if (count($anObject->monies()) != count($this->fMonies)) { - return FALSE; - } - - foreach ($this->fMonies as $m) { - if (!$anObject->contains($m)) { - return FALSE; - } - } - - return TRUE; - } - - return FALSE; - } - - protected function findMoney($currency) - { - foreach ($this->fMonies as $m) { - if ($m->currency() == $currency) { - return $m; - } - } - - return NULL; - } - - protected function contains(Money $m) - { - $found = $this->findMoney($m->currency()); - - if ($found == NULL) { - return FALSE; - } - - return $found->amount() == $m->amount(); - } - - public function hashCode() - { - $hash = 0; - - foreach ($this->fMonies as $m) { - $hash ^= $m->hashCode(); - } - - return $hash; - } - - public function isZero() - { - return count($this->fMonies) == 0; - } - - public function multiply($factor) - { - $result = new MoneyBag; - - if ($factor != 0) { - foreach ($this->fMonies as $m) { - $result->appendMoney($m->multiply($factor)); - } - } - - return $result; - } - - public function negate() - { - $result = new MoneyBag; - - foreach ($this->fMonies as $m) { - $result->appendMoney($m->negate()); - } - - return $result; - } - - protected function simplify() - { - if (count($this->fMonies) == 1) { - return array_pop($this->fMonies); - } - - return $this; - } - - public function subtract(IMoney $m) - { - return $this->add($m->negate()); - } - - public function toString() - { - $buffer = '{'; - - foreach ($this->fMonies as $m) { - $buffer .= $m->toString(); - } - - return $buffer . '}'; - } - - public function appendTo(MoneyBag $m) - { - $m->appendBag($this); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/Samples/Money/MoneyTest.php phpunit-3.6.10/PHPUnit-3.5.5/Samples/Money/MoneyTest.php --- phpunit-3.5.5/PHPUnit-3.5.5/Samples/Money/MoneyTest.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/Samples/Money/MoneyTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,244 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 2.3.0 - */ - -require_once 'PHPUnit/Framework/TestCase.php'; - -require_once 'Money.php'; -require_once 'MoneyBag.php'; - -/** - * Tests for the Money and MoneyBag classes. - * - * @package PHPUnit - * @author Sebastian Bergmann - * @copyright 2002-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.5.5 - * @link http://www.phpunit.de/ - * @since Class available since Release 2.3.0 - */ -class MoneyTest extends PHPUnit_Framework_TestCase -{ - protected $f12EUR; - protected $f14EUR; - protected $f7USD; - protected $f21USD; - - protected $fMB1; - protected $fMB2; - - protected function setUp() - { - $this->f12EUR = new Money(12, 'EUR'); - $this->f14EUR = new Money(14, 'EUR'); - $this->f7USD = new Money( 7, 'USD'); - $this->f21USD = new Money(21, 'USD'); - - $this->fMB1 = MoneyBag::create($this->f12EUR, $this->f7USD); - $this->fMB2 = MoneyBag::create($this->f14EUR, $this->f21USD); - } - - public function testBagMultiply() - { - // {[12 EUR][7 USD]} *2 == {[24 EUR][14 USD]} - $expected = MoneyBag::create(new Money(24, 'EUR'), new Money(14, 'USD')); - - $this->assertTrue($expected->equals($this->fMB1->multiply(2))); - $this->assertTrue($this->fMB1->equals($this->fMB1->multiply(1))); - $this->assertTrue($this->fMB1->multiply(0)->isZero()); - } - - public function testBagNegate() - { - // {[12 EUR][7 USD]} negate == {[-12 EUR][-7 USD]} - $expected = MoneyBag::create(new Money(-12, 'EUR'), new Money(-7, 'USD')); - $this->assertTrue($expected->equals($this->fMB1->negate())); - } - - public function testBagSimpleAdd() - { - // {[12 EUR][7 USD]} + [14 EUR] == {[26 EUR][7 USD]} - $expected = MoneyBag::create(new Money(26, 'EUR'), new Money(7, 'USD')); - $this->assertTrue($expected->equals($this->fMB1->add($this->f14EUR))); - } - - public function testBagSubtract() - { - // {[12 EUR][7 USD]} - {[14 EUR][21 USD] == {[-2 EUR][-14 USD]} - $expected = MoneyBag::create(new Money(-2, 'EUR'), new Money(-14, 'USD')); - $this->assertTrue($expected->equals($this->fMB1->subtract($this->fMB2))); - } - - public function testBagSumAdd() - { - // {[12 EUR][7 USD]} + {[14 EUR][21 USD]} == {[26 EUR][28 USD]} - $expected = MoneyBag::create(new Money(26, 'EUR'), new Money(28, 'USD')); - $this->assertTrue($expected->equals($this->fMB1->add($this->fMB2))); - } - - public function testIsZero() - { - //$this->assertTrue($this->fMB1->subtract($this->fMB1)->isZero()); - $this->assertTrue(MoneyBag::create(new Money (0, 'EUR'), new Money (0, 'USD'))->isZero()); - } - - public function testMixedSimpleAdd() - { - // [12 EUR] + [7 USD] == {[12 EUR][7 USD]} - $expected = MoneyBag::create($this->f12EUR, $this->f7USD); - $this->assertTrue($expected->equals($this->f12EUR->add($this->f7USD))); - } - - public function testBagNotEquals() - { - $bag1 = MoneyBag::create($this->f12EUR, $this->f7USD); - $bag2 = new Money(12, 'CHF'); - $bag2->add($this->f7USD); - $this->assertFalse($bag1->equals($bag2)); - } - - public function testMoneyBagEquals() - { - $this->assertTrue(!$this->fMB1->equals(NULL)); - - $this->assertTrue($this->fMB1->equals($this->fMB1)); - $equal = MoneyBag::create(new Money(12, 'EUR'), new Money(7, 'USD')); - $this->assertTrue($this->fMB1->equals($equal)); - $this->assertTrue(!$this->fMB1->equals($this->f12EUR)); - $this->assertTrue(!$this->f12EUR->equals($this->fMB1)); - $this->assertTrue(!$this->fMB1->equals($this->fMB2)); - } - - public function testMoneyBagHash() - { - $equal = MoneyBag::create(new Money(12, 'EUR'), new Money(7, 'USD')); - $this->assertEquals($this->fMB1->hashCode(), $equal->hashCode()); - } - - public function testMoneyEquals() - { - $this->assertTrue(!$this->f12EUR->equals(NULL)); - $equalMoney = new Money(12, 'EUR'); - $this->assertTrue($this->f12EUR->equals($this->f12EUR)); - $this->assertTrue($this->f12EUR->equals($equalMoney)); - $this->assertEquals($this->f12EUR->hashCode(), $equalMoney->hashCode()); - $this->assertFalse($this->f12EUR->equals($this->f14EUR)); - } - - public function testMoneyHash() - { - $this->assertNotNull($this->f12EUR); - $equal= new Money(12, 'EUR'); - $this->assertEquals($this->f12EUR->hashCode(), $equal->hashCode()); - } - - public function testSimplify() - { - $money = MoneyBag::create(new Money(26, 'EUR'), new Money(28, 'EUR')); - $this->assertTrue($money->equals(new Money(54, 'EUR'))); - } - - public function testNormalize2() - { - // {[12 EUR][7 USD]} - [12 EUR] == [7 USD] - $expected = new Money(7, 'USD'); - $this->assertTrue($expected->equals($this->fMB1->subtract($this->f12EUR))); - } - - public function testNormalize3() - { - // {[12 EUR][7 USD]} - {[12 EUR][3 USD]} == [4 USD] - $ms1 = MoneyBag::create(new Money(12, 'EUR'), new Money(3, 'USD')); - $expected = new Money(4, 'USD'); - $this->assertTrue($expected->equals($this->fMB1->subtract($ms1))); - } - - public function testNormalize4() - { - // [12 EUR] - {[12 EUR][3 USD]} == [-3 USD] - $ms1 = MoneyBag::create(new Money(12, 'EUR'), new Money(3, 'USD')); - $expected = new Money(-3, 'USD'); - $this->assertTrue($expected->equals($this->f12EUR->subtract($ms1))); - } - - public function testPrint() - { - $this->assertEquals('[12 EUR]', $this->f12EUR->toString()); - } - - public function testSimpleAdd() - { - // [12 EUR] + [14 EUR] == [26 EUR] - $expected = new Money(26, 'EUR'); - $this->assertTrue($expected->equals($this->f12EUR->add($this->f14EUR))); - } - - public function testSimpleBagAdd() - { - // [14 EUR] + {[12 EUR][7 USD]} == {[26 EUR][7 USD]} - $expected = MoneyBag::create(new Money(26, 'EUR'), new Money(7, 'USD')); - $this->assertTrue($expected->equals($this->f14EUR->add($this->fMB1))); - } - - public function testSimpleMultiply() - { - // [14 EUR] *2 == [28 EUR] - $expected = new Money(28, 'EUR'); - $this->assertTrue($expected->equals($this->f14EUR->multiply(2))); - } - - public function testSimpleNegate() - { - // [14 EUR] negate == [-14 EUR] - $expected = new Money(-14, 'EUR'); - $this->assertTrue($expected->equals($this->f14EUR->negate())); - } - - public function testSimpleSubtract() - { - // [14 EUR] - [12 EUR] == [2 EUR] - $expected = new Money(2, 'EUR'); - $this->assertTrue($expected->equals($this->f14EUR->subtract($this->f12EUR))); - } -} diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/phpunit.bat phpunit-3.6.10/PHPUnit-3.5.5/phpunit.bat --- phpunit-3.5.5/PHPUnit-3.5.5/phpunit.bat 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/phpunit.bat 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -@echo off -REM PHPUnit -REM -REM Copyright (c) 2002-2010, Sebastian Bergmann . -REM All rights reserved. -REM -REM Redistribution and use in source and binary forms, with or without -REM modification, are permitted provided that the following conditions -REM are met: -REM -REM * Redistributions of source code must retain the above copyright -REM notice, this list of conditions and the following disclaimer. -REM -REM * Redistributions in binary form must reproduce the above copyright -REM notice, this list of conditions and the following disclaimer in -REM the documentation and/or other materials provided with the -REM distribution. -REM -REM * Neither the name of Sebastian Bergmann nor the names of his -REM contributors may be used to endorse or promote products derived -REM from this software without specific prior written permission. -REM -REM THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -REM "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -REM LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -REM FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -REM COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -REM INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -REM BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -REM LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -REM CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC -REM LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -REM ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -REM POSSIBILITY OF SUCH DAMAGE. -REM - -if "%PHPBIN%" == "" set PHPBIN=@php_bin@ -if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH -GOTO RUN -:USE_PEAR_PATH -set PHPBIN=%PHP_PEAR_PHP_BIN% -:RUN -"%PHPBIN%" "@bin_dir@\phpunit" %* diff -Nru phpunit-3.5.5/PHPUnit-3.5.5/phpunit.php phpunit-3.6.10/PHPUnit-3.5.5/phpunit.php --- phpunit-3.5.5/PHPUnit-3.5.5/phpunit.php 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.5.5/phpunit.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -#!/usr/bin/env php -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * 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 - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -require_once 'PHP/CodeCoverage/Filter.php'; -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'PHPUNIT'); - -if (extension_loaded('xdebug')) { - xdebug_disable(); -} - -if (strpos('@php_bin@', '@php_bin') === 0) { - set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path()); -} - -require_once 'PHPUnit/Autoload.php'; - -define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main'); - -PHPUnit_TextUI_Command::main(); diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/ChangeLog.markdown phpunit-3.6.10/PHPUnit-3.6.10/ChangeLog.markdown --- phpunit-3.5.5/PHPUnit-3.6.10/ChangeLog.markdown 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/ChangeLog.markdown 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,113 @@ +PHPUnit 3.6 +=========== + +This is the list of changes for the PHPUnit 3.6 release series. + +PHPUnit 3.6.10 +-------------- + +* Tests for which the execution is aborted due to a timeout are no longer shown as incomplete but as an error instead. +* Fixed the fix for #466. + +PHPUnit 3.6.9 +------------- + +* Fixed #466: Undefined offset in `Configuration.php`. + +PHPUnit 3.6.8 +------------- + +* Fixed #463: `PHPUnit_Framework_TestCase::testRequirements()` collides with actual test methods. +* Fixed reflection errors when `PHPUnit_Framework_Warning` is used. +* Marked `--skeleton-class` and `--skeleton-test` as deprecated. Please use the `phpunit-skelgen` tool that is provided by the `PHPUnit_SkeletonGenerator` package instead. + +PHPUnit 3.6.7 +------------- + +* Fixed #452: Regression when using (deprecated) `AllTests.php` approach to organize test suites. + +PHPUnit 3.6.6 +------------- + +* Improved exception message in `PHPUnit_Framework_TestSuite::__construct()`. +* Improved failure messages for exception expectations. +* `@expectedExceptionCode` may now be 0. +* Test output now is included as an `output` element in the JSON logfile. +* Fixed #445: Assertions on output did not work in strict mode. +* Fixed stacktraces on Windows wrongly showing the PHPUnit files. + +PHPUnit 3.6.5 +------------- + +* Implemented #406: Improved the failure description for `assertStringMatchesFormat*()`. +* Fixed #204: Bootstrap script should be loaded before trying to load `testSuiteLoaderClass`. +* Fixed #413: PHPT test failures display double diffs. +* Fixed #420: Using the `@outputBuffering enabled` annotation leads to failing tests when an output string was expected. +* Fixed #430: `OutputTestCase` did not work with `@depends`. Please note that this way of output testing is still deprecated. +* Fixed #432: Process Isolation did not work when PHPUnit is invoked through Apache Ant, for instance, due to PHP binary detection issues. +* Fixed #433: Testing output always printed the output during test execution. + +PHPUnit 3.6.4 +------------- + +* Fixed #244: `@expectedExceptionCode` may now be a string. +* Fixed #264: XML test suite configuration using `` tags failed when PHPUnit was run from another directory. +* Fixed #306: Assertions with binary data caused problems. Strings with non-printable characters will now be shown in hexadecimal representation. +* Fixed #328: Parsing of one line annotations did not work. +* Fixed #407: `$_SERVER['_']` was not utilized properly to specify the PHP interpreter used for process isolation. +* Fixed #411: Do not swallow output printed from test(ed) code by default. + +PHPUnit 3.6.3 +------------- + +* Fixed #386: `` in XML configuration file does not call `putenv()`. +* Fixed `--coverage-php` not working from the XML configuration. +* Fixed `--coverage-text` producing a notice in some cases when used from the XML configuration + +PHPUnit 3.6.2 +------------- + +* Fixed #391: Code Coverage does not work when no XML configuration file is used. + +PHPUnit 3.6.1 +------------- + +* Implemented #395: `--debug` now prints the output of tests for debugging purposes. +* Fixed #394: Backwards compatibility break with regard to comparison of numeric values. +* Fixed `--coverage-php` and `--coverage-text`. + +PHPUnit 3.6.0 +------------- + +* Added `assertCount()` and `assertAttributeCount()` as well as `assertNotCount()` and `assertAttributeNotCount()` to assert the number of elements in an array (or `Countable` or `Iterator` objects). +* Added `assertSameSize()` and `assertNotSameSize()` to assert that the size of two arrays (or `Countable` or `Iterator` objects) is the same. +* Added `returnSelf()` to ease the stubbing and mocking of fluent interfaces. +* Added an option to disable the check for object identity in `assertContains()` and related methods. +* Implemented comparator framework (used by `assertEquals()`, for instance) and improved test failure output. +* Implemented #63: Invalid `@covers` annotations should produce a test error instead of aborting PHPUnit. +* Implemented #82: Test Skeleton Generator should create `@covers` annotations. +* Implemented #83: Test errors and failures as well as incomplete and skipped tests now get coloured letters in the test progress. +* Implemented #88: `@expectedException` (and `setExpectedException()`) no longer accept `Exception` as the expected exception class. +* Implemented #126: Show used configuration file. +* Implemented #189: Add `@requires` annotation to specify the version of PHP and/or PHPUnit required to run a test. +* `assertEquals()` now looks for (and invokes) a `__toString()` method when an object and string are compared. +* `setUpBeforeClass()` and `tearDownAfterClass()` are no longer invoked when all tests of the class are skipped. +* Using the `@small` (alias for `@group small`), `@medium` (alias for `@group medium`), and `@large` (alias for `@group large`) annotations, a test can now be marked to be of a certain size. By default, a test is "small". +* A test must not `@depend` on a test that is larger than itself. +* In strict mode, the execution of a small test is (by default) aborted after 1 second (when the `PHP_Invoker` package is installed and the `pcntl` extension is available). +* In strict mode, the execution of a medium test is (by default) aborted after 10 seconds (when the `PHP_Invoker` package is installed and the `pcntl` extension is available). +* In strict mode, the execution of a large test is (by default) aborted after 60 seconds (when the `PHP_Invoker` package is installed and the `pcntl` extension is available). +* In strict mode, a test must not print any output. +* Any output made by a test is now "swallowed". +* `@ticket` is now an alias for `@group`. +* Added `--printer` to specify a class (that extends `PHPUnit_Util_Printer` and implements `PHPUnit_Framework_TestListener`) to print test runner output. +* Added `-h` as alias for `--help` and `-c` as alias for `--configuration`. +* Added an option to disable the caching of `PHP_Token_Stream` objects during code coverage report generation to reduce the memory usage. +* `assertType()` and `assertNotType()` as well as `assertAttributeType()` and `assertAttributeNotType()` have been removed. `assertInternalType()` should be used for asserting internal types such as `integer` or `string` whereas `assertInstanceOf()` should be used for asserting that an object is an instance of a specified class or interface. +* The `PHPUnit_Extensions_OutputTestCase` functionality has been merged into `PHPUnit_Framework_TestCase`. +* The `PHPUnit_Extensions_Story_TestCase` functionality has been moved to a separate package (`PHPUnit_Story`). +* The `PHPUnit_Util_Log_DBUS` functionality has been moved to a separate package (`PHPUnit_TestListener_DBUS`). +* The `PHPUnit_Util_Log_XHProf` functionality has been moved to a separate package (`PHPUnit_TestListener_XHProf`). +* The `--wait` functionality has been removed. +* The syntax check functionality has been removed. +* The XML configuration file is now the only way to configure the blacklist and whitelist for code coverage reporting. diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/LICENSE phpunit-3.6.10/PHPUnit-3.6.10/LICENSE --- phpunit-3.5.5/PHPUnit-3.6.10/LICENSE 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/LICENSE 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,33 @@ +PHPUnit + +Copyright (c) 2002-2012, Sebastian Bergmann . +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * 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 + distribution. + + * Neither the name of Sebastian Bergmann nor the names of his + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Autoload.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Autoload.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Autoload.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Autoload.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,223 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.5.0 + */ + +require_once 'File/Iterator/Autoload.php'; +require_once 'PHP/CodeCoverage/Autoload.php'; +require_once 'PHP/Timer/Autoload.php'; +require_once 'PHPUnit/Framework/MockObject/Autoload.php'; +require_once 'Text/Template/Autoload.php'; + +function phpunit_autoload($class = NULL) +{ + static $classes = NULL; + static $path = NULL; + + if ($classes === NULL) { + $classes = array( + 'phpunit_extensions_grouptestsuite' => '/Extensions/GroupTestSuite.php', + 'phpunit_extensions_outputtestcase' => '/Extensions/OutputTestCase.php', + 'phpunit_extensions_phpttestcase' => '/Extensions/PhptTestCase.php', + 'phpunit_extensions_phpttestcase_logger' => '/Extensions/PhptTestCase/Logger.php', + 'phpunit_extensions_phpttestsuite' => '/Extensions/PhptTestSuite.php', + 'phpunit_extensions_repeatedtest' => '/Extensions/RepeatedTest.php', + 'phpunit_extensions_testdecorator' => '/Extensions/TestDecorator.php', + 'phpunit_extensions_ticketlistener' => '/Extensions/TicketListener.php', + 'phpunit_framework_assert' => '/Framework/Assert.php', + 'phpunit_framework_assertionfailederror' => '/Framework/AssertionFailedError.php', + 'phpunit_framework_comparator' => '/Framework/Comparator.php', + 'phpunit_framework_comparator_array' => '/Framework/Comparator/Array.php', + 'phpunit_framework_comparator_domdocument' => '/Framework/Comparator/DOMDocument.php', + 'phpunit_framework_comparator_double' => '/Framework/Comparator/Double.php', + 'phpunit_framework_comparator_exception' => '/Framework/Comparator/Exception.php', + 'phpunit_framework_comparator_mockobject' => '/Framework/Comparator/MockObject.php', + 'phpunit_framework_comparator_numeric' => '/Framework/Comparator/Numeric.php', + 'phpunit_framework_comparator_object' => '/Framework/Comparator/Object.php', + 'phpunit_framework_comparator_resource' => '/Framework/Comparator/Resource.php', + 'phpunit_framework_comparator_scalar' => '/Framework/Comparator/Scalar.php', + 'phpunit_framework_comparator_splobjectstorage' => '/Framework/Comparator/SplObjectStorage.php', + 'phpunit_framework_comparator_type' => '/Framework/Comparator/Type.php', + 'phpunit_framework_comparatorfactory' => '/Framework/ComparatorFactory.php', + 'phpunit_framework_comparisonfailure' => '/Framework/ComparisonFailure.php', + 'phpunit_framework_constraint' => '/Framework/Constraint.php', + 'phpunit_framework_constraint_and' => '/Framework/Constraint/And.php', + 'phpunit_framework_constraint_arrayhaskey' => '/Framework/Constraint/ArrayHasKey.php', + 'phpunit_framework_constraint_attribute' => '/Framework/Constraint/Attribute.php', + 'phpunit_framework_constraint_classhasattribute' => '/Framework/Constraint/ClassHasAttribute.php', + 'phpunit_framework_constraint_classhasstaticattribute' => '/Framework/Constraint/ClassHasStaticAttribute.php', + 'phpunit_framework_constraint_composite' => '/Framework/Constraint/Composite.php', + 'phpunit_framework_constraint_count' => '/Framework/Constraint/Count.php', + 'phpunit_framework_constraint_exception' => '/Framework/Constraint/Exception.php', + 'phpunit_framework_constraint_exceptioncode' => '/Framework/Constraint/ExceptionCode.php', + 'phpunit_framework_constraint_exceptionmessage' => '/Framework/Constraint/ExceptionMessage.php', + 'phpunit_framework_constraint_fileexists' => '/Framework/Constraint/FileExists.php', + 'phpunit_framework_constraint_greaterthan' => '/Framework/Constraint/GreaterThan.php', + 'phpunit_framework_constraint_isanything' => '/Framework/Constraint/IsAnything.php', + 'phpunit_framework_constraint_isempty' => '/Framework/Constraint/IsEmpty.php', + 'phpunit_framework_constraint_isequal' => '/Framework/Constraint/IsEqual.php', + 'phpunit_framework_constraint_isfalse' => '/Framework/Constraint/IsFalse.php', + 'phpunit_framework_constraint_isidentical' => '/Framework/Constraint/IsIdentical.php', + 'phpunit_framework_constraint_isinstanceof' => '/Framework/Constraint/IsInstanceOf.php', + 'phpunit_framework_constraint_isnull' => '/Framework/Constraint/IsNull.php', + 'phpunit_framework_constraint_istrue' => '/Framework/Constraint/IsTrue.php', + 'phpunit_framework_constraint_istype' => '/Framework/Constraint/IsType.php', + 'phpunit_framework_constraint_lessthan' => '/Framework/Constraint/LessThan.php', + 'phpunit_framework_constraint_not' => '/Framework/Constraint/Not.php', + 'phpunit_framework_constraint_objecthasattribute' => '/Framework/Constraint/ObjectHasAttribute.php', + 'phpunit_framework_constraint_or' => '/Framework/Constraint/Or.php', + 'phpunit_framework_constraint_pcrematch' => '/Framework/Constraint/PCREMatch.php', + 'phpunit_framework_constraint_samesize' => '/Framework/Constraint/SameSize.php', + 'phpunit_framework_constraint_stringcontains' => '/Framework/Constraint/StringContains.php', + 'phpunit_framework_constraint_stringendswith' => '/Framework/Constraint/StringEndsWith.php', + 'phpunit_framework_constraint_stringmatches' => '/Framework/Constraint/StringMatches.php', + 'phpunit_framework_constraint_stringstartswith' => '/Framework/Constraint/StringStartsWith.php', + 'phpunit_framework_constraint_traversablecontains' => '/Framework/Constraint/TraversableContains.php', + 'phpunit_framework_constraint_traversablecontainsonly' => '/Framework/Constraint/TraversableContainsOnly.php', + 'phpunit_framework_constraint_xor' => '/Framework/Constraint/Xor.php', + 'phpunit_framework_error' => '/Framework/Error.php', + 'phpunit_framework_error_deprecated' => '/Framework/Error/Deprecated.php', + 'phpunit_framework_error_notice' => '/Framework/Error/Notice.php', + 'phpunit_framework_error_warning' => '/Framework/Error/Warning.php', + 'phpunit_framework_exception' => '/Framework/Exception.php', + 'phpunit_framework_expectationfailedexception' => '/Framework/ExpectationFailedException.php', + 'phpunit_framework_incompletetest' => '/Framework/IncompleteTest.php', + 'phpunit_framework_incompletetesterror' => '/Framework/IncompleteTestError.php', + 'phpunit_framework_outputerror' => '/Framework/OutputError.php', + 'phpunit_framework_selfdescribing' => '/Framework/SelfDescribing.php', + 'phpunit_framework_skippedtest' => '/Framework/SkippedTest.php', + 'phpunit_framework_skippedtesterror' => '/Framework/SkippedTestError.php', + 'phpunit_framework_skippedtestsuiteerror' => '/Framework/SkippedTestSuiteError.php', + 'phpunit_framework_syntheticerror' => '/Framework/SyntheticError.php', + 'phpunit_framework_test' => '/Framework/Test.php', + 'phpunit_framework_testcase' => '/Framework/TestCase.php', + 'phpunit_framework_testfailure' => '/Framework/TestFailure.php', + 'phpunit_framework_testlistener' => '/Framework/TestListener.php', + 'phpunit_framework_testresult' => '/Framework/TestResult.php', + 'phpunit_framework_testsuite' => '/Framework/TestSuite.php', + 'phpunit_framework_testsuite_dataprovider' => '/Framework/TestSuite/DataProvider.php', + 'phpunit_framework_warning' => '/Framework/Warning.php', + 'phpunit_runner_basetestrunner' => '/Runner/BaseTestRunner.php', + 'phpunit_runner_standardtestsuiteloader' => '/Runner/StandardTestSuiteLoader.php', + 'phpunit_runner_testsuiteloader' => '/Runner/TestSuiteLoader.php', + 'phpunit_runner_version' => '/Runner/Version.php', + 'phpunit_textui_command' => '/TextUI/Command.php', + 'phpunit_textui_resultprinter' => '/TextUI/ResultPrinter.php', + 'phpunit_textui_testrunner' => '/TextUI/TestRunner.php', + 'phpunit_util_class' => '/Util/Class.php', + 'phpunit_util_configuration' => '/Util/Configuration.php', + 'phpunit_util_deprecatedfeature' => '/Util/DeprecatedFeature.php', + 'phpunit_util_deprecatedfeature_logger' => '/Util/DeprecatedFeature/Logger.php', + 'phpunit_util_diff' => '/Util/Diff.php', + 'phpunit_util_errorhandler' => '/Util/ErrorHandler.php', + 'phpunit_util_file' => '/Util/File.php', + 'phpunit_util_fileloader' => '/Util/Fileloader.php', + 'phpunit_util_filesystem' => '/Util/Filesystem.php', + 'phpunit_util_filter' => '/Util/Filter.php', + 'phpunit_util_getopt' => '/Util/Getopt.php', + 'phpunit_util_globalstate' => '/Util/GlobalState.php', + 'phpunit_util_invalidargumenthelper' => '/Util/InvalidArgumentHelper.php', + 'phpunit_util_log_json' => '/Util/Log/JSON.php', + 'phpunit_util_log_junit' => '/Util/Log/JUnit.php', + 'phpunit_util_log_tap' => '/Util/Log/TAP.php', + 'phpunit_util_php' => '/Util/PHP.php', + 'phpunit_util_php_default' => '/Util/PHP/Default.php', + 'phpunit_util_php_windows' => '/Util/PHP/Windows.php', + 'phpunit_util_printer' => '/Util/Printer.php', + 'phpunit_util_skeleton' => '/Util/Skeleton.php', + 'phpunit_util_skeleton_class' => '/Util/Skeleton/Class.php', + 'phpunit_util_skeleton_test' => '/Util/Skeleton/Test.php', + 'phpunit_util_string' => '/Util/String.php', + 'phpunit_util_test' => '/Util/Test.php', + 'phpunit_util_testdox_nameprettifier' => '/Util/TestDox/NamePrettifier.php', + 'phpunit_util_testdox_resultprinter' => '/Util/TestDox/ResultPrinter.php', + 'phpunit_util_testdox_resultprinter_html' => '/Util/TestDox/ResultPrinter/HTML.php', + 'phpunit_util_testdox_resultprinter_text' => '/Util/TestDox/ResultPrinter/Text.php', + 'phpunit_util_testsuiteiterator' => '/Util/TestSuiteIterator.php', + 'phpunit_util_type' => '/Util/Type.php', + 'phpunit_util_xml' => '/Util/XML.php' + ); + + $path = dirname(__FILE__); + } + + if ($class === NULL) { + $result = array(__FILE__); + + if (isset($_SERVER['_']) && + strpos($_SERVER['_'], 'phpunit') !== FALSE) { + $result[] = $_SERVER['_']; + } + + foreach ($classes as $file) { + $result[] = $path . $file; + } + + return $result; + } + + $cn = strtolower($class); + + if (isset($classes[$cn])) { + $file = $path . $classes[$cn]; + + require $file; + } +} + +spl_autoload_register('phpunit_autoload'); + +if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('PHP/Invoker/Autoload.php')) { + require_once 'PHP/Invoker/Autoload.php'; +} + +if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('PHPUnit/Extensions/Database/Autoload.php')) { + require_once 'PHPUnit/Extensions/Database/Autoload.php'; +} + +if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('PHPUnit/Extensions/SeleniumTestCase/Autoload.php')) { + require_once 'PHPUnit/Extensions/SeleniumTestCase/Autoload.php'; +} + +if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('PHPUnit/Extensions/Story/Autoload.php')) { + require_once 'PHPUnit/Extensions/Story/Autoload.php'; +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/GroupTestSuite.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/GroupTestSuite.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/GroupTestSuite.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/GroupTestSuite.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,100 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Extensions + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.3.0 + */ + +/** + * We have a TestSuite object A. + * In TestSuite object A we have Tests tagged with @group. + * We want a TestSuite object B that contains TestSuite objects C, D, ... + * for the Tests tagged with @group C, @group D, ... + * Running the Tests from TestSuite object B results in Tests tagged with both + * @group C and @group D in TestSuite object A to be run twice . + * + * + * $suite = new PHPUnit_Extensions_GroupTestSuite($A, array('C', 'D')); + * + * + * @package PHPUnit + * @subpackage Extensions + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.3.0 + */ +class PHPUnit_Extensions_GroupTestSuite extends PHPUnit_Framework_TestSuite +{ + public function __construct(PHPUnit_Framework_TestSuite $suite, array $groups) + { + $groupSuites = array(); + $name = $suite->getName(); + + foreach ($groups as $group) { + $groupSuites[$group] = new PHPUnit_Framework_TestSuite($name . ' - ' . $group); + $this->addTest($groupSuites[$group]); + } + + $tests = new RecursiveIteratorIterator( + new PHPUnit_Util_TestSuiteIterator($suite), + RecursiveIteratorIterator::LEAVES_ONLY + ); + + foreach ($tests as $test) { + if ($test instanceof PHPUnit_Framework_TestCase) { + $testGroups = PHPUnit_Util_Test::getGroups( + get_class($test), $test->getName(FALSE) + ); + + foreach ($groups as $group) { + foreach ($testGroups as $testGroup) { + if ($group == $testGroup) { + $groupSuites[$group]->addTest($test); + } + } + } + } + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/OutputTestCase.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/OutputTestCase.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/OutputTestCase.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/OutputTestCase.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,76 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Extensions + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * A TestCase that expects a specified output. + * + * @package PHPUnit + * @subpackage Extensions + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + * @deprecated + */ +abstract class PHPUnit_Extensions_OutputTestCase extends PHPUnit_Framework_TestCase +{ + /** + * @return mixed + * @throws RuntimeException + */ + protected function runTest() + { + PHPUnit_Util_DeprecatedFeature_Logger::log( + 'The functionality of PHPUnit_Extensions_OutputTestCase has been ' . + 'merged into PHPUnit_Framework_TestCase. Please update your test ' . + 'by extending PHPUnit_Framework_TestCase instead of ' . + 'PHPUnit_Extensions_OutputTestCase.' + ); + + return parent::runTest(); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/PhptTestCase/Logger.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/PhptTestCase/Logger.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/PhptTestCase/Logger.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/PhptTestCase/Logger.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,63 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Extensions_PhptTestCase + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.1.4 + */ + +/** + * Dummy logger for PEAR_RunTest. + * + * @package PHPUnit + * @subpackage Extensions_PhptTestCase + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @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) + { + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/PhptTestCase.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/PhptTestCase.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/PhptTestCase.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/PhptTestCase.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,270 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Extensions_PhptTestCase + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.1.4 + */ + +if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('PEAR/RunTest.php')) { + $currentErrorReporting = error_reporting(E_ERROR | E_WARNING | E_PARSE); + require_once 'PEAR/RunTest.php'; + error_reporting($currentErrorReporting); +} + +/** + * Wrapper to run .phpt test cases. + * + * @package PHPUnit + * @subpackage Extensions_PhptTestCase + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.1.4 + */ +class PHPUnit_Extensions_PhptTestCase implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing +{ + /** + * The filename of the .phpt file. + * + * @var string + */ + protected $filename; + + /** + * Options for PEAR_RunTest. + * + * @var array + */ + protected $options = array(); + + /** + * Constructs a test case with the given filename. + * + * @param string $filename + * @param array $options + */ + public function __construct($filename, array $options = array()) + { + if (!is_string($filename)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_file($filename)) { + throw new PHPUnit_Framework_Exception( + sprintf( + 'File "%s" does not exist.', + $filename + ) + ); + } + + $this->filename = $filename; + $this->options = $options; + } + + /** + * Counts the number of test cases executed by run(TestResult result). + * + * @return integer + */ + public function count() + { + return 1; + } + + /** + * Runs a test and collects its result in a TestResult instance. + * + * @param PHPUnit_Framework_TestResult $result + * @param array $options + * @return PHPUnit_Framework_TestResult + */ + public function run(PHPUnit_Framework_TestResult $result = NULL, array $options = array()) + { + if (!class_exists('PEAR_RunTest', FALSE)) { + throw new PHPUnit_Framework_Exception('Class PEAR_RunTest not found.'); + } + + if (isset($GLOBALS['_PEAR_destructor_object_list']) && + is_array($GLOBALS['_PEAR_destructor_object_list']) && + !empty($GLOBALS['_PEAR_destructor_object_list'])) { + $pearDestructorObjectListCount = count($GLOBALS['_PEAR_destructor_object_list']); + } else { + $pearDestructorObjectListCount = 0; + } + + if ($result === NULL) { + $result = new PHPUnit_Framework_TestResult; + } + + $coverage = $result->getCollectCodeCoverageInformation(); + $options = array_merge($options, $this->options); + + if (!isset($options['include_path'])) { + $options['include_path'] = get_include_path(); + } + + if ($coverage) { + $options['coverage'] = TRUE; + } else { + $options['coverage'] = FALSE; + } + + $currentErrorReporting = error_reporting(E_ERROR | E_WARNING | E_PARSE); + $runner = new PEAR_RunTest(new PHPUnit_Extensions_PhptTestCase_Logger, $options); + + if ($coverage) { + $runner->xdebug_loaded = TRUE; + } else { + $runner->xdebug_loaded = FALSE; + } + + $result->startTest($this); + + PHP_Timer::start(); + + $buffer = $runner->run($this->filename, $options); + $time = PHP_Timer::stop(); + + error_reporting($currentErrorReporting); + + $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') { + $expContent = file_get_contents($expFile); + $outContent = file_get_contents($outFile); + + $result->addFailure( + $this, + new PHPUnit_Framework_ComparisonFailure( + $expContent, + $outContent, + $expContent, + $outContent + ), + $time + ); + } + + foreach (array($diffFile, $expFile, $logFile, $phpFile, $outFile) as $file) { + if (file_exists($file)) { + unlink($file); + } + } + + if ($coverage && file_exists($coverageFile)) { + eval('$coverageData = ' . file_get_contents($coverageFile) . ';'); + unset($coverageData[$phpFile]); + + $result->getCodeCoverage()->append($coverageData, $this); + unlink($coverageFile); + } + + $result->endTest($this, $time); + + // Do not invoke PEAR's destructor mechanism for PHP 4 + // as it raises an E_STRICT. + if ($pearDestructorObjectListCount == 0) { + unset($GLOBALS['_PEAR_destructor_object_list']); + } else { + $count = count($GLOBALS['_PEAR_destructor_object_list']) - $pearDestructorObjectListCount; + + for ($i = 0; $i < $count; $i++) { + array_pop($GLOBALS['_PEAR_destructor_object_list']); + } + } + + return $result; + } + + /** + * Returns the name of the test case. + * + * @return string + */ + public function getName() + { + return $this->toString(); + } + + /** + * Returns a string representation of the test case. + * + * @return string + */ + public function toString() + { + return $this->filename; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/PhptTestSuite.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/PhptTestSuite.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/PhptTestSuite.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/PhptTestSuite.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,83 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Extensions_PhptTestCase + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.1.4 + */ + +/** + * Suite for .phpt test cases. + * + * @package PHPUnit + * @subpackage Extensions_PhptTestCase + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @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 + */ + public function __construct($directory, array $options = array()) + { + if (is_string($directory) && is_dir($directory)) { + $this->setName($directory); + + $facade = new File_Iterator_Facade; + $files = $facade->getFilesAsArray($directory, '.phpt'); + + foreach ($files as $file) { + $this->addTestFile($file, $options); + } + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'directory name'); + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/RepeatedTest.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/RepeatedTest.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/RepeatedTest.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/RepeatedTest.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,156 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * A Decorator that runs a test repeatedly. + * + * @package PHPUnit + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_Extensions_RepeatedTest extends PHPUnit_Extensions_TestDecorator +{ + /** + * @var mixed + */ + protected $filter = FALSE; + + /** + * @var array + */ + protected $groups = array(); + + /** + * @var array + */ + protected $excludeGroups = array(); + + /** + * @var boolean + */ + protected $processIsolation = FALSE; + + /** + * @var integer + */ + protected $timesRepeat = 1; + + /** + * Constructor. + * + * @param PHPUnit_Framework_Test $test + * @param integer $timesRepeat + * @param mixed $filter + * @param array $groups + * @param array $excludeGroups + * @param boolean $processIsolation + * @throws InvalidArgumentException + */ + public function __construct(PHPUnit_Framework_Test $test, $timesRepeat = 1, $filter = FALSE, array $groups = array(), array $excludeGroups = array(), $processIsolation = FALSE) + { + parent::__construct($test); + + if (is_integer($timesRepeat) && + $timesRepeat >= 0) { + $this->timesRepeat = $timesRepeat; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory( + 2, 'positive integer' + ); + } + + $this->filter = $filter; + $this->groups = $groups; + $this->excludeGroups = $excludeGroups; + $this->processIsolation = $processIsolation; + } + + /** + * Counts the number of test cases that + * will be run by this test. + * + * @return integer + */ + 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 + */ + public function run(PHPUnit_Framework_TestResult $result = NULL) + { + if ($result === NULL) { + $result = $this->createResult(); + } + + //@codingStandardsIgnoreStart + for ($i = 0; $i < $this->timesRepeat && !$result->shouldStop(); $i++) { + //@codingStandardsIgnoreEnd + if ($this->test instanceof PHPUnit_Framework_TestSuite) { + $this->test->run( + $result, + $this->filter, + $this->groups, + $this->excludeGroups, + $this->processIsolation + ); + } else { + $this->test->run($result); + } + } + + return $result; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/TestDecorator.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/TestDecorator.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/TestDecorator.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/TestDecorator.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,151 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Extensions + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * A Decorator for Tests. + * + * Use TestDecorator as the base class for defining new + * test decorators. Test decorator subclasses can be introduced + * to add behaviour before or after a test is run. + * + * @package PHPUnit + * @subpackage Extensions + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_Extensions_TestDecorator extends PHPUnit_Framework_Assert implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing +{ + /** + * The Test to be decorated. + * + * @var object + */ + protected $test = NULL; + + /** + * Constructor. + * + * @param PHPUnit_Framework_Test $test + */ + public function __construct(PHPUnit_Framework_Test $test) + { + $this->test = $test; + } + + /** + * Returns a string representation of the test. + * + * @return string + */ + public function toString() + { + return $this->test->toString(); + } + + /** + * Runs the test and collects the + * result in a TestResult. + * + * @param PHPUnit_Framework_TestResult $result + */ + public function basicRun(PHPUnit_Framework_TestResult $result) + { + $this->test->run($result); + } + + /** + * Counts the number of test cases that + * will be run by this test. + * + * @return integer + */ + public function count() + { + return count($this->test); + } + + /** + * Creates a default TestResult object. + * + * @return PHPUnit_Framework_TestResult + */ + protected function createResult() + { + return new PHPUnit_Framework_TestResult; + } + + /** + * Returns the test to be run. + * + * @return PHPUnit_Framework_Test + */ + public function getTest() + { + return $this->test; + } + + /** + * Runs the decorated test and collects the + * result in a TestResult. + * + * @param PHPUnit_Framework_TestResult $result + * @return PHPUnit_Framework_TestResult + * @throws InvalidArgumentException + */ + public function run(PHPUnit_Framework_TestResult $result = NULL) + { + if ($result === NULL) { + $result = $this->createResult(); + } + + $this->basicRun($result); + + return $result; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/TicketListener.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/TicketListener.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Extensions/TicketListener.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Extensions/TicketListener.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,225 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Extensions_TicketListener + * @author Sean Coates + * @author Raphael Stolt + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.4.0 + */ + +/** + * Base class for test listeners that interact with an issue tracker. + * + * @package PHPUnit + * @subpackage Extensions_TicketListener + * @author Sean Coates + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.4.0 + */ +abstract class PHPUnit_Extensions_TicketListener implements PHPUnit_Framework_TestListener +{ + /** + * @var array + */ + protected $ticketCounts = array(); + + /** + * @var boolean + */ + protected $ran = FALSE; + + /** + * An error occurred. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) + { + } + + /** + * A failure occurred. + * + * @param PHPUnit_Framework_Test $test + * @param PHPUnit_Framework_AssertionFailedError $e + * @param float $time + */ + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) + { + } + + /** + * Incomplete test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + } + + /** + * Skipped test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + * @since Method available since Release 3.0.0 + */ + public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + } + + /** + * A test suite started. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit_Framework_TestSuite $suite) + { + } + + /** + * A test suite ended. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit_Framework_TestSuite $suite) + { + } + + /** + * A test started. + * + * @param PHPUnit_Framework_Test $test + */ + public function startTest(PHPUnit_Framework_Test $test) + { + if (!$test instanceof PHPUnit_Framework_Warning) { + if ($this->ran) { + return; + } + + $name = $test->getName(FALSE); + $tickets = PHPUnit_Util_Test::getTickets(get_class($test), $name); + + foreach ($tickets as $ticket) { + $this->ticketCounts[$ticket][$name] = 1; + } + + $this->ran = TRUE; + } + } + + /** + * A test ended. + * + * @param PHPUnit_Framework_Test $test + * @param float $time + */ + public function endTest(PHPUnit_Framework_Test $test, $time) + { + if (!$test instanceof PHPUnit_Framework_Warning) { + if ($test->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) { + $ifStatus = array('assigned', 'new', 'reopened'); + $newStatus = 'closed'; + $message = 'Automatically closed by PHPUnit (test passed).'; + $resolution = 'fixed'; + $cumulative = TRUE; + } + + else if ($test->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) { + $ifStatus = array('closed'); + $newStatus = 'reopened'; + $message = 'Automatically reopened by PHPUnit (test failed).'; + $resolution = ''; + $cumulative = FALSE; + } + + else { + return; + } + + $name = $test->getName(FALSE); + $tickets = PHPUnit_Util_Test::getTickets(get_class($test), $name); + + foreach ($tickets as $ticket) { + // Remove this test from the totals (if it passed). + if ($test->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) { + unset($this->ticketCounts[$ticket][$name]); + } + + // Only close tickets if ALL referenced cases pass + // but reopen tickets if a single test fails. + if ($cumulative) { + // Determine number of to-pass tests: + if (count($this->ticketCounts[$ticket]) > 0) { + // There exist remaining test cases with this reference. + $adjustTicket = FALSE; + } else { + // No remaining tickets, go ahead and adjust. + $adjustTicket = TRUE; + } + } else { + $adjustTicket = TRUE; + } + + $ticketInfo = $this->getTicketInfo($ticket); + + if ($adjustTicket && in_array($ticketInfo['status'], $ifStatus)) { + $this->updateTicket($ticket, $newStatus, $message, $resolution); + } + } + } + } + + abstract protected function getTicketInfo($ticketId = NULL); + abstract protected function updateTicket($ticketId, $newStatus, $message, $resolution); +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Assert/Functions.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Assert/Functions.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Assert/Functions.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Assert/Functions.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,1884 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.5.0 + */ + +/** + * Returns a matcher that matches when the method it is evaluated for + * is executed zero or more times. + * + * @return PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount + * @since Method available since Release 3.0.0 + */ +function any() +{ + return PHPUnit_Framework_TestCase::any(); +} + +/** + * Returns a PHPUnit_Framework_Constraint_IsAnything matcher object. + * + * @return PHPUnit_Framework_Constraint_IsAnything + * @since Method available since Release 3.0.0 + */ +function anything() +{ + return PHPUnit_Framework_Assert::anything(); +} + +/** + * Returns a PHPUnit_Framework_Constraint_ArrayHasKey matcher object. + * + * @param mixed $key + * @return PHPUnit_Framework_Constraint_ArrayHasKey + * @since Method available since Release 3.0.0 + */ +function arrayHasKey($key) +{ + return PHPUnit_Framework_Assert::arrayHasKey($key); +} + +/** + * Asserts that an array has a specified key. + * + * @param mixed $key + * @param array $array + * @param string $message + * @since Method available since Release 3.0.0 + */ +function assertArrayHasKey($key, array $array, $message = '') +{ + return PHPUnit_Framework_Assert::assertArrayHasKey($key, $array, $message); +} + +/** + * Asserts that an array does not have a specified key. + * + * @param mixed $key + * @param array $array + * @param string $message + * @since Method available since Release 3.0.0 + */ +function assertArrayNotHasKey($key, array $array, $message = '') +{ + return PHPUnit_Framework_Assert::assertArrayNotHasKey($key, $array, $message); +} + +/** + * Asserts that a haystack that is stored in a static attribute of a class + * or an attribute of an object contains a needle. + * + * @param mixed $needle + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param string $message + * @param boolean $ignoreCase + * @param boolean $checkForObjectIdentity + * @since Method available since Release 3.0.0 + */ +function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) +{ + return PHPUnit_Framework_Assert::assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message, $ignoreCase, $checkForObjectIdentity); +} + +/** + * Asserts that a haystack that is stored in a static attribute of a class + * or an attribute of an object contains only values of a given type. + * + * @param string $type + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param boolean $isNativeType + * @param string $message + * @since Method available since Release 3.1.4 + */ +function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType, $message); +} + +/** + * Asserts the number of elements of an array, Countable or Iterator + * that is stored in an attribute. + * + * @param integer $expectedCount + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param string $message + * @since Method available since Release 3.6.0 + */ +function assertAttributeCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message); +} + +/** + * Asserts that a static attribute of a class or an attribute of an object + * is empty. + * + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message); +} + +/** + * Asserts that a variable is equal to an attribute of an object. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param string $actualClassOrObject + * @param string $message + * @param float $delta + * @param integer $maxDepth + * @param boolean $canonicalize + * @param boolean $ignoreCase + */ +function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) +{ + return PHPUnit_Framework_Assert::assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); +} + +/** + * Asserts that an attribute is greater than another value. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param string $actualClassOrObject + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message); +} + +/** + * Asserts that an attribute is greater than or equal to another value. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param string $actualClassOrObject + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message); +} + +/** + * Asserts that an attribute is of a given type. + * + * @param string $expected + * @param string $attributeName + * @param mixed $classOrObject + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message); +} + +/** + * Asserts that an attribute is of a given type. + * + * @param string $expected + * @param string $attributeName + * @param mixed $classOrObject + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeInternalType($expected, $attributeName, $classOrObject, $message); +} + +/** + * Asserts that an attribute is smaller than another value. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param string $actualClassOrObject + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message); +} + +/** + * Asserts that an attribute is smaller than or equal to another value. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param string $actualClassOrObject + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message); +} + +/** + * Asserts that a haystack that is stored in a static attribute of a class + * or an attribute of an object does not contain a needle. + * + * @param mixed $needle + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param string $message + * @param boolean $ignoreCase + * @param boolean $checkForObjectIdentity + * @since Method available since Release 3.0.0 + */ +function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) +{ + return PHPUnit_Framework_Assert::assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message, $ignoreCase, $checkForObjectIdentity); +} + +/** + * Asserts that a haystack that is stored in a static attribute of a class + * or an attribute of an object does not contain only values of a given + * type. + * + * @param string $type + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param boolean $isNativeType + * @param string $message + * @since Method available since Release 3.1.4 + */ +function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType, $message); +} + +/** + * Asserts the number of elements of an array, Countable or Iterator + * that is stored in an attribute. + * + * @param integer $expectedCount + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param string $message + * @since Method available since Release 3.6.0 + */ +function assertAttributeNotCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeNotCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message); +} + +/** + * Asserts that a static attribute of a class or an attribute of an object + * is not empty. + * + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message); +} + +/** + * Asserts that a variable is not equal to an attribute of an object. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param string $actualClassOrObject + * @param string $message + * @param float $delta + * @param integer $maxDepth + * @param boolean $canonicalize + * @param boolean $ignoreCase + */ +function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) +{ + return PHPUnit_Framework_Assert::assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); +} + +/** + * Asserts that an attribute is of a given type. + * + * @param string $expected + * @param string $attributeName + * @param mixed $classOrObject + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message); +} + +/** + * Asserts that an attribute is of a given type. + * + * @param string $expected + * @param string $attributeName + * @param mixed $classOrObject + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message); +} + +/** + * Asserts that a variable and an attribute of an object do not have the + * same type and value. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param object $actualClassOrObject + * @param string $message + */ +function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message); +} + +/** + * Asserts that a variable and an attribute of an object have the same type + * and value. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param object $actualClassOrObject + * @param string $message + */ +function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') +{ + return PHPUnit_Framework_Assert::assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message); +} + +/** + * Asserts that a class has a specified attribute. + * + * @param string $attributeName + * @param string $className + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertClassHasAttribute($attributeName, $className, $message = '') +{ + return PHPUnit_Framework_Assert::assertClassHasAttribute($attributeName, $className, $message); +} + +/** + * Asserts that a class has a specified static attribute. + * + * @param string $attributeName + * @param string $className + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertClassHasStaticAttribute($attributeName, $className, $message = '') +{ + return PHPUnit_Framework_Assert::assertClassHasStaticAttribute($attributeName, $className, $message); +} + +/** + * Asserts that a class does not have a specified attribute. + * + * @param string $attributeName + * @param string $className + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertClassNotHasAttribute($attributeName, $className, $message = '') +{ + return PHPUnit_Framework_Assert::assertClassNotHasAttribute($attributeName, $className, $message); +} + +/** + * Asserts that a class does not have a specified static attribute. + * + * @param string $attributeName + * @param string $className + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertClassNotHasStaticAttribute($attributeName, $className, $message = '') +{ + return PHPUnit_Framework_Assert::assertClassNotHasStaticAttribute($attributeName, $className, $message); +} + +/** + * Asserts that a haystack contains a needle. + * + * @param mixed $needle + * @param mixed $haystack + * @param string $message + * @param boolean $ignoreCase + * @param boolean $checkForObjectIdentity + * @since Method available since Release 2.1.0 + */ +function assertContains($needle, $haystack, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) +{ + return PHPUnit_Framework_Assert::assertContains($needle, $haystack, $message, $ignoreCase, $checkForObjectIdentity); +} + +/** + * Asserts that a haystack contains only values of a given type. + * + * @param string $type + * @param mixed $haystack + * @param boolean $isNativeType + * @param string $message + * @since Method available since Release 3.1.4 + */ +function assertContainsOnly($type, $haystack, $isNativeType = NULL, $message = '') +{ + return PHPUnit_Framework_Assert::assertContainsOnly($type, $haystack, $isNativeType, $message); +} + +/** + * Asserts the number of elements of an array, Countable or Iterator. + * + * @param integer $expectedCount + * @param mixed $haystack + * @param string $message + */ +function assertCount($expectedCount, $haystack, $message = '') +{ + return PHPUnit_Framework_Assert::assertCount($expectedCount, $haystack, $message); +} + +/** + * Asserts that a variable is empty. + * + * @param mixed $actual + * @param string $message + * @throws PHPUnit_Framework_AssertionFailedError + */ +function assertEmpty($actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertEmpty($actual, $message); +} + +/** + * Asserts that a hierarchy of DOMElements matches. + * + * @param DOMElement $expectedElement + * @param DOMElement $actualElement + * @param boolean $checkAttributes + * @param string $message + * @author Mattis Stordalen Flister + * @since Method available since Release 3.3.0 + */ +function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, $checkAttributes = FALSE, $message = '') +{ + return PHPUnit_Framework_Assert::assertEqualXMLStructure($expectedElement, $actualElement, $checkAttributes, $message); +} + +/** + * Asserts that two variables are equal. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @param float $delta + * @param integer $maxDepth + * @param boolean $canonicalize + * @param boolean $ignoreCase + */ +function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) +{ + return PHPUnit_Framework_Assert::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); +} + +/** + * Asserts that a condition is false. + * + * @param boolean $condition + * @param string $message + * @throws PHPUnit_Framework_AssertionFailedError + */ +function assertFalse($condition, $message = '') +{ + return PHPUnit_Framework_Assert::assertFalse($condition, $message); +} + +/** + * Asserts that the contents of one file is equal to the contents of another + * file. + * + * @param string $expected + * @param string $actual + * @param string $message + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @since Method available since Release 3.2.14 + */ +function assertFileEquals($expected, $actual, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) +{ + return PHPUnit_Framework_Assert::assertFileEquals($expected, $actual, $message, $canonicalize, $ignoreCase); +} + +/** + * Asserts that a file exists. + * + * @param string $filename + * @param string $message + * @since Method available since Release 3.0.0 + */ +function assertFileExists($filename, $message = '') +{ + return PHPUnit_Framework_Assert::assertFileExists($filename, $message); +} + +/** + * Asserts that the contents of one file is not equal to the contents of + * another file. + * + * @param string $expected + * @param string $actual + * @param string $message + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @since Method available since Release 3.2.14 + */ +function assertFileNotEquals($expected, $actual, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) +{ + return PHPUnit_Framework_Assert::assertFileNotEquals($expected, $actual, $message, $canonicalize, $ignoreCase); +} + +/** + * Asserts that a file does not exist. + * + * @param string $filename + * @param string $message + * @since Method available since Release 3.0.0 + */ +function assertFileNotExists($filename, $message = '') +{ + return PHPUnit_Framework_Assert::assertFileNotExists($filename, $message); +} + +/** + * Asserts that a value is greater than another value. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertGreaterThan($expected, $actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertGreaterThan($expected, $actual, $message); +} + +/** + * Asserts that a value is greater than or equal to another value. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertGreaterThanOrEqual($expected, $actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertGreaterThanOrEqual($expected, $actual, $message); +} + +/** + * Asserts that a variable is of a given type. + * + * @param string $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertInstanceOf($expected, $actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertInstanceOf($expected, $actual, $message); +} + +/** + * Asserts that a variable is of a given type. + * + * @param string $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertInternalType($expected, $actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertInternalType($expected, $actual, $message); +} + +/** + * Asserts that a value is smaller than another value. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertLessThan($expected, $actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertLessThan($expected, $actual, $message); +} + +/** + * Asserts that a value is smaller than or equal to another value. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertLessThanOrEqual($expected, $actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertLessThanOrEqual($expected, $actual, $message); +} + +/** + * Asserts that a haystack does not contain a needle. + * + * @param mixed $needle + * @param mixed $haystack + * @param string $message + * @param boolean $ignoreCase + * @param boolean $checkForObjectIdentity + * @since Method available since Release 2.1.0 + */ +function assertNotContains($needle, $haystack, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) +{ + return PHPUnit_Framework_Assert::assertNotContains($needle, $haystack, $message, $ignoreCase, $checkForObjectIdentity); +} + +/** + * Asserts that a haystack does not contain only values of a given type. + * + * @param string $type + * @param mixed $haystack + * @param boolean $isNativeType + * @param string $message + * @since Method available since Release 3.1.4 + */ +function assertNotContainsOnly($type, $haystack, $isNativeType = NULL, $message = '') +{ + return PHPUnit_Framework_Assert::assertNotContainsOnly($type, $haystack, $isNativeType, $message); +} + +/** + * Asserts the number of elements of an array, Countable or Iterator. + * + * @param integer $expectedCount + * @param mixed $haystack + * @param string $message + */ +function assertNotCount($expectedCount, $haystack, $message = '') +{ + return PHPUnit_Framework_Assert::assertNotCount($expectedCount, $haystack, $message); +} + +/** + * Asserts that a variable is not empty. + * + * @param mixed $actual + * @param string $message + * @throws PHPUnit_Framework_AssertionFailedError + */ +function assertNotEmpty($actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertNotEmpty($actual, $message); +} + +/** + * Asserts that two variables are not equal. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @param float $delta + * @param integer $maxDepth + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @since Method available since Release 2.3.0 + */ +function assertNotEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) +{ + return PHPUnit_Framework_Assert::assertNotEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); +} + +/** + * Asserts that a variable is not of a given type. + * + * @param string $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertNotInstanceOf($expected, $actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertNotInstanceOf($expected, $actual, $message); +} + +/** + * Asserts that a variable is not of a given type. + * + * @param string $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertNotInternalType($expected, $actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertNotInternalType($expected, $actual, $message); +} + +/** + * Asserts that a variable is not NULL. + * + * @param mixed $actual + * @param string $message + */ +function assertNotNull($actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertNotNull($actual, $message); +} + +/** + * Asserts that a string does not match a given regular expression. + * + * @param string $pattern + * @param string $string + * @param string $message + * @since Method available since Release 2.1.0 + */ +function assertNotRegExp($pattern, $string, $message = '') +{ + return PHPUnit_Framework_Assert::assertNotRegExp($pattern, $string, $message); +} + +/** + * Asserts that two variables do not have the same type and value. + * Used on objects, it asserts that two variables do not reference + * the same object. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + */ +function assertNotSame($expected, $actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertNotSame($expected, $actual, $message); +} + +/** + * Assert that the size of two arrays (or `Countable` or `Iterator` objects) + * is not the same. + * + * @param integer $expected + * @param mixed $actual + * @param string $message + */ +function assertNotSameSize($expectedCount, $haystack, $message = '') +{ + return PHPUnit_Framework_Assert::assertNotSameSize($expectedCount, $haystack, $message); +} + +/** + * This assertion is the exact opposite of assertTag(). + * + * Rather than asserting that $matcher results in a match, it asserts that + * $matcher does not match. + * + * @param array $matcher + * @param string $actual + * @param string $message + * @param boolean $isHtml + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ +function assertNotTag($matcher, $actual, $message = '', $isHtml = TRUE) +{ + return PHPUnit_Framework_Assert::assertNotTag($matcher, $actual, $message, $isHtml); +} + +/** + * Asserts that a variable is NULL. + * + * @param mixed $actual + * @param string $message + */ +function assertNull($actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertNull($actual, $message); +} + +/** + * Asserts that an object has a specified attribute. + * + * @param string $attributeName + * @param object $object + * @param string $message + * @since Method available since Release 3.0.0 + */ +function assertObjectHasAttribute($attributeName, $object, $message = '') +{ + return PHPUnit_Framework_Assert::assertObjectHasAttribute($attributeName, $object, $message); +} + +/** + * Asserts that an object does not have a specified attribute. + * + * @param string $attributeName + * @param object $object + * @param string $message + * @since Method available since Release 3.0.0 + */ +function assertObjectNotHasAttribute($attributeName, $object, $message = '') +{ + return PHPUnit_Framework_Assert::assertObjectNotHasAttribute($attributeName, $object, $message); +} + +/** + * Asserts that a string matches a given regular expression. + * + * @param string $pattern + * @param string $string + * @param string $message + */ +function assertRegExp($pattern, $string, $message = '') +{ + return PHPUnit_Framework_Assert::assertRegExp($pattern, $string, $message); +} + +/** + * Asserts that two variables have the same type and value. + * Used on objects, it asserts that two variables reference + * the same object. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + */ +function assertSame($expected, $actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertSame($expected, $actual, $message); +} + +/** + * Assert that the size of two arrays (or `Countable` or `Iterator` objects) + * is the same. + * + * @param integer $expected + * @param mixed $actual + * @param string $message + */ +function assertSameSize($expected, $actual, $message = '') +{ + return PHPUnit_Framework_Assert::assertSameSize($expected, $actual, $message); +} + +/** + * Assert the presence, absence, or count of elements in a document matching + * the CSS $selector, regardless of the contents of those elements. + * + * The first argument, $selector, is the CSS selector used to match + * the elements in the $actual document. + * + * The second argument, $count, can be either boolean or numeric. + * When boolean, it asserts for presence of elements matching the selector + * (TRUE) or absence of elements (FALSE). + * When numeric, it asserts the count of elements. + * + * assertSelectCount("#binder", true, $xml); // any? + * assertSelectCount(".binder", 3, $xml); // exactly 3? + * + * @param array $selector + * @param integer $count + * @param mixed $actual + * @param string $message + * @param boolean $isHtml + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ +function assertSelectCount($selector, $count, $actual, $message = '', $isHtml = TRUE) +{ + return PHPUnit_Framework_Assert::assertSelectCount($selector, $count, $actual, $message, $isHtml); +} + +/** + * assertSelectEquals("#binder .name", "Chuck", true, $xml); // any? + * assertSelectEquals("#binder .name", "Chuck", false, $xml); // none? + * + * @param array $selector + * @param string $content + * @param integer $count + * @param mixed $actual + * @param string $message + * @param boolean $isHtml + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ +function assertSelectEquals($selector, $content, $count, $actual, $message = '', $isHtml = TRUE) +{ + return PHPUnit_Framework_Assert::assertSelectEquals($selector, $content, $count, $actual, $message, $isHtml); +} + +/** + * assertSelectRegExp("#binder .name", "/Mike|Derek/", true, $xml); // any? + * assertSelectRegExp("#binder .name", "/Mike|Derek/", 3, $xml);// 3? + * + * @param array $selector + * @param string $pattern + * @param integer $count + * @param mixed $actual + * @param string $message + * @param boolean $isHtml + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ +function assertSelectRegExp($selector, $pattern, $count, $actual, $message = '', $isHtml = TRUE) +{ + return PHPUnit_Framework_Assert::assertSelectRegExp($selector, $pattern, $count, $actual, $message, $isHtml); +} + +/** + * Asserts that a string ends not with a given prefix. + * + * @param string $suffix + * @param string $string + * @param string $message + * @since Method available since Release 3.4.0 + */ +function assertStringEndsNotWith($suffix, $string, $message = '') +{ + return PHPUnit_Framework_Assert::assertStringEndsNotWith($suffix, $string, $message); +} + +/** + * Asserts that a string ends with a given prefix. + * + * @param string $suffix + * @param string $string + * @param string $message + * @since Method available since Release 3.4.0 + */ +function assertStringEndsWith($suffix, $string, $message = '') +{ + return PHPUnit_Framework_Assert::assertStringEndsWith($suffix, $string, $message); +} + +/** + * Asserts that the contents of a string is equal + * to the contents of a file. + * + * @param string $expectedFile + * @param string $actualString + * @param string $message + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @since Method available since Release 3.3.0 + */ +function assertStringEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) +{ + return PHPUnit_Framework_Assert::assertStringEqualsFile($expectedFile, $actualString, $message, $canonicalize, $ignoreCase); +} + +/** + * Asserts that a string matches a given format string. + * + * @param string $format + * @param string $string + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertStringMatchesFormat($format, $string, $message = '') +{ + return PHPUnit_Framework_Assert::assertStringMatchesFormat($format, $string, $message); +} + +/** + * Asserts that a string matches a given format file. + * + * @param string $formatFile + * @param string $string + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertStringMatchesFormatFile($formatFile, $string, $message = '') +{ + return PHPUnit_Framework_Assert::assertStringMatchesFormatFile($formatFile, $string, $message); +} + +/** + * Asserts that the contents of a string is not equal + * to the contents of a file. + * + * @param string $expectedFile + * @param string $actualString + * @param string $message + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @since Method available since Release 3.3.0 + */ +function assertStringNotEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) +{ + return PHPUnit_Framework_Assert::assertStringNotEqualsFile($expectedFile, $actualString, $message, $canonicalize, $ignoreCase); +} + +/** + * Asserts that a string does not match a given format string. + * + * @param string $format + * @param string $string + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertStringNotMatchesFormat($format, $string, $message = '') +{ + return PHPUnit_Framework_Assert::assertStringNotMatchesFormat($format, $string, $message); +} + +/** + * Asserts that a string does not match a given format string. + * + * @param string $formatFile + * @param string $string + * @param string $message + * @since Method available since Release 3.5.0 + */ +function assertStringNotMatchesFormatFile($formatFile, $string, $message = '') +{ + return PHPUnit_Framework_Assert::assertStringNotMatchesFormatFile($formatFile, $string, $message); +} + +/** + * Asserts that a string starts not with a given prefix. + * + * @param string $prefix + * @param string $string + * @param string $message + * @since Method available since Release 3.4.0 + */ +function assertStringStartsNotWith($prefix, $string, $message = '') +{ + return PHPUnit_Framework_Assert::assertStringStartsNotWith($prefix, $string, $message); +} + +/** + * Asserts that a string starts with a given prefix. + * + * @param string $prefix + * @param string $string + * @param string $message + * @since Method available since Release 3.4.0 + */ +function assertStringStartsWith($prefix, $string, $message = '') +{ + return PHPUnit_Framework_Assert::assertStringStartsWith($prefix, $string, $message); +} + +/** + * Evaluate an HTML or XML string and assert its structure and/or contents. + * + * The first argument ($matcher) is an associative array that specifies the + * match criteria for the assertion: + * + * - `id` : the node with the given id attribute must match the + * corresponsing value. + * - `tag` : the node type must match the corresponding value. + * - `attributes` : a hash. The node's attributres must match the + * corresponsing values in the hash. + * - `content` : The text content must match the given value. + * - `parent` : a hash. The node's parent must match the + * corresponsing hash. + * - `child`: a hash. At least one of the node's immediate children + * must meet the criteria described by the hash. + * - `ancestor` : a hash. At least one of the node's ancestors must + * meet the criteria described by the hash. + * - `descendant` : a hash. At least one of the node's descendants must + * meet the criteria described by the hash. + * - `children` : a hash, for counting children of a node. + * Accepts the keys: + *- `count`: a number which must equal the number of children + * that match + *- `less_than`: the number of matching children must be greater + * than this number + *- `greater_than` : the number of matching children must be less than + * this number + *- `only` : another hash consisting of the keys to use to match + * on the children, and only matching children will be + * counted + * + * + * // Matcher that asserts that there is an element with an id="my_id". + * $matcher = array('id' => 'my_id'); + * + * // Matcher that asserts that there is a "span" tag. + * $matcher = array('tag' => 'span'); + * + * // Matcher that asserts that there is a "span" tag with the content + * // "Hello World". + * $matcher = array('tag' => 'span', 'content' => 'Hello World'); + * + * // Matcher that asserts that there is a "span" tag with content matching + * // the regular expression pattern. + * $matcher = array('tag' => 'span', 'content' => 'regexp:/Try P(HP|ython)/'); + * + * // Matcher that asserts that there is a "span" with an "list" class + * // attribute. + * $matcher = array( + * 'tag'=> 'span', + * 'attributes' => array('class' => 'list') + * ); + * + * // Matcher that asserts that there is a "span" inside of a "div". + * $matcher = array( + * 'tag'=> 'span', + * 'parent' => array('tag' => 'div') + * ); + * + * // Matcher that asserts that there is a "span" somewhere inside a + * // "table". + * $matcher = array( + * 'tag' => 'span', + * 'ancestor' => array('tag' => 'table') + * ); + * + * // Matcher that asserts that there is a "span" with at least one "em" + * // child. + * $matcher = array( + * 'tag' => 'span', + * 'child' => array('tag' => 'em') + * ); + * + * // Matcher that asserts that there is a "span" containing a (possibly + * // nested) "strong" tag. + * $matcher = array( + * 'tag'=> 'span', + * 'descendant' => array('tag' => 'strong') + * ); + * + * // Matcher that asserts that there is a "span" containing 5-10 "em" tags + * // as immediate children. + * $matcher = array( + * 'tag' => 'span', + * 'children' => array( + * 'less_than'=> 11, + * 'greater_than' => 4, + * 'only' => array('tag' => 'em') + * ) + * ); + * + * // Matcher that asserts that there is a "div", with an "ul" ancestor and + * // a "li" parent (with class="enum"), and containing a "span" descendant + * // that contains an element with id="my_test" and the text "Hello World". + * $matcher = array( + * 'tag'=> 'div', + * 'ancestor' => array('tag' => 'ul'), + * 'parent' => array( + * 'tag'=> 'li', + * 'attributes' => array('class' => 'enum') + * ), + * 'descendant' => array( + * 'tag' => 'span', + * 'child' => array( + * 'id' => 'my_test', + * 'content' => 'Hello World' + * ) + * ) + * ); + * + * // Use assertTag() to apply a $matcher to a piece of $html. + * $this->assertTag($matcher, $html); + * + * // Use assertTag() to apply a $matcher to a piece of $xml. + * $this->assertTag($matcher, $xml, '', FALSE); + * + * + * The second argument ($actual) is a string containing either HTML or + * XML text to be tested. + * + * The third argument ($message) is an optional message that will be + * used if the assertion fails. + * + * The fourth argument ($html) is an optional flag specifying whether + * to load the $actual string into a DOMDocument using the HTML or + * XML load strategy. It is TRUE by default, which assumes the HTML + * load strategy. In many cases, this will be acceptable for XML as well. + * + * @param array $matcher + * @param string $actual + * @param string $message + * @param boolean $isHtml + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ +function assertTag($matcher, $actual, $message = '', $isHtml = TRUE) +{ + return PHPUnit_Framework_Assert::assertTag($matcher, $actual, $message, $isHtml); +} + +/** + * Evaluates a PHPUnit_Framework_Constraint matcher object. + * + * @param mixed$value + * @param PHPUnit_Framework_Constraint $constraint + * @param string $message + * @since Method available since Release 3.0.0 + */ +function assertThat($value, PHPUnit_Framework_Constraint $constraint, $message = '') +{ + return PHPUnit_Framework_Assert::assertThat($value, $constraint, $message); +} + +/** + * Asserts that a condition is true. + * + * @param boolean $condition + * @param string $message + * @throws PHPUnit_Framework_AssertionFailedError + */ +function assertTrue($condition, $message = '') +{ + return PHPUnit_Framework_Assert::assertTrue($condition, $message); +} + +/** + * Asserts that two XML files are equal. + * + * @param string $expectedFile + * @param string $actualFile + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = '') +{ + return PHPUnit_Framework_Assert::assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message); +} + +/** + * Asserts that two XML files are not equal. + * + * @param string $expectedFile + * @param string $actualFile + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = '') +{ + return PHPUnit_Framework_Assert::assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message); +} + +/** + * Asserts that two XML documents are equal. + * + * @param string $expectedFile + * @param string $actualXml + * @param string $message + * @since Method available since Release 3.3.0 + */ +function assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = '') +{ + return PHPUnit_Framework_Assert::assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message); +} + +/** + * Asserts that two XML documents are equal. + * + * @param string $expectedXml + * @param string $actualXml + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '') +{ + return PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message); +} + +/** + * Asserts that two XML documents are not equal. + * + * @param string $expectedFile + * @param string $actualXml + * @param string $message + * @since Method available since Release 3.3.0 + */ +function assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = '') +{ + return PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message); +} + +/** + * Asserts that two XML documents are not equal. + * + * @param string $expectedXml + * @param string $actualXml + * @param string $message + * @since Method available since Release 3.1.0 + */ +function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = '') +{ + return PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message); +} + +/** + * Returns a matcher that matches when the method it is evaluated for + * is invoked at the given $index. + * + * @param integer $index + * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex + * @since Method available since Release 3.0.0 + */ +function at($index) +{ + return PHPUnit_Framework_TestCase::at($index); +} + +/** + * Returns a matcher that matches when the method it is evaluated for + * is executed at least once. + * + * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce + * @since Method available since Release 3.0.0 + */ +function atLeastOnce() +{ + return PHPUnit_Framework_TestCase::atLeastOnce(); +} + +/** + * Returns a PHPUnit_Framework_Constraint_Attribute matcher object. + * + * @param PHPUnit_Framework_Constraint $constraint + * @param string $attributeName + * @return PHPUnit_Framework_Constraint_Attribute + * @since Method available since Release 3.1.0 + */ +function attribute(PHPUnit_Framework_Constraint $constraint, $attributeName) +{ + return PHPUnit_Framework_Assert::attribute($constraint, $attributeName); +} + +/** + * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object + * that is wrapped in a PHPUnit_Framework_Constraint_Attribute matcher + * object. + * + * @param string $attributeName + * @param mixed $value + * @param float $delta + * @param integer $maxDepth + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @return PHPUnit_Framework_Constraint_Attribute + * @since Method available since Release 3.1.0 + */ +function attributeEqualTo($attributeName, $value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) +{ + return PHPUnit_Framework_Assert::attributeEqualTo($attributeName, $value, $delta, $maxDepth, $canonicalize, $ignoreCase); +} + +/** + * Returns a PHPUnit_Framework_Constraint_ClassHasAttribute matcher object. + * + * @param string $attributeName + * @return PHPUnit_Framework_Constraint_ClassHasAttribute + * @since Method available since Release 3.1.0 + */ +function classHasAttribute($attributeName) +{ + return PHPUnit_Framework_Assert::classHasAttribute($attributeName); +} + +/** + * Returns a PHPUnit_Framework_Constraint_ClassHasStaticAttribute matcher + * object. + * + * @param string $attributeName + * @return PHPUnit_Framework_Constraint_ClassHasStaticAttribute + * @since Method available since Release 3.1.0 + */ +function classHasStaticAttribute($attributeName) +{ + return PHPUnit_Framework_Assert::classHasStaticAttribute($attributeName); +} + +/** + * Returns a PHPUnit_Framework_Constraint_TraversableContains matcher + * object. + * + * @param mixed $value + * @param boolean $checkForObjectIdentity + * @return PHPUnit_Framework_Constraint_TraversableContains + * @since Method available since Release 3.0.0 + */ +function contains($value, $checkForObjectIdentity = TRUE) +{ + return PHPUnit_Framework_Assert::contains($value, $checkForObjectIdentity); +} + +/** + * Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher + * object. + * + * @param string $type + * @return PHPUnit_Framework_Constraint_TraversableContainsOnly + * @since Method available since Release 3.1.4 + */ +function containsOnly($type) +{ + return PHPUnit_Framework_Assert::containsOnly($type); +} + +/** + * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object. + * + * @param mixed $value + * @param float $delta + * @param integer $maxDepth + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @return PHPUnit_Framework_Constraint_IsEqual + * @since Method available since Release 3.0.0 + */ +function equalTo($value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) +{ + return PHPUnit_Framework_Assert::equalTo($value, $delta, $maxDepth, $canonicalize, $ignoreCase); +} + +/** + * Returns a matcher that matches when the method it is evaluated for + * is executed exactly $count times. + * + * @param integer $count + * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount + * @since Method available since Release 3.0.0 + */ +function exactly($count) +{ + return PHPUnit_Framework_TestCase::exactly($count); +} + +/** + * Returns a PHPUnit_Framework_Constraint_FileExists matcher object. + * + * @return PHPUnit_Framework_Constraint_FileExists + * @since Method available since Release 3.0.0 + */ +function fileExists() +{ + return PHPUnit_Framework_Assert::fileExists(); +} + +/** + * Returns a PHPUnit_Framework_Constraint_GreaterThan matcher object. + * + * @param mixed $value + * @return PHPUnit_Framework_Constraint_GreaterThan + * @since Method available since Release 3.0.0 + */ +function greaterThan($value) +{ + return PHPUnit_Framework_Assert::greaterThan($value); +} + +/** + * Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps + * a PHPUnit_Framework_Constraint_IsEqual and a + * PHPUnit_Framework_Constraint_GreaterThan matcher object. + * + * @param mixed $value + * @return PHPUnit_Framework_Constraint_Or + * @since Method available since Release 3.1.0 + */ +function greaterThanOrEqual($value) +{ + return PHPUnit_Framework_Assert::greaterThanOrEqual($value); +} + +/** + * Returns a PHPUnit_Framework_Constraint_IsIdentical matcher object. + * + * @param mixed $value + * @return PHPUnit_Framework_Constraint_IsIdentical + * @since Method available since Release 3.0.0 + */ +function identicalTo($value) +{ + return PHPUnit_Framework_Assert::identicalTo($value); +} + +/** + * Returns a PHPUnit_Framework_Constraint_IsEmpty matcher object. + * + * @return PHPUnit_Framework_Constraint_IsEmpty + * @since Method available since Release 3.5.0 + */ +function isEmpty() +{ + return PHPUnit_Framework_Assert::isEmpty(); +} + +/** + * Returns a PHPUnit_Framework_Constraint_IsFalse matcher object. + * + * @return PHPUnit_Framework_Constraint_IsFalse + * @since Method available since Release 3.3.0 + */ +function isFalse() +{ + return PHPUnit_Framework_Assert::isFalse(); +} + +/** + * Returns a PHPUnit_Framework_Constraint_IsInstanceOf matcher object. + * + * @param string $className + * @return PHPUnit_Framework_Constraint_IsInstanceOf + * @since Method available since Release 3.0.0 + */ +function isInstanceOf($className) +{ + return PHPUnit_Framework_Assert::isInstanceOf($className); +} + +/** + * Returns a PHPUnit_Framework_Constraint_IsNull matcher object. + * + * @return PHPUnit_Framework_Constraint_IsNull + * @since Method available since Release 3.3.0 + */ +function isNull() +{ + return PHPUnit_Framework_Assert::isNull(); +} + +/** + * Returns a PHPUnit_Framework_Constraint_IsTrue matcher object. + * + * @return PHPUnit_Framework_Constraint_IsTrue + * @since Method available since Release 3.3.0 + */ +function isTrue() +{ + return PHPUnit_Framework_Assert::isTrue(); +} + +/** + * Returns a PHPUnit_Framework_Constraint_IsType matcher object. + * + * @param string $type + * @return PHPUnit_Framework_Constraint_IsType + * @since Method available since Release 3.0.0 + */ +function isType($type) +{ + return PHPUnit_Framework_Assert::isType($type); +} + +/** + * Returns a PHPUnit_Framework_Constraint_LessThan matcher object. + * + * @param mixed $value + * @return PHPUnit_Framework_Constraint_LessThan + * @since Method available since Release 3.0.0 + */ +function lessThan($value) +{ + return PHPUnit_Framework_Assert::lessThan($value); +} + +/** + * Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps + * a PHPUnit_Framework_Constraint_IsEqual and a + * PHPUnit_Framework_Constraint_LessThan matcher object. + * + * @param mixed $value + * @return PHPUnit_Framework_Constraint_Or + * @since Method available since Release 3.1.0 + */ +function lessThanOrEqual($value) +{ + return PHPUnit_Framework_Assert::lessThanOrEqual($value); +} + +/** + * Returns a PHPUnit_Framework_Constraint_And matcher object. + * + * @return PHPUnit_Framework_Constraint_And + * @since Method available since Release 3.0.0 + */ +function logicalAnd() +{ + return PHPUnit_Framework_Assert::logicalAnd(); +} + +/** + * Returns a PHPUnit_Framework_Constraint_Not matcher object. + * + * @param PHPUnit_Framework_Constraint $constraint + * @return PHPUnit_Framework_Constraint_Not + * @since Method available since Release 3.0.0 + */ +function logicalNot(PHPUnit_Framework_Constraint $constraint) +{ + return PHPUnit_Framework_Assert::logicalNot($constraint); +} + +/** + * Returns a PHPUnit_Framework_Constraint_Or matcher object. + * + * @return PHPUnit_Framework_Constraint_Or + * @since Method available since Release 3.0.0 + */ +function logicalOr() +{ + return PHPUnit_Framework_Assert::logicalOr(); +} + +/** + * Returns a PHPUnit_Framework_Constraint_Xor matcher object. + * + * @return PHPUnit_Framework_Constraint_Xor + * @since Method available since Release 3.0.0 + */ +function logicalXor() +{ + return PHPUnit_Framework_Assert::logicalXor(); +} + +/** + * Returns a PHPUnit_Framework_Constraint_StringMatches matcher object. + * + * @param string $string + * @return PHPUnit_Framework_Constraint_StringMatches + * @since Method available since Release 3.5.0 + */ +function matches($string) +{ + return PHPUnit_Framework_Assert::matches($string); +} + +/** + * Returns a PHPUnit_Framework_Constraint_PCREMatch matcher object. + * + * @param string $pattern + * @return PHPUnit_Framework_Constraint_PCREMatch + * @since Method available since Release 3.0.0 + */ +function matchesRegularExpression($pattern) +{ + return PHPUnit_Framework_Assert::matchesRegularExpression($pattern); +} + +/** + * Returns a matcher that matches when the method it is evaluated for + * is never executed. + * + * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount + * @since Method available since Release 3.0.0 + */ +function never() +{ + return PHPUnit_Framework_TestCase::never(); +} + +/** + * Returns a PHPUnit_Framework_Constraint_ObjectHasAttribute matcher object. + * + * @param string $attributeName + * @return PHPUnit_Framework_Constraint_ObjectHasAttribute + * @since Method available since Release 3.0.0 + */ +function objectHasAttribute($attributeName) +{ + return PHPUnit_Framework_Assert::objectHasAttribute($attributeName); +} + +/** + * + * + * @param mixed $value, ... + * @return PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls + * @since Method available since Release 3.0.0 + */ +function onConsecutiveCalls() +{ + return PHPUnit_Framework_TestCase::onConsecutiveCalls(); +} + +/** + * Returns a matcher that matches when the method it is evaluated for + * is executed exactly once. + * + * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount + * @since Method available since Release 3.0.0 + */ +function once() +{ + return PHPUnit_Framework_TestCase::once(); +} + +/** + * + * + * @param integer $argumentIndex + * @return PHPUnit_Framework_MockObject_Stub_ReturnArgument + * @since Method available since Release 3.3.0 + */ +function returnArgument($argumentIndex) +{ + return PHPUnit_Framework_TestCase::returnArgument($argumentIndex); +} + +/** + * + * + * @param mixed $callback + * @return PHPUnit_Framework_MockObject_Stub_ReturnCallback + * @since Method available since Release 3.3.0 + */ +function returnCallback($callback) +{ + return PHPUnit_Framework_TestCase::returnCallback($callback); +} + +/** + * Returns the current object. + * + * This method is useful when mocking a fluent interface. + * + * @return PHPUnit_Framework_MockObject_Stub_ReturnSelf + * @since Method available since Release 3.6.0 + */ +function returnSelf() +{ + return PHPUnit_Framework_TestCase::returnSelf(); +} + +/** + * + * + * @param mixed $value + * @return PHPUnit_Framework_MockObject_Stub_Return + * @since Method available since Release 3.0.0 + */ +function returnValue($value) +{ + return PHPUnit_Framework_TestCase::returnValue($value); +} + +/** + * + * + * @param array $valueMap + * @return PHPUnit_Framework_MockObject_Stub_ReturnValueMap + * @since Method available since Release 3.6.0 + */ +function returnValueMap(array $valueMap) +{ + return PHPUnit_Framework_TestCase::returnValueMap($valueMap); +} + +/** + * Returns a PHPUnit_Framework_Constraint_StringContains matcher object. + * + * @param string $string + * @param boolean $case + * @return PHPUnit_Framework_Constraint_StringContains + * @since Method available since Release 3.0.0 + */ +function stringContains($string, $case = TRUE) +{ + return PHPUnit_Framework_Assert::stringContains($string, $case); +} + +/** + * Returns a PHPUnit_Framework_Constraint_StringEndsWith matcher object. + * + * @param mixed $suffix + * @return PHPUnit_Framework_Constraint_StringEndsWith + * @since Method available since Release 3.4.0 + */ +function stringEndsWith($suffix) +{ + return PHPUnit_Framework_Assert::stringEndsWith($suffix); +} + +/** + * Returns a PHPUnit_Framework_Constraint_StringStartsWith matcher object. + * + * @param mixed $prefix + * @return PHPUnit_Framework_Constraint_StringStartsWith + * @since Method available since Release 3.4.0 + */ +function stringStartsWith($prefix) +{ + return PHPUnit_Framework_Assert::stringStartsWith($prefix); +} + +/** + * + * + * @param Exception $exception + * @return PHPUnit_Framework_MockObject_Stub_Exception + * @since Method available since Release 3.1.0 + */ +function throwException(Exception $exception) +{ + return PHPUnit_Framework_TestCase::throwException($exception); +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Assert.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Assert.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Assert.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Assert.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,2619 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * A set of assert methods. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +abstract class PHPUnit_Framework_Assert +{ + /** + * @var integer + */ + private static $count = 0; + + /** + * Asserts that an array has a specified key. + * + * @param mixed $key + * @param array $array + * @param string $message + * @since Method available since Release 3.0.0 + */ + public static function assertArrayHasKey($key, array $array, $message = '') + { + if (!(is_integer($key) || is_string($key))) { + throw PHPUnit_Util_InvalidArgumentHelper::factory( + 1, 'integer or string' + ); + } + + $constraint = new PHPUnit_Framework_Constraint_ArrayHasKey($key); + + self::assertThat($array, $constraint, $message); + } + + /** + * Asserts that an array does not have a specified key. + * + * @param mixed $key + * @param array $array + * @param string $message + * @since Method available since Release 3.0.0 + */ + public static function assertArrayNotHasKey($key, array $array, $message = '') + { + if (!(is_integer($key) || is_string($key))) { + throw PHPUnit_Util_InvalidArgumentHelper::factory( + 1, 'integer or string' + ); + } + + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_ArrayHasKey($key) + ); + + self::assertThat($array, $constraint, $message); + } + + /** + * Asserts that a haystack contains a needle. + * + * @param mixed $needle + * @param mixed $haystack + * @param string $message + * @param boolean $ignoreCase + * @param boolean $checkForObjectIdentity + * @since Method available since Release 2.1.0 + */ + public static function assertContains($needle, $haystack, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) + { + if (is_array($haystack) || + is_object($haystack) && $haystack instanceof Traversable) { + $constraint = new PHPUnit_Framework_Constraint_TraversableContains( + $needle, $checkForObjectIdentity + ); + } + + else if (is_string($haystack)) { + $constraint = new PHPUnit_Framework_Constraint_StringContains( + $needle, $ignoreCase + ); + } + + else { + throw PHPUnit_Util_InvalidArgumentHelper::factory( + 2, 'array, iterator or string' + ); + } + + self::assertThat($haystack, $constraint, $message); + } + + /** + * Asserts that a haystack that is stored in a static attribute of a class + * or an attribute of an object contains a needle. + * + * @param mixed $needle + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param string $message + * @param boolean $ignoreCase + * @param boolean $checkForObjectIdentity + * @since Method available since Release 3.0.0 + */ + public static function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) + { + self::assertContains( + $needle, + self::readAttribute($haystackClassOrObject, $haystackAttributeName), + $message, + $ignoreCase, + $checkForObjectIdentity + ); + } + + /** + * Asserts that a haystack does not contain a needle. + * + * @param mixed $needle + * @param mixed $haystack + * @param string $message + * @param boolean $ignoreCase + * @param boolean $checkForObjectIdentity + * @since Method available since Release 2.1.0 + */ + public static function assertNotContains($needle, $haystack, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) + { + if (is_array($haystack) || + is_object($haystack) && $haystack instanceof Traversable) { + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_TraversableContains( + $needle, $checkForObjectIdentity + ) + ); + } + + else if (is_string($haystack)) { + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_StringContains( + $needle, $ignoreCase + ) + ); + } + + else { + throw PHPUnit_Util_InvalidArgumentHelper::factory( + 2, 'array, iterator or string' + ); + } + + self::assertThat($haystack, $constraint, $message); + } + + /** + * Asserts that a haystack that is stored in a static attribute of a class + * or an attribute of an object does not contain a needle. + * + * @param mixed $needle + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param string $message + * @param boolean $ignoreCase + * @param boolean $checkForObjectIdentity + * @since Method available since Release 3.0.0 + */ + public static function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) + { + self::assertNotContains( + $needle, + self::readAttribute($haystackClassOrObject, $haystackAttributeName), + $message, + $ignoreCase, + $checkForObjectIdentity + ); + } + + /** + * Asserts that a haystack contains only values of a given type. + * + * @param string $type + * @param mixed $haystack + * @param boolean $isNativeType + * @param string $message + * @since Method available since Release 3.1.4 + */ + public static function assertContainsOnly($type, $haystack, $isNativeType = NULL, $message = '') + { + if (!(is_array($haystack) || + is_object($haystack) && $haystack instanceof Traversable)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory( + 2, 'array or iterator' + ); + } + + if ($isNativeType == NULL) { + $isNativeType = PHPUnit_Util_Type::isType($type); + } + + self::assertThat( + $haystack, + new PHPUnit_Framework_Constraint_TraversableContainsOnly( + $type, $isNativeType + ), + $message + ); + } + + /** + * Asserts that a haystack that is stored in a static attribute of a class + * or an attribute of an object contains only values of a given type. + * + * @param string $type + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param boolean $isNativeType + * @param string $message + * @since Method available since Release 3.1.4 + */ + public static function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '') + { + self::assertContainsOnly( + $type, + self::readAttribute($haystackClassOrObject, $haystackAttributeName), + $isNativeType, + $message + ); + } + + /** + * Asserts that a haystack does not contain only values of a given type. + * + * @param string $type + * @param mixed $haystack + * @param boolean $isNativeType + * @param string $message + * @since Method available since Release 3.1.4 + */ + public static function assertNotContainsOnly($type, $haystack, $isNativeType = NULL, $message = '') + { + if (!(is_array($haystack) || + is_object($haystack) && $haystack instanceof Traversable)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory( + 2, 'array or iterator' + ); + } + + if ($isNativeType == NULL) { + $isNativeType = PHPUnit_Util_Type::isType($type); + } + + self::assertThat( + $haystack, + new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_TraversableContainsOnly( + $type, $isNativeType + ) + ), + $message + ); + } + + /** + * Asserts that a haystack that is stored in a static attribute of a class + * or an attribute of an object does not contain only values of a given + * type. + * + * @param string $type + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param boolean $isNativeType + * @param string $message + * @since Method available since Release 3.1.4 + */ + public static function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '') + { + self::assertNotContainsOnly( + $type, + self::readAttribute($haystackClassOrObject, $haystackAttributeName), + $isNativeType, + $message + ); + } + + /** + * Asserts the number of elements of an array, Countable or Iterator. + * + * @param integer $expectedCount + * @param mixed $haystack + * @param string $message + */ + public static function assertCount($expectedCount, $haystack, $message = '') + { + if (!is_int($expectedCount)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer'); + } + + if (!$haystack instanceof Countable && + !$haystack instanceof Iterator && + !is_array($haystack)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'countable'); + } + + self::assertThat( + $haystack, + new PHPUnit_Framework_Constraint_Count($expectedCount), + $message + ); + } + + /** + * Asserts the number of elements of an array, Countable or Iterator + * that is stored in an attribute. + * + * @param integer $expectedCount + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param string $message + * @since Method available since Release 3.6.0 + */ + public static function assertAttributeCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '') + { + self::assertCount( + $expectedCount, + self::readAttribute($haystackClassOrObject, $haystackAttributeName), + $message + ); + } + + /** + * Asserts the number of elements of an array, Countable or Iterator. + * + * @param integer $expectedCount + * @param mixed $haystack + * @param string $message + */ + public static function assertNotCount($expectedCount, $haystack, $message = '') + { + if (!is_int($expectedCount)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer'); + } + + if (!$haystack instanceof Countable && + !$haystack instanceof Iterator && + !is_array($haystack)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'countable'); + } + + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_Count($expectedCount) + ); + + self::assertThat($haystack, $constraint, $message); + } + + /** + * Asserts the number of elements of an array, Countable or Iterator + * that is stored in an attribute. + * + * @param integer $expectedCount + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param string $message + * @since Method available since Release 3.6.0 + */ + public static function assertAttributeNotCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '') + { + self::assertNotCount( + $expectedCount, + self::readAttribute($haystackClassOrObject, $haystackAttributeName), + $message + ); + } + + /** + * Asserts that two variables are equal. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @param float $delta + * @param integer $maxDepth + * @param boolean $canonicalize + * @param boolean $ignoreCase + */ + public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) + { + $constraint = new PHPUnit_Framework_Constraint_IsEqual( + $expected, $delta, $maxDepth, $canonicalize, $ignoreCase + ); + + self::assertThat($actual, $constraint, $message); + } + + /** + * Asserts that a variable is equal to an attribute of an object. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param string $actualClassOrObject + * @param string $message + * @param float $delta + * @param integer $maxDepth + * @param boolean $canonicalize + * @param boolean $ignoreCase + */ + public static function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) + { + self::assertEquals( + $expected, + self::readAttribute($actualClassOrObject, $actualAttributeName), + $message, + $delta, + $maxDepth, + $canonicalize, + $ignoreCase + ); + } + + /** + * Asserts that two variables are not equal. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @param float $delta + * @param integer $maxDepth + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @since Method available since Release 2.3.0 + */ + public static function assertNotEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) + { + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_IsEqual( + $expected, $delta, $maxDepth, $canonicalize, $ignoreCase + ) + ); + + self::assertThat($actual, $constraint, $message); + } + + /** + * Asserts that a variable is not equal to an attribute of an object. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param string $actualClassOrObject + * @param string $message + * @param float $delta + * @param integer $maxDepth + * @param boolean $canonicalize + * @param boolean $ignoreCase + */ + public static function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) + { + self::assertNotEquals( + $expected, + self::readAttribute($actualClassOrObject, $actualAttributeName), + $message, + $delta, + $maxDepth, + $canonicalize, + $ignoreCase + ); + } + + /** + * Asserts that a variable is empty. + * + * @param mixed $actual + * @param string $message + * @throws PHPUnit_Framework_AssertionFailedError + */ + public static function assertEmpty($actual, $message = '') + { + self::assertThat($actual, self::isEmpty(), $message); + } + + /** + * Asserts that a static attribute of a class or an attribute of an object + * is empty. + * + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') + { + self::assertEmpty( + self::readAttribute($haystackClassOrObject, $haystackAttributeName), + $message + ); + } + + /** + * Asserts that a variable is not empty. + * + * @param mixed $actual + * @param string $message + * @throws PHPUnit_Framework_AssertionFailedError + */ + public static function assertNotEmpty($actual, $message = '') + { + self::assertThat($actual, self::logicalNot(self::isEmpty()), $message); + } + + /** + * Asserts that a static attribute of a class or an attribute of an object + * is not empty. + * + * @param string $haystackAttributeName + * @param mixed $haystackClassOrObject + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') + { + self::assertNotEmpty( + self::readAttribute($haystackClassOrObject, $haystackAttributeName), + $message + ); + } + + /** + * Asserts that a value is greater than another value. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertGreaterThan($expected, $actual, $message = '') + { + self::assertThat($actual, self::greaterThan($expected), $message); + } + + /** + * Asserts that an attribute is greater than another value. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param string $actualClassOrObject + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') + { + self::assertGreaterThan( + $expected, + self::readAttribute($actualClassOrObject, $actualAttributeName), + $message + ); + } + + /** + * Asserts that a value is greater than or equal to another value. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertGreaterThanOrEqual($expected, $actual, $message = '') + { + self::assertThat( + $actual, self::greaterThanOrEqual($expected), $message + ); + } + + /** + * Asserts that an attribute is greater than or equal to another value. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param string $actualClassOrObject + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') + { + self::assertGreaterThanOrEqual( + $expected, + self::readAttribute($actualClassOrObject, $actualAttributeName), + $message + ); + } + + /** + * Asserts that a value is smaller than another value. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertLessThan($expected, $actual, $message = '') + { + self::assertThat($actual, self::lessThan($expected), $message); + } + + /** + * Asserts that an attribute is smaller than another value. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param string $actualClassOrObject + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') + { + self::assertLessThan( + $expected, + self::readAttribute($actualClassOrObject, $actualAttributeName), + $message + ); + } + + /** + * Asserts that a value is smaller than or equal to another value. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertLessThanOrEqual($expected, $actual, $message = '') + { + self::assertThat($actual, self::lessThanOrEqual($expected), $message); + } + + /** + * Asserts that an attribute is smaller than or equal to another value. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param string $actualClassOrObject + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') + { + self::assertLessThanOrEqual( + $expected, + self::readAttribute($actualClassOrObject, $actualAttributeName), + $message + ); + } + + /** + * Asserts that the contents of one file is equal to the contents of another + * file. + * + * @param string $expected + * @param string $actual + * @param string $message + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @since Method available since Release 3.2.14 + */ + public static function assertFileEquals($expected, $actual, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) + { + self::assertFileExists($expected, $message); + self::assertFileExists($actual, $message); + + self::assertEquals( + file_get_contents($expected), + file_get_contents($actual), + $message, + 0, + 10, + $canonicalize, + $ignoreCase + ); + } + + /** + * Asserts that the contents of one file is not equal to the contents of + * another file. + * + * @param string $expected + * @param string $actual + * @param string $message + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @since Method available since Release 3.2.14 + */ + public static function assertFileNotEquals($expected, $actual, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) + { + self::assertFileExists($expected, $message); + self::assertFileExists($actual, $message); + + self::assertNotEquals( + file_get_contents($expected), + file_get_contents($actual), + $message, + 0, + 10, + $canonicalize, + $ignoreCase + ); + } + + /** + * Asserts that the contents of a string is equal + * to the contents of a file. + * + * @param string $expectedFile + * @param string $actualString + * @param string $message + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @since Method available since Release 3.3.0 + */ + public static function assertStringEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) + { + self::assertFileExists($expectedFile, $message); + + self::assertEquals( + file_get_contents($expectedFile), + $actualString, + $message, + 0, + 10, + $canonicalize, + $ignoreCase + ); + } + + /** + * Asserts that the contents of a string is not equal + * to the contents of a file. + * + * @param string $expectedFile + * @param string $actualString + * @param string $message + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @since Method available since Release 3.3.0 + */ + public static function assertStringNotEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE) + { + self::assertFileExists($expectedFile, $message); + + self::assertNotEquals( + file_get_contents($expectedFile), + $actualString, + $message, + 0, + 10, + $canonicalize, + $ignoreCase + ); + } + + /** + * Asserts that a file exists. + * + * @param string $filename + * @param string $message + * @since Method available since Release 3.0.0 + */ + public static function assertFileExists($filename, $message = '') + { + if (!is_string($filename)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + $constraint = new PHPUnit_Framework_Constraint_FileExists; + + self::assertThat($filename, $constraint, $message); + } + + /** + * Asserts that a file does not exist. + * + * @param string $filename + * @param string $message + * @since Method available since Release 3.0.0 + */ + public static function assertFileNotExists($filename, $message = '') + { + if (!is_string($filename)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_FileExists + ); + + self::assertThat($filename, $constraint, $message); + } + + /** + * Asserts that a condition is true. + * + * @param boolean $condition + * @param string $message + * @throws PHPUnit_Framework_AssertionFailedError + */ + public static function assertTrue($condition, $message = '') + { + self::assertThat($condition, self::isTrue(), $message); + } + + /** + * Asserts that a condition is false. + * + * @param boolean $condition + * @param string $message + * @throws PHPUnit_Framework_AssertionFailedError + */ + public static function assertFalse($condition, $message = '') + { + self::assertThat($condition, self::isFalse(), $message); + } + + /** + * Asserts that a variable is not NULL. + * + * @param mixed $actual + * @param string $message + */ + public static function assertNotNull($actual, $message = '') + { + self::assertThat($actual, self::logicalNot(self::isNull()), $message); + } + + /** + * Asserts that a variable is NULL. + * + * @param mixed $actual + * @param string $message + */ + public static function assertNull($actual, $message = '') + { + self::assertThat($actual, self::isNull(), $message); + } + + /** + * Asserts that a class has a specified attribute. + * + * @param string $attributeName + * @param string $className + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertClassHasAttribute($attributeName, $className, $message = '') + { + if (!is_string($attributeName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($className) || !class_exists($className, FALSE)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name'); + } + + $constraint = new PHPUnit_Framework_Constraint_ClassHasAttribute( + $attributeName + ); + + self::assertThat($className, $constraint, $message); + } + + /** + * Asserts that a class does not have a specified attribute. + * + * @param string $attributeName + * @param string $className + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertClassNotHasAttribute($attributeName, $className, $message = '') + { + if (!is_string($attributeName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($className) || !class_exists($className, FALSE)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name'); + } + + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_ClassHasAttribute($attributeName) + ); + + self::assertThat($className, $constraint, $message); + } + + /** + * Asserts that a class has a specified static attribute. + * + * @param string $attributeName + * @param string $className + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertClassHasStaticAttribute($attributeName, $className, $message = '') + { + if (!is_string($attributeName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($className) || !class_exists($className, FALSE)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name'); + } + + $constraint = new PHPUnit_Framework_Constraint_ClassHasStaticAttribute( + $attributeName + ); + + self::assertThat($className, $constraint, $message); + } + + /** + * Asserts that a class does not have a specified static attribute. + * + * @param string $attributeName + * @param string $className + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertClassNotHasStaticAttribute($attributeName, $className, $message = '') + { + if (!is_string($attributeName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($className) || !class_exists($className, FALSE)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name'); + } + + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_ClassHasStaticAttribute( + $attributeName + ) + ); + + self::assertThat($className, $constraint, $message); + } + + /** + * Asserts that an object has a specified attribute. + * + * @param string $attributeName + * @param object $object + * @param string $message + * @since Method available since Release 3.0.0 + */ + public static function assertObjectHasAttribute($attributeName, $object, $message = '') + { + if (!is_string($attributeName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_object($object)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'object'); + } + + $constraint = new PHPUnit_Framework_Constraint_ObjectHasAttribute( + $attributeName + ); + + self::assertThat($object, $constraint, $message); + } + + /** + * Asserts that an object does not have a specified attribute. + * + * @param string $attributeName + * @param object $object + * @param string $message + * @since Method available since Release 3.0.0 + */ + public static function assertObjectNotHasAttribute($attributeName, $object, $message = '') + { + if (!is_string($attributeName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_object($object)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'object'); + } + + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_ObjectHasAttribute($attributeName) + ); + + self::assertThat($object, $constraint, $message); + } + + /** + * Asserts that two variables have the same type and value. + * Used on objects, it asserts that two variables reference + * the same object. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + */ + public static function assertSame($expected, $actual, $message = '') + { + if (is_bool($expected) && is_bool($actual)) { + self::assertEquals($expected, $actual, $message); + } else { + $constraint = new PHPUnit_Framework_Constraint_IsIdentical( + $expected + ); + + self::assertThat($actual, $constraint, $message); + } + } + + /** + * Asserts that a variable and an attribute of an object have the same type + * and value. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param object $actualClassOrObject + * @param string $message + */ + public static function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') + { + self::assertSame( + $expected, + self::readAttribute($actualClassOrObject, $actualAttributeName), + $message + ); + } + + /** + * Asserts that two variables do not have the same type and value. + * Used on objects, it asserts that two variables do not reference + * the same object. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + */ + public static function assertNotSame($expected, $actual, $message = '') + { + if (is_bool($expected) && is_bool($actual)) { + self::assertNotEquals($expected, $actual, $message); + } else { + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_IsIdentical($expected) + ); + + self::assertThat($actual, $constraint, $message); + } + } + + /** + * Asserts that a variable and an attribute of an object do not have the + * same type and value. + * + * @param mixed $expected + * @param string $actualAttributeName + * @param object $actualClassOrObject + * @param string $message + */ + public static function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') + { + self::assertNotSame( + $expected, + self::readAttribute($actualClassOrObject, $actualAttributeName), + $message + ); + } + + /** + * Asserts that a variable is of a given type. + * + * @param string $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertInstanceOf($expected, $actual, $message = '') + { + if (is_string($expected)) { + if (class_exists($expected) || interface_exists($expected)) { + $constraint = new PHPUnit_Framework_Constraint_IsInstanceOf( + $expected + ); + } + + else { + throw PHPUnit_Util_InvalidArgumentHelper::factory( + 1, 'class or interface name' + ); + } + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + self::assertThat($actual, $constraint, $message); + } + + /** + * Asserts that an attribute is of a given type. + * + * @param string $expected + * @param string $attributeName + * @param mixed $classOrObject + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '') + { + self::assertInstanceOf( + $expected, + self::readAttribute($classOrObject, $attributeName), + $message + ); + } + + /** + * Asserts that a variable is not of a given type. + * + * @param string $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertNotInstanceOf($expected, $actual, $message = '') + { + if (is_string($expected)) { + if (class_exists($expected) || interface_exists($expected)) { + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_IsInstanceOf($expected) + ); + } + + else { + throw PHPUnit_Util_InvalidArgumentHelper::factory( + 1, 'class or interface name' + ); + } + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + self::assertThat($actual, $constraint, $message); + } + + /** + * Asserts that an attribute is of a given type. + * + * @param string $expected + * @param string $attributeName + * @param mixed $classOrObject + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '') + { + self::assertNotInstanceOf( + $expected, + self::readAttribute($classOrObject, $attributeName), + $message + ); + } + + /** + * Asserts that a variable is of a given type. + * + * @param string $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertInternalType($expected, $actual, $message = '') + { + if (is_string($expected)) { + $constraint = new PHPUnit_Framework_Constraint_IsType( + $expected + ); + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + self::assertThat($actual, $constraint, $message); + } + + /** + * Asserts that an attribute is of a given type. + * + * @param string $expected + * @param string $attributeName + * @param mixed $classOrObject + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '') + { + self::assertInternalType( + $expected, + self::readAttribute($classOrObject, $attributeName), + $message + ); + } + + /** + * Asserts that a variable is not of a given type. + * + * @param string $expected + * @param mixed $actual + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertNotInternalType($expected, $actual, $message = '') + { + if (is_string($expected)) { + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_IsType($expected) + ); + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + self::assertThat($actual, $constraint, $message); + } + + /** + * Asserts that an attribute is of a given type. + * + * @param string $expected + * @param string $attributeName + * @param mixed $classOrObject + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '') + { + self::assertNotInternalType( + $expected, + self::readAttribute($classOrObject, $attributeName), + $message + ); + } + + /** + * Asserts that a string matches a given regular expression. + * + * @param string $pattern + * @param string $string + * @param string $message + */ + public static function assertRegExp($pattern, $string, $message = '') + { + if (!is_string($pattern)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($string)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); + } + + $constraint = new PHPUnit_Framework_Constraint_PCREMatch($pattern); + + self::assertThat($string, $constraint, $message); + } + + /** + * Asserts that a string does not match a given regular expression. + * + * @param string $pattern + * @param string $string + * @param string $message + * @since Method available since Release 2.1.0 + */ + public static function assertNotRegExp($pattern, $string, $message = '') + { + if (!is_string($pattern)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($string)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); + } + + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_PCREMatch($pattern) + ); + + self::assertThat($string, $constraint, $message); + } + + /** + * Assert that the size of two arrays (or `Countable` or `Iterator` objects) + * is the same. + * + * @param integer $expected + * @param mixed $actual + * @param string $message + */ + public function assertSameSize($expected, $actual, $message = '') + { + if (!$expected instanceof Countable && + !$expected instanceof Iterator && + !is_array($expected)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'countable'); + } + + if (!$actual instanceof Countable && + !$actual instanceof Iterator && + !is_array($actual)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'countable'); + } + + self::assertThat( + $actual, + new PHPUnit_Framework_Constraint_SameSize($expected), + $message + ); + } + + /** + * Assert that the size of two arrays (or `Countable` or `Iterator` objects) + * is not the same. + * + * @param integer $expected + * @param mixed $actual + * @param string $message + */ + public function assertNotSameSize($expected, $actual, $message = '') + { + if (!$expected instanceof Countable && + !$expected instanceof Iterator && + !is_array($expected)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'countable'); + } + + if (!$actual instanceof Countable && + !$actual instanceof Iterator && + !is_array($actual)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'countable'); + } + + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_SameSize($expected) + ); + + self::assertThat($actual, $constraint, $message); + } + + /** + * Asserts that a string matches a given format string. + * + * @param string $format + * @param string $string + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertStringMatchesFormat($format, $string, $message = '') + { + if (!is_string($format)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($string)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); + } + + $constraint = new PHPUnit_Framework_Constraint_StringMatches($format); + + self::assertThat($string, $constraint, $message); + } + + /** + * Asserts that a string does not match a given format string. + * + * @param string $format + * @param string $string + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertStringNotMatchesFormat($format, $string, $message = '') + { + if (!is_string($format)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($string)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); + } + + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_StringMatches($format) + ); + + self::assertThat($string, $constraint, $message); + } + + /** + * Asserts that a string matches a given format file. + * + * @param string $formatFile + * @param string $string + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertStringMatchesFormatFile($formatFile, $string, $message = '') + { + self::assertFileExists($formatFile, $message); + + if (!is_string($string)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); + } + + $constraint = new PHPUnit_Framework_Constraint_StringMatches( + file_get_contents($formatFile) + ); + + self::assertThat($string, $constraint, $message); + } + + /** + * Asserts that a string does not match a given format string. + * + * @param string $formatFile + * @param string $string + * @param string $message + * @since Method available since Release 3.5.0 + */ + public static function assertStringNotMatchesFormatFile($formatFile, $string, $message = '') + { + self::assertFileExists($formatFile, $message); + + if (!is_string($string)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); + } + + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_StringMatches( + file_get_contents($formatFile) + ) + ); + + self::assertThat($string, $constraint, $message); + } + + /** + * Asserts that a string starts with a given prefix. + * + * @param string $prefix + * @param string $string + * @param string $message + * @since Method available since Release 3.4.0 + */ + public static function assertStringStartsWith($prefix, $string, $message = '') + { + if (!is_string($prefix)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($string)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); + } + + $constraint = new PHPUnit_Framework_Constraint_StringStartsWith( + $prefix + ); + + self::assertThat($string, $constraint, $message); + } + + /** + * Asserts that a string starts not with a given prefix. + * + * @param string $prefix + * @param string $string + * @param string $message + * @since Method available since Release 3.4.0 + */ + public static function assertStringStartsNotWith($prefix, $string, $message = '') + { + if (!is_string($prefix)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($string)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); + } + + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_StringStartsWith($prefix) + ); + + self::assertThat($string, $constraint, $message); + } + + /** + * Asserts that a string ends with a given prefix. + * + * @param string $suffix + * @param string $string + * @param string $message + * @since Method available since Release 3.4.0 + */ + public static function assertStringEndsWith($suffix, $string, $message = '') + { + if (!is_string($suffix)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($string)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); + } + + $constraint = new PHPUnit_Framework_Constraint_StringEndsWith($suffix); + + self::assertThat($string, $constraint, $message); + } + + /** + * Asserts that a string ends not with a given prefix. + * + * @param string $suffix + * @param string $string + * @param string $message + * @since Method available since Release 3.4.0 + */ + public static function assertStringEndsNotWith($suffix, $string, $message = '') + { + if (!is_string($suffix)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($string)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); + } + + $constraint = new PHPUnit_Framework_Constraint_Not( + new PHPUnit_Framework_Constraint_StringEndsWith($suffix) + ); + + self::assertThat($string, $constraint, $message); + } + + /** + * Asserts that two XML files are equal. + * + * @param string $expectedFile + * @param string $actualFile + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = '') + { + self::assertFileExists($expectedFile); + self::assertFileExists($actualFile); + + $expected = new DOMDocument; + $expected->preserveWhiteSpace = FALSE; + $expected->load($expectedFile); + + $actual = new DOMDocument; + $actual->preserveWhiteSpace = FALSE; + $actual->load($actualFile); + + self::assertEquals($expected, $actual, $message); + } + + /** + * Asserts that two XML files are not equal. + * + * @param string $expectedFile + * @param string $actualFile + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = '') + { + self::assertFileExists($expectedFile); + self::assertFileExists($actualFile); + + $expected = new DOMDocument; + $expected->preserveWhiteSpace = FALSE; + $expected->load($expectedFile); + + $actual = new DOMDocument; + $actual->preserveWhiteSpace = FALSE; + $actual->load($actualFile); + + self::assertNotEquals($expected, $actual, $message); + } + + /** + * Asserts that two XML documents are equal. + * + * @param string $expectedFile + * @param string $actualXml + * @param string $message + * @since Method available since Release 3.3.0 + */ + public static function assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = '') + { + self::assertFileExists($expectedFile); + + $expected = new DOMDocument; + $expected->preserveWhiteSpace = FALSE; + $expected->load($expectedFile); + + $actual = new DOMDocument; + $actual->preserveWhiteSpace = FALSE; + $actual->loadXML($actualXml); + + self::assertEquals($expected, $actual, $message); + } + + /** + * Asserts that two XML documents are not equal. + * + * @param string $expectedFile + * @param string $actualXml + * @param string $message + * @since Method available since Release 3.3.0 + */ + public static function assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = '') + { + self::assertFileExists($expectedFile); + + $expected = new DOMDocument; + $expected->preserveWhiteSpace = FALSE; + $expected->load($expectedFile); + + $actual = new DOMDocument; + $actual->preserveWhiteSpace = FALSE; + $actual->loadXML($actualXml); + + self::assertNotEquals($expected, $actual, $message); + } + + /** + * Asserts that two XML documents are equal. + * + * @param string $expectedXml + * @param string $actualXml + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '') + { + $expected = new DOMDocument; + $expected->preserveWhiteSpace = FALSE; + $expected->loadXML($expectedXml); + + $actual = new DOMDocument; + $actual->preserveWhiteSpace = FALSE; + $actual->loadXML($actualXml); + + self::assertEquals($expected, $actual, $message); + } + + /** + * Asserts that two XML documents are not equal. + * + * @param string $expectedXml + * @param string $actualXml + * @param string $message + * @since Method available since Release 3.1.0 + */ + public static function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = '') + { + $expected = new DOMDocument; + $expected->preserveWhiteSpace = FALSE; + $expected->loadXML($expectedXml); + + $actual = new DOMDocument; + $actual->preserveWhiteSpace = FALSE; + $actual->loadXML($actualXml); + + self::assertNotEquals($expected, $actual, $message); + } + + /** + * Asserts that a hierarchy of DOMElements matches. + * + * @param DOMElement $expectedElement + * @param DOMElement $actualElement + * @param boolean $checkAttributes + * @param string $message + * @author Mattis Stordalen Flister + * @since Method available since Release 3.3.0 + */ + public static function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, $checkAttributes = FALSE, $message = '') + { + self::assertEquals( + $expectedElement->tagName, + $actualElement->tagName, + $message + ); + + if ($checkAttributes) { + self::assertEquals( + $expectedElement->attributes->length, + $actualElement->attributes->length, + sprintf( + '%s%sNumber of attributes on node "%s" does not match', + $message, + !empty($message) ? "\n" : '', + $expectedElement->tagName + ) + ); + + for ($i = 0 ; $i < $expectedElement->attributes->length; $i++) { + $expectedAttribute = $expectedElement->attributes->item($i); + $actualAttribute = $actualElement->attributes->getNamedItem( + $expectedAttribute->name + ); + + if (!$actualAttribute) { + self::fail( + sprintf( + '%s%sCould not find attribute "%s" on node "%s"', + $message, + !empty($message) ? "\n" : '', + $expectedAttribute->name, + $expectedElement->tagName + ) + ); + } + } + } + + PHPUnit_Util_XML::removeCharacterDataNodes($expectedElement); + PHPUnit_Util_XML::removeCharacterDataNodes($actualElement); + + self::assertEquals( + $expectedElement->childNodes->length, + $actualElement->childNodes->length, + sprintf( + '%s%sNumber of child nodes of "%s" differs', + $message, + !empty($message) ? "\n" : '', + $expectedElement->tagName + ) + ); + + for ($i = 0; $i < $expectedElement->childNodes->length; $i++) { + self::assertEqualXMLStructure( + $expectedElement->childNodes->item($i), + $actualElement->childNodes->item($i), + $checkAttributes, + $message + ); + } + } + + /** + * Assert the presence, absence, or count of elements in a document matching + * the CSS $selector, regardless of the contents of those elements. + * + * The first argument, $selector, is the CSS selector used to match + * the elements in the $actual document. + * + * The second argument, $count, can be either boolean or numeric. + * When boolean, it asserts for presence of elements matching the selector + * (TRUE) or absence of elements (FALSE). + * When numeric, it asserts the count of elements. + * + * assertSelectCount("#binder", true, $xml); // any? + * assertSelectCount(".binder", 3, $xml); // exactly 3? + * + * @param array $selector + * @param integer $count + * @param mixed $actual + * @param string $message + * @param boolean $isHtml + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ + public static function assertSelectCount($selector, $count, $actual, $message = '', $isHtml = TRUE) + { + self::assertSelectEquals( + $selector, TRUE, $count, $actual, $message, $isHtml + ); + } + + /** + * assertSelectRegExp("#binder .name", "/Mike|Derek/", true, $xml); // any? + * assertSelectRegExp("#binder .name", "/Mike|Derek/", 3, $xml); // 3? + * + * @param array $selector + * @param string $pattern + * @param integer $count + * @param mixed $actual + * @param string $message + * @param boolean $isHtml + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ + public static function assertSelectRegExp($selector, $pattern, $count, $actual, $message = '', $isHtml = TRUE) + { + self::assertSelectEquals( + $selector, "regexp:$pattern", $count, $actual, $message, $isHtml + ); + } + + /** + * assertSelectEquals("#binder .name", "Chuck", true, $xml); // any? + * assertSelectEquals("#binder .name", "Chuck", false, $xml); // none? + * + * @param array $selector + * @param string $content + * @param integer $count + * @param mixed $actual + * @param string $message + * @param boolean $isHtml + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ + public static function assertSelectEquals($selector, $content, $count, $actual, $message = '', $isHtml = TRUE) + { + $tags = PHPUnit_Util_XML::cssSelect( + $selector, $content, $actual, $isHtml + ); + + // assert specific number of elements + if (is_numeric($count)) { + $counted = $tags ? count($tags) : 0; + self::assertEquals($count, $counted, $message); + } + + // assert any elements exist if true, assert no elements exist if false + else if (is_bool($count)) { + $any = count($tags) > 0 && $tags[0] instanceof DOMNode; + + if ($count) { + self::assertTrue($any, $message); + } else { + self::assertFalse($any, $message); + } + } + + // check for range number of elements + else if (is_array($count) && + (isset($count['>']) || isset($count['<']) || + isset($count['>=']) || isset($count['<=']))) { + $counted = $tags ? count($tags) : 0; + + if (isset($count['>'])) { + self::assertTrue($counted > $count['>'], $message); + } + + if (isset($count['>='])) { + self::assertTrue($counted >= $count['>='], $message); + } + + if (isset($count['<'])) { + self::assertTrue($counted < $count['<'], $message); + } + + if (isset($count['<='])) { + self::assertTrue($counted <= $count['<='], $message); + } + } else { + throw new InvalidArgumentException(); + } + } + + /** + * Evaluate an HTML or XML string and assert its structure and/or contents. + * + * The first argument ($matcher) is an associative array that specifies the + * match criteria for the assertion: + * + * - `id` : the node with the given id attribute must match the + * corresponsing value. + * - `tag` : the node type must match the corresponding value. + * - `attributes` : a hash. The node's attributres must match the + * corresponsing values in the hash. + * - `content` : The text content must match the given value. + * - `parent` : a hash. The node's parent must match the + * corresponsing hash. + * - `child` : a hash. At least one of the node's immediate children + * must meet the criteria described by the hash. + * - `ancestor` : a hash. At least one of the node's ancestors must + * meet the criteria described by the hash. + * - `descendant` : a hash. At least one of the node's descendants must + * meet the criteria described by the hash. + * - `children` : a hash, for counting children of a node. + * Accepts the keys: + * - `count` : a number which must equal the number of children + * that match + * - `less_than` : the number of matching children must be greater + * than this number + * - `greater_than` : the number of matching children must be less than + * this number + * - `only` : another hash consisting of the keys to use to match + * on the children, and only matching children will be + * counted + * + * + * // Matcher that asserts that there is an element with an id="my_id". + * $matcher = array('id' => 'my_id'); + * + * // Matcher that asserts that there is a "span" tag. + * $matcher = array('tag' => 'span'); + * + * // Matcher that asserts that there is a "span" tag with the content + * // "Hello World". + * $matcher = array('tag' => 'span', 'content' => 'Hello World'); + * + * // Matcher that asserts that there is a "span" tag with content matching + * // the regular expression pattern. + * $matcher = array('tag' => 'span', 'content' => 'regexp:/Try P(HP|ython)/'); + * + * // Matcher that asserts that there is a "span" with an "list" class + * // attribute. + * $matcher = array( + * 'tag' => 'span', + * 'attributes' => array('class' => 'list') + * ); + * + * // Matcher that asserts that there is a "span" inside of a "div". + * $matcher = array( + * 'tag' => 'span', + * 'parent' => array('tag' => 'div') + * ); + * + * // Matcher that asserts that there is a "span" somewhere inside a + * // "table". + * $matcher = array( + * 'tag' => 'span', + * 'ancestor' => array('tag' => 'table') + * ); + * + * // Matcher that asserts that there is a "span" with at least one "em" + * // child. + * $matcher = array( + * 'tag' => 'span', + * 'child' => array('tag' => 'em') + * ); + * + * // Matcher that asserts that there is a "span" containing a (possibly + * // nested) "strong" tag. + * $matcher = array( + * 'tag' => 'span', + * 'descendant' => array('tag' => 'strong') + * ); + * + * // Matcher that asserts that there is a "span" containing 5-10 "em" tags + * // as immediate children. + * $matcher = array( + * 'tag' => 'span', + * 'children' => array( + * 'less_than' => 11, + * 'greater_than' => 4, + * 'only' => array('tag' => 'em') + * ) + * ); + * + * // Matcher that asserts that there is a "div", with an "ul" ancestor and + * // a "li" parent (with class="enum"), and containing a "span" descendant + * // that contains an element with id="my_test" and the text "Hello World". + * $matcher = array( + * 'tag' => 'div', + * 'ancestor' => array('tag' => 'ul'), + * 'parent' => array( + * 'tag' => 'li', + * 'attributes' => array('class' => 'enum') + * ), + * 'descendant' => array( + * 'tag' => 'span', + * 'child' => array( + * 'id' => 'my_test', + * 'content' => 'Hello World' + * ) + * ) + * ); + * + * // Use assertTag() to apply a $matcher to a piece of $html. + * $this->assertTag($matcher, $html); + * + * // Use assertTag() to apply a $matcher to a piece of $xml. + * $this->assertTag($matcher, $xml, '', FALSE); + * + * + * The second argument ($actual) is a string containing either HTML or + * XML text to be tested. + * + * The third argument ($message) is an optional message that will be + * used if the assertion fails. + * + * The fourth argument ($html) is an optional flag specifying whether + * to load the $actual string into a DOMDocument using the HTML or + * XML load strategy. It is TRUE by default, which assumes the HTML + * load strategy. In many cases, this will be acceptable for XML as well. + * + * @param array $matcher + * @param string $actual + * @param string $message + * @param boolean $isHtml + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ + public static function assertTag($matcher, $actual, $message = '', $isHtml = TRUE) + { + $dom = PHPUnit_Util_XML::load($actual, $isHtml); + $tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $isHtml); + $matched = count($tags) > 0 && $tags[0] instanceof DOMNode; + + self::assertTrue($matched, $message); + } + + /** + * This assertion is the exact opposite of assertTag(). + * + * Rather than asserting that $matcher results in a match, it asserts that + * $matcher does not match. + * + * @param array $matcher + * @param string $actual + * @param string $message + * @param boolean $isHtml + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ + public static function assertNotTag($matcher, $actual, $message = '', $isHtml = TRUE) + { + $dom = PHPUnit_Util_XML::load($actual, $isHtml); + $tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $isHtml); + $matched = count($tags) > 0 && $tags[0] instanceof DOMNode; + + self::assertFalse($matched, $message); + } + + /** + * Evaluates a PHPUnit_Framework_Constraint matcher object. + * + * @param mixed $value + * @param PHPUnit_Framework_Constraint $constraint + * @param string $message + * @since Method available since Release 3.0.0 + */ + public static function assertThat($value, PHPUnit_Framework_Constraint $constraint, $message = '') + { + self::$count += count($constraint); + + $constraint->evaluate($value, $message); + } + + /** + * Returns a PHPUnit_Framework_Constraint_And matcher object. + * + * @return PHPUnit_Framework_Constraint_And + * @since Method available since Release 3.0.0 + */ + public static function logicalAnd() + { + $constraints = func_get_args(); + + $constraint = new PHPUnit_Framework_Constraint_And; + $constraint->setConstraints($constraints); + + return $constraint; + } + + /** + * Returns a PHPUnit_Framework_Constraint_Or matcher object. + * + * @return PHPUnit_Framework_Constraint_Or + * @since Method available since Release 3.0.0 + */ + public static function logicalOr() + { + $constraints = func_get_args(); + + $constraint = new PHPUnit_Framework_Constraint_Or; + $constraint->setConstraints($constraints); + + return $constraint; + } + + /** + * Returns a PHPUnit_Framework_Constraint_Not matcher object. + * + * @param PHPUnit_Framework_Constraint $constraint + * @return PHPUnit_Framework_Constraint_Not + * @since Method available since Release 3.0.0 + */ + public static function logicalNot(PHPUnit_Framework_Constraint $constraint) + { + return new PHPUnit_Framework_Constraint_Not($constraint); + } + + /** + * Returns a PHPUnit_Framework_Constraint_Xor matcher object. + * + * @return PHPUnit_Framework_Constraint_Xor + * @since Method available since Release 3.0.0 + */ + public static function logicalXor() + { + $constraints = func_get_args(); + + $constraint = new PHPUnit_Framework_Constraint_Xor; + $constraint->setConstraints($constraints); + + return $constraint; + } + + /** + * Returns a PHPUnit_Framework_Constraint_IsAnything matcher object. + * + * @return PHPUnit_Framework_Constraint_IsAnything + * @since Method available since Release 3.0.0 + */ + public static function anything() + { + return new PHPUnit_Framework_Constraint_IsAnything; + } + + /** + * Returns a PHPUnit_Framework_Constraint_IsTrue matcher object. + * + * @return PHPUnit_Framework_Constraint_IsTrue + * @since Method available since Release 3.3.0 + */ + public static function isTrue() + { + return new PHPUnit_Framework_Constraint_IsTrue; + } + + /** + * Returns a PHPUnit_Framework_Constraint_IsFalse matcher object. + * + * @return PHPUnit_Framework_Constraint_IsFalse + * @since Method available since Release 3.3.0 + */ + public static function isFalse() + { + return new PHPUnit_Framework_Constraint_IsFalse; + } + + /** + * Returns a PHPUnit_Framework_Constraint_IsNull matcher object. + * + * @return PHPUnit_Framework_Constraint_IsNull + * @since Method available since Release 3.3.0 + */ + public static function isNull() + { + return new PHPUnit_Framework_Constraint_IsNull; + } + + /** + * Returns a PHPUnit_Framework_Constraint_Attribute matcher object. + * + * @param PHPUnit_Framework_Constraint $constraint + * @param string $attributeName + * @return PHPUnit_Framework_Constraint_Attribute + * @since Method available since Release 3.1.0 + */ + public static function attribute(PHPUnit_Framework_Constraint $constraint, $attributeName) + { + return new PHPUnit_Framework_Constraint_Attribute( + $constraint, $attributeName + ); + } + + /** + * Returns a PHPUnit_Framework_Constraint_TraversableContains matcher + * object. + * + * @param mixed $value + * @param boolean $checkForObjectIdentity + * @return PHPUnit_Framework_Constraint_TraversableContains + * @since Method available since Release 3.0.0 + */ + public static function contains($value, $checkForObjectIdentity = TRUE) + { + return new PHPUnit_Framework_Constraint_TraversableContains($value, $checkForObjectIdentity); + } + + /** + * Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher + * object. + * + * @param string $type + * @return PHPUnit_Framework_Constraint_TraversableContainsOnly + * @since Method available since Release 3.1.4 + */ + public static function containsOnly($type) + { + return new PHPUnit_Framework_Constraint_TraversableContainsOnly($type); + } + + /** + * Returns a PHPUnit_Framework_Constraint_ArrayHasKey matcher object. + * + * @param mixed $key + * @return PHPUnit_Framework_Constraint_ArrayHasKey + * @since Method available since Release 3.0.0 + */ + public static function arrayHasKey($key) + { + return new PHPUnit_Framework_Constraint_ArrayHasKey($key); + } + + /** + * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object. + * + * @param mixed $value + * @param float $delta + * @param integer $maxDepth + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @return PHPUnit_Framework_Constraint_IsEqual + * @since Method available since Release 3.0.0 + */ + public static function equalTo($value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) + { + return new PHPUnit_Framework_Constraint_IsEqual( + $value, $delta, $maxDepth, $canonicalize, $ignoreCase + ); + } + + /** + * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object + * that is wrapped in a PHPUnit_Framework_Constraint_Attribute matcher + * object. + * + * @param string $attributeName + * @param mixed $value + * @param float $delta + * @param integer $maxDepth + * @param boolean $canonicalize + * @param boolean $ignoreCase + * @return PHPUnit_Framework_Constraint_Attribute + * @since Method available since Release 3.1.0 + */ + public static function attributeEqualTo($attributeName, $value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) + { + return self::attribute( + self::equalTo( + $value, $delta, $maxDepth, $canonicalize, $ignoreCase + ), + $attributeName + ); + } + + /** + * Returns a PHPUnit_Framework_Constraint_IsEmpty matcher object. + * + * @return PHPUnit_Framework_Constraint_IsEmpty + * @since Method available since Release 3.5.0 + */ + public static function isEmpty() + { + return new PHPUnit_Framework_Constraint_IsEmpty; + } + /** + * Returns a PHPUnit_Framework_Constraint_FileExists matcher object. + * + * @return PHPUnit_Framework_Constraint_FileExists + * @since Method available since Release 3.0.0 + */ + public static function fileExists() + { + return new PHPUnit_Framework_Constraint_FileExists; + } + + /** + * Returns a PHPUnit_Framework_Constraint_GreaterThan matcher object. + * + * @param mixed $value + * @return PHPUnit_Framework_Constraint_GreaterThan + * @since Method available since Release 3.0.0 + */ + public static function greaterThan($value) + { + return new PHPUnit_Framework_Constraint_GreaterThan($value); + } + + /** + * Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps + * a PHPUnit_Framework_Constraint_IsEqual and a + * PHPUnit_Framework_Constraint_GreaterThan matcher object. + * + * @param mixed $value + * @return PHPUnit_Framework_Constraint_Or + * @since Method available since Release 3.1.0 + */ + public static function greaterThanOrEqual($value) + { + return self::logicalOr( + new PHPUnit_Framework_Constraint_IsEqual($value), + new PHPUnit_Framework_Constraint_GreaterThan($value) + ); + } + + /** + * Returns a PHPUnit_Framework_Constraint_ClassHasAttribute matcher object. + * + * @param string $attributeName + * @return PHPUnit_Framework_Constraint_ClassHasAttribute + * @since Method available since Release 3.1.0 + */ + public static function classHasAttribute($attributeName) + { + return new PHPUnit_Framework_Constraint_ClassHasAttribute( + $attributeName + ); + } + + /** + * Returns a PHPUnit_Framework_Constraint_ClassHasStaticAttribute matcher + * object. + * + * @param string $attributeName + * @return PHPUnit_Framework_Constraint_ClassHasStaticAttribute + * @since Method available since Release 3.1.0 + */ + public static function classHasStaticAttribute($attributeName) + { + return new PHPUnit_Framework_Constraint_ClassHasStaticAttribute( + $attributeName + ); + } + + /** + * Returns a PHPUnit_Framework_Constraint_ObjectHasAttribute matcher object. + * + * @param string $attributeName + * @return PHPUnit_Framework_Constraint_ObjectHasAttribute + * @since Method available since Release 3.0.0 + */ + public static function objectHasAttribute($attributeName) + { + return new PHPUnit_Framework_Constraint_ObjectHasAttribute( + $attributeName + ); + } + + /** + * Returns a PHPUnit_Framework_Constraint_IsIdentical matcher object. + * + * @param mixed $value + * @return PHPUnit_Framework_Constraint_IsIdentical + * @since Method available since Release 3.0.0 + */ + public static function identicalTo($value) + { + return new PHPUnit_Framework_Constraint_IsIdentical($value); + } + + /** + * Returns a PHPUnit_Framework_Constraint_IsInstanceOf matcher object. + * + * @param string $className + * @return PHPUnit_Framework_Constraint_IsInstanceOf + * @since Method available since Release 3.0.0 + */ + public static function isInstanceOf($className) + { + return new PHPUnit_Framework_Constraint_IsInstanceOf($className); + } + + /** + * Returns a PHPUnit_Framework_Constraint_IsType matcher object. + * + * @param string $type + * @return PHPUnit_Framework_Constraint_IsType + * @since Method available since Release 3.0.0 + */ + public static function isType($type) + { + return new PHPUnit_Framework_Constraint_IsType($type); + } + + /** + * Returns a PHPUnit_Framework_Constraint_LessThan matcher object. + * + * @param mixed $value + * @return PHPUnit_Framework_Constraint_LessThan + * @since Method available since Release 3.0.0 + */ + public static function lessThan($value) + { + return new PHPUnit_Framework_Constraint_LessThan($value); + } + + /** + * Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps + * a PHPUnit_Framework_Constraint_IsEqual and a + * PHPUnit_Framework_Constraint_LessThan matcher object. + * + * @param mixed $value + * @return PHPUnit_Framework_Constraint_Or + * @since Method available since Release 3.1.0 + */ + public static function lessThanOrEqual($value) + { + return self::logicalOr( + new PHPUnit_Framework_Constraint_IsEqual($value), + new PHPUnit_Framework_Constraint_LessThan($value) + ); + } + + /** + * Returns a PHPUnit_Framework_Constraint_PCREMatch matcher object. + * + * @param string $pattern + * @return PHPUnit_Framework_Constraint_PCREMatch + * @since Method available since Release 3.0.0 + */ + public static function matchesRegularExpression($pattern) + { + return new PHPUnit_Framework_Constraint_PCREMatch($pattern); + } + + /** + * Returns a PHPUnit_Framework_Constraint_StringMatches matcher object. + * + * @param string $string + * @return PHPUnit_Framework_Constraint_StringMatches + * @since Method available since Release 3.5.0 + */ + public static function matches($string) + { + return new PHPUnit_Framework_Constraint_StringMatches($string); + } + + /** + * Returns a PHPUnit_Framework_Constraint_StringStartsWith matcher object. + * + * @param mixed $prefix + * @return PHPUnit_Framework_Constraint_StringStartsWith + * @since Method available since Release 3.4.0 + */ + public static function stringStartsWith($prefix) + { + return new PHPUnit_Framework_Constraint_StringStartsWith($prefix); + } + + /** + * Returns a PHPUnit_Framework_Constraint_StringContains matcher object. + * + * @param string $string + * @param boolean $case + * @return PHPUnit_Framework_Constraint_StringContains + * @since Method available since Release 3.0.0 + */ + public static function stringContains($string, $case = TRUE) + { + return new PHPUnit_Framework_Constraint_StringContains($string, $case); + } + + /** + * Returns a PHPUnit_Framework_Constraint_StringEndsWith matcher object. + * + * @param mixed $suffix + * @return PHPUnit_Framework_Constraint_StringEndsWith + * @since Method available since Release 3.4.0 + */ + public static function stringEndsWith($suffix) + { + return new PHPUnit_Framework_Constraint_StringEndsWith($suffix); + } + + /** + * Fails a test with the given message. + * + * @param string $message + * @throws PHPUnit_Framework_AssertionFailedError + */ + public static function fail($message = '') + { + throw new PHPUnit_Framework_AssertionFailedError($message); + } + + /** + * Returns the value of an attribute of a class or an object. + * This also works for attributes that are declared protected or private. + * + * @param mixed $classOrObject + * @param string $attributeName + * @return mixed + * @throws InvalidArgumentException + */ + public static function readAttribute($classOrObject, $attributeName) + { + if (!is_string($attributeName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); + } + + if (is_string($classOrObject)) { + if (!class_exists($classOrObject)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory( + 1, 'class name' + ); + } + + return PHPUnit_Util_Class::getStaticAttribute( + $classOrObject, + $attributeName + ); + } + + else if (is_object($classOrObject)) { + return PHPUnit_Util_Class::getObjectAttribute( + $classOrObject, + $attributeName + ); + } + + else { + throw PHPUnit_Util_InvalidArgumentHelper::factory( + 1, 'class name or object' + ); + } + } + + /** + * Mark the test as incomplete. + * + * @param string $message + * @throws PHPUnit_Framework_IncompleteTestError + * @since Method available since Release 3.0.0 + */ + public static function markTestIncomplete($message = '') + { + throw new PHPUnit_Framework_IncompleteTestError($message); + } + + /** + * Mark the test as skipped. + * + * @param string $message + * @throws PHPUnit_Framework_SkippedTestError + * @since Method available since Release 3.0.0 + */ + public static function markTestSkipped($message = '') + { + throw new PHPUnit_Framework_SkippedTestError($message); + } + + /** + * Return the current assertion count. + * + * @return integer + * @since Method available since Release 3.3.3 + */ + public static function getCount() + { + return self::$count; + } + + /** + * Reset the assertion counter. + * + * @since Method available since Release 3.3.3 + */ + public static function resetCount() + { + self::$count = 0; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/AssertionFailedError.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/AssertionFailedError.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/AssertionFailedError.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/AssertionFailedError.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,69 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * Thrown when an assertion failed. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_Framework_AssertionFailedError extends Exception implements PHPUnit_Framework_SelfDescribing +{ + /** + * Wrapper for getMessage() which is declared as final. + * + * @return string + */ + public function toString() + { + return $this->getMessage(); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Array.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Array.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Array.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Array.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,178 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Compares arrays for equality. + * + * @package PHPUnit + * @subpackage Framework_Comparator + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_Comparator_Array extends PHPUnit_Framework_Comparator +{ + /** + * Returns whether the comparator can compare two values. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @return boolean + */ + public function accepts($expected, $actual) + { + return is_array($expected) && is_array($actual); + } + + /** + * Asserts that two values are equal. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @param float $delta The allowed numerical distance between two values to + * consider them equal + * @param bool $canonicalize If set to TRUE, arrays are sorted before + * comparison + * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is + * ignored when comparing string values + * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison + * fails. Contains information about the + * specific errors that lead to the failure. + */ + public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE, array &$processed = array()) + { + if ($canonicalize) { + sort($expected); + sort($actual); + } + + $remaining = $actual; + $expString = $actString = "Array (\n"; + $equal = TRUE; + + foreach ($expected as $key => $value) { + unset($remaining[$key]); + + if (!array_key_exists($key, $actual)) { + $expString .= sprintf( + " %s => %s\n", + + PHPUnit_Util_Type::export($key), + PHPUnit_Util_Type::shortenedExport($value) + ); + $equal = FALSE; + continue; + } + + try { + $this->factory->getComparatorFor($value, $actual[$key])->assertEquals($value, $actual[$key], $delta, $canonicalize, $ignoreCase, $processed); + $expString .= sprintf( + " %s => %s\n", + + PHPUnit_Util_Type::export($key), + PHPUnit_Util_Type::shortenedExport($value) + ); + $actString .= sprintf( + " %s => %s\n", + + PHPUnit_Util_Type::export($key), + PHPUnit_Util_Type::shortenedExport($actual[$key]) + ); + } + + catch (PHPUnit_Framework_ComparisonFailure $e) { + $expString .= sprintf( + " %s => %s\n", + + PHPUnit_Util_Type::export($key), + $e->getExpectedAsString() + ? $this->indent($e->getExpectedAsString()) + : PHPUnit_Util_Type::shortenedExport($e->getExpected()) + ); + $actString .= sprintf( + " %s => %s\n", + + PHPUnit_Util_Type::export($key), + $e->getActualAsString() + ? $this->indent($e->getActualAsString()) + : PHPUnit_Util_Type::shortenedExport($e->getActual()) + ); + $equal = FALSE; + } + } + + foreach ($remaining as $key => $value) { + $actString .= sprintf( + " %s => %s\n", + + PHPUnit_Util_Type::export($key), + PHPUnit_Util_Type::shortenedExport($value) + ); + $equal = FALSE; + } + + $expString .= ')'; + $actString .= ')'; + + if (!$equal) { + throw new PHPUnit_Framework_ComparisonFailure( + $expected, + $actual, + $expString, + $actString, + FALSE, + 'Failed asserting that two arrays are equal.' + ); + } + } + + protected function indent($lines) + { + return trim(str_replace("\n", "\n ", $lines)); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/DOMDocument.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/DOMDocument.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/DOMDocument.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/DOMDocument.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,115 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Compares DOMDocument instances for equality. + * + * @package PHPUnit + * @subpackage Framework_Comparator + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_Comparator_DOMDocument extends PHPUnit_Framework_Comparator_Object +{ + /** + * Returns whether the comparator can compare two values. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @return boolean + */ + public function accepts($expected, $actual) + { + return $expected instanceof DOMDocument && $actual instanceof DOMDocument; + } + + /** + * Asserts that two values are equal. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @param float $delta The allowed numerical distance between two values to + * consider them equal + * @param bool $canonicalize If set to TRUE, arrays are sorted before + * comparison + * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is + * ignored when comparing string values + * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison + * fails. Contains information about the + * specific errors that lead to the failure. + */ + public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) + { + if ($expected->C14N() !== $actual->C14N()) { + throw new PHPUnit_Framework_ComparisonFailure( + $expected, + $actual, + $this->domToText($expected), + $this->domToText($actual), + FALSE, + 'Failed asserting that two DOM documents are equal.' + ); + } + } + + /** + * Returns the normalized, whitespace-cleaned, and indented textual + * representation of a DOMDocument. + * + * @param DOMDocument $document + * @return string + */ + protected function domToText(DOMDocument $document) + { + $document->formatOutput = TRUE; + $document->normalizeDocument(); + + return $document->saveXML(); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Double.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Double.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Double.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Double.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,102 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Compares doubles for equality. + * + * @package PHPUnit + * @subpackage Framework_Comparator + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_Comparator_Double extends PHPUnit_Framework_Comparator_Numeric +{ + /** + * Smallest value available in PHP. + * + * @var float + */ + const EPSILON = 0.0000000001; + + /** + * Returns whether the comparator can compare two values. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @return boolean + */ + public function accepts($expected, $actual) + { + return (is_double($expected) || is_double($actual)) && is_numeric($expected) && is_numeric($actual); + } + + /** + * Asserts that two values are equal. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @param float $delta The allowed numerical distance between two values to + * consider them equal + * @param bool $canonicalize If set to TRUE, arrays are sorted before + * comparison + * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is + * ignored when comparing string values + * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison + * fails. Contains information about the + * specific errors that lead to the failure. + */ + public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) + { + if ($delta == 0) { + $delta = self::EPSILON; + } + + parent::assertEquals($expected, $actual, $delta, $canonicalize, $ignoreCase); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Exception.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Exception.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Exception.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Exception.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,93 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Compares Exception instances for equality. + * + * @package PHPUnit + * @subpackage Framework_Comparator + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_Comparator_Exception extends PHPUnit_Framework_Comparator_Object +{ + /** + * Returns whether the comparator can compare two values. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @return boolean + */ + public function accepts($expected, $actual) + { + return $expected instanceof Exception && $actual instanceof Exception; + } + + /** + * Converts an object to an array containing all of its private, protected + * and public properties. + * + * @param object $object + * @return array + */ + protected function toArray($object) + { + $array = parent::toArray($object); + + unset( + $array['file'], + $array['line'], + $array['trace'], + $array['string'], // some internal property of Exception + $array['xdebug_message'] // some internal property added by XDebug + ); + + return $array; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/MockObject.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/MockObject.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/MockObject.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/MockObject.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,87 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Compares PHPUnit_Framework_MockObject_MockObject instances for equality. + * + * @package PHPUnit + * @subpackage Framework_Comparator + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_Comparator_MockObject extends PHPUnit_Framework_Comparator_Object +{ + /** + * Returns whether the comparator can compare two values. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @return boolean + */ + public function accepts($expected, $actual) + { + return $expected instanceof PHPUnit_Framework_MockObject_MockObject && $actual instanceof PHPUnit_Framework_MockObject_MockObject; + } + + /** + * Converts an object to an array containing all of its private, protected + * and public properties. + * + * @param object $object + * @return array + */ + protected function toArray($object) + { + $array = parent::toArray($object); + + unset($array['invocationMocker']); + + return $array; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Numeric.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Numeric.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Numeric.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Numeric.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,117 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Compares numerical values for equality. + * + * @package PHPUnit + * @subpackage Framework_Comparator + * @author Bernhard Schussek + * @author Alexander + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_Comparator_Numeric extends PHPUnit_Framework_Comparator_Scalar +{ + /** + * Returns whether the comparator can compare two values. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @return boolean + */ + public function accepts($expected, $actual) + { + // all numerical values, but not if one of them is a double + return is_numeric($expected) && is_numeric($actual) && !(is_double($expected) || is_double($actual)); + } + + /** + * Asserts that two values are equal. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @param float $delta The allowed numerical distance between two values to + * consider them equal + * @param bool $canonicalize If set to TRUE, arrays are sorted before + * comparison + * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is + * ignored when comparing string values + * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison + * fails. Contains information about the + * specific errors that lead to the failure. + */ + public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) + { + if (is_infinite($actual) && is_infinite($expected)) { + return; + } + + if (is_nan($actual) && is_nan($expected)) { + return; + } + + if ((is_infinite($actual) XOR is_infinite($expected)) || + (is_nan($actual) XOR is_nan($expected)) || + abs($actual - $expected) > $delta) { + throw new PHPUnit_Framework_ComparisonFailure( + $expected, + $actual, + '', + '', + FALSE, + sprintf( + 'Failed asserting that %s matches expected %s.', + + PHPUnit_Util_Type::export($actual), + PHPUnit_Util_Type::export($expected) + ) + ); + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Object.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Object.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Object.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Object.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,146 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Compares objects for equality. + * + * @package PHPUnit + * @subpackage Framework_Comparator + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_Comparator_Object extends PHPUnit_Framework_Comparator_Array +{ + /** + * Returns whether the comparator can compare two values. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @return boolean + */ + public function accepts($expected, $actual) + { + return is_object($expected) && is_object($actual); + } + + /** + * Asserts that two values are equal. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @param float $delta The allowed numerical distance between two values to + * consider them equal + * @param bool $canonicalize If set to TRUE, arrays are sorted before + * comparison + * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is + * ignored when comparing string values + * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison + * fails. Contains information about the + * specific errors that lead to the failure. + */ + public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE, array &$processed = array()) + { + if (get_class($actual) !== get_class($expected)) { + throw new PHPUnit_Framework_ComparisonFailure( + $expected, + $actual, + PHPUnit_Util_Type::export($expected), + PHPUnit_Util_Type::export($actual), + FALSE, + sprintf( + '%s is not instance of expected class "%s".', + + PHPUnit_Util_Type::export($actual), + get_class($expected) + ) + ); + } + + // don't compare twice to allow for cyclic dependencies + if (in_array(array($actual, $expected), $processed, TRUE) || + in_array(array($expected, $actual), $processed, TRUE)) { + return; + } + + $processed[] = array($actual, $expected); + + // don't compare objects if they are identical + // this helps to avoid the error "maximum function nesting level reached" + // CAUTION: this conditional clause is not tested + if ($actual !== $expected) { + try { + parent::assertEquals($this->toArray($expected), $this->toArray($actual), $delta, $canonicalize, $ignoreCase, $processed); + } + + catch (PHPUnit_Framework_ComparisonFailure $e) { + throw new PHPUnit_Framework_ComparisonFailure( + $expected, + $actual, + // replace "Array" with "MyClass object" + substr_replace($e->getExpectedAsString(), get_class($expected) . ' Object', 0, 5), + substr_replace($e->getActualAsString(), get_class($actual) . ' Object', 0, 5), + FALSE, + 'Failed asserting that two objects are equal.' + ); + } + } + } + + /** + * Converts an object to an array containing all of its private, protected + * and public properties. + * + * @param object $object + * @return array + */ + protected function toArray($object) + { + return PHPUnit_Util_Type::toArray($object); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Resource.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Resource.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Resource.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Resource.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,98 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Compares resources for equality. + * + * @package PHPUnit + * @subpackage Framework_Comparator + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_Comparator_Resource extends PHPUnit_Framework_Comparator +{ + /** + * Returns whether the comparator can compare two values. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @return boolean + */ + public function accepts($expected, $actual) + { + return is_resource($expected) && is_resource($actual); + } + + /** + * Asserts that two values are equal. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @param float $delta The allowed numerical distance between two values to + * consider them equal + * @param bool $canonicalize If set to TRUE, arrays are sorted before + * comparison + * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is + * ignored when comparing string values + * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison + * fails. Contains information about the + * specific errors that lead to the failure. + */ + public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) + { + if ($actual != $expected) { + throw new PHPUnit_Framework_ComparisonFailure( + $expected, + $actual, + PHPUnit_Util_Type::export($expected), + PHPUnit_Util_Type::export($actual) + ); + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Scalar.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Scalar.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Scalar.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Scalar.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,137 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Compares scalar or NULL values for equality. + * + * @package PHPUnit + * @subpackage Framework_Comparator + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_Comparator_Scalar extends PHPUnit_Framework_Comparator +{ + /** + * Returns whether the comparator can compare two values. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @return boolean + * @since Method available since Release 3.6.0 + */ + public function accepts($expected, $actual) + { + return ((is_scalar($expected) XOR NULL === $expected) && + (is_scalar($actual) XOR NULL === $actual)) + // allow comparison between strings and objects featuring __toString() + || (is_string($expected) && is_object($actual) && method_exists($actual, '__toString')) + || (is_object($expected) && method_exists($expected, '__toString') && is_string($actual)); + } + + /** + * Asserts that two values are equal. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @param float $delta The allowed numerical distance between two values to + * consider them equal + * @param bool $canonicalize If set to TRUE, arrays are sorted before + * comparison + * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is + * ignored when comparing string values + * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison + * fails. Contains information about the + * specific errors that lead to the failure. + */ + public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) + { + $expectedToCompare = $expected; + $actualToCompare = $actual; + + // always compare as strings to avoid strange behaviour + // otherwise 0 == 'Foobar' + if (is_string($expected) || is_string($actual)) { + $expectedToCompare = (string)$expectedToCompare; + $actualToCompare = (string)$actualToCompare; + + if ($ignoreCase) { + $expectedToCompare = strtolower($expectedToCompare); + $actualToCompare = strtolower($actualToCompare); + } + } + + if ($expectedToCompare != $actualToCompare) { + if (is_string($expected) && is_string($actual)) { + throw new PHPUnit_Framework_ComparisonFailure( + $expected, + $actual, + PHPUnit_Util_Type::export($expected), + PHPUnit_Util_Type::export($actual), + FALSE, + 'Failed asserting that two strings are equal.' + ); + } + + throw new PHPUnit_Framework_ComparisonFailure( + $expected, + $actual, + // no diff is required + '', + '', + FALSE, + sprintf( + 'Failed asserting that %s matches expected %s.', + + PHPUnit_Util_Type::export($actual), + PHPUnit_Util_Type::export($expected) + ) + ); + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/SplObjectStorage.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/SplObjectStorage.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/SplObjectStorage.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/SplObjectStorage.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,115 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Compares SplObjectStorage instances for equality. + * + * @package PHPUnit + * @subpackage Framework_Comparator + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_Comparator_SplObjectStorage extends PHPUnit_Framework_Comparator +{ + /** + * Returns whether the comparator can compare two values. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @return boolean + */ + public function accepts($expected, $actual) + { + return $expected instanceof SplObjectStorage && $actual instanceof SplObjectStorage; + } + + /** + * Asserts that two values are equal. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @param float $delta The allowed numerical distance between two values to + * consider them equal + * @param bool $canonicalize If set to TRUE, arrays are sorted before + * comparison + * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is + * ignored when comparing string values + * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison + * fails. Contains information about the + * specific errors that lead to the failure. + */ + public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) + { + foreach ($actual as $object) { + if (!$expected->contains($object)) { + throw new PHPUnit_Framework_ComparisonFailure( + $expected, + $actual, + PHPUnit_Util_Type::export($expected), + PHPUnit_Util_Type::export($actual), + FALSE, + 'Failed asserting that two objects are equal.' + ); + } + } + + foreach ($expected as $object) { + if (!$actual->contains($object)) { + throw new PHPUnit_Framework_ComparisonFailure( + $expected, + $actual, + PHPUnit_Util_Type::export($expected), + PHPUnit_Util_Type::export($actual), + FALSE, + 'Failed asserting that two objects are equal.' + ); + } + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Type.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Type.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Type.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator/Type.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,106 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Compares values for type equality. + * + * @package PHPUnit + * @subpackage Framework_Comparator + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_Comparator_Type extends PHPUnit_Framework_Comparator +{ + /** + * Returns whether the comparator can compare two values. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @return boolean + */ + public function accepts($expected, $actual) + { + return TRUE; + } + + /** + * Asserts that two values are equal. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @param float $delta The allowed numerical distance between two values to + * consider them equal + * @param bool $canonicalize If set to TRUE, arrays are sorted before + * comparison + * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is + * ignored when comparing string values + * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison + * fails. Contains information about the + * specific errors that lead to the failure. + */ + public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) + { + if (gettype($expected) != gettype($actual)) { + throw new PHPUnit_Framework_ComparisonFailure( + $expected, + $actual, + // we don't need a diff + '', + '', + FALSE, + sprintf( + '%s does not match expected type "%s".', + + PHPUnit_Util_Type::shortenedExport($actual), + gettype($expected) + ) + ); + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Comparator.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Comparator.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,98 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Abstract base class for comparators which compare values for equality. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +abstract class PHPUnit_Framework_Comparator +{ + /** + * @var PHPUnit_Framework_ComparatorFactory + */ + protected $factory; + + /** + * @param PHPUnit_Framework_ComparatorFactory $factory + */ + public function setFactory(PHPUnit_Framework_ComparatorFactory $factory) + { + $this->factory = $factory; + } + + /** + * Returns whether the comparator can compare two values. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @return boolean + */ + abstract public function accepts($expected, $actual); + + /** + * Asserts that two values are equal. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @param float $delta The allowed numerical distance between two values to + * consider them equal + * @param bool $canonicalize If set to TRUE, arrays are sorted before + * comparison + * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is + * ignored when comparing string values + * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison + * fails. Contains information about the + * specific errors that lead to the failure. + */ + abstract public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE); +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/ComparatorFactory.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/ComparatorFactory.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/ComparatorFactory.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/ComparatorFactory.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,156 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Factory for comparators which compare values for equality. + * + * @package PHPUnit + * @subpackage Framework + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_ComparatorFactory +{ + /** + * @var array + */ + protected $comparators = array(); + + /** + * @var PHPUnit_Framework_ComparatorFactory + */ + private static $defaultInstance = NULL; + + /** + * Constructs a new factory. + */ + public function __construct() + { + $this->register(new PHPUnit_Framework_Comparator_Type); + $this->register(new PHPUnit_Framework_Comparator_Scalar); + $this->register(new PHPUnit_Framework_Comparator_Numeric); + $this->register(new PHPUnit_Framework_Comparator_Double); + $this->register(new PHPUnit_Framework_Comparator_Array); + $this->register(new PHPUnit_Framework_Comparator_Resource); + $this->register(new PHPUnit_Framework_Comparator_Object); + $this->register(new PHPUnit_Framework_Comparator_Exception); + $this->register(new PHPUnit_Framework_Comparator_SplObjectStorage); + $this->register(new PHPUnit_Framework_Comparator_DOMDocument); + $this->register(new PHPUnit_Framework_Comparator_MockObject); + } + + /** + * Returns the default instance. + * + * @return PHPUnit_Framework_ComparatorFactory + */ + public static function getDefaultInstance() + { + if (self::$defaultInstance === NULL) { + self::$defaultInstance = new PHPUnit_Framework_ComparatorFactory; + } + + return self::$defaultInstance; + } + + /** + * Returns the correct comparator for comparing two values. + * + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * @return PHPUnit_Framework_Comparator + */ + public function getComparatorFor($expected, $actual) + { + foreach ($this->comparators as $comparator) { + if ($comparator->accepts($expected, $actual)) { + return $comparator; + } + } + + throw new InvalidArgumentException( + sprintf( + 'No comparator is registered for comparing the types "%s" and "%s"', + gettype($expected), gettype($actual) + ) + ); + } + + /** + * Registers a new comparator. + * + * This comparator will be returned by getInstance() if its accept() method + * returns TRUE for the compared values. It has higher priority than the + * existing comparators, meaning that its accept() method will be tested + * before those of the other comparators. + * + * @param PHPUnit_Framework_Comparator $comparator The registered comparator + */ + public function register(PHPUnit_Framework_Comparator $comparator) + { + array_unshift($this->comparators, $comparator); + $comparator->setFactory($this); + } + + /** + * Unregisters a comparator. + * + * This comparator will no longer be returned by getInstance(). + * + * @param PHPUnit_Framework_Comparator $comparator The unregistered comparator + */ + public function unregister(PHPUnit_Framework_Comparator $comparator) + { + foreach ($this->comparators as $key => $_comparator) { + if ($comparator === $_comparator) { + unset($this->comparators[$key]); + } + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/ComparisonFailure.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/ComparisonFailure.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/ComparisonFailure.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/ComparisonFailure.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,165 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * Thrown when an assertion for string equality failed. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_Framework_ComparisonFailure extends PHPUnit_Framework_AssertionFailedError +{ + /** + * Expected value of the retrieval which does not match $actual. + * @var mixed + */ + protected $expected; + + /** + * Actually retrieved value which does not match $expected. + * @var mixed + */ + protected $actual; + + /** + * The string representation of the expected value + * @var string + */ + protected $expectedAsString; + + /** + * The string representation of the actual value + * @var string + */ + protected $actualAsString; + + /** + * @var boolean + */ + protected $identical; + + /** + * Optional message which is placed in front of the first line + * returned by toString(). + * @var string + */ + protected $message; + + /** + * Initialises with the expected value and the actual value. + * + * @param mixed $expected Expected value retrieved. + * @param mixed $actual Actual value retrieved. + * @param boolean $identical + * @param string $message A string which is prefixed on all returned lines + * in the difference output. + */ + public function __construct($expected, $actual, $expectedAsString, $actualAsString, $identical = FALSE, $message = '') + { + $this->expected = $expected; + $this->actual = $actual; + $this->expectedAsString = $expectedAsString; + $this->actualAsString = $actualAsString; + $this->message = $message; + } + + /** + * @return mixed + */ + public function getActual() + { + return $this->actual; + } + + /** + * @return mixed + */ + public function getExpected() + { + return $this->expected; + } + + /** + * @return string + */ + public function getActualAsString() + { + return $this->actualAsString; + } + + /** + * @return string + */ + public function getExpectedAsString() + { + return $this->expectedAsString; + } + + /** + * @return string + */ + public function getDiff() + { + return $this->actualAsString || $this->expectedAsString + ? PHPUnit_Util_Diff::diff($this->expectedAsString, $this->actualAsString) + : ''; + } + + /** + * @return string + */ + public function toString() + { + return $this->message . $this->getDiff(); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/And.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/And.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/And.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/And.php 2012-01-27 10:49:18.000000000 +0000 @@ -0,0 +1,164 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Logical AND. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_And extends PHPUnit_Framework_Constraint +{ + /** + * @var PHPUnit_Framework_Constraint[] + */ + protected $constraints = array(); + + /** + * @var PHPUnit_Framework_Constraint + */ + protected $lastConstraint = NULL; + + /** + * @param PHPUnit_Framework_Constraint[] $constraints + */ + public function setConstraints(array $constraints) + { + $this->constraints = array(); + + foreach ($constraints as $key => $constraint) { + if (!($constraint instanceof PHPUnit_Framework_Constraint)) { + throw new InvalidArgumentException( + 'All parameters to ' . __CLASS__ . + ' must be a constraint object.' + ); + } + + $this->constraints[] = $constraint; + } + } + + /** + * Evaluates the constraint for parameter $other + * + * If $returnResult is set to FALSE (the default), an exception is thrown + * in case of a failure. NULL is returned otherwise. + * + * If $returnResult is TRUE, the result of the evaluation is returned as + * a boolean value instead: TRUE in case of success, FALSE in case of a + * failure. + * + * @param mixed $other Value or object to evaluate. + * @param string $description Additional information about the test + * @param bool $returnResult Whether to return a result or throw an exception + * @return mixed + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function evaluate($other, $description = '', $returnResult = FALSE) + { + $success = TRUE; + $constraint = NULL; + + foreach ($this->constraints as $constraint) { + if (!$constraint->evaluate($other, $description, TRUE)) { + $success = FALSE; + break; + } + } + + if ($returnResult) { + return $success; + } + + if (!$success) { + $this->fail($other, $description); + } + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + $text = ''; + + foreach ($this->constraints as $key => $constraint) { + if ($key > 0) { + $text .= ' and '; + } + + $text .= $constraint->toString(); + } + + return $text; + } + + /** + * Counts the number of constraint elements. + * + * @return integer + * @since Method available since Release 3.4.0 + */ + public function count() + { + $count = 0; + + foreach ($this->constraints as $constraint) { + $count += count($constraint); + } + + return $count; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ArrayHasKey.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ArrayHasKey.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ArrayHasKey.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ArrayHasKey.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,115 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Constraint that asserts that the array it is evaluated for has a given key. + * + * Uses array_key_exists() to check if the key is found in the input array, if + * not found the evaluaton fails. + * + * The array key is passed in the constructor. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_ArrayHasKey extends PHPUnit_Framework_Constraint +{ + /** + * @var integer|string + */ + protected $key; + + /** + * @param integer|string $key + */ + public function __construct($key) + { + $this->key = $key; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return array_key_exists($this->key, $other); + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'has the key ' . PHPUnit_Util_Type::export($this->key); + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + return 'an array ' . $this->toString(); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Attribute.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Attribute.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Attribute.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Attribute.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,130 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.1.0 + */ + +/** + * + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.1.0 + */ + +class PHPUnit_Framework_Constraint_Attribute extends PHPUnit_Framework_Constraint_Composite +{ + /** + * @var string + */ + protected $attributeName; + + /** + * @param PHPUnit_Framework_Constraint $constraint + * @param string $attributeName + */ + public function __construct(PHPUnit_Framework_Constraint $constraint, $attributeName) + { + parent::__construct($constraint); + + $this->attributeName = $attributeName; + } + + /** + * Evaluates the constraint for parameter $other + * + * If $returnResult is set to FALSE (the default), an exception is thrown + * in case of a failure. NULL is returned otherwise. + * + * If $returnResult is TRUE, the result of the evaluation is returned as + * a boolean value instead: TRUE in case of success, FALSE in case of a + * failure. + * + * @param mixed $other Value or object to evaluate. + * @param string $description Additional information about the test + * @param bool $returnResult Whether to return a result or throw an exception + * @return mixed + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function evaluate($other, $description = '', $returnResult = FALSE) + { + return parent::evaluate( + PHPUnit_Framework_Assert::readAttribute( + $other, $this->attributeName + ), + $description, + $returnResult + ); + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'attribute "' . $this->attributeName . '" ' . + $this->innerConstraint->toString(); + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + return $this->toString(); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ClassHasAttribute.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ClassHasAttribute.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ClassHasAttribute.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ClassHasAttribute.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,125 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.1.0 + */ + +/** + * Constraint that asserts that the class it is evaluated for has a given + * attribute. + * + * The attribute name is passed in the constructor. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.1.0 + */ +class PHPUnit_Framework_Constraint_ClassHasAttribute extends PHPUnit_Framework_Constraint +{ + /** + * @var string + */ + protected $attributeName; + + /** + * @param string $attributeName + */ + public function __construct($attributeName) + { + $this->attributeName = $attributeName; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + $class = new ReflectionClass($other); + + return $class->hasProperty($this->attributeName); + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return sprintf( + 'has attribute "%s"', + + $this->attributeName + ); + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + return sprintf( + '%sclass "%s" %s', + + is_object($other) ? 'object of ' : '', + is_object($other) ? get_class($other) : $other, + $this->toString() + ); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ClassHasStaticAttribute.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ClassHasStaticAttribute.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ClassHasStaticAttribute.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ClassHasStaticAttribute.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,99 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.1.0 + */ + +/** + * Constraint that asserts that the class it is evaluated for has a given + * static attribute. + * + * The attribute name is passed in the constructor. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.1.0 + */ +class PHPUnit_Framework_Constraint_ClassHasStaticAttribute extends PHPUnit_Framework_Constraint_ClassHasAttribute +{ + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + $class = new ReflectionClass($other); + + if ($class->hasProperty($this->attributeName)) { + $attribute = $class->getProperty($this->attributeName); + + return $attribute->isStatic(); + } else { + return FALSE; + } + } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @since Method available since Release 3.3.0 + */ + public function toString() + { + return sprintf( + 'has static attribute "%s"', + + $this->attributeName + ); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Composite.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Composite.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Composite.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Composite.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,115 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ + +abstract class PHPUnit_Framework_Constraint_Composite extends PHPUnit_Framework_Constraint +{ + /** + * @var PHPUnit_Framework_Constraint + */ + protected $innerConstraint; + + /** + * @param PHPUnit_Framework_Constraint $innerConstraint + * @param string $attributeName + */ + public function __construct(PHPUnit_Framework_Constraint $innerConstraint) + { + $this->innerConstraint = $innerConstraint; + } + + /** + * Evaluates the constraint for parameter $other + * + * If $returnResult is set to FALSE (the default), an exception is thrown + * in case of a failure. NULL is returned otherwise. + * + * If $returnResult is TRUE, the result of the evaluation is returned as + * a boolean value instead: TRUE in case of success, FALSE in case of a + * failure. + * + * @param mixed $other Value or object to evaluate. + * @param string $description Additional information about the test + * @param bool $returnResult Whether to return a result or throw an exception + * @return mixed + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function evaluate($other, $description = '', $returnResult = FALSE) + { + try { + return $this->innerConstraint->evaluate( + $other, + $description, + $returnResult + ); + } + + catch (PHPUnit_Framework_ExpectationFailedException $e) { + $this->fail($other, $description); + } + } + + /** + * Counts the number of constraint elements. + * + * @return integer + */ + public function count() + { + return count($this->innerConstraint); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Count.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Count.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Count.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Count.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,129 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_Constraint_Count extends PHPUnit_Framework_Constraint +{ + /** + * @var integer + */ + protected $expectedCount = 0; + + /** + * @param integer $expected + */ + public function __construct($expected) + { + $this->expectedCount = $expected; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other + * @return boolean + */ + protected function matches($other) + { + return $this->expectedCount === $this->getCountOf($other); + } + + /** + * @param mixed $other + * @return boolean + */ + protected function getCountOf($other) + { + if ($other instanceof Countable || is_array($other)) { + return count($other); + } + + else if ($other instanceof Iterator) { + return iterator_count($other); + } + } + + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + return sprintf( + 'actual size %d matches expected size %d', + + $this->getCountOf($other), + $this->expectedCount + ); + } + + /** + * @return string + */ + public function toString() + { + return 'count matches '; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Exception.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Exception.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Exception.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Exception.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,125 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.6 + */ + +/** + * + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.6 + */ +class PHPUnit_Framework_Constraint_Exception extends PHPUnit_Framework_Constraint +{ + /** + * @var string + */ + protected $className; + + /** + * @param string $className + */ + public function __construct($className) + { + $this->className = $className; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return $other instanceof $this->className; + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + if ($other !== NULL) { + return sprintf( + 'exception of type "%s" matches expected exception "%s"', + + get_class($other), + $this->className + ); + } + + return sprintf( + 'exception of type "%s" is thrown', + + $this->className + ); + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return sprintf( + 'exception of type "%s"', + + $this->className + ); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ExceptionCode.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ExceptionCode.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ExceptionCode.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ExceptionCode.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,110 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.6 + */ + +/** + * + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.6 + */ +class PHPUnit_Framework_Constraint_ExceptionCode extends PHPUnit_Framework_Constraint +{ + /** + * @var integer + */ + protected $expectedCode; + + /** + * @param integer $expected + */ + public function __construct($expected) + { + $this->expectedCode = $expected; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param Exception $other + * @return boolean + */ + protected function matches($other) + { + return (string)$other->getCode() == (string)$this->expectedCode; + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + return sprintf( + '%s is equal to expected exception code %s', + PHPUnit_Util_Type::export($other->getCode()), + PHPUnit_Util_Type::export($this->expectedCode) + ); + } + + /** + * @return string + */ + public function toString() + { + return 'exception code is '; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ExceptionMessage.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ExceptionMessage.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ExceptionMessage.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ExceptionMessage.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,110 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.6 + */ + +/** + * + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.6 + */ +class PHPUnit_Framework_Constraint_ExceptionMessage extends PHPUnit_Framework_Constraint +{ + /** + * @var integer + */ + protected $expectedMessage; + + /** + * @param string $expected + */ + public function __construct($expected) + { + $this->expectedMessage = $expected; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param Exception $other + * @return boolean + */ + protected function matches($other) + { + return strpos($other->getMessage(), $this->expectedMessage) !== FALSE; + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + return sprintf( + "exception message '%s' contains '%s'", + $other->getMessage(), + $this->expectedMessage + ); + } + + /** + * @return string + */ + public function toString() + { + return 'exception message contains '; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/FileExists.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/FileExists.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/FileExists.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/FileExists.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,103 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Constraint that checks if the file(name) that it is evaluated for exists. + * + * The file path to check is passed as $other in evaluate(). + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_FileExists extends PHPUnit_Framework_Constraint +{ + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return file_exists($other); + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + return sprintf( + 'file "%s" exists', + + $other + ); + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'file exists'; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/GreaterThan.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/GreaterThan.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/GreaterThan.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/GreaterThan.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,97 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Constraint that asserts that the value it is evaluated for is greater + * than a given value. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_GreaterThan extends PHPUnit_Framework_Constraint +{ + /** + * @var numeric + */ + protected $value; + + /** + * @param numeric $value + */ + public function __construct($value) + { + $this->value = $value; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return $this->value < $other; + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'is greater than ' . PHPUnit_Util_Type::export($this->value); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsAnything.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsAnything.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsAnything.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsAnything.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,103 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Constraint that accepts any input value. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_IsAnything extends PHPUnit_Framework_Constraint +{ + /** + * Evaluates the constraint for parameter $other + * + * If $returnResult is set to FALSE (the default), an exception is thrown + * in case of a failure. NULL is returned otherwise. + * + * If $returnResult is TRUE, the result of the evaluation is returned as + * a boolean value instead: TRUE in case of success, FALSE in case of a + * failure. + * + * @param mixed $other Value or object to evaluate. + * @param string $description Additional information about the test + * @param bool $returnResult Whether to return a result or throw an exception + * @return mixed + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function evaluate($other, $description = '', $returnResult = FALSE) + { + return $returnResult ? TRUE : NULL; + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'is anything'; + } + + /** + * Counts the number of constraint elements. + * + * @return integer + * @since Method available since Release 3.5.0 + */ + public function count() + { + return 0; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsEmpty.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsEmpty.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsEmpty.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsEmpty.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,105 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.5.0 + */ + +/** + * Constraint that checks whether a variable is empty(). + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.5.0 + */ +class PHPUnit_Framework_Constraint_IsEmpty extends PHPUnit_Framework_Constraint +{ + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return empty($other); + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'is empty'; + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + $type = gettype($other); + + return sprintf( + '%s %s %s', + + $type[0] == 'a' || $type[0] == 'o' ? 'an' : 'a', + $type, + $this->toString() + ); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsEqual.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsEqual.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsEqual.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsEqual.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,216 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Kore Nordmann + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Constraint that checks if one value is equal to another. + * + * Equality is checked with PHP's == operator, the operator is explained in + * detail at {@url http://www.php.net/manual/en/types.comparisons.php}. + * Two values are equal if they have the same value disregarding type. + * + * The expected value is passed in the constructor. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Kore Nordmann + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_IsEqual extends PHPUnit_Framework_Constraint +{ + /** + * @var mixed + */ + protected $value; + + /** + * @var float + */ + protected $delta = 0; + + /** + * @var integer + */ + protected $maxDepth = 10; + + /** + * @var boolean + */ + protected $canonicalize = FALSE; + + /** + * @var boolean + */ + protected $ignoreCase = FALSE; + + /** + * @var PHPUnit_Framework_ComparisonFailure + */ + protected $lastFailure; + + /** + * @param mixed $value + * @param float $delta + * @param integer $maxDepth + * @param boolean $canonicalize + * @param boolean $ignoreCase + */ + public function __construct($value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) + { + if (!is_numeric($delta)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'numeric'); + } + + if (!is_int($maxDepth)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(3, 'integer'); + } + + if (!is_bool($canonicalize)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(4, 'boolean'); + } + + if (!is_bool($ignoreCase)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(5, 'boolean'); + } + + $this->value = $value; + $this->delta = $delta; + $this->maxDepth = $maxDepth; + $this->canonicalize = $canonicalize; + $this->ignoreCase = $ignoreCase; + } + + /** + * Evaluates the constraint for parameter $other + * + * If $returnResult is set to FALSE (the default), an exception is thrown + * in case of a failure. NULL is returned otherwise. + * + * If $returnResult is TRUE, the result of the evaluation is returned as + * a boolean value instead: TRUE in case of success, FALSE in case of a + * failure. + * + * @param mixed $other Value or object to evaluate. + * @param string $description Additional information about the test + * @param bool $returnResult Whether to return a result or throw an exception + * @return mixed + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function evaluate($other, $description = '', $returnResult = FALSE) + { + $comparatorFactory = PHPUnit_Framework_ComparatorFactory::getDefaultInstance(); + + try { + $comparator = $comparatorFactory->getComparatorFor( + $other, $this->value + ); + + $comparator->assertEquals( + $this->value, + $other, + $this->delta, + $this->canonicalize, + $this->ignoreCase + ); + } + + catch (PHPUnit_Framework_ComparisonFailure $f) { + if ($returnResult) { + return FALSE; + } + + throw new PHPUnit_Framework_ExpectationFailedException( + trim($description . "\n" . $f->getMessage()), + $f + ); + } + + return TRUE; + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + $delta = ''; + + if (is_string($this->value)) { + if (strpos($this->value, "\n") !== FALSE) { + return 'is equal to '; + } else { + return sprintf( + 'is equal to ', + + $this->value + ); + } + } else { + if ($this->delta != 0) { + $delta = sprintf( + ' with delta <%F>', + + $this->delta + ); + } + + return sprintf( + 'is equal to %s%s', + + PHPUnit_Util_Type::export($this->value), + $delta + ); + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsFalse.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsFalse.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsFalse.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsFalse.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,83 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.3.0 + */ + +/** + * Constraint that accepts FALSE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.3.0 + */ +class PHPUnit_Framework_Constraint_IsFalse extends PHPUnit_Framework_Constraint +{ + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return $other === FALSE; + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'is false'; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsIdentical.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsIdentical.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsIdentical.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsIdentical.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,173 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Constraint that asserts that one value is identical to another. + * + * Identical check is performed with PHP's === operator, the operator is + * explained in detail at + * {@url http://www.php.net/manual/en/types.comparisons.php}. + * Two values are identical if they have the same value and are of the same + * type. + * + * The expected value is passed in the constructor. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_IsIdentical extends PHPUnit_Framework_Constraint +{ + /** + * @var double + */ + const EPSILON = 0.0000000001; + + /** + * @var mixed + */ + protected $value; + + /** + * @param mixed $value + */ + public function __construct($value) + { + $this->value = $value; + } + + /** + * Evaluates the constraint for parameter $other + * + * If $returnResult is set to FALSE (the default), an exception is thrown + * in case of a failure. NULL is returned otherwise. + * + * If $returnResult is TRUE, the result of the evaluation is returned as + * a boolean value instead: TRUE in case of success, FALSE in case of a + * failure. + * + * @param mixed $other Value or object to evaluate. + * @param string $description Additional information about the test + * @param bool $returnResult Whether to return a result or throw an exception + * @return mixed + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function evaluate($other, $description = '', $returnResult = FALSE) + { + if (is_double($this->value) && is_double($other) && + !is_infinite($this->value) && !is_infinite($other)) { + $success = abs($this->value - $other) < self::EPSILON; + } + + else { + $success = $this->value === $other; + } + + if ($returnResult) { + return $success; + } + + if (!$success) { + $f = NULL; + + // if both values are strings, make sure a diff is generated + if (is_string($this->value) && is_string($other)) { + $f = new PHPUnit_Framework_ComparisonFailure( + $this->value, + $other, + $this->value, + $other + ); + } + + $this->fail($other, $description, $f); + } + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + if (is_object($this->value) && is_object($other)) { + return 'two variables reference the same object'; + } + + if (is_string($this->value) && is_string($other)) { + return 'two strings are identical'; + } + + return parent::failureDescription($other); + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + if (is_object($this->value)) { + return 'is identical to an object of class "' . + get_class($this->value) . '"'; + } else { + return 'is identical to ' . + PHPUnit_Util_Type::export($this->value); + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsInstanceOf.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsInstanceOf.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsInstanceOf.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsInstanceOf.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,122 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Constraint that asserts that the object it is evaluated for is an instance + * of a given class. + * + * The expected class name is passed in the constructor. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_IsInstanceOf extends PHPUnit_Framework_Constraint +{ + /** + * @var string + */ + protected $className; + + /** + * @param string $className + */ + public function __construct($className) + { + $this->className = $className; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return ($other instanceof $this->className); + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + return sprintf( + '%s is an instance of class "%s"', + + PHPUnit_Util_Type::shortenedExport($other), + $this->className + ); + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return sprintf( + 'is instance of class "%s"', + + $this->className + ); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsNull.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsNull.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsNull.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsNull.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,83 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.3.0 + */ + +/** + * Constraint that accepts NULL. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.3.0 + */ +class PHPUnit_Framework_Constraint_IsNull extends PHPUnit_Framework_Constraint +{ + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return $other === NULL; + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'is null'; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsTrue.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsTrue.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsTrue.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsTrue.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,83 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.3.0 + */ + +/** + * Constraint that accepts TRUE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.3.0 + */ +class PHPUnit_Framework_Constraint_IsTrue extends PHPUnit_Framework_Constraint +{ + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return $other === TRUE; + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'is true'; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsType.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsType.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsType.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/IsType.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,191 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Constraint that asserts that the value it is evaluated for is of a + * specified type. + * + * The expected value is passed in the constructor. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_IsType extends PHPUnit_Framework_Constraint +{ + const TYPE_ARRAY = 'array'; + const TYPE_BOOL = 'bool'; + const TYPE_FLOAT = 'float'; + const TYPE_INT = 'int'; + const TYPE_NULL = 'null'; + const TYPE_NUMERIC = 'numeric'; + const TYPE_OBJECT = 'object'; + const TYPE_RESOURCE = 'resource'; + const TYPE_STRING = 'string'; + const TYPE_SCALAR = 'scalar'; + const TYPE_CALLABLE = 'callable'; + + /** + * @var array + */ + protected $types = array( + 'array' => TRUE, + 'boolean' => TRUE, + 'bool' => TRUE, + 'float' => TRUE, + 'integer' => TRUE, + 'int' => TRUE, + 'null' => TRUE, + 'numeric' => TRUE, + 'object' => TRUE, + 'resource' => TRUE, + 'string' => TRUE, + 'scalar' => TRUE, + 'callable' => TRUE + ); + + /** + * @var string + */ + protected $type; + + /** + * @param string $type + * @throws InvalidArgumentException + */ + public function __construct($type) + { + if (!isset($this->types[$type])) { + throw new InvalidArgumentException( + sprintf( + 'Type specified for PHPUnit_Framework_Constraint_IsType <%s> ' . + 'is not a valid type.', + $type + ) + ); + } + + $this->type = $type; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + switch ($this->type) { + case 'numeric': { + return is_numeric($other); + } + + case 'integer': + case 'int': { + return is_integer($other); + } + + case 'float': { + return is_float($other); + } + + case 'string': { + return is_string($other); + } + + case 'boolean': + case 'bool': { + return is_bool($other); + } + + case 'null': { + return is_null($other); + } + + case 'array': { + return is_array($other); + } + + case 'object': { + return is_object($other); + } + + case 'resource': { + return is_resource($other); + } + + case 'scalar': { + return is_scalar($other); + } + + case 'callable': { + return is_callable($other); + } + } + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return sprintf( + 'is of type "%s"', + + $this->type + ); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/LessThan.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/LessThan.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/LessThan.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/LessThan.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,97 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Constraint that asserts that the value it is evaluated for is less than + * a given value. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_LessThan extends PHPUnit_Framework_Constraint +{ + /** + * @var numeric + */ + protected $value; + + /** + * @param numeric $value + */ + public function __construct($value) + { + $this->value = $value; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return $this->value > $other; + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'is less than ' . PHPUnit_Util_Type::export($this->value); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Not.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Not.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Not.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Not.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,204 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Logical NOT. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ + +class PHPUnit_Framework_Constraint_Not extends PHPUnit_Framework_Constraint +{ + /** + * @var PHPUnit_Framework_Constraint + */ + protected $constraint; + + /** + * @param PHPUnit_Framework_Constraint $constraint + */ + public function __construct($constraint) + { + if (!($constraint instanceof PHPUnit_Framework_Constraint)) { + $constraint = new PHPUnit_Framework_Constraint_IsEqual($constraint); + } + + $this->constraint = $constraint; + } + + /** + * @param string $string + * @return string + */ + public static function negate($string) + { + return str_replace( + array( + 'contains ', + 'exists', + 'has ', + 'is ', + 'are ', + 'matches ', + 'starts with ', + 'ends with ', + 'reference ', + 'not not ' + ), + array( + 'does not contain ', + 'does not exist', + 'does not have ', + 'is not ', + 'are not ', + 'does not match ', + 'starts not with ', + 'ends not with ', + 'don\'t reference ', + 'not ' + ), + $string + ); + } + + /** + * Evaluates the constraint for parameter $other + * + * If $returnResult is set to FALSE (the default), an exception is thrown + * in case of a failure. NULL is returned otherwise. + * + * If $returnResult is TRUE, the result of the evaluation is returned as + * a boolean value instead: TRUE in case of success, FALSE in case of a + * failure. + * + * @param mixed $other Value or object to evaluate. + * @param string $description Additional information about the test + * @param bool $returnResult Whether to return a result or throw an exception + * @return mixed + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function evaluate($other, $description = '', $returnResult = FALSE) + { + $success = !$this->constraint->evaluate($other, $description, TRUE); + + if ($returnResult) { + return $success; + } + + if (!$success) { + $this->fail($other, $description); + } + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + switch (get_class($this->constraint)) { + case 'PHPUnit_Framework_Constraint_And': + case 'PHPUnit_Framework_Constraint_Not': + case 'PHPUnit_Framework_Constraint_Or': { + return 'not( ' . $this->constraint->failureDescription($other) . ' )'; + } + break; + + default: { + return self::negate( + $this->constraint->failureDescription($other) + ); + } + } + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + switch (get_class($this->constraint)) { + case 'PHPUnit_Framework_Constraint_And': + case 'PHPUnit_Framework_Constraint_Not': + case 'PHPUnit_Framework_Constraint_Or': { + return 'not( ' . $this->constraint->toString() . ' )'; + } + break; + + default: { + return self::negate( + $this->constraint->toString() + ); + } + } + } + + /** + * Counts the number of constraint elements. + * + * @return integer + * @since Method available since Release 3.4.0 + */ + public function count() + { + return count($this->constraint); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ObjectHasAttribute.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ObjectHasAttribute.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ObjectHasAttribute.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/ObjectHasAttribute.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,78 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Constraint that asserts that the object it is evaluated for has a given + * attribute. + * + * The attribute name is passed in the constructor. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_ObjectHasAttribute extends PHPUnit_Framework_Constraint_ClassHasAttribute +{ + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + $object = new ReflectionObject($other); + + return $object->hasProperty($this->attributeName); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Or.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Or.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Or.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Or.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,158 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Logical OR. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_Or extends PHPUnit_Framework_Constraint +{ + /** + * @var PHPUnit_Framework_Constraint[] + */ + protected $constraints = array(); + + /** + * @param PHPUnit_Framework_Constraint[] $constraints + */ + public function setConstraints(array $constraints) + { + $this->constraints = array(); + + foreach ($constraints as $key => $constraint) { + if (!($constraint instanceof PHPUnit_Framework_Constraint)) { + $constraint = new PHPUnit_Framework_Constraint_IsEqual( + $constraint + ); + } + + $this->constraints[] = $constraint; + } + } + + /** + * Evaluates the constraint for parameter $other + * + * If $returnResult is set to FALSE (the default), an exception is thrown + * in case of a failure. NULL is returned otherwise. + * + * If $returnResult is TRUE, the result of the evaluation is returned as + * a boolean value instead: TRUE in case of success, FALSE in case of a + * failure. + * + * @param mixed $other Value or object to evaluate. + * @param string $description Additional information about the test + * @param bool $returnResult Whether to return a result or throw an exception + * @return mixed + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function evaluate($other, $description = '', $returnResult = FALSE) + { + $success = FALSE; + $constraint = NULL; + + foreach ($this->constraints as $constraint) { + if ($constraint->evaluate($other, $description, TRUE)) { + $success = TRUE; + break; + } + } + + if ($returnResult) { + return $success; + } + + if (!$success) { + $this->fail($other, $description); + } + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + $text = ''; + + foreach ($this->constraints as $key => $constraint) { + if ($key > 0) { + $text .= ' or '; + } + + $text .= $constraint->toString(); + } + + return $text; + } + + /** + * Counts the number of constraint elements. + * + * @return integer + * @since Method available since Release 3.4.0 + */ + public function count() + { + $count = 0; + + foreach ($this->constraints as $constraint) { + $count += count($constraint); + } + + return $count; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/PCREMatch.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/PCREMatch.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/PCREMatch.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/PCREMatch.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,106 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Constraint that asserts that the string it is evaluated for matches + * a regular expression. + * + * Checks a given value using the Perl Compatible Regular Expression extension + * in PHP. The pattern is matched by executing preg_match(). + * + * The pattern string passed in the constructor. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_PCREMatch extends PHPUnit_Framework_Constraint +{ + /** + * @var string + */ + protected $pattern; + + /** + * @param string $pattern + */ + public function __construct($pattern) + { + $this->pattern = $pattern; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return preg_match($this->pattern, $other) > 0; + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return sprintf( + 'matches PCRE pattern "%s"', + + $this->pattern + ); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/SameSize.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/SameSize.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/SameSize.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/SameSize.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,74 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_Constraint_SameSize extends PHPUnit_Framework_Constraint_Count +{ + /** + * @var integer + */ + protected $expectedCount; + + /** + * @param integer $expected + */ + public function __construct($expected) + { + $this->expectedCount = $this->getCountOf($expected); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringContains.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringContains.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringContains.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringContains.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,123 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Constraint that asserts that the string it is evaluated for contains + * a given string. + * + * Uses strpos() to find the position of the string in the input, if not found + * the evaluaton fails. + * + * The sub-string is passed in the constructor. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_StringContains extends PHPUnit_Framework_Constraint +{ + /** + * @var string + */ + protected $string; + + /** + * @var boolean + */ + protected $ignoreCase; + + /** + * @param string $string + * @param boolean $ignoreCase + */ + public function __construct($string, $ignoreCase = FALSE) + { + $this->string = $string; + $this->ignoreCase = $ignoreCase; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + if ($this->ignoreCase) { + return stripos($other, $this->string) !== FALSE; + } else { + return strpos($other, $this->string) !== FALSE; + } + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + if ($this->ignoreCase) { + $string = strtolower($this->string); + } else { + $string = $this->string; + } + + return sprintf( + 'contains "%s"', + + $string + ); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringEndsWith.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringEndsWith.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringEndsWith.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringEndsWith.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,97 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.4.0 + */ + +/** + * Constraint that asserts that the string it is evaluated for ends with a given + * suffix. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.4.0 + */ +class PHPUnit_Framework_Constraint_StringEndsWith extends PHPUnit_Framework_Constraint +{ + /** + * @var string + */ + protected $suffix; + + /** + * @param string $suffix + */ + public function __construct($suffix) + { + $this->suffix = $suffix; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return substr($other, 0 - strlen($this->suffix)) == $this->suffix; + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'ends with "' . $this->suffix . '"'; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringMatches.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringMatches.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringMatches.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringMatches.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,118 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.5.0 + */ + +/** + * ... + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.5.0 + */ +class PHPUnit_Framework_Constraint_StringMatches extends PHPUnit_Framework_Constraint_PCREMatch +{ + /** + * @var string + */ + protected $string; + + /** + * @param string $string + */ + public function __construct($string) + { + $this->pattern = preg_quote(preg_replace('/\r\n/', "\n", $string), '/'); + $this->pattern = str_replace( + array( + '%e', + '%s', + '%S', + '%a', + '%A', + '%w', + '%i', + '%d', + '%x', + '%f', + '%c' + ), + array( + '\\' . DIRECTORY_SEPARATOR, + '[^\r\n]+', + '[^\r\n]*', + '.+', + '.*', + '\s*', + '[+-]?\d+', + '\d+', + '[0-9a-fA-F]+', + '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', + '.' + ), + $this->pattern + ); + + $this->pattern = '/^' . $this->pattern . '$/s'; + $this->string = $string; + } + + protected function failureDescription($other) + { + return "format description matches text"; + } + + protected function additionalFailureDescription($other) + { + return PHPUnit_Util_Diff::diff($this->string, $other); + } + +} + diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringStartsWith.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringStartsWith.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringStartsWith.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/StringStartsWith.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,97 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.4.0 + */ + +/** + * Constraint that asserts that the string it is evaluated for begins with a + * given prefix. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.4.0 + */ +class PHPUnit_Framework_Constraint_StringStartsWith extends PHPUnit_Framework_Constraint +{ + /** + * @var string + */ + protected $prefix; + + /** + * @param string $prefix + */ + public function __construct($prefix) + { + $this->prefix = $prefix; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return strpos($other, $this->prefix) === 0; + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'starts with "' . $this->prefix . '"'; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/TraversableContains.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/TraversableContains.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/TraversableContains.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/TraversableContains.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,153 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Constraint that asserts that the Traversable it is applied to contains + * a given value. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_TraversableContains extends PHPUnit_Framework_Constraint +{ + /** + * @var boolean + */ + protected $checkForObjectIdentity; + + /** + * @var mixed + */ + protected $value; + + /** + * @param boolean $value + * @param mixed $checkForObjectIdentity + * @throws InvalidArgumentException + */ + public function __construct($value, $checkForObjectIdentity = TRUE) + { + if (!is_bool($checkForObjectIdentity)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'boolean'); + } + + $this->checkForObjectIdentity = $checkForObjectIdentity; + $this->value = $value; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + if ($other instanceof SplObjectStorage) { + return $other->contains($this->value); + } + + if (is_object($this->value)) { + foreach ($other as $element) { + if (($this->checkForObjectIdentity && + $element === $this->value) || + (!$this->checkForObjectIdentity && + $element == $this->value)) { + return TRUE; + } + } + } else { + foreach ($other as $element) { + if ($element == $this->value) { + return TRUE; + } + } + } + + return FALSE; + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + if (is_string($this->value) && strpos($this->value, "\n") !== FALSE) { + return 'contains "' . $this->value . '"'; + } else { + return 'contains ' . PHPUnit_Util_Type::export($this->value); + } + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + return sprintf( + 'an %s %s', + + is_array($other) ? 'array' : 'iterator', + $this->toString() + ); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/TraversableContainsOnly.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/TraversableContainsOnly.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/TraversableContainsOnly.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/TraversableContainsOnly.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,136 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.1.4 + */ + +/** + * Constraint that asserts that the Traversable it is applied to contains + * only values of a given type. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.1.4 + */ +class PHPUnit_Framework_Constraint_TraversableContainsOnly extends PHPUnit_Framework_Constraint +{ + /** + * @var PHPUnit_Framework_Constraint + */ + protected $constraint; + + /** + * @var string + */ + protected $type; + + /** + * @param string $type + * @param boolean $isNativeType + */ + public function __construct($type, $isNativeType = TRUE) + { + if ($isNativeType) { + $this->constraint = new PHPUnit_Framework_Constraint_IsType($type); + } else { + $this->constraint = new PHPUnit_Framework_Constraint_IsInstanceOf( + $type + ); + } + + $this->type = $type; + } + + /** + * Evaluates the constraint for parameter $other + * + * If $returnResult is set to FALSE (the default), an exception is thrown + * in case of a failure. NULL is returned otherwise. + * + * If $returnResult is TRUE, the result of the evaluation is returned as + * a boolean value instead: TRUE in case of success, FALSE in case of a + * failure. + * + * @param mixed $other Value or object to evaluate. + * @param string $description Additional information about the test + * @param bool $returnResult Whether to return a result or throw an exception + * @return mixed + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function evaluate($other, $description = '', $returnResult = FALSE) + { + $success = TRUE; + $constraint = NULL; + + foreach ($other as $item) { + if (!$this->constraint->evaluate($item, '', TRUE)) { + $success = FALSE; + break; + } + } + + if ($returnResult) { + return $success; + } + + if (!$success) { + $this->fail($other, $description); + } + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'contains only values of type "' . $this->type . '"'; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Xor.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Xor.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Xor.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint/Xor.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,163 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Logical XOR. + * + * @package PHPUnit + * @subpackage Framework_Constraint + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_Constraint_Xor extends PHPUnit_Framework_Constraint +{ + /** + * @var PHPUnit_Framework_Constraint[] + */ + protected $constraints = array(); + + /** + * @param PHPUnit_Framework_Constraint[] $constraints + */ + public function setConstraints(array $constraints) + { + $this->constraints = array(); + + foreach ($constraints as $key => $constraint) { + if (!($constraint instanceof PHPUnit_Framework_Constraint)) { + $constraint = new PHPUnit_Framework_Constraint_IsEqual( + $constraint + ); + } + + $this->constraints[] = $constraint; + } + } + + /** + * Evaluates the constraint for parameter $other + * + * If $returnResult is set to FALSE (the default), an exception is thrown + * in case of a failure. NULL is returned otherwise. + * + * If $returnResult is TRUE, the result of the evaluation is returned as + * a boolean value instead: TRUE in case of success, FALSE in case of a + * failure. + * + * @param mixed $other Value or object to evaluate. + * @param string $description Additional information about the test + * @param bool $returnResult Whether to return a result or throw an exception + * @return mixed + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function evaluate($other, $description = '', $returnResult = FALSE) + { + $success = TRUE; + $lastResult = NULL; + $constraint = NULL; + + foreach ($this->constraints as $constraint) { + $result = $constraint->evaluate($other, $description, TRUE); + + if ($result === $lastResult) { + $success = FALSE; + break; + } + + $lastResult = $result; + } + + if ($returnResult) { + return $success; + } + + if (!$success) { + $this->fail($other, $description); + } + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + $text = ''; + + foreach ($this->constraints as $key => $constraint) { + if ($key > 0) { + $text .= ' xor '; + } + + $text .= $constraint->toString(); + } + + return $text; + } + + /** + * Counts the number of constraint elements. + * + * @return integer + * @since Method available since Release 3.4.0 + */ + public function count() + { + $count = 0; + + foreach ($this->constraints as $constraint) { + $count += count($constraint); + } + + return $count; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Constraint.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Constraint.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,181 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Abstract base class for constraints. which are placed upon any value. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @author Bernhard Schussek + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Interface available since Release 3.0.0 + */ +abstract class PHPUnit_Framework_Constraint implements Countable, PHPUnit_Framework_SelfDescribing +{ + + /** + * Evaluates the constraint for parameter $other + * + * If $returnResult is set to FALSE (the default), an exception is thrown + * in case of a failure. NULL is returned otherwise. + * + * If $returnResult is TRUE, the result of the evaluation is returned as + * a boolean value instead: TRUE in case of success, FALSE in case of a + * failure. + * + * @param mixed $other Value or object to evaluate. + * @param string $description Additional information about the test + * @param bool $returnResult Whether to return a result or throw an exception + * @return mixed + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function evaluate($other, $description = '', $returnResult = FALSE) + { + $success = FALSE; + + if ($this->matches($other)) { + $success = TRUE; + } + + if ($returnResult) { + return $success; + } + + if (!$success) { + $this->fail($other, $description); + } + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * This method can be overridden to implement the evaluation algorithm. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + protected function matches($other) + { + return FALSE; + } + + /** + * Counts the number of constraint elements. + * + * @return integer + * @since Method available since Release 3.4.0 + */ + public function count() + { + return 1; + } + + /** + * Throws an exception for the given compared value and test description + * + * @param mixed $other Evaluated value or object. + * @param string $description Additional information about the test + * @param PHPUnit_Framework_ComparisonFailure $comparisonFailure + * @throws PHPUnit_Framework_ExpectationFailedException + */ + protected function fail($other, $description, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL) + { + $failureDescription = sprintf( + 'Failed asserting that %s.', + $this->failureDescription($other) + ); + + $additionalFailureDescription = $this->additionalFailureDescription($other); + if ($additionalFailureDescription) { + $failureDescription .= "\n" . $additionalFailureDescription; + } + + if (!empty($description)) { + $failureDescription = $description . "\n" . $failureDescription; + } + + throw new PHPUnit_Framework_ExpectationFailedException( + $failureDescription, + $comparisonFailure + ); + } + + /** + * Return additional failure description where needed + * + * The function can be overritten to provide additional failure + * information like a diff + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function additionalFailureDescription($other) + { + return ""; + } + + /** + * Returns the description of the failure + * + * The beginning of failure messages is "Failed asserting that" in most + * cases. This method should return the second part of that sentence. + * + * To provide additional failure information additionalFailureDescription + * can be used. + * + * @param mixed $other Evaluated value or object. + * @return string + */ + protected function failureDescription($other) + { + return PHPUnit_Util_Type::export($other) . ' ' . $this->toString(); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Error/Deprecated.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Error/Deprecated.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Error/Deprecated.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Error/Deprecated.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,66 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Error + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.3.0 + */ + +/** + * Wrapper for PHP deprecated errors. + * You can disable deprecated-to-exception conversion by setting + * + * + * PHPUnit_Framework_Error_Deprecated::$enabled = FALSE; + * + * + * @package PHPUnit + * @subpackage Framework_Error + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.3.0 + */ +class PHPUnit_Framework_Error_Deprecated extends PHPUnit_Framework_Error +{ + public static $enabled = TRUE; +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Error/Notice.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Error/Notice.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Error/Notice.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Error/Notice.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,66 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Error + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.3.0 + */ + +/** + * Wrapper for PHP notices. + * You can disable notice-to-exception conversion by setting + * + * + * PHPUnit_Framework_Error_Notice::$enabled = FALSE; + * + * + * @package PHPUnit + * @subpackage Framework_Error + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.3.0 + */ +class PHPUnit_Framework_Error_Notice extends PHPUnit_Framework_Error +{ + public static $enabled = TRUE; +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Error/Warning.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Error/Warning.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Error/Warning.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Error/Warning.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,66 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_Error + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.3.0 + */ + +/** + * Wrapper for PHP warnings. + * You can disable notice-to-exception conversion by setting + * + * + * PHPUnit_Framework_Error_Warning::$enabled = FALSE; + * + * + * @package PHPUnit + * @subpackage Framework_Error + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.3.0 + */ +class PHPUnit_Framework_Error_Warning extends PHPUnit_Framework_Error +{ + public static $enabled = TRUE; +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Error.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Error.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Error.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Error.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,77 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.2.0 + */ + +/** + * Wrapper for PHP errors. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.2.0 + */ +class PHPUnit_Framework_Error extends Exception +{ + /** + * Constructor. + * + * @param string $message + * @param integer $code + * @param string $file + * @param integer $line + * @param array $trace + */ + public function __construct($message, $code, $file, $line, $trace) + { + parent::__construct($message, $code); + + $this->file = $file; + $this->line = $line; + $this->trace = $trace; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Exception.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Exception.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Exception.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Exception.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,60 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.4.0 + */ + +/** + * Exception for PHPUnit runtime errors. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.4.0 + */ +class PHPUnit_Framework_Exception extends RuntimeException +{ +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/ExpectationFailedException.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/ExpectationFailedException.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/ExpectationFailedException.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/ExpectationFailedException.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,83 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Exception for expectations which failed their check. + * + * The exception contains the error message and optionally a + * PHPUnit_Framework_ComparisonFailure which is used to + * generate diff output of the failed expectations. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_ExpectationFailedException extends PHPUnit_Framework_AssertionFailedError +{ + /** + * @var PHPUnit_Framework_ComparisonFailure + */ + protected $comparisonFailure; + + public function __construct($message, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL) + { + $this->comparisonFailure = $comparisonFailure; + + parent::__construct($message); + } + + /** + * @return PHPUnit_Framework_ComparisonFailure + */ + public function getComparisonFailure() + { + return $this->comparisonFailure; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/IncompleteTest.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/IncompleteTest.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/IncompleteTest.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/IncompleteTest.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,61 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * A marker interface for marking any exception/error as result of an unit + * test as incomplete implementation or currently not implemented. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Interface available since Release 2.0.0 + */ +interface PHPUnit_Framework_IncompleteTest +{ +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/IncompleteTestError.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/IncompleteTestError.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/IncompleteTestError.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/IncompleteTestError.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,61 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * Extension to PHPUnit_Framework_AssertionFailedError to mark the special + * case of an incomplete test. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_Framework_IncompleteTestError extends PHPUnit_Framework_AssertionFailedError implements PHPUnit_Framework_IncompleteTest +{ +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/OutputError.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/OutputError.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/OutputError.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/OutputError.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,61 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * Extension to PHPUnit_Framework_AssertionFailedError to mark the special + * case of a test that printed output. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Framework_OutputError extends PHPUnit_Framework_AssertionFailedError +{ +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Process/TestCaseMethod.tpl.dist phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Process/TestCaseMethod.tpl.dist --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Process/TestCaseMethod.tpl.dist 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Process/TestCaseMethod.tpl.dist 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,51 @@ +setCodeCoverage(new PHP_CodeCoverage); + } + + $result->strictMode({strict}); + + $test = new {className}('{methodName}', unserialize('{data}'), '{dataName}'); + $test->setDependencyInput(unserialize('{dependencyInput}')); + $test->setInIsolation(TRUE); + + ob_end_clean(); + ob_start(); + $test->run($result); + $output = ob_get_clean(); + + print serialize( + array( + 'testResult' => $test->getResult(), + 'numAssertions' => $test->getNumAssertions(), + 'result' => $result, + 'output' => $output + ) + ); + + ob_start(); +} + +{constants} +{included_files} +{globals} + +if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP'])) { + require_once $GLOBALS['__PHPUNIT_BOOTSTRAP']; + unset($GLOBALS['__PHPUNIT_BOOTSTRAP']); +} + +__phpunit_run_isolated_test(); +ob_end_clean(); diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/SelfDescribing.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/SelfDescribing.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/SelfDescribing.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/SelfDescribing.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,66 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Interface for classes that can return a description of itself. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Interface available since Release 3.0.0 + */ +interface PHPUnit_Framework_SelfDescribing +{ + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString(); +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/SkippedTest.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/SkippedTest.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/SkippedTest.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/SkippedTest.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,60 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * A marker interface for marking a unit test as being skipped. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Interface available since Release 3.0.0 + */ +interface PHPUnit_Framework_SkippedTest +{ +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/SkippedTestError.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/SkippedTestError.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/SkippedTestError.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/SkippedTestError.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,61 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Extension to PHPUnit_Framework_AssertionFailedError to mark the special + * case of a skipped test. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Framework_SkippedTestError extends PHPUnit_Framework_AssertionFailedError implements PHPUnit_Framework_SkippedTest +{ +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/SkippedTestSuiteError.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/SkippedTestSuiteError.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/SkippedTestSuiteError.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/SkippedTestSuiteError.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,61 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.1.0 + */ + +/** + * Extension to PHPUnit_Framework_AssertionFailedError to mark the special + * case of a skipped test suite. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.1.0 + */ +class PHPUnit_Framework_SkippedTestSuiteError extends PHPUnit_Framework_AssertionFailedError implements PHPUnit_Framework_SkippedTest +{ +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/SyntheticError.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/SyntheticError.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/SyntheticError.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/SyntheticError.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,122 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.5.0 + */ + +/** + * Creates a synthetic failed assertion. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.5.0 + */ +class PHPUnit_Framework_SyntheticError extends PHPUnit_Framework_AssertionFailedError +{ + /** + * The synthetic file. + * + * @var string + */ + protected $syntheticFile = ''; + + /** + * The synthetic line number. + * + * @var integer + */ + protected $syntheticLine = 0; + + /** + * The synthetic trace. + * + * @var array + */ + protected $syntheticTrace = array(); + + /** + * Constructor. + * + * @param string $message + * @param integer $code + * @param string $file + * @param integer $line + * @param array $trace + */ + public function __construct($message, $code, $file, $line, $trace) + { + parent::__construct($message, $code); + + $this->syntheticFile = $file; + $this->syntheticLine = $line; + $this->syntheticTrace = $trace; + } + + /** + * @return string + */ + public function getSyntheticFile() + { + return $this->syntheticFile; + } + + /** + * @return integer + */ + public function getSyntheticLine() + { + return $this->syntheticLine; + } + + /** + * @return array + */ + public function getSyntheticTrace() + { + return $this->syntheticTrace; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Test.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Test.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Test.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Test.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,67 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * A Test can be run and collect its results. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Interface available since Release 2.0.0 + */ +interface PHPUnit_Framework_Test extends Countable +{ + /** + * Runs a test and collects its result in a TestResult instance. + * + * @param PHPUnit_Framework_TestResult $result + * @return PHPUnit_Framework_TestResult + */ + public function run(PHPUnit_Framework_TestResult $result = NULL); +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/TestCase.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/TestCase.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/TestCase.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/TestCase.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,1831 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * A TestCase defines the fixture to run multiple tests. + * + * To define a TestCase + * + * 1) Implement a subclass of PHPUnit_Framework_TestCase. + * 2) Define instance variables that store the state of the fixture. + * 3) Initialize the fixture state by overriding setUp(). + * 4) Clean-up after a test by overriding tearDown(). + * + * Each test runs in its own fixture so there can be no side effects + * among test runs. + * + * Here is an example: + * + * + * value1 = 2; + * $this->value2 = 3; + * } + * } + * ?> + * + * + * For each test implement a method which interacts with the fixture. + * Verify the expected results with assertions specified by calling + * assert with a boolean. + * + * + * assertTrue($this->value1 + $this->value2 == 5); + * } + * ?> + * + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +abstract class PHPUnit_Framework_TestCase extends PHPUnit_Framework_Assert implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing +{ + /** + * Enable or disable the backup and restoration of the $GLOBALS array. + * Overwrite this attribute in a child class of TestCase. + * Setting this attribute in setUp() has no effect! + * + * @var boolean + */ + protected $backupGlobals = NULL; + + /** + * @var array + */ + protected $backupGlobalsBlacklist = array(); + + /** + * Enable or disable the backup and restoration of static attributes. + * Overwrite this attribute in a child class of TestCase. + * Setting this attribute in setUp() has no effect! + * + * @var boolean + */ + protected $backupStaticAttributes = NULL; + + /** + * @var array + */ + protected $backupStaticAttributesBlacklist = array(); + + /** + * Whether or not this test is to be run in a separate PHP process. + * + * @var boolean + */ + protected $runTestInSeparateProcess = NULL; + + /** + * Whether or not this test should preserve the global state when + * running in a separate PHP process. + * + * @var boolean + */ + protected $preserveGlobalState = TRUE; + + /** + * Whether or not this test is running in a separate PHP process. + * + * @var boolean + */ + private $inIsolation = FALSE; + + /** + * @var array + */ + private $data = array(); + + /** + * @var string + */ + private $dataName = ''; + + /** + * @var boolean + */ + private $useErrorHandler = NULL; + + /** + * @var boolean + */ + private $useOutputBuffering = NULL; + + /** + * The name of the expected Exception. + * + * @var mixed + */ + private $expectedException = NULL; + + /** + * The message of the expected Exception. + * + * @var string + */ + private $expectedExceptionMessage = ''; + + /** + * The code of the expected Exception. + * + * @var integer + */ + private $expectedExceptionCode; + + /** + * The stack trace to where the expected exception was set. + * + * @var array + */ + private $expectedExceptionTrace = array(); + + /** + * The required version of PHP. + * + * @var string + */ + private $requiredPhp = ''; + + /** + * The required version of PHPUnit. + * + * @var string + */ + private $requiredPhpUnit = ''; + + /** + * The name of the test case. + * + * @var string + */ + private $name = NULL; + + /** + * @var array + */ + private $dependencies = array(); + + /** + * @var array + */ + private $dependencyInput = array(); + + /** + * @var array + */ + private $iniSettings = array(); + + /** + * @var array + */ + private $locale = array(); + + /** + * @var array + */ + private $mockObjects = array(); + + /** + * @var integer + */ + private $status; + + /** + * @var string + */ + private $statusMessage = ''; + + /** + * @var integer + */ + private $numAssertions = 0; + + /** + * @var PHPUnit_Framework_TestResult + */ + private $result; + + /** + * @var mixed + */ + private $testResult; + + /** + * @var string + */ + private $output = ''; + + /** + * @var string + */ + private $outputExpectedRegex = NULL; + + /** + * @var string + */ + private $outputExpectedString = NULL; + + /** + * @var bool + */ + private $hasPerformedExpectationsOnOutput = FALSE; + + /** + * @var mixed + */ + private $outputCallback = FALSE; + + /** + * @var boolean + */ + private $outputBufferingActive = FALSE; + + /** + * Constructs a test case with the given name. + * + * @param string $name + * @param array $data + * @param string $dataName + */ + public function __construct($name = NULL, array $data = array(), $dataName = '') + { + if ($name !== NULL) { + $this->setName($name); + } + + $this->data = $data; + $this->dataName = $dataName; + } + + /** + * Returns a string representation of the test case. + * + * @return string + */ + public function toString() + { + $class = new ReflectionClass($this); + + $buffer = sprintf( + '%s::%s', + + $class->name, + $this->getName(FALSE) + ); + + return $buffer . $this->getDataSetAsString(); + } + + /** + * Counts the number of test cases executed by run(TestResult result). + * + * @return integer + */ + public function count() + { + return 1; + } + + /** + * Returns the annotations for this test. + * + * @return array + * @since Method available since Release 3.4.0 + */ + public function getAnnotations() + { + return PHPUnit_Util_Test::parseTestMethodAnnotations( + get_class($this), $this->name + ); + } + + /** + * Gets the name of a TestCase. + * + * @param boolean $withDataSet + * @return string + */ + public function getName($withDataSet = TRUE) + { + if ($withDataSet) { + return $this->name . $this->getDataSetAsString(FALSE); + } else { + return $this->name; + } + } + + /** + * Returns the size of the test. + * + * @return integer + * @since Method available since Release 3.6.0 + */ + public function getSize() + { + return PHPUnit_Util_Test::getSize( + get_class($this), $this->getName(FALSE) + ); + } + + /** + * @return string + * @since Method available since Release 3.6.0 + */ + public function getActualOutput() + { + if (!$this->outputBufferingActive) { + return $this->output; + } else { + return ob_get_contents(); + } + } + + /** + * @return string + * @since Method available since Release 3.6.0 + */ + public function hasOutput() + { + if (empty($this->output)) { + return FALSE; + } + + if ($this->outputExpectedString !== NULL || + $this->outputExpectedRegex !== NULL || + $this->hasPerformedExpectationsOnOutput) { + return FALSE; + } + + return TRUE; + } + + /** + * @param string $expectedRegex + * @since Method available since Release 3.6.0 + */ + public function expectOutputRegex($expectedRegex) + { + if ($this->outputExpectedString !== NULL) { + throw new PHPUnit_Framework_Exception; + } + + if (is_string($expectedRegex) || is_null($expectedRegex)) { + $this->outputExpectedRegex = $expectedRegex; + } + } + + /** + * @param string $expectedString + * @since Method available since Release 3.6.0 + */ + public function expectOutputString($expectedString) + { + if ($this->outputExpectedRegex !== NULL) { + throw new PHPUnit_Framework_Exception; + } + + if (is_string($expectedString) || is_null($expectedString)) { + $this->outputExpectedString = $expectedString; + } + } + + /** + * @return bool + * @since Method available since Release 3.6.5 + */ + public function hasPerformedExpectationsOnOutput() + { + return $this->hasPerformedExpectationsOnOutput; + } + + /** + * @return string + * @since Method available since Release 3.2.0 + */ + public function getExpectedException() + { + return $this->expectedException; + } + + /** + * @param mixed $exceptionName + * @param string $exceptionMessage + * @param integer $exceptionCode + * @throws InvalidArgumentException + * @since Method available since Release 3.2.0 + */ + public function setExpectedException($exceptionName, $exceptionMessage = '', $exceptionCode = NULL) + { + if ($exceptionName == 'Exception' || $exceptionName == '\\Exception') { + throw new InvalidArgumentException( + 'You must not expect the generic exception class.' + ); + } + + $this->expectedException = $exceptionName; + $this->expectedExceptionMessage = $exceptionMessage; + $this->expectedExceptionCode = $exceptionCode; + $this->expectedExceptionTrace = debug_backtrace(); + } + + /** + * @since Method available since Release 3.4.0 + */ + protected function setExpectedExceptionFromAnnotation() + { + try { + $expectedException = PHPUnit_Util_Test::getExpectedException( + get_class($this), $this->name + ); + + if ($expectedException !== FALSE) { + $this->setExpectedException( + $expectedException['class'], + $expectedException['message'], + $expectedException['code'] + ); + } + } + + catch (ReflectionException $e) { + } + } + + /** + * @param boolean $useErrorHandler + * @since Method available since Release 3.4.0 + */ + public function setUseErrorHandler($useErrorHandler) + { + $this->useErrorHandler = $useErrorHandler; + } + + /** + * @since Method available since Release 3.4.0 + */ + protected function setUseErrorHandlerFromAnnotation() + { + try { + $useErrorHandler = PHPUnit_Util_Test::getErrorHandlerSettings( + get_class($this), $this->name + ); + + if ($useErrorHandler !== NULL) { + $this->setUseErrorHandler($useErrorHandler); + } + } + + catch (ReflectionException $e) { + } + } + + /** + * @param boolean $useOutputBuffering + * @since Method available since Release 3.4.0 + */ + public function setUseOutputBuffering($useOutputBuffering) + { + $this->useOutputBuffering = $useOutputBuffering; + } + + /** + * @since Method available since Release 3.4.0 + */ + protected function setUseOutputBufferingFromAnnotation() + { + try { + $useOutputBuffering = PHPUnit_Util_Test::getOutputBufferingSettings( + get_class($this), $this->name + ); + + if ($useOutputBuffering !== NULL) { + $this->setUseOutputBuffering($useOutputBuffering); + } + } + + catch (ReflectionException $e) { + } + } + + /** + * @since Method available since Release 3.6.0 + */ + protected function setRequirementsFromAnnotation() + { + try { + $requirements = PHPUnit_Util_Test::getRequirements( + get_class($this), $this->name + ); + + if (isset($requirements['PHP'])) { + $this->requiredPhp = $requirements['PHP']; + } + + if (isset($requirements['PHPUnit'])) { + $this->requiredPhpUnit = $requirements['PHPUnit']; + } + } + + catch (ReflectionException $e) { + } + } + + /** + * @since Method available since Release 3.6.0 + */ + protected function checkRequirements() + { + $this->setRequirementsFromAnnotation(); + + if ($this->requiredPhp && + version_compare(PHP_VERSION, $this->requiredPhp, '<')) { + $this->markTestSkipped( + sprintf( + 'PHP %s (or later) is required.', + $this->requiredPhp + ) + ); + } + + $phpunitVersion = PHPUnit_Runner_Version::id(); + if ($this->requiredPhpUnit && + version_compare($phpunitVersion, $this->requiredPhpUnit, '<')) { + $this->markTestSkipped( + sprintf( + 'PHPUnit %s (or later) is required.', + $this->requiredPhpUnit + ) + ); + } + } + + /** + * Returns the status of this test. + * + * @return integer + * @since Method available since Release 3.1.0 + */ + public function getStatus() + { + return $this->status; + } + + /** + * Returns the status message of this test. + * + * @return string + * @since Method available since Release 3.3.0 + */ + public function getStatusMessage() + { + return $this->statusMessage; + } + + /** + * Returns whether or not this test has failed. + * + * @return boolean + * @since Method available since Release 3.0.0 + */ + public function hasFailed() + { + $status = $this->getStatus(); + + return $status == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE || + $status == PHPUnit_Runner_BaseTestRunner::STATUS_ERROR; + } + + /** + * Runs the test case and collects the results in a TestResult object. + * If no TestResult object is passed a new one will be created. + * + * @param PHPUnit_Framework_TestResult $result + * @return PHPUnit_Framework_TestResult + * @throws InvalidArgumentException + */ + public function run(PHPUnit_Framework_TestResult $result = NULL) + { + if ($result === NULL) { + $result = $this->createResult(); + } + + if (!$this instanceof PHPUnit_Framework_Warning) { + $this->setTestResultObject($result); + $this->setUseErrorHandlerFromAnnotation(); + $this->setUseOutputBufferingFromAnnotation(); + } + + if ($this->useErrorHandler !== NULL) { + $oldErrorHandlerSetting = $result->getConvertErrorsToExceptions(); + $result->convertErrorsToExceptions($this->useErrorHandler); + } + + if (!$this->handleDependencies()) { + return; + } + + if ($this->runTestInSeparateProcess === TRUE && + $this->inIsolation !== TRUE && + !$this instanceof PHPUnit_Extensions_SeleniumTestCase && + !$this instanceof PHPUnit_Extensions_PhptTestCase) { + $class = new ReflectionClass($this); + + $template = new Text_Template( + sprintf( + '%s%sProcess%sTestCaseMethod.tpl', + + dirname(__FILE__), + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR + ) + ); + + if ($this->preserveGlobalState) { + $constants = PHPUnit_Util_GlobalState::getConstantsAsString(); + $globals = PHPUnit_Util_GlobalState::getGlobalsAsString(); + $includedFiles = PHPUnit_Util_GlobalState::getIncludedFilesAsString(); + } else { + $constants = ''; + $globals = ''; + $includedFiles = ''; + } + + if ($result->getCollectCodeCoverageInformation()) { + $coverage = 'TRUE'; + } else { + $coverage = 'FALSE'; + } + + if ($result->isStrict()) { + $strict = 'TRUE'; + } else { + $strict = 'FALSE'; + } + + $data = addcslashes(serialize($this->data), "'"); + $dependencyInput = addcslashes( + serialize($this->dependencyInput), "'" + ); + $includePath = addslashes(get_include_path()); + + $template->setVar( + array( + 'filename' => $class->getFileName(), + 'className' => $class->getName(), + 'methodName' => $this->name, + 'collectCodeCoverageInformation' => $coverage, + 'data' => $data, + 'dataName' => $this->dataName, + 'dependencyInput' => $dependencyInput, + 'constants' => $constants, + 'globals' => $globals, + 'include_path' => $includePath, + 'included_files' => $includedFiles, + 'strict' => $strict + ) + ); + + $this->prepareTemplate($template); + + $php = PHPUnit_Util_PHP::factory(); + $php->runJob($template->render(), $this, $result); + } else { + $result->run($this); + } + + if ($this->useErrorHandler !== NULL) { + $result->convertErrorsToExceptions($oldErrorHandlerSetting); + } + + $this->result = NULL; + + return $result; + } + + /** + * Runs the bare test sequence. + */ + public function runBare() + { + $this->numAssertions = 0; + + // Backup the $GLOBALS array and static attributes. + if ($this->runTestInSeparateProcess !== TRUE && + $this->inIsolation !== TRUE) { + if ($this->backupGlobals === NULL || + $this->backupGlobals === TRUE) { + PHPUnit_Util_GlobalState::backupGlobals( + $this->backupGlobalsBlacklist + ); + } + + if (version_compare(PHP_VERSION, '5.3', '>') && + $this->backupStaticAttributes === TRUE) { + PHPUnit_Util_GlobalState::backupStaticAttributes( + $this->backupStaticAttributesBlacklist + ); + } + } + + // Start output buffering. + ob_start(); + $this->outputBufferingActive = TRUE; + + // Clean up stat cache. + clearstatcache(); + + try { + if ($this->inIsolation) { + $this->setUpBeforeClass(); + } + + $this->setExpectedExceptionFromAnnotation(); + $this->setUp(); + $this->checkRequirements(); + $this->assertPreConditions(); + $this->testResult = $this->runTest(); + $this->verifyMockObjects(); + $this->assertPostConditions(); + $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_PASSED; + } + + catch (PHPUnit_Framework_IncompleteTest $e) { + $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE; + $this->statusMessage = $e->getMessage(); + } + + catch (PHPUnit_Framework_SkippedTest $e) { + $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED; + $this->statusMessage = $e->getMessage(); + } + + catch (PHPUnit_Framework_AssertionFailedError $e) { + $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE; + $this->statusMessage = $e->getMessage(); + } + + catch (Exception $e) { + $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_ERROR; + $this->statusMessage = $e->getMessage(); + } + + // Tear down the fixture. An exception raised in tearDown() will be + // caught and passed on when no exception was raised before. + try { + $this->tearDown(); + + if ($this->inIsolation) { + $this->tearDownAfterClass(); + } + } + + catch (Exception $_e) { + if (!isset($e)) { + $e = $_e; + } + } + + // Stop output buffering. + 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(); + $this->outputBufferingActive = FALSE; + + // Clean up stat cache. + clearstatcache(); + + // Restore the $GLOBALS array and static attributes. + if ($this->runTestInSeparateProcess !== TRUE && + $this->inIsolation !== TRUE) { + if ($this->backupGlobals === NULL || + $this->backupGlobals === TRUE) { + PHPUnit_Util_GlobalState::restoreGlobals( + $this->backupGlobalsBlacklist + ); + } + + if (version_compare(PHP_VERSION, '5.3', '>') && + $this->backupStaticAttributes === TRUE) { + PHPUnit_Util_GlobalState::restoreStaticAttributes(); + } + } + + // Clean up INI settings. + foreach ($this->iniSettings as $varName => $oldValue) { + ini_set($varName, $oldValue); + } + + $this->iniSettings = array(); + + // Clean up locale settings. + foreach ($this->locale as $category => $locale) { + setlocale($category, $locale); + } + + // Perform assertion on output. + if (!isset($e)) { + try { + if ($this->outputExpectedRegex !== NULL) { + $this->hasPerformedExpectationsOnOutput = TRUE; + $this->assertRegExp($this->outputExpectedRegex, $this->output); + $this->outputExpectedRegex = NULL; + } + + else if ($this->outputExpectedString !== NULL) { + $this->hasPerformedExpectationsOnOutput = TRUE; + $this->assertEquals($this->outputExpectedString, $this->output); + $this->outputExpectedString = NULL; + } + } + + catch (Exception $_e) { + $e = $_e; + } + } + + // Workaround for missing "finally". + if (isset($e)) { + $this->onNotSuccessfulTest($e); + } + } + + /** + * Override to run the test and assert its state. + * + * @return mixed + * @throws RuntimeException + */ + protected function runTest() + { + if ($this->name === NULL) { + throw new PHPUnit_Framework_Exception( + 'PHPUnit_Framework_TestCase::$name must not be NULL.' + ); + } + + try { + $class = new ReflectionClass($this); + $method = $class->getMethod($this->name); + } + + catch (ReflectionException $e) { + $this->fail($e->getMessage()); + } + + try { + $testResult = $method->invokeArgs( + $this, array_merge($this->data, $this->dependencyInput) + ); + } + + catch (Exception $e) { + if (!$e instanceof PHPUnit_Framework_IncompleteTest && + !$e instanceof PHPUnit_Framework_SkippedTest && + is_string($this->expectedException)) { + $this->assertThat( + $e, + new PHPUnit_Framework_Constraint_Exception( + $this->expectedException + ) + ); + + if (is_string($this->expectedExceptionMessage) && + !empty($this->expectedExceptionMessage)) { + $this->assertThat( + $e, + new PHPUnit_Framework_Constraint_ExceptionMessage( + $this->expectedExceptionMessage + ) + ); + } + + if ($this->expectedExceptionCode !== NULL) { + $this->assertThat( + $e, + new PHPUnit_Framework_Constraint_ExceptionCode( + $this->expectedExceptionCode + ) + ); + } + + return; + } else { + throw $e; + } + } + + if ($this->expectedException !== NULL) { + $this->assertThat( + NULL, + new PHPUnit_Framework_Constraint_Exception( + $this->expectedException + ) + ); + } + + return $testResult; + } + + /** + * Verifies the mock object expectations. + * + * @since Method available since Release 3.5.0 + */ + protected function verifyMockObjects() + { + foreach ($this->mockObjects as $mockObject) { + if ($mockObject->__phpunit_hasMatchers()) { + $this->numAssertions++; + } + + $mockObject->__phpunit_verify(); + $mockObject->__phpunit_cleanup(); + } + + $this->mockObjects = array(); + } + + /** + * Sets the name of a TestCase. + * + * @param string + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * Sets the dependencies of a TestCase. + * + * @param array $dependencies + * @since Method available since Release 3.4.0 + */ + public function setDependencies(array $dependencies) + { + $this->dependencies = $dependencies; + } + + /** + * Sets + * + * @param array $dependencyInput + * @since Method available since Release 3.4.0 + */ + public function setDependencyInput(array $dependencyInput) + { + $this->dependencyInput = $dependencyInput; + } + + /** + * Calling this method in setUp() has no effect! + * + * @param boolean $backupGlobals + * @since Method available since Release 3.3.0 + */ + public function setBackupGlobals($backupGlobals) + { + if (is_null($this->backupGlobals) && is_bool($backupGlobals)) { + $this->backupGlobals = $backupGlobals; + } + } + + /** + * Calling this method in setUp() has no effect! + * + * @param boolean $backupStaticAttributes + * @since Method available since Release 3.4.0 + */ + public function setBackupStaticAttributes($backupStaticAttributes) + { + if (is_null($this->backupStaticAttributes) && + is_bool($backupStaticAttributes)) { + $this->backupStaticAttributes = $backupStaticAttributes; + } + } + + /** + * @param boolean $runTestInSeparateProcess + * @throws InvalidArgumentException + * @since Method available since Release 3.4.0 + */ + public function setRunTestInSeparateProcess($runTestInSeparateProcess) + { + if (is_bool($runTestInSeparateProcess)) { + if ($this->runTestInSeparateProcess === NULL) { + $this->runTestInSeparateProcess = $runTestInSeparateProcess; + } + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); + } + } + + /** + * @param boolean $preserveGlobalState + * @throws InvalidArgumentException + * @since Method available since Release 3.4.0 + */ + public function setPreserveGlobalState($preserveGlobalState) + { + if (is_bool($preserveGlobalState)) { + $this->preserveGlobalState = $preserveGlobalState; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); + } + } + + /** + * @param boolean $inIsolation + * @throws InvalidArgumentException + * @since Method available since Release 3.4.0 + */ + public function setInIsolation($inIsolation) + { + if (is_bool($inIsolation)) { + $this->inIsolation = $inIsolation; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); + } + } + + /** + * @return mixed + * @since Method available since Release 3.4.0 + */ + public function getResult() + { + return $this->testResult; + } + + /** + * @param mixed $result + * @since Method available since Release 3.4.0 + */ + public function setResult($result) + { + $this->testResult = $result; + } + + /** + * @param callable $callback + * @since Method available since Release 3.6.0 + */ + public function setOutputCallback($callback) + { + if (!is_callable($callback)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'callback'); + } + + $this->outputCallback = $callback; + } + + /** + * @return PHPUnit_Framework_TestResult + * @since Method available since Release 3.5.7 + */ + public function getTestResultObject() + { + return $this->result; + } + + /** + * @param PHPUnit_Framework_TestResult $result + * @since Method available since Release 3.6.0 + */ + public function setTestResultObject(PHPUnit_Framework_TestResult $result) + { + $this->result = $result; + } + + /** + * This method is a wrapper for the ini_set() function that automatically + * resets the modified php.ini setting to its original value after the + * test is run. + * + * @param string $varName + * @param string $newValue + * @throws InvalidArgumentException + * @throws RuntimeException + * @since Method available since Release 3.0.0 + */ + protected function iniSet($varName, $newValue) + { + if (!is_string($varName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + $currentValue = ini_set($varName, $newValue); + + if ($currentValue !== FALSE) { + $this->iniSettings[$varName] = $currentValue; + } else { + throw new PHPUnit_Framework_Exception( + sprintf( + 'INI setting "%s" could not be set to "%s".', + $varName, + $newValue + ) + ); + } + } + + /** + * This method is a wrapper for the setlocale() function that automatically + * resets the locale to its original value after the test is run. + * + * @param integer $category + * @param string $locale + * @throws InvalidArgumentException + * @throws RuntimeException + * @since Method available since Release 3.1.0 + */ + protected function setLocale() + { + $args = func_get_args(); + + if (count($args) < 2) { + throw new InvalidArgumentException; + } + + $category = $args[0]; + $locale = $args[1]; + + $categories = array( + LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME + ); + + if (defined('LC_MESSAGES')) { + $categories[] = LC_MESSAGES; + } + + if (!in_array($category, $categories)) { + throw new InvalidArgumentException; + } + + if (!is_array($locale) && !is_string($locale)) { + throw new InvalidArgumentException; + } + + $this->locale[$category] = setlocale($category, NULL); + + $result = call_user_func_array( 'setlocale', $args ); + + if ($result === FALSE) { + throw new PHPUnit_Framework_Exception( + 'The locale functionality is not implemented on your platform, ' . + 'the specified locale does not exist or the category name is ' . + 'invalid.' + ); + } + } + + /** + * Returns a mock object for the specified class. + * + * @param string $originalClassName + * @param array $methods + * @param array $arguments + * @param string $mockClassName + * @param boolean $callOriginalConstructor + * @param boolean $callOriginalClone + * @param boolean $callAutoload + * @return PHPUnit_Framework_MockObject_MockObject + * @throws InvalidArgumentException + * @since Method available since Release 3.0.0 + */ + public function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE) + { + $mockObject = PHPUnit_Framework_MockObject_Generator::getMock( + $originalClassName, + $methods, + $arguments, + $mockClassName, + $callOriginalConstructor, + $callOriginalClone, + $callAutoload + ); + + $this->mockObjects[] = $mockObject; + + return $mockObject; + } + + /** + * Returns a builder object to create mock objects using a fluent interface. + * + * @param string $className + * @return PHPUnit_Framework_MockObject_MockBuilder + * @since Method available since Release 3.5.0 + */ + public function getMockBuilder($className) + { + return new PHPUnit_Framework_MockObject_MockBuilder( + $this, $className + ); + } + + /** + * Mocks the specified class and returns the name of the mocked class. + * + * @param string $originalClassName + * @param array $methods + * @param array $arguments + * @param string $mockClassName + * @param boolean $callOriginalConstructor + * @param boolean $callOriginalClone + * @param boolean $callAutoload + * @return string + * @throws InvalidArgumentException + * @since Method available since Release 3.5.0 + */ + protected function getMockClass($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = FALSE, $callOriginalClone = TRUE, $callAutoload = TRUE) + { + $mock = $this->getMock( + $originalClassName, + $methods, + $arguments, + $mockClassName, + $callOriginalConstructor, + $callOriginalClone, + $callAutoload + ); + + return get_class($mock); + } + + /** + * Returns a mock object for the specified abstract class with all abstract + * methods of the class mocked. Concrete methods to mock can be specified with + * the last parameter + * + * @param string $originalClassName + * @param array $arguments + * @param string $mockClassName + * @param boolean $callOriginalConstructor + * @param boolean $callOriginalClone + * @param boolean $callAutoload + * @param array $mockedMethods + * @return PHPUnit_Framework_MockObject_MockObject + * @since Method available since Release 3.4.0 + * @throws InvalidArgumentException + */ + public function getMockForAbstractClass($originalClassName, array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $mockedMethods = array()) + { + $mockObject = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass( + $originalClassName, + $arguments, + $mockClassName, + $callOriginalConstructor, + $callOriginalClone, + $callAutoload, + $mockedMethods + ); + + $this->mockObjects[] = $mockObject; + + return $mockObject; + } + + /** + * Returns a mock object based on the given WSDL file. + * + * @param string $wsdlFile + * @param string $originalClassName + * @param string $mockClassName + * @param array $methods + * @param boolean $callOriginalConstructor + * @return PHPUnit_Framework_MockObject_MockObject + * @since Method available since Release 3.4.0 + */ + protected function getMockFromWsdl($wsdlFile, $originalClassName = '', $mockClassName = '', array $methods = array(), $callOriginalConstructor = TRUE) + { + if ($originalClassName === '') { + $originalClassName = str_replace( + '.wsdl', '', basename($wsdlFile) + ); + } + + eval( + PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl( + $wsdlFile, $originalClassName, $methods + ) + ); + + return $this->getMock( + $originalClassName, + $methods, + array('', array()), + $mockClassName, + $callOriginalConstructor, + FALSE, + FALSE + ); + } + + /** + * Returns an object for the specified trait. + * + * @param string $traitName + * @param array $arguments + * @param string $traitClassName + * @param boolean $callOriginalConstructor + * @param boolean $callOriginalClone + * @param boolean $callAutoload + * @return object + * @since Method available since Release 3.6.0 + * @throws InvalidArgumentException + */ + protected function getObjectForTrait($traitName, array $arguments = array(), $traitClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE) + { + return PHPUnit_Framework_MockObject_Generator::getObjectForTrait( + $traitName, + $arguments, + $traitClassName, + $callOriginalConstructor, + $callOriginalClone, + $callAutoload + ); + } + + /** + * Adds a value to the assertion counter. + * + * @param integer $count + * @since Method available since Release 3.3.3 + */ + public function addToAssertionCount($count) + { + $this->numAssertions += $count; + } + + /** + * Returns the number of assertions performed by this test. + * + * @return integer + * @since Method available since Release 3.3.0 + */ + public function getNumAssertions() + { + return $this->numAssertions; + } + + /** + * Returns a matcher that matches when the method it is evaluated for + * is executed zero or more times. + * + * @return PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount + * @since Method available since Release 3.0.0 + */ + public static function any() + { + return new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount; + } + + /** + * Returns a matcher that matches when the method it is evaluated for + * is never executed. + * + * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount + * @since Method available since Release 3.0.0 + */ + public static function never() + { + return new PHPUnit_Framework_MockObject_Matcher_InvokedCount(0); + } + + /** + * Returns a matcher that matches when the method it is evaluated for + * is executed at least once. + * + * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce + * @since Method available since Release 3.0.0 + */ + public static function atLeastOnce() + { + return new PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce; + } + + /** + * Returns a matcher that matches when the method it is evaluated for + * is executed exactly once. + * + * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount + * @since Method available since Release 3.0.0 + */ + public static function once() + { + return new PHPUnit_Framework_MockObject_Matcher_InvokedCount(1); + } + + /** + * Returns a matcher that matches when the method it is evaluated for + * is executed exactly $count times. + * + * @param integer $count + * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount + * @since Method available since Release 3.0.0 + */ + public static function exactly($count) + { + return new PHPUnit_Framework_MockObject_Matcher_InvokedCount($count); + } + + /** + * Returns a matcher that matches when the method it is evaluated for + * is invoked at the given $index. + * + * @param integer $index + * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex + * @since Method available since Release 3.0.0 + */ + public static function at($index) + { + return new PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex($index); + } + + /** + * + * + * @param mixed $value + * @return PHPUnit_Framework_MockObject_Stub_Return + * @since Method available since Release 3.0.0 + */ + public static function returnValue($value) + { + return new PHPUnit_Framework_MockObject_Stub_Return($value); + } + + /** + * + * + * @param array $valueMap + * @return PHPUnit_Framework_MockObject_Stub_ReturnValueMap + * @since Method available since Release 3.6.0 + */ + public static function returnValueMap(array $valueMap) + { + return new PHPUnit_Framework_MockObject_Stub_ReturnValueMap($valueMap); + } + + /** + * + * + * @param integer $argumentIndex + * @return PHPUnit_Framework_MockObject_Stub_ReturnArgument + * @since Method available since Release 3.3.0 + */ + public static function returnArgument($argumentIndex) + { + return new PHPUnit_Framework_MockObject_Stub_ReturnArgument( + $argumentIndex + ); + } + + /** + * + * + * @param mixed $callback + * @return PHPUnit_Framework_MockObject_Stub_ReturnCallback + * @since Method available since Release 3.3.0 + */ + public static function returnCallback($callback) + { + return new PHPUnit_Framework_MockObject_Stub_ReturnCallback($callback); + } + + /** + * Returns the current object. + * + * This method is useful when mocking a fluent interface. + * + * @return PHPUnit_Framework_MockObject_Stub_ReturnSelf + * @since Method available since Release 3.6.0 + */ + public static function returnSelf() + { + return new PHPUnit_Framework_MockObject_Stub_ReturnSelf(); + } + + /** + * + * + * @param Exception $exception + * @return PHPUnit_Framework_MockObject_Stub_Exception + * @since Method available since Release 3.1.0 + */ + public static function throwException(Exception $exception) + { + return new PHPUnit_Framework_MockObject_Stub_Exception($exception); + } + + /** + * + * + * @param mixed $value, ... + * @return PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls + * @since Method available since Release 3.0.0 + */ + public static function onConsecutiveCalls() + { + $args = func_get_args(); + + return new PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls($args); + } + + /** + * @param mixed $data + * @return string + * @since Method available since Release 3.2.1 + */ + protected function dataToString($data) + { + $result = array(); + + // There seems to be no other way to check arrays for recursion + // http://www.php.net/manual/en/language.types.array.php#73936 + preg_match_all('/\n \[(\w+)\] => Array\s+\*RECURSION\*/', print_r($data, TRUE), $matches); + $recursiveKeys = array_unique($matches[1]); + + // Convert to valid array keys + // Numeric integer strings are automatically converted to integers + // by PHP + foreach ($recursiveKeys as $key => $recursiveKey) { + if ((string)(integer)$recursiveKey === $recursiveKey) { + $recursiveKeys[$key] = (integer)$recursiveKey; + } + } + + foreach ($data as $key => $_data) { + if (in_array($key, $recursiveKeys, TRUE)) { + $result[] = '*RECURSION*'; + } + + else if (is_array($_data)) { + $result[] = 'array(' . $this->dataToString($_data) . ')'; + } + + else if (is_object($_data)) { + $object = new ReflectionObject($_data); + + if ($object->hasMethod('__toString')) { + $result[] = (string)$_data; + } else { + $result[] = get_class($_data); + } + } + + else if (is_resource($_data)) { + $result[] = ''; + } + + else { + $result[] = var_export($_data, TRUE); + } + } + + return join(', ', $result); + } + + /** + * Gets the data set description of a TestCase. + * + * @param boolean $includeData + * @return string + * @since Method available since Release 3.3.0 + */ + protected function getDataSetAsString($includeData = TRUE) + { + $buffer = ''; + + if (!empty($this->data)) { + if (is_int($this->dataName)) { + $buffer .= sprintf(' with data set #%d', $this->dataName); + } else { + $buffer .= sprintf(' with data set "%s"', $this->dataName); + } + + if ($includeData) { + $buffer .= sprintf(' (%s)', $this->dataToString($this->data)); + } + } + + return $buffer; + } + + /** + * Creates a default TestResult object. + * + * @return PHPUnit_Framework_TestResult + */ + protected function createResult() + { + return new PHPUnit_Framework_TestResult; + } + + /** + * @since Method available since Release 3.5.4 + */ + protected function handleDependencies() + { + if (!empty($this->dependencies) && !$this->inIsolation) { + $className = get_class($this); + $passed = $this->result->passed(); + $passedKeys = array_keys($passed); + $numKeys = count($passedKeys); + + for ($i = 0; $i < $numKeys; $i++) { + $pos = strpos($passedKeys[$i], ' with data set'); + + if ($pos !== FALSE) { + $passedKeys[$i] = substr($passedKeys[$i], 0, $pos); + } + } + + $passedKeys = array_flip(array_unique($passedKeys)); + + foreach ($this->dependencies as $dependency) { + if (strpos($dependency, '::') === FALSE) { + $dependency = $className . '::' . $dependency; + } + + if (!isset($passedKeys[$dependency])) { + $this->result->addError( + $this, + new PHPUnit_Framework_SkippedTestError( + sprintf( + 'This test depends on "%s" to pass.', $dependency + ) + ), + 0 + ); + + return FALSE; + } + + if (isset($passed[$dependency])) { + if ($passed[$dependency]['size'] > $this->getSize()) { + $this->result->addError( + $this, + new PHPUnit_Framework_SkippedTestError( + 'This test depends on a test that is larger than itself.' + ), + 0 + ); + + return FALSE; + } + + $this->dependencyInput[] = $passed[$dependency]['result']; + } else { + $this->dependencyInput[] = NULL; + } + } + } + + return TRUE; + } + + /** + * This method is called before the first test of this test class is run. + * + * @since Method available since Release 3.4.0 + */ + public static function setUpBeforeClass() + { + } + + /** + * Sets up the fixture, for example, open a network connection. + * This method is called before a test is executed. + * + */ + protected function setUp() + { + } + + /** + * Performs assertions shared by all tests of a test case. + * + * This method is called before the execution of a test starts + * and after setUp() is called. + * + * @since Method available since Release 3.2.8 + */ + protected function assertPreConditions() + { + } + + /** + * Performs assertions shared by all tests of a test case. + * + * This method is called before the execution of a test ends + * and before tearDown() is called. + * + * @since Method available since Release 3.2.8 + */ + protected function assertPostConditions() + { + } + + /** + * Tears down the fixture, for example, close a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * This method is called after the last test of this test class is run. + * + * @since Method available since Release 3.4.0 + */ + public static function tearDownAfterClass() + { + } + + /** + * This method is called when a test method did not execute successfully. + * + * @param Exception $e + * @since Method available since Release 3.4.0 + */ + protected function onNotSuccessfulTest(Exception $e) + { + throw $e; + } + + /** + * Performs custom preparations on the process isolation template. + * + * @param Text_Template $template + * @since Method available since Release 3.4.0 + */ + protected function prepareTemplate(Text_Template $template) + { + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/TestFailure.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/TestFailure.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/TestFailure.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/TestFailure.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,180 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * A TestFailure collects a failed test together with the caught exception. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_Framework_TestFailure +{ + /** + * @var PHPUnit_Framework_Test + */ + protected $failedTest; + + /** + * @var Exception + */ + protected $thrownException; + + /** + * Constructs a TestFailure with the given test and exception. + * + * @param PHPUnit_Framework_Test $failedTest + * @param Exception $thrownException + */ + public function __construct(PHPUnit_Framework_Test $failedTest, Exception $thrownException) + { + $this->failedTest = $failedTest; + $this->thrownException = $thrownException; + } + + /** + * Returns a short description of the failure. + * + * @return string + */ + public function toString() + { + return sprintf( + '%s: %s', + + $this->failedTest, + $this->thrownException->getMessage() + ); + } + + /** + * Returns a description for the thrown exception. + * + * @return string + * @since Method available since Release 3.4.0 + */ + public function getExceptionAsString() + { + return self::exceptionToString($this->thrownException); + } + + /** + * Returns a description for an exception. + * + * @param Exception $e + * @return string + * @since Method available since Release 3.2.0 + */ + public static function exceptionToString(Exception $e) + { + if ($e instanceof PHPUnit_Framework_SelfDescribing) { + $buffer = $e->toString(); + + if ($e instanceof PHPUnit_Framework_ExpectationFailedException && $e->getComparisonFailure()) { + $buffer = $buffer . "\n" . $e->getComparisonFailure()->getDiff(); + } + + if (!empty($buffer)) { + $buffer = trim($buffer) . "\n"; + } + } + + else if ($e instanceof PHPUnit_Framework_Error) { + $buffer = $e->getMessage() . "\n"; + } + + else { + $buffer = get_class($e) . ': ' . $e->getMessage() . "\n"; + } + + return $buffer; + } + + /** + * Gets the failed test. + * + * @return Test + */ + public function failedTest() + { + return $this->failedTest; + } + + /** + * Gets the thrown exception. + * + * @return Exception + */ + public function thrownException() + { + return $this->thrownException; + } + + /** + * Returns the exception's message. + * + * @return string + */ + public function exceptionMessage() + { + return $this->thrownException()->getMessage(); + } + + /** + * Returns TRUE if the thrown exception + * is of type AssertionFailedError. + * + * @return boolean + */ + public function isFailure() + { + return ($this->thrownException() instanceof PHPUnit_Framework_AssertionFailedError); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/TestListener.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/TestListener.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/TestListener.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/TestListener.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,127 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * A Listener for test progress. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Interface available since Release 2.0.0 + */ +interface PHPUnit_Framework_TestListener +{ + /** + * An error occurred. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time); + + /** + * A failure occurred. + * + * @param PHPUnit_Framework_Test $test + * @param PHPUnit_Framework_AssertionFailedError $e + * @param float $time + */ + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time); + + /** + * Incomplete test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time); + + /** + * Skipped test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + * @since Method available since Release 3.0.0 + */ + public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time); + + /** + * A test suite started. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit_Framework_TestSuite $suite); + + /** + * A test suite ended. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit_Framework_TestSuite $suite); + + /** + * A test started. + * + * @param PHPUnit_Framework_Test $test + */ + public function startTest(PHPUnit_Framework_Test $test); + + /** + * A test ended. + * + * @param PHPUnit_Framework_Test $test + * @param float $time + */ + public function endTest(PHPUnit_Framework_Test $test, $time); +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/TestResult.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/TestResult.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/TestResult.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/TestResult.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,957 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * A TestResult collects the results of executing a test case. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_Framework_TestResult implements Countable +{ + /** + * @var boolean + */ + protected static $xdebugLoaded = NULL; + + /** + * @var boolean + */ + protected static $useXdebug = NULL; + + /** + * @var array + */ + protected $passed = array(); + + /** + * @var array + */ + protected $errors = array(); + + /** + * @var array + */ + protected $deprecatedFeatures = array(); + + /** + * @var array + */ + protected $failures = array(); + + /** + * @var array + */ + protected $notImplemented = array(); + + /** + * @var array + */ + protected $skipped = array(); + + /** + * @var array + */ + protected $listeners = array(); + + /** + * @var integer + */ + protected $runTests = 0; + + /** + * @var float + */ + protected $time = 0; + + /** + * @var PHPUnit_Framework_TestSuite + */ + protected $topTestSuite = NULL; + + /** + * Code Coverage information. + * + * @var PHP_CodeCoverage + */ + protected $codeCoverage; + + /** + * @var boolean + */ + protected $convertErrorsToExceptions = TRUE; + + /** + * @var boolean + */ + protected $stop = FALSE; + + /** + * @var boolean + */ + protected $stopOnError = FALSE; + + /** + * @var boolean + */ + protected $stopOnFailure = FALSE; + + /** + * @var boolean + */ + protected $strictMode = FALSE; + + /** + * @var boolean + */ + protected $stopOnIncomplete = FALSE; + + /** + * @var boolean + */ + protected $stopOnSkipped = FALSE; + + /** + * @var boolean + */ + protected $lastTestFailed = FALSE; + + /** + * @var integer + */ + protected $timeoutForSmallTests = 1; + + /** + * @var integer + */ + protected $timeoutForMediumTests = 10; + + /** + * @var integer + */ + protected $timeoutForLargeTests = 60; + + /** + * Registers a TestListener. + * + * @param PHPUnit_Framework_TestListener + */ + public function addListener(PHPUnit_Framework_TestListener $listener) + { + $this->listeners[] = $listener; + } + + /** + * Unregisters a TestListener. + * + * @param PHPUnit_Framework_TestListener $listener + */ + public function removeListener(PHPUnit_Framework_TestListener $listener) + { + foreach ($this->listeners as $key => $_listener) { + if ($listener === $_listener) { + unset($this->listeners[$key]); + } + } + } + + /** + * Flushes all flushable TestListeners. + * + * @since Method available since Release 3.0.0 + */ + public function flushListeners() + { + foreach ($this->listeners as $listener) { + if ($listener instanceof PHPUnit_Util_Printer) { + $listener->flush(); + } + } + } + + /** + * Adds an error to the list of errors. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) + { + if ($e instanceof PHPUnit_Framework_IncompleteTest) { + $this->notImplemented[] = new PHPUnit_Framework_TestFailure( + $test, $e + ); + + $notifyMethod = 'addIncompleteTest'; + + if ($this->stopOnIncomplete) { + $this->stop(); + } + } + + else if ($e instanceof PHPUnit_Framework_SkippedTest) { + $this->skipped[] = new PHPUnit_Framework_TestFailure($test, $e); + $notifyMethod = 'addSkippedTest'; + + if ($this->stopOnSkipped) { + $this->stop(); + } + } + + else { + $this->errors[] = new PHPUnit_Framework_TestFailure($test, $e); + $notifyMethod = 'addError'; + + if ($this->stopOnError || $this->stopOnFailure) { + $this->stop(); + } + } + + foreach ($this->listeners as $listener) { + $listener->$notifyMethod($test, $e, $time); + } + + $this->lastTestFailed = TRUE; + $this->time += $time; + } + + /** + * Adds a failure to the list of failures. + * The passed in exception caused the failure. + * + * @param PHPUnit_Framework_Test $test + * @param PHPUnit_Framework_AssertionFailedError $e + * @param float $time + */ + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) + { + if ($e instanceof PHPUnit_Framework_IncompleteTest) { + $this->notImplemented[] = new PHPUnit_Framework_TestFailure( + $test, $e + ); + + $notifyMethod = 'addIncompleteTest'; + + if ($this->stopOnIncomplete) { + $this->stop(); + } + } + + else if ($e instanceof PHPUnit_Framework_SkippedTest) { + $this->skipped[] = new PHPUnit_Framework_TestFailure($test, $e); + $notifyMethod = 'addSkippedTest'; + + if ($this->stopOnSkipped) { + $this->stop(); + } + } + + else { + $this->failures[] = new PHPUnit_Framework_TestFailure($test, $e); + $notifyMethod = 'addFailure'; + + if ($this->stopOnFailure) { + $this->stop(); + } + } + + foreach ($this->listeners as $listener) { + $listener->$notifyMethod($test, $e, $time); + } + + $this->lastTestFailed = TRUE; + $this->time += $time; + } + + /** + * Adds a deprecated feature notice to the list of deprecated features used during run + * + * @param PHPUnit_Util_DeprecatedFeature $deprecatedFeature + */ + public function addDeprecatedFeature(PHPUnit_Util_DeprecatedFeature $deprecatedFeature) + { + $this->deprecatedFeatures[] = $deprecatedFeature; + } + + /** + * Informs the result that a testsuite will be started. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit_Framework_TestSuite $suite) + { + if ($this->topTestSuite === NULL) { + $this->topTestSuite = $suite; + } + + foreach ($this->listeners as $listener) { + $listener->startTestSuite($suite); + } + } + + /** + * Informs the result that a testsuite was completed. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit_Framework_TestSuite $suite) + { + foreach ($this->listeners as $listener) { + $listener->endTestSuite($suite); + } + } + + /** + * Informs the result that a test will be started. + * + * @param PHPUnit_Framework_Test $test + */ + public function startTest(PHPUnit_Framework_Test $test) + { + $this->lastTestFailed = FALSE; + $this->runTests += count($test); + + foreach ($this->listeners as $listener) { + $listener->startTest($test); + } + } + + /** + * Informs the result that a test was completed. + * + * @param PHPUnit_Framework_Test $test + * @param float $time + */ + public function endTest(PHPUnit_Framework_Test $test, $time) + { + foreach ($this->listeners as $listener) { + $listener->endTest($test, $time); + } + + if (!$this->lastTestFailed && $test instanceof PHPUnit_Framework_TestCase) { + $class = get_class($test); + $key = $class . '::' . $test->getName(); + + $this->passed[$key] = array( + 'result' => $test->getResult(), + 'size' => PHPUnit_Util_Test::getSize( + $class, $test->getName(FALSE) + ) + ); + + $this->time += $time; + } + } + + /** + * Returns TRUE if no incomplete test occured. + * + * @return boolean + */ + public function allCompletlyImplemented() + { + return $this->notImplementedCount() == 0; + } + + /** + * Gets the number of incomplete tests. + * + * @return integer + */ + public function notImplementedCount() + { + return count($this->notImplemented); + } + + /** + * Returns an Enumeration for the incomplete tests. + * + * @return array + */ + public function notImplemented() + { + return $this->notImplemented; + } + + /** + * Returns TRUE if no test has been skipped. + * + * @return boolean + * @since Method available since Release 3.0.0 + */ + public function noneSkipped() + { + return $this->skippedCount() == 0; + } + + /** + * Gets the number of skipped tests. + * + * @return integer + * @since Method available since Release 3.0.0 + */ + public function skippedCount() + { + return count($this->skipped); + } + + /** + * Returns an Enumeration for the skipped tests. + * + * @return array + * @since Method available since Release 3.0.0 + */ + public function skipped() + { + return $this->skipped; + } + + /** + * Gets the number of detected errors. + * + * @return integer + */ + public function errorCount() + { + return count($this->errors); + } + + /** + * Returns an Enumeration for the errors. + * + * @return array + */ + public function errors() + { + return $this->errors; + } + + /** + * Returns an Enumeration for the deprecated features used. + * + * @return array + * @since Method available since Release 3.5.7 + */ + public function deprecatedFeatures() + { + return $this->deprecatedFeatures; + } + + /** + * Returns an Enumeration for the deprecated features used. + * + * @return array + * @since Method available since Release 3.5.7 + */ + public function deprecatedFeaturesCount() + { + return count($this->deprecatedFeatures); + } + + /** + * Gets the number of detected failures. + * + * @return integer + */ + public function failureCount() + { + return count($this->failures); + } + + /** + * Returns an Enumeration for the failures. + * + * @return array + */ + public function failures() + { + return $this->failures; + } + + /** + * Returns the names of the tests that have passed. + * + * @return array + * @since Method available since Release 3.4.0 + */ + public function passed() + { + return $this->passed; + } + + /** + * Returns the (top) test suite. + * + * @return PHPUnit_Framework_TestSuite + * @since Method available since Release 3.0.0 + */ + public function topTestSuite() + { + return $this->topTestSuite; + } + + /** + * Returns whether code coverage information should be collected. + * + * @return boolean If code coverage should be collected + * @since Method available since Release 3.2.0 + */ + public function getCollectCodeCoverageInformation() + { + return $this->codeCoverage !== NULL; + } + + /** + * Returns the strict mode configuration option + * + * @return boolean + */ + public function isStrict() + { + return $this->strictMode; + } + + /** + * Runs a TestCase. + * + * @param PHPUnit_Framework_Test $test + */ + public function run(PHPUnit_Framework_Test $test) + { + PHPUnit_Framework_Assert::resetCount(); + + $error = FALSE; + $failure = FALSE; + $incomplete = FALSE; + $skipped = FALSE; + + $this->startTest($test); + + $errorHandlerSet = FALSE; + + if ($this->convertErrorsToExceptions) { + $oldErrorHandler = set_error_handler( + array('PHPUnit_Util_ErrorHandler', 'handleError'), + E_ALL | E_STRICT + ); + + if ($oldErrorHandler === NULL) { + $errorHandlerSet = TRUE; + } else { + restore_error_handler(); + } + } + + if (self::$xdebugLoaded === NULL) { + self::$xdebugLoaded = extension_loaded('xdebug'); + self::$useXdebug = self::$xdebugLoaded; + } + + $useXdebug = self::$useXdebug && + $this->codeCoverage !== NULL && + !$test instanceof PHPUnit_Extensions_SeleniumTestCase && + !$test instanceof PHPUnit_Framework_Warning; + + if ($useXdebug) { + // We need to blacklist test source files when no whitelist is used. + if (!$this->codeCoverage->filter()->hasWhitelist()) { + $classes = PHPUnit_Util_Class::getHierarchy( + get_class($test), TRUE + ); + + foreach ($classes as $class) { + $this->codeCoverage->filter()->addFileToBlacklist( + $class->getFileName() + ); + } + } + + $this->codeCoverage->start($test); + } + + PHP_Timer::start(); + + try { + if (!$test instanceof PHPUnit_Framework_Warning && + $this->strictMode && + extension_loaded('pcntl') && class_exists('PHP_Invoker')) { + switch ($test->getSize()) { + case PHPUnit_Util_Test::SMALL: { + $_timeout = $this->timeoutForSmallTests; + } + break; + + case PHPUnit_Util_Test::MEDIUM: { + $_timeout = $this->timeoutForMediumTests; + } + break; + + case PHPUnit_Util_Test::LARGE: { + $_timeout = $this->timeoutForLargeTests; + } + break; + } + + $invoker = new PHP_Invoker; + $invoker->invoke(array($test, 'runBare'), array(), $_timeout); + } else { + $test->runBare(); + } + } + + catch (PHPUnit_Framework_AssertionFailedError $e) { + $failure = TRUE; + + if ($e instanceof PHPUnit_Framework_IncompleteTestError) { + $incomplete = TRUE; + } + + else if ($e instanceof PHPUnit_Framework_SkippedTestError) { + $skipped = TRUE; + } + } + + catch (Exception $e) { + $error = TRUE; + } + + $time = PHP_Timer::stop(); + $test->addToAssertionCount(PHPUnit_Framework_Assert::getCount()); + + if ($this->strictMode && $test->getNumAssertions() == 0) { + $incomplete = TRUE; + } + + if ($useXdebug) { + try { + $this->codeCoverage->stop(!$incomplete && !$skipped); + } + + catch (PHP_CodeCoverage_Exception $cce) { + $error = TRUE; + + if (!isset($e)) { + $e = $cce; + } + } + } + + if ($errorHandlerSet === TRUE) { + restore_error_handler(); + } + + if ($error === TRUE) { + $this->addError($test, $e, $time); + } + + else if ($failure === TRUE) { + $this->addFailure($test, $e, $time); + } + + else if ($this->strictMode && $test->getNumAssertions() == 0) { + $this->addFailure( + $test, + new PHPUnit_Framework_IncompleteTestError( + 'This test did not perform any assertions' + ), + $time + ); + } + + else if ($this->strictMode && $test->hasOutput()) { + $this->addFailure( + $test, + new PHPUnit_Framework_OutputError( + sprintf( + 'This test printed output: %s', + $test->getActualOutput() + ) + ), + $time + ); + } + + $this->endTest($test, $time); + } + + /** + * Gets the number of run tests. + * + * @return integer + */ + public function count() + { + return $this->runTests; + } + + /** + * Checks whether the test run should stop. + * + * @return boolean + */ + public function shouldStop() + { + return $this->stop; + } + + /** + * Marks that the test run should stop. + * + */ + public function stop() + { + $this->stop = TRUE; + } + + /** + * Returns the PHP_CodeCoverage object. + * + * @return PHP_CodeCoverage + * @since Method available since Release 3.5.0 + */ + public function getCodeCoverage() + { + return $this->codeCoverage; + } + + /** + * Returns the PHP_CodeCoverage object. + * + * @return PHP_CodeCoverage + * @since Method available since Release 3.6.0 + */ + public function setCodeCoverage(PHP_CodeCoverage $codeCoverage) + { + $this->codeCoverage = $codeCoverage; + } + + /** + * Enables or disables the error-to-exception conversion. + * + * @param boolean $flag + * @throws InvalidArgumentException + * @since Method available since Release 3.2.14 + */ + public function convertErrorsToExceptions($flag) + { + if (is_bool($flag)) { + $this->convertErrorsToExceptions = $flag; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); + } + } + + /** + * Returns the error-to-exception conversion setting. + * + * @return boolean + * @since Method available since Release 3.4.0 + */ + public function getConvertErrorsToExceptions() + { + return $this->convertErrorsToExceptions; + } + + /** + * Enables or disables the stopping when an error occurs. + * + * @param boolean $flag + * @throws InvalidArgumentException + * @since Method available since Release 3.5.0 + */ + public function stopOnError($flag) + { + if (is_bool($flag)) { + $this->stopOnError = $flag; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); + } + } + + /** + * Enables or disables the stopping when a failure occurs. + * + * @param boolean $flag + * @throws InvalidArgumentException + * @since Method available since Release 3.1.0 + */ + public function stopOnFailure($flag) + { + if (is_bool($flag)) { + $this->stopOnFailure = $flag; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); + } + } + + /** + * Enables or disables the strict mode. + * + * When active + * * Tests that do not assert anything will be marked as incomplete. + * * Tests that are incomplete or skipped yield no code coverage. + * + * @param boolean $flag + * @throws InvalidArgumentException + * @since Method available since Release 3.5.2 + */ + public function strictMode($flag) + { + if (is_bool($flag)) { + $this->strictMode = $flag; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); + } + } + + /** + * Enables or disables the stopping for incomplete tests. + * + * @param boolean $flag + * @throws InvalidArgumentException + * @since Method available since Release 3.5.0 + */ + public function stopOnIncomplete($flag) + { + if (is_bool($flag)) { + $this->stopOnIncomplete = $flag; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); + } + } + + /** + * Enables or disables the stopping for skipped tests. + * + * @param boolean $flag + * @throws InvalidArgumentException + * @since Method available since Release 3.1.0 + */ + public function stopOnSkipped($flag) + { + if (is_bool($flag)) { + $this->stopOnSkipped = $flag; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); + } + } + + /** + * Returns the time spent running the tests. + * + * @return float + */ + public function time() + { + return $this->time; + } + + /** + * Returns whether the entire test was successful or not. + * + * @return boolean + */ + public function wasSuccessful() + { + return empty($this->errors) && empty($this->failures); + } + + /** + * Sets the timeout for small tests. + * + * @param integer $timeout + * @throws InvalidArgumentException + * @since Method available since Release 3.6.0 + */ + public function setTimeoutForSmallTests($timeout) + { + if (is_integer($timeout)) { + $this->timeoutForSmallTests = $timeout; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer'); + } + } + + /** + * Sets the timeout for medium tests. + * + * @param integer $timeout + * @throws InvalidArgumentException + * @since Method available since Release 3.6.0 + */ + public function setTimeoutForMediumTests($timeout) + { + if (is_integer($timeout)) { + $this->timeoutForMediumTests = $timeout; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer'); + } + } + + /** + * Sets the timeout for large tests. + * + * @param integer $timeout + * @throws InvalidArgumentException + * @since Method available since Release 3.6.0 + */ + public function setTimeoutForLargeTests($timeout) + { + if (is_integer($timeout)) { + $this->timeoutForLargeTests = $timeout; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer'); + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/TestSuite/DataProvider.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/TestSuite/DataProvider.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/TestSuite/DataProvider.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/TestSuite/DataProvider.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,71 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework_TestSuite + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.4.0 + */ + +/** + * + * + * @package PHPUnit + * @subpackage Framework_TestSuite + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.4.0 + */ +class PHPUnit_Framework_TestSuite_DataProvider extends PHPUnit_Framework_TestSuite +{ + /** + * Sets the dependencies of a TestCase. + * + * @param array $dependencies + */ + public function setDependencies(array $dependencies) + { + foreach ($this->tests as $test) { + $test->setDependencies($dependencies); + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/TestSuite.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/TestSuite.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/TestSuite.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/TestSuite.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,947 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * A TestSuite is a composite of Tests. It runs a collection of test cases. + * + * Here is an example using the dynamic test definition. + * + * + * addTest(new MathTest('testPass')); + * ?> + * + * + * Alternatively, a TestSuite can extract the tests to be run automatically. + * To do so you pass a ReflectionClass instance for your + * PHPUnit_Framework_TestCase class to the PHPUnit_Framework_TestSuite + * constructor. + * + * + * + * + * + * This constructor creates a suite with all the methods starting with + * "test" that take no arguments. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_Framework_TestSuite implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing, IteratorAggregate +{ + /** + * Enable or disable the backup and restoration of the $GLOBALS array. + * + * @var boolean + */ + protected $backupGlobals = NULL; + + /** + * Enable or disable the backup and restoration of static attributes. + * + * @var boolean + */ + protected $backupStaticAttributes = NULL; + + /** + * The name of the test suite. + * + * @var string + */ + protected $name = ''; + + /** + * The test groups of the test suite. + * + * @var array + */ + protected $groups = array(); + + /** + * The tests in the test suite. + * + * @var array + */ + protected $tests = array(); + + /** + * The number of tests in the test suite. + * + * @var integer + */ + protected $numTests = -1; + + /** + * @var boolean + */ + protected $testCase = FALSE; + + /** + * Constructs a new TestSuite: + * + * - PHPUnit_Framework_TestSuite() constructs an empty TestSuite. + * + * - PHPUnit_Framework_TestSuite(ReflectionClass) constructs a + * TestSuite from the given class. + * + * - PHPUnit_Framework_TestSuite(ReflectionClass, String) + * constructs a TestSuite from the given class with the given + * name. + * + * - PHPUnit_Framework_TestSuite(String) either constructs a + * TestSuite from the given class (if the passed string is the + * name of an existing class) or constructs an empty TestSuite + * with the given name. + * + * @param mixed $theClass + * @param string $name + * @throws InvalidArgumentException + */ + public function __construct($theClass = '', $name = '') + { + $argumentsValid = FALSE; + + if (is_object($theClass) && + $theClass instanceof ReflectionClass) { + $argumentsValid = TRUE; + } + + else if (is_string($theClass) && + $theClass !== '' && + class_exists($theClass, FALSE)) { + $argumentsValid = TRUE; + + if ($name == '') { + $name = $theClass; + } + + $theClass = new ReflectionClass($theClass); + } + + else if (is_string($theClass)) { + $this->setName($theClass); + return; + } + + if (!$argumentsValid) { + throw new InvalidArgumentException; + } + + if (!$theClass->isSubclassOf('PHPUnit_Framework_TestCase')) { + throw new InvalidArgumentException( + 'Class "' . $theClass->name . '" does not extend PHPUnit_Framework_TestCase.' + ); + } + + if ($name != '') { + $this->setName($name); + } else { + $this->setName($theClass->getName()); + } + + $constructor = $theClass->getConstructor(); + + if ($constructor !== NULL && + !$constructor->isPublic()) { + $this->addTest( + self::warning( + sprintf( + 'Class "%s" has no public constructor.', + + $theClass->getName() + ) + ) + ); + + return; + } + + foreach ($theClass->getMethods() as $method) { + if (strpos($method->getDeclaringClass()->getName(), 'PHPUnit_') !== 0) { + $this->addTestMethod($theClass, $method); + } + } + + if (empty($this->tests)) { + $this->addTest( + self::warning( + sprintf( + 'No tests found in class "%s".', + + $theClass->getName() + ) + ) + ); + } + + $this->testCase = TRUE; + } + + /** + * Returns a string representation of the test suite. + * + * @return string + */ + public function toString() + { + return $this->getName(); + } + + /** + * Adds a test to the suite. + * + * @param PHPUnit_Framework_Test $test + * @param array $groups + */ + public function addTest(PHPUnit_Framework_Test $test, $groups = array()) + { + $class = new ReflectionClass($test); + + if (!$class->isAbstract()) { + $this->tests[] = $test; + $this->numTests = -1; + + if ($test instanceof PHPUnit_Framework_TestSuite && + empty($groups)) { + $groups = $test->getGroups(); + } + + if (empty($groups)) { + $groups = array('__nogroup__'); + } + + foreach ($groups as $group) { + if (!isset($this->groups[$group])) { + $this->groups[$group] = array($test); + } else { + $this->groups[$group][] = $test; + } + } + } + } + + /** + * Adds the tests from the given class to the suite. + * + * @param mixed $testClass + * @throws InvalidArgumentException + */ + public function addTestSuite($testClass) + { + if (is_string($testClass) && class_exists($testClass)) { + $testClass = new ReflectionClass($testClass); + } + + if (!is_object($testClass)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory( + 1, 'class name or object' + ); + } + + if ($testClass instanceof PHPUnit_Framework_TestSuite) { + $this->addTest($testClass); + } + + else if ($testClass instanceof ReflectionClass) { + $suiteMethod = FALSE; + + if (!$testClass->isAbstract()) { + if ($testClass->hasMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME)) { + $method = $testClass->getMethod( + PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME + ); + + if ($method->isStatic()) { + $this->addTest( + $method->invoke(NULL, $testClass->getName()) + ); + + $suiteMethod = TRUE; + } + } + } + + if (!$suiteMethod && !$testClass->isAbstract()) { + $this->addTest(new PHPUnit_Framework_TestSuite($testClass)); + } + } + + else { + throw new InvalidArgumentException; + } + } + + /** + * Wraps both addTest() and addTestSuite + * as well as the separate import statements for the user's convenience. + * + * If the named file cannot be read or there are no new tests that can be + * added, a PHPUnit_Framework_Warning will be created instead, + * leaving the current test run untouched. + * + * @param string $filename + * @param array $phptOptions Array with ini settings for the php instance + * run, key being the name if the setting, + * value the ini value. + * @throws InvalidArgumentException + * @since Method available since Release 2.3.0 + * @author Stefano F. Rausch + */ + public function addTestFile($filename, $phptOptions = array()) + { + if (!is_string($filename)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (file_exists($filename) && substr($filename, -5) == '.phpt') { + $this->addTest( + new PHPUnit_Extensions_PhptTestCase($filename, $phptOptions) + ); + + return; + } + + PHPUnit_Util_Class::collectStart(); + $filename = PHPUnit_Util_Fileloader::checkAndLoad($filename); + $newClasses = PHPUnit_Util_Class::collectEnd(); + $baseName = str_replace('.php', '', basename($filename)); + + foreach ($newClasses as $className) { + if (substr($className, 0 - strlen($baseName)) == $baseName) { + $class = new ReflectionClass($className); + + if ($class->getFileName() == $filename) { + $newClasses = array($className); + break; + } + } + } + + $testsFound = FALSE; + + foreach ($newClasses as $className) { + $class = new ReflectionClass($className); + + if (!$class->isAbstract()) { + if ($class->hasMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME)) { + $method = $class->getMethod( + PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME + ); + + if ($method->isStatic()) { + $this->addTest($method->invoke(NULL, $className)); + + $testsFound = TRUE; + } + } + + else if ($class->implementsInterface('PHPUnit_Framework_Test')) { + $this->addTestSuite($class); + + $testsFound = TRUE; + } + } + } + + $this->numTests = -1; + } + + /** + * Wrapper for addTestFile() that adds multiple test files. + * + * @param array|Iterator $filenames + * @throws InvalidArgumentException + * @since Method available since Release 2.3.0 + */ + public function addTestFiles($filenames) + { + if (!(is_array($filenames) || + (is_object($filenames) && $filenames instanceof Iterator))) { + throw PHPUnit_Util_InvalidArgumentHelper::factory( + 1, 'array or iterator' + ); + } + + foreach ($filenames as $filename) { + $this->addTestFile((string)$filename); + } + } + + /** + * Counts the number of test cases that will be run by this test. + * + * @return integer + */ + public function count() + { + if ($this->numTests > -1) { + return $this->numTests; + } + + $this->numTests = 0; + + foreach ($this->tests as $test) { + $this->numTests += count($test); + } + + return $this->numTests; + } + + /** + * @param ReflectionClass $theClass + * @param string $name + * @return PHPUnit_Framework_Test + * @throws RuntimeException + */ + public static function createTest(ReflectionClass $theClass, $name) + { + $className = $theClass->getName(); + + if (!$theClass->isInstantiable()) { + return self::warning( + sprintf('Cannot instantiate class "%s".', $className) + ); + } + + $backupSettings = PHPUnit_Util_Test::getBackupSettings( + $className, $name + ); + $preserveGlobalState = PHPUnit_Util_Test::getPreserveGlobalStateSettings( + $className, $name + ); + $runTestInSeparateProcess = PHPUnit_Util_Test::getProcessIsolationSettings( + $className, $name + ); + + $constructor = $theClass->getConstructor(); + + if ($constructor !== NULL) { + $parameters = $constructor->getParameters(); + + // TestCase() or TestCase($name) + if (count($parameters) < 2) { + $test = new $className; + } + + // TestCase($name, $data) + else { + try { + $data = PHPUnit_Util_Test::getProvidedData( + $className, $name + ); + } + + catch (Exception $e) { + $message = sprintf( + 'The data provider specified for %s::%s is invalid.', + $className, + $name + ); + + $_message = $e->getMessage(); + + if (!empty($_message)) { + $message .= "\n" . $_message; + } + + $data = self::warning($message); + } + + // Test method with @dataProvider. + if (isset($data)) { + $test = new PHPUnit_Framework_TestSuite_DataProvider( + $className . '::' . $name + ); + + if (empty($data)) { + $data = self::warning( + sprintf( + 'No tests found in suite "%s".', + $test->getName() + ) + ); + } + + if ($data instanceof PHPUnit_Framework_Warning) { + $test->addTest($data); + } + + else { + $groups = PHPUnit_Util_Test::getGroups($className, $name); + + foreach ($data as $_dataName => $_data) { + $_test = new $className($name, $_data, $_dataName); + + if ($runTestInSeparateProcess) { + $_test->setRunTestInSeparateProcess(TRUE); + + if ($preserveGlobalState !== NULL) { + $_test->setPreserveGlobalState($preserveGlobalState); + } + } + + if ($backupSettings['backupGlobals'] !== NULL) { + $_test->setBackupGlobals( + $backupSettings['backupGlobals'] + ); + } + + if ($backupSettings['backupStaticAttributes'] !== NULL) { + $_test->setBackupStaticAttributes( + $backupSettings['backupStaticAttributes'] + ); + } + + $test->addTest($_test, $groups); + } + } + } + + else { + $test = new $className; + } + } + } + + if (!isset($test)) { + throw new RuntimeException('No valid test provided.'); + } + + if ($test instanceof PHPUnit_Framework_TestCase) { + $test->setName($name); + + if ($runTestInSeparateProcess) { + $test->setRunTestInSeparateProcess(TRUE); + + if ($preserveGlobalState !== NULL) { + $test->setPreserveGlobalState($preserveGlobalState); + } + } + + if ($backupSettings['backupGlobals'] !== NULL) { + $test->setBackupGlobals($backupSettings['backupGlobals']); + } + + if ($backupSettings['backupStaticAttributes'] !== NULL) { + $test->setBackupStaticAttributes( + $backupSettings['backupStaticAttributes'] + ); + } + } + + return $test; + } + + /** + * Creates a default TestResult object. + * + * @return PHPUnit_Framework_TestResult + */ + protected function createResult() + { + return new PHPUnit_Framework_TestResult; + } + + /** + * Returns the name of the suite. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Returns the test groups of the suite. + * + * @return array + * @since Method available since Release 3.2.0 + */ + public function getGroups() + { + return array_keys($this->groups); + } + + /** + * Runs the tests and collects their result in a TestResult. + * + * @param PHPUnit_Framework_TestResult $result + * @param mixed $filter + * @param array $groups + * @param array $excludeGroups + * @param boolean $processIsolation + * @return PHPUnit_Framework_TestResult + * @throws InvalidArgumentException + */ + public function run(PHPUnit_Framework_TestResult $result = NULL, $filter = FALSE, array $groups = array(), array $excludeGroups = array(), $processIsolation = FALSE) + { + if ($result === NULL) { + $result = $this->createResult(); + } + + $result->startTestSuite($this); + + $doSetup = TRUE; + + if (!empty($excludeGroups)) { + foreach ($this->groups as $_group => $_tests) { + if (in_array($_group, $excludeGroups) && + count($_tests) == count($this->tests)) { + $doSetup = FALSE; + } + } + } + + if ($doSetup) { + try { + $this->setUp(); + + if ($this->testCase && + method_exists($this->name, 'setUpBeforeClass')) { + call_user_func(array($this->name, 'setUpBeforeClass')); + } + } + + catch (PHPUnit_Framework_SkippedTestSuiteError $e) { + $numTests = count($this); + + for ($i = 0; $i < $numTests; $i++) { + $result->addFailure($this, $e, 0); + } + + return $result; + } + + catch (Exception $e) { + $numTests = count($this); + + for ($i = 0; $i < $numTests; $i++) { + $result->addError($this, $e, 0); + } + + return $result; + } + } + + if (empty($groups)) { + $tests = $this->tests; + } else { + $tests = new SplObjectStorage; + + foreach ($groups as $group) { + if (isset($this->groups[$group])) { + foreach ($this->groups[$group] as $test) { + $tests->attach($test); + } + } + } + } + + foreach ($tests as $test) { + if ($result->shouldStop()) { + break; + } + + if ($test instanceof PHPUnit_Framework_TestSuite) { + $test->setBackupGlobals($this->backupGlobals); + $test->setBackupStaticAttributes($this->backupStaticAttributes); + + $test->run( + $result, $filter, $groups, $excludeGroups, $processIsolation + ); + } else { + $runTest = TRUE; + + if ($filter !== FALSE ) { + $tmp = PHPUnit_Util_Test::describe($test, FALSE); + + if ($tmp[0] != '') { + $name = join('::', $tmp); + } else { + $name = $tmp[1]; + } + + if (preg_match($filter, $name) == 0) { + $runTest = FALSE; + } + } + + if ($runTest && !empty($excludeGroups)) { + foreach ($this->groups as $_group => $_tests) { + if (in_array($_group, $excludeGroups)) { + foreach ($_tests as $_test) { + if ($test === $_test) { + $runTest = FALSE; + break 2; + } + } + } + } + } + + if ($runTest) { + if ($test instanceof PHPUnit_Framework_TestCase) { + $test->setBackupGlobals($this->backupGlobals); + $test->setBackupStaticAttributes( + $this->backupStaticAttributes + ); + $test->setRunTestInSeparateProcess($processIsolation); + } + + $this->runTest($test, $result); + } + } + } + + if ($doSetup) { + if ($this->testCase && + method_exists($this->name, 'tearDownAfterClass')) { + call_user_func(array($this->name, 'tearDownAfterClass')); + } + + $this->tearDown(); + } + + $result->endTestSuite($this); + + return $result; + } + + /** + * Runs a test. + * + * @param PHPUnit_Framework_Test $test + * @param PHPUnit_Framework_TestResult $testResult + */ + public function runTest(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result) + { + $test->run($result); + } + + /** + * Sets the name of the suite. + * + * @param string + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * Returns the test at the given index. + * + * @param integer + * @return PHPUnit_Framework_Test + */ + public function testAt($index) + { + if (isset($this->tests[$index])) { + return $this->tests[$index]; + } else { + return FALSE; + } + } + + /** + * Returns the tests as an enumeration. + * + * @return array + */ + public function tests() + { + return $this->tests; + } + + /** + * Mark the test suite as skipped. + * + * @param string $message + * @throws PHPUnit_Framework_SkippedTestSuiteError + * @since Method available since Release 3.0.0 + */ + public function markTestSuiteSkipped($message = '') + { + throw new PHPUnit_Framework_SkippedTestSuiteError($message); + } + + /** + * @param ReflectionClass $class + * @param ReflectionMethod $method + */ + protected function addTestMethod(ReflectionClass $class, ReflectionMethod $method) + { + $name = $method->getName(); + + if ($this->isPublicTestMethod($method)) { + $test = self::createTest($class, $name); + + if ($test instanceof PHPUnit_Framework_TestCase || + $test instanceof PHPUnit_Framework_TestSuite_DataProvider) { + $test->setDependencies( + PHPUnit_Util_Test::getDependencies($class->getName(), $name) + ); + } + + $this->addTest($test, PHPUnit_Util_Test::getGroups( + $class->getName(), $name) + ); + } + + else if ($this->isTestMethod($method)) { + $this->addTest( + self::warning( + sprintf( + 'Test method "%s" in test class "%s" is not public.', + $name, + $class->getName() + ) + ) + ); + } + } + + /** + * @param ReflectionMethod $method + * @return boolean + */ + public static function isPublicTestMethod(ReflectionMethod $method) + { + return (self::isTestMethod($method) && $method->isPublic()); + } + + /** + * @param ReflectionMethod $method + * @return boolean + */ + public static function isTestMethod(ReflectionMethod $method) + { + if (strpos($method->name, 'test') === 0) { + return TRUE; + } + + // @scenario on TestCase::testMethod() + // @test on TestCase::testMethod() + return strpos($method->getDocComment(), '@test') !== FALSE || + strpos($method->getDocComment(), '@scenario') !== FALSE; + } + + /** + * @param string $message + * @return PHPUnit_Framework_Warning + */ + protected static function warning($message) + { + return new PHPUnit_Framework_Warning($message); + } + + /** + * @param boolean $backupGlobals + * @since Method available since Release 3.3.0 + */ + public function setBackupGlobals($backupGlobals) + { + if (is_null($this->backupGlobals) && is_bool($backupGlobals)) { + $this->backupGlobals = $backupGlobals; + } + } + + /** + * @param boolean $backupStaticAttributes + * @since Method available since Release 3.4.0 + */ + public function setBackupStaticAttributes($backupStaticAttributes) + { + if (is_null($this->backupStaticAttributes) && + is_bool($backupStaticAttributes)) { + $this->backupStaticAttributes = $backupStaticAttributes; + } + } + + /** + * Returns an iterator for this test suite. + * + * @return RecursiveIteratorIterator + * @since Method available since Release 3.1.0 + */ + public function getIterator() + { + return new RecursiveIteratorIterator( + new PHPUnit_Util_TestSuiteIterator($this) + ); + } + + /** + * Template Method that is called before the tests + * of this test suite are run. + * + * @since Method available since Release 3.1.0 + */ + protected function setUp() + { + } + + /** + * Template Method that is called after the tests + * of this test suite have finished running. + * + * @since Method available since Release 3.1.0 + */ + protected function tearDown() + { + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Warning.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Warning.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Framework/Warning.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Framework/Warning.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,126 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * A warning. + * + * @package PHPUnit + * @subpackage Framework + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_Framework_Warning extends PHPUnit_Framework_TestCase +{ + /** + * @var string + */ + protected $message = ''; + + /** + * @var boolean + */ + protected $backupGlobals = FALSE; + + /** + * @var boolean + */ + protected $backupStaticAttributes = FALSE; + + /** + * @var boolean + */ + protected $runTestInSeparateProcess = FALSE; + + /** + * @var boolean + */ + protected $useErrorHandler = FALSE; + + /** + * @var boolean + */ + protected $useOutputBuffering = FALSE; + + /** + * @param string $message + */ + public function __construct($message = '') + { + $this->message = $message; + parent::__construct('Warning'); + } + + /** + * @throws RuntimeException + */ + protected function runTest() + { + $this->fail($this->message); + } + + /** + * @return string + * @since Method available since Release 3.0.0 + */ + public function getMessage() + { + return $this->message; + } + + /** + * Returns a string representation of the test case. + * + * @return string + * @since Method available since Release 3.4.0 + */ + public function toString() + { + return 'Warning'; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Runner/BaseTestRunner.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Runner/BaseTestRunner.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Runner/BaseTestRunner.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Runner/BaseTestRunner.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,189 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Runner + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * Base class for all test runners. + * + * @package PHPUnit + * @subpackage Runner + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +abstract class PHPUnit_Runner_BaseTestRunner +{ + const STATUS_PASSED = 0; + const STATUS_SKIPPED = 1; + const STATUS_INCOMPLETE = 2; + const STATUS_FAILURE = 3; + const STATUS_ERROR = 4; + const SUITE_METHODNAME = 'suite'; + + /** + * Returns the loader to be used. + * + * @return PHPUnit_Runner_TestSuiteLoader + */ + public function getLoader() + { + return new PHPUnit_Runner_StandardTestSuiteLoader; + } + + /** + * Returns the Test corresponding to the given suite. + * This is a template method, subclasses override + * the runFailed() and clearStatus() methods. + * + * @param string $suiteClassName + * @param string $suiteClassFile + * @return PHPUnit_Framework_Test + */ + public function getTest($suiteClassName, $suiteClassFile = '') + { + if (is_dir($suiteClassName) && + !is_file($suiteClassName . '.php') && empty($suiteClassFile)) { + $facade = new File_Iterator_Facade; + $files = $facade->getFilesAsArray( + $suiteClassName, array('Test.php', '.phpt') + ); + + $suite = new PHPUnit_Framework_TestSuite($suiteClassName); + $suite->addTestFiles($files); + + return $suite; + } + + try { + $testClass = $this->loadSuiteClass( + $suiteClassName, $suiteClassFile + ); + } + + catch (Exception $e) { + $this->runFailed($e->getMessage()); + return NULL; + } + + try { + $suiteMethod = $testClass->getMethod(self::SUITE_METHODNAME); + + if (!$suiteMethod->isStatic()) { + $this->runFailed( + 'suite() method must be static.' + ); + + return NULL; + } + + try { + $test = $suiteMethod->invoke(NULL, $testClass->getName()); + } + + catch (ReflectionException $e) { + $this->runFailed( + sprintf( + "Failed to invoke suite() method.\n%s", + + $e->getMessage() + ) + ); + + return NULL; + } + } + + catch (ReflectionException $e) { + try { + $test = new PHPUnit_Framework_TestSuite($testClass); + } + + catch (InvalidArgumentException $e) { + $test = new PHPUnit_Framework_TestSuite; + $test->setName($suiteClassName); + } + } + + $this->clearStatus(); + + return $test; + } + + /** + * Returns the loaded ReflectionClass for a suite name. + * + * @param string $suiteClassName + * @param string $suiteClassFile + * @return ReflectionClass + */ + protected function loadSuiteClass($suiteClassName, $suiteClassFile = '') + { + $loader = $this->getLoader(); + + if ($loader instanceof PHPUnit_Runner_StandardTestSuiteLoader) { + return $loader->load($suiteClassName, $suiteClassFile); + } else { + return $loader->load($suiteClassName, $suiteClassFile); + } + } + + /** + * Clears the status message. + * + */ + protected function clearStatus() + { + } + + /** + * Override to define how to handle a failed loading of + * a test suite. + * + * @param string $message + */ + abstract protected function runFailed($message); +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Runner/StandardTestSuiteLoader.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Runner/StandardTestSuiteLoader.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Runner/StandardTestSuiteLoader.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Runner/StandardTestSuiteLoader.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,154 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Runner + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * The standard test suite loader. + * + * @package PHPUnit + * @subpackage Runner + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_Runner_StandardTestSuiteLoader implements PHPUnit_Runner_TestSuiteLoader +{ + /** + * @param string $suiteClassName + * @param string $suiteClassFile + * @return ReflectionClass + * @throws RuntimeException + */ + public function load($suiteClassName, $suiteClassFile = '') + { + $suiteClassName = str_replace('.php', '', $suiteClassName); + + if (empty($suiteClassFile)) { + $suiteClassFile = PHPUnit_Util_Filesystem::classNameToFilename( + $suiteClassName + ); + } + + if (!class_exists($suiteClassName, FALSE)) { + PHPUnit_Util_Class::collectStart(); + $filename = PHPUnit_Util_Fileloader::checkAndLoad($suiteClassFile); + $loadedClasses = PHPUnit_Util_Class::collectEnd(); + } + + if (!class_exists($suiteClassName, FALSE) && !empty($loadedClasses)) { + $offset = 0 - strlen($suiteClassName); + + foreach ($loadedClasses as $loadedClass) { + $class = new ReflectionClass($loadedClass); + if (substr($loadedClass, $offset) === $suiteClassName && + $class->getFileName() == $filename) { + $suiteClassName = $loadedClass; + break; + } + } + } + + if (!class_exists($suiteClassName, FALSE) && !empty($loadedClasses)) { + $testCaseClass = 'PHPUnit_Framework_TestCase'; + + foreach ($loadedClasses as $loadedClass) { + $class = new ReflectionClass($loadedClass); + $classFile = $class->getFileName(); + + if ($class->isSubclassOf($testCaseClass) && + !$class->isAbstract()) { + $suiteClassName = $loadedClass; + $testCaseClass = $loadedClass; + + if ($classFile == realpath($suiteClassFile)) { + break; + } + } + + if ($class->hasMethod('suite')) { + $method = $class->getMethod('suite'); + + if (!$method->isAbstract() && + $method->isPublic() && + $method->isStatic()) { + $suiteClassName = $loadedClass; + + if ($classFile == realpath($suiteClassFile)) { + break; + } + } + } + } + } + + if (class_exists($suiteClassName, FALSE)) { + $class = new ReflectionClass($suiteClassName); + + if ($class->getFileName() == realpath($suiteClassFile)) { + return $class; + } + } + + throw new PHPUnit_Framework_Exception( + sprintf( + 'Class %s could not be found in %s.', + + $suiteClassName, + $suiteClassFile + ) + ); + } + + /** + * @param ReflectionClass $aClass + * @return ReflectionClass + */ + public function reload(ReflectionClass $aClass) + { + return $aClass; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Runner/TestSuiteLoader.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Runner/TestSuiteLoader.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Runner/TestSuiteLoader.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Runner/TestSuiteLoader.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,72 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Runner + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * An interface to define how a test suite should be loaded. + * + * @package PHPUnit + * @subpackage Runner + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Interface available since Release 2.0.0 + */ +interface PHPUnit_Runner_TestSuiteLoader +{ + /** + * @param string $suiteClassName + * @param string $suiteClassFile + * @return ReflectionClass + */ + public function load($suiteClassName, $suiteClassFile = ''); + + /** + * @param ReflectionClass $aClass + * @return ReflectionClass + */ + public function reload(ReflectionClass $aClass); +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Runner/Version.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Runner/Version.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Runner/Version.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Runner/Version.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,77 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Runner + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * This class defines the current version of PHPUnit. + * + * @package PHPUnit + * @subpackage Runner + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_Runner_Version +{ + /** + * Returns the current version of PHPUnit. + * + * @return string + */ + public static function id() + { + return '3.6.10'; + } + + /** + * @return string + */ + public static function getVersionString() + { + return 'PHPUnit 3.6.10 by Sebastian Bergmann.'; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/TextUI/Command.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/TextUI/Command.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/TextUI/Command.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/TextUI/Command.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,985 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage TextUI + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * A TestRunner for the Command Line Interface (CLI) + * PHP SAPI Module. + * + * @package PHPUnit + * @subpackage TextUI + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_TextUI_Command +{ + /** + * @var array + */ + protected $arguments = array( + 'listGroups' => FALSE, + 'loader' => NULL, + 'useDefaultConfiguration' => TRUE + ); + + /** + * @var array + */ + protected $options = array(); + + /** + * @var array + */ + protected $longOptions = array( + 'colors' => NULL, + 'bootstrap=' => NULL, + 'configuration=' => NULL, + 'coverage-html=' => NULL, + 'coverage-clover=' => NULL, + 'coverage-php=' => NULL, + 'coverage-text==' => NULL, + 'debug' => NULL, + 'exclude-group=' => NULL, + 'filter=' => NULL, + 'group=' => NULL, + 'help' => NULL, + 'include-path=' => NULL, + 'list-groups' => NULL, + 'loader=' => NULL, + 'log-json=' => NULL, + 'log-junit=' => NULL, + 'log-tap=' => NULL, + 'process-isolation' => NULL, + 'repeat=' => NULL, + 'skeleton-class' => NULL, + 'skeleton-test' => NULL, + 'stderr' => NULL, + 'stop-on-error' => NULL, + 'stop-on-failure' => NULL, + 'stop-on-incomplete' => NULL, + 'stop-on-skipped' => NULL, + 'strict' => NULL, + 'tap' => NULL, + 'testdox' => NULL, + 'testdox-html=' => NULL, + 'testdox-text=' => NULL, + 'no-configuration' => NULL, + 'no-globals-backup' => NULL, + 'printer=' => NULL, + 'static-backup' => NULL, + 'verbose' => NULL, + 'version' => NULL + ); + + /** + * @var array + */ + protected $missingExtensions = array(); + + /** + * @param boolean $exit + */ + public static function main($exit = TRUE) + { + $command = new PHPUnit_TextUI_Command; + return $command->run($_SERVER['argv'], $exit); + } + + /** + * @param array $argv + * @param boolean $exit + */ + public function run(array $argv, $exit = TRUE) + { + $this->handleArguments($argv); + + $runner = $this->createRunner(); + + if (is_object($this->arguments['test']) && + $this->arguments['test'] instanceof PHPUnit_Framework_Test) { + $suite = $this->arguments['test']; + } else { + $suite = $runner->getTest( + $this->arguments['test'], + $this->arguments['testFile'] + ); + } + + if (count($suite) == 0) { + $skeleton = new PHPUnit_Util_Skeleton_Test( + $suite->getName(), + $this->arguments['testFile'] + ); + + $result = $skeleton->generate(TRUE); + + if (!$result['incomplete']) { + eval(str_replace(array(''), '', $result['code'])); + $suite = new PHPUnit_Framework_TestSuite( + $this->arguments['test'] . 'Test' + ); + } + } + + if ($this->arguments['listGroups']) { + PHPUnit_TextUI_TestRunner::printVersionString(); + + print "Available test group(s):\n"; + + $groups = $suite->getGroups(); + sort($groups); + + foreach ($groups as $group) { + print " - $group\n"; + } + + if ($exit) { + exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); + } else { + return PHPUnit_TextUI_TestRunner::SUCCESS_EXIT; + } + } + + unset($this->arguments['test']); + unset($this->arguments['testFile']); + + try { + $result = $runner->doRun($suite, $this->arguments); + } + + catch (PHPUnit_Framework_Exception $e) { + print $e->getMessage() . "\n"; + } + + $ret = PHPUnit_TextUI_TestRunner::FAILURE_EXIT; + + if (isset($result) && $result->wasSuccessful()) { + $ret = PHPUnit_TextUI_TestRunner::SUCCESS_EXIT; + } + + else if (!isset($result) || $result->errorCount() > 0) { + $ret = PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT; + } + + if ($exit) { + exit($ret); + } else { + return $ret; + } + } + + /** + * Create a TestRunner, override in subclasses. + * + * @return PHPUnit_TextUI_TestRunner + * @since Method available since Release 3.6.0 + */ + protected function createRunner() + { + return new PHPUnit_TextUI_TestRunner($this->arguments['loader']); + } + + /** + * Handles the command-line arguments. + * + * A child class of PHPUnit_TextUI_Command can hook into the argument + * parsing by adding the switch(es) to the $longOptions array and point to a + * callback method that handles the switch(es) in the child class like this + * + * + * longOptions['--my-switch'] = 'myHandler'; + * } + * + * // --my-switch foo -> myHandler('foo') + * protected function myHandler($value) + * { + * } + * } + * + * + * @param array $argv + */ + protected function handleArguments(array $argv) + { + try { + $this->options = PHPUnit_Util_Getopt::getopt( + $argv, + 'd:c:hv', + array_keys($this->longOptions) + ); + } + + catch (RuntimeException $e) { + PHPUnit_TextUI_TestRunner::showError($e->getMessage()); + } + + $skeletonClass = FALSE; + $skeletonTest = FALSE; + + foreach ($this->options[0] as $option) { + switch ($option[0]) { + case '--colors': { + $this->arguments['colors'] = TRUE; + } + break; + + case '--bootstrap': { + $this->arguments['bootstrap'] = $option[1]; + } + break; + + case 'c': + case '--configuration': { + $this->arguments['configuration'] = $option[1]; + } + break; + + case '--coverage-clover': + case '--coverage-html': + case '--coverage-php': + case '--coverage-text': { + if (!extension_loaded('tokenizer')) { + $this->showExtensionNotLoadedMessage( + 'tokenizer', 'No code coverage will be generated.' + ); + + continue; + } + + if (!extension_loaded('xdebug')) { + $this->showExtensionNotLoadedMessage( + 'Xdebug', 'No code coverage will be generated.' + ); + + continue; + } + + switch ($option[0]) { + case '--coverage-clover': { + $this->arguments['coverageClover'] = $option[1]; + } + break; + + case '--coverage-html': { + $this->arguments['reportDirectory'] = $option[1]; + } + break; + + case '--coverage-php': { + $this->arguments['coveragePHP'] = $option[1]; + } + break; + + case '--coverage-text': { + if ($option[1] === NULL) { + $option[1] = 'php://stdout'; + } + + $this->arguments['coverageText'] = $option[1]; + $this->arguments['coverageTextShowUncoveredFiles'] = FALSE; + } + break; + } + } + break; + + case 'd': { + $ini = explode('=', $option[1]); + + if (isset($ini[0])) { + if (isset($ini[1])) { + ini_set($ini[0], $ini[1]); + } else { + ini_set($ini[0], TRUE); + } + } + } + break; + + case '--debug': { + $this->arguments['debug'] = TRUE; + } + break; + + case 'h': + case '--help': { + $this->showHelp(); + exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); + } + break; + + case '--filter': { + $this->arguments['filter'] = $option[1]; + } + break; + + case '--group': { + $this->arguments['groups'] = explode(',', $option[1]); + } + break; + + case '--exclude-group': { + $this->arguments['excludeGroups'] = explode( + ',', $option[1] + ); + } + break; + + case '--include-path': { + $includePath = $option[1]; + } + break; + + case '--list-groups': { + $this->arguments['listGroups'] = TRUE; + } + break; + + case '--printer': { + $this->arguments['printer'] = $option[1]; + } + break; + + case '--loader': { + $this->arguments['loader'] = $option[1]; + } + break; + + case '--log-json': { + $this->arguments['jsonLogfile'] = $option[1]; + } + break; + + case '--log-junit': { + $this->arguments['junitLogfile'] = $option[1]; + } + break; + + case '--log-tap': { + $this->arguments['tapLogfile'] = $option[1]; + } + break; + + case '--process-isolation': { + $this->arguments['processIsolation'] = TRUE; + } + break; + + case '--repeat': { + $this->arguments['repeat'] = (int)$option[1]; + } + break; + + case '--stderr': { + $this->arguments['printer'] = new PHPUnit_TextUI_ResultPrinter( + 'php://stderr', + isset($this->arguments['verbose']) ? $this->arguments['verbose'] : FALSE + ); + } + break; + + case '--stop-on-error': { + $this->arguments['stopOnError'] = TRUE; + } + break; + + case '--stop-on-failure': { + $this->arguments['stopOnFailure'] = TRUE; + } + break; + + case '--stop-on-incomplete': { + $this->arguments['stopOnIncomplete'] = TRUE; + } + break; + + case '--stop-on-skipped': { + $this->arguments['stopOnSkipped'] = TRUE; + } + break; + + case '--skeleton-test': { + $skeletonTest = TRUE; + $skeletonClass = FALSE; + } + break; + + case '--skeleton-class': { + $skeletonClass = TRUE; + $skeletonTest = FALSE; + } + break; + + case '--tap': { + $this->arguments['printer'] = new PHPUnit_Util_Log_TAP; + } + break; + + case '--testdox': { + $this->arguments['printer'] = new PHPUnit_Util_TestDox_ResultPrinter_Text; + } + break; + + case '--testdox-html': { + $this->arguments['testdoxHTMLFile'] = $option[1]; + } + break; + + case '--testdox-text': { + $this->arguments['testdoxTextFile'] = $option[1]; + } + break; + + case '--no-configuration': { + $this->arguments['useDefaultConfiguration'] = FALSE; + } + break; + + case '--no-globals-backup': { + $this->arguments['backupGlobals'] = FALSE; + } + break; + + case '--static-backup': { + $this->arguments['backupStaticAttributes'] = TRUE; + } + break; + + case 'v': + case '--verbose': { + $this->arguments['verbose'] = TRUE; + } + break; + + case '--version': { + PHPUnit_TextUI_TestRunner::printVersionString(); + exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); + } + break; + + case '--strict': { + $this->arguments['strict'] = TRUE; + } + break; + + default: { + $optionName = str_replace('--', '', $option[0]); + + if (isset($this->longOptions[$optionName])) { + $handler = $this->longOptions[$optionName]; + } + + else if (isset($this->longOptions[$optionName . '='])) { + $handler = $this->longOptions[$optionName . '=']; + } + + if (isset($handler) && is_callable(array($this, $handler))) { + $this->$handler($option[1]); + } + } + } + } + + $this->handleCustomTestSuite(); + + if (!isset($this->arguments['test'])) { + if (isset($this->options[1][0])) { + $this->arguments['test'] = $this->options[1][0]; + } + + if (isset($this->options[1][1])) { + $this->arguments['testFile'] = $this->options[1][1]; + } else { + $this->arguments['testFile'] = ''; + } + + if (isset($this->arguments['test']) && + is_file($this->arguments['test']) && + substr($this->arguments['test'], -5, 5) != '.phpt') { + $this->arguments['testFile'] = realpath($this->arguments['test']); + $this->arguments['test'] = substr($this->arguments['test'], 0, strrpos($this->arguments['test'], '.')); + } + } + + if (isset($includePath)) { + ini_set( + 'include_path', + $includePath . PATH_SEPARATOR . ini_get('include_path') + ); + } + + if (isset($this->arguments['bootstrap'])) { + $this->handleBootstrap($this->arguments['bootstrap']); + } + + if (isset($this->arguments['printer']) && + is_string($this->arguments['printer'])) { + $this->arguments['printer'] = $this->handlePrinter($this->arguments['printer']); + } + + if ($this->arguments['loader'] !== NULL) { + $this->arguments['loader'] = $this->handleLoader($this->arguments['loader']); + } + + if (isset($this->arguments['configuration']) && + is_dir($this->arguments['configuration'])) { + $configurationFile = $this->arguments['configuration'] . + '/phpunit.xml'; + + if (file_exists($configurationFile)) { + $this->arguments['configuration'] = realpath( + $configurationFile + ); + } + + else if (file_exists($configurationFile . '.dist')) { + $this->arguments['configuration'] = realpath( + $configurationFile . '.dist' + ); + } + } + + else if (!isset($this->arguments['configuration']) && + $this->arguments['useDefaultConfiguration']) { + if (file_exists('phpunit.xml')) { + $this->arguments['configuration'] = realpath('phpunit.xml'); + } else if (file_exists('phpunit.xml.dist')) { + $this->arguments['configuration'] = realpath( + 'phpunit.xml.dist' + ); + } + } + + if (isset($this->arguments['configuration'])) { + try { + $configuration = PHPUnit_Util_Configuration::getInstance( + $this->arguments['configuration'] + ); + } + + catch (Exception $e) { + print $e->getMessage() . "\n"; + exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); + } + + $phpunit = $configuration->getPHPUnitConfiguration(); + + $configuration->handlePHPConfiguration(); + + if (!isset($this->arguments['bootstrap']) && isset($phpunit['bootstrap'])) { + $this->handleBootstrap($phpunit['bootstrap']); + } + + if (isset($phpunit['printerClass'])) { + if (isset($phpunit['printerFile'])) { + $file = $phpunit['printerFile']; + } else { + $file = ''; + } + + $this->arguments['printer'] = $this->handlePrinter( + $phpunit['printerClass'], $file + ); + } + + if (isset($phpunit['testSuiteLoaderClass'])) { + if (isset($phpunit['testSuiteLoaderFile'])) { + $file = $phpunit['testSuiteLoaderFile']; + } else { + $file = ''; + } + + $this->arguments['loader'] = $this->handleLoader( + $phpunit['testSuiteLoaderClass'], $file + ); + } + + $logging = $configuration->getLoggingConfiguration(); + + if (isset($logging['coverage-html']) || isset($logging['coverage-clover']) || isset($logging['coverage-text']) ) { + if (!extension_loaded('tokenizer')) { + $this->showExtensionNotLoadedMessage( + 'tokenizer', 'No code coverage will be generated.' + ); + } + + else if (!extension_loaded('Xdebug')) { + $this->showExtensionNotLoadedMessage( + 'Xdebug', 'No code coverage will be generated.' + ); + } + } + + $browsers = $configuration->getSeleniumBrowserConfiguration(); + + if (!empty($browsers) && + class_exists('PHPUnit_Extensions_SeleniumTestCase')) { + PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers; + } + + if (!isset($this->arguments['test'])) { + $testSuite = $configuration->getTestSuiteConfiguration(); + + if ($testSuite !== NULL) { + $this->arguments['test'] = $testSuite; + } + } + } + + if (isset($this->arguments['test']) && is_string($this->arguments['test']) && substr($this->arguments['test'], -5, 5) == '.phpt') { + $test = new PHPUnit_Extensions_PhptTestCase($this->arguments['test']); + + $this->arguments['test'] = new PHPUnit_Framework_TestSuite; + $this->arguments['test']->addTest($test); + } + + if (!isset($this->arguments['test']) || + (isset($this->arguments['testDatabaseLogRevision']) && !isset($this->arguments['testDatabaseDSN']))) { + $this->showHelp(); + exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); + } + + if ($skeletonClass || $skeletonTest) { + if (isset($this->arguments['test']) && $this->arguments['test'] !== FALSE) { + PHPUnit_TextUI_TestRunner::printVersionString(); + + print <<options[1][$i])) { + $args[] = $this->options[1][$i]; + } + } + + $skeleton = $reflector->newInstanceArgs($args); + $skeleton->write(); + } + + catch (Exception $e) { + print $e->getMessage() . "\n"; + exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); + } + + printf( + 'Wrote skeleton for "%s" to "%s".' . "\n", + $skeleton->getOutClassName(), + $skeleton->getOutSourceFile() + ); + + exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); + } else { + $this->showHelp(); + exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); + } + } + } + + /** + * Handles the loading of the PHPUnit_Runner_TestSuiteLoader implementation. + * + * @param string $loaderClass + * @param string $loaderFile + * @return PHPUnit_Runner_TestSuiteLoader + */ + protected function handleLoader($loaderClass, $loaderFile = '') + { + if (!class_exists($loaderClass, FALSE)) { + if ($loaderFile == '') { + $loaderFile = PHPUnit_Util_Filesystem::classNameToFilename( + $loaderClass + ); + } + + $loaderFile = PHPUnit_Util_Filesystem::fileExistsInIncludePath( + $loaderFile + ); + + if ($loaderFile !== FALSE) { + require $loaderFile; + } + } + + if (class_exists($loaderClass, FALSE)) { + $class = new ReflectionClass($loaderClass); + + if ($class->implementsInterface('PHPUnit_Runner_TestSuiteLoader') && + $class->isInstantiable()) { + $loader = $class->newInstance(); + } + } + + if (!isset($loader)) { + PHPUnit_TextUI_TestRunner::showError( + sprintf( + 'Could not use "%s" as loader.', + + $loaderClass + ) + ); + } + + return $loader; + } + + /** + * Handles the loading of the PHPUnit_Util_Printer implementation. + * + * @param string $printerClass + * @param string $printerFile + * @return PHPUnit_Util_Printer + */ + protected function handlePrinter($printerClass, $printerFile = '') + { + if (!class_exists($printerClass, FALSE)) { + if ($printerFile == '') { + $printerFile = PHPUnit_Util_Filesystem::classNameToFilename( + $printerClass + ); + } + + $printerFile = PHPUnit_Util_Filesystem::fileExistsInIncludePath( + $printerFile + ); + + if ($printerFile !== FALSE) { + require $printerFile; + } + } + + if (class_exists($printerClass, FALSE)) { + $class = new ReflectionClass($printerClass); + + if ($class->implementsInterface('PHPUnit_Framework_TestListener') && + $class->isSubclassOf('PHPUnit_Util_Printer') && + $class->isInstantiable()) { + $printer = $class->newInstance(); + } + } + + if (!isset($printer)) { + PHPUnit_TextUI_TestRunner::showError( + sprintf( + 'Could not use "%s" as printer.', + + $printerClass + ) + ); + } + + return $printer; + } + + /** + * Loads a bootstrap file. + * + * @param string $filename + */ + protected function handleBootstrap($filename) + { + try { + PHPUnit_Util_Fileloader::checkAndLoad($filename); + } + + catch (RuntimeException $e) { + PHPUnit_TextUI_TestRunner::showError($e->getMessage()); + } + } + + /** + * @param string $message + * @since Method available since Release 3.6.0 + */ + protected function showExtensionNotLoadedMessage($extension, $message = '') + { + if (isset($this->missingExtensions[$extension])) { + return; + } + + if (!empty($message)) { + $message = ' ' . $message; + } + + $this->showMessage( + 'The ' . $extension . ' extension is not loaded.' . $message . "\n", + FALSE + ); + + $this->missingExtensions[$extension] = TRUE; + } + + /** + * Shows a message. + * + * @param string $message + * @param boolean $exit + */ + protected function showMessage($message, $exit = TRUE) + { + PHPUnit_TextUI_TestRunner::printVersionString(); + print $message . "\n"; + + if ($exit) { + exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); + } else { + print "\n"; + } + } + + /** + * Show the help message. + */ + protected function showHelp() + { + PHPUnit_TextUI_TestRunner::printVersionString(); + + print << + + --log-junit Log test execution in JUnit XML format to file. + --log-tap Log test execution in TAP format to file. + --log-json Log test execution in JSON format. + + --coverage-clover Generate code coverage report in Clover XML format. + --coverage-html Generate code coverage report in HTML format. + --coverage-php Serialize PHP_CodeCoverage object to file. + --coverage-text= Generate code coverage report in text format. + Default to writing to the standard output. + + --testdox-html Write agile documentation in HTML format to file. + --testdox-text Write agile documentation in Text format to file. + + --filter Filter which tests to run. + --group ... Only runs tests from the specified group(s). + --exclude-group ... Exclude tests from the specified group(s). + --list-groups List available test groups. + + --loader TestSuiteLoader implementation to use. + --printer TestSuiteListener implementation to use. + --repeat Runs the test(s) repeatedly. + + --tap Report test execution progress in TAP format. + --testdox Report test execution progress in TestDox format. + + --colors Use colors in output. + --stderr Write to STDERR instead of STDOUT. + --stop-on-error Stop execution upon first error. + --stop-on-failure Stop execution upon first error or failure. + --stop-on-skipped Stop execution upon first skipped test. + --stop-on-incomplete Stop execution upon first incomplete test. + --strict Run tests in strict mode. + -v|--verbose Output more verbose information. + --debug Display debbuging information during test execution. + + --process-isolation Run each test in a separate PHP process. + --no-globals-backup Do not backup and restore \$GLOBALS for each test. + --static-backup Backup and restore static attributes for each test. + + --bootstrap A "bootstrap" PHP file that is run before the tests. + -c|--configuration Read configuration from XML file. + --no-configuration Ignore default configuration file (phpunit.xml). + --include-path Prepend PHP's include_path with given path(s). + -d key[=value] Sets a php.ini value. + + -h|--help Prints this usage information. + --version Prints the version and exits. + + --debug Output debugging information. + +EOT; + } + + /** + * Custom callback for test suite discovery. + */ + protected function handleCustomTestSuite() + { + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/TextUI/ResultPrinter.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/TextUI/ResultPrinter.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/TextUI/ResultPrinter.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/TextUI/ResultPrinter.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,639 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage TextUI + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * Prints the result of a TextUI TestRunner run. + * + * @package PHPUnit + * @subpackage TextUI + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_TextUI_ResultPrinter extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener +{ + const EVENT_TEST_START = 0; + const EVENT_TEST_END = 1; + const EVENT_TESTSUITE_START = 2; + const EVENT_TESTSUITE_END = 3; + + /** + * @var integer + */ + protected $column = 0; + + /** + * @var integer + */ + protected $maxColumn; + + /** + * @var boolean + */ + protected $lastTestFailed = FALSE; + + /** + * @var integer + */ + protected $numAssertions = 0; + + /** + * @var integer + */ + protected $numTests = -1; + + /** + * @var integer + */ + protected $numTestsRun = 0; + + /** + * @var integer + */ + protected $numTestsWidth; + + /** + * @var boolean + */ + protected $colors = FALSE; + + /** + * @var boolean + */ + protected $debug = FALSE; + + /** + * @var boolean + */ + protected $verbose = FALSE; + + /** + * Constructor. + * + * @param mixed $out + * @param boolean $verbose + * @param boolean $colors + * @param boolean $debug + * @throws InvalidArgumentException + * @since Method available since Release 3.0.0 + */ + public function __construct($out = NULL, $verbose = FALSE, $colors = FALSE, $debug = FALSE) + { + parent::__construct($out); + + if (is_bool($verbose)) { + $this->verbose = $verbose; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'boolean'); + } + + if (is_bool($colors)) { + $this->colors = $colors; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(3, 'boolean'); + } + + if (is_bool($debug)) { + $this->debug = $debug; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(4, 'boolean'); + } + } + + /** + * @param PHPUnit_Framework_TestResult $result + */ + public function printResult(PHPUnit_Framework_TestResult $result) + { + $this->printHeader(); + + if ($result->errorCount() > 0) { + $this->printErrors($result); + } + + if ($result->failureCount() > 0) { + if ($result->errorCount() > 0) { + print "\n--\n\n"; + } + + $this->printFailures($result); + } + + if ($this->verbose) { + if ($result->deprecatedFeaturesCount() > 0) { + if ($result->failureCount() > 0) { + print "\n--\n\nDeprecated PHPUnit features are being used"; + } + + foreach ($result->deprecatedFeatures() as $deprecatedFeature) { + $this->write($deprecatedFeature . "\n\n"); + } + } + + if ($result->notImplementedCount() > 0) { + if ($result->failureCount() > 0) { + print "\n--\n\n"; + } + + $this->printIncompletes($result); + } + + if ($result->skippedCount() > 0) { + if ($result->notImplementedCount() > 0) { + print "\n--\n\n"; + } + + $this->printSkipped($result); + } + } + + $this->printFooter($result); + } + + /** + * @param array $defects + * @param integer $count + * @param string $type + */ + protected function printDefects(array $defects, $count, $type) + { + static $called = FALSE; + + if ($count == 0) { + return; + } + + $this->write( + sprintf( + "%sThere %s %d %s%s:\n", + + $called ? "\n" : '', + ($count == 1) ? 'was' : 'were', + $count, + $type, + ($count == 1) ? '' : 's' + ) + ); + + $i = 1; + + foreach ($defects as $defect) { + $this->printDefect($defect, $i++); + } + + $called = TRUE; + } + + /** + * @param PHPUnit_Framework_TestFailure $defect + * @param integer $count + */ + protected function printDefect(PHPUnit_Framework_TestFailure $defect, $count) + { + $this->printDefectHeader($defect, $count); + $this->printDefectTrace($defect); + } + + /** + * @param PHPUnit_Framework_TestFailure $defect + * @param integer $count + */ + protected function printDefectHeader(PHPUnit_Framework_TestFailure $defect, $count) + { + $failedTest = $defect->failedTest(); + + if ($failedTest instanceof PHPUnit_Framework_SelfDescribing) { + $testName = $failedTest->toString(); + } else { + $testName = get_class($failedTest); + } + + $this->write( + sprintf( + "\n%d) %s\n", + + $count, + $testName + ) + ); + } + + /** + * @param PHPUnit_Framework_TestFailure $defect + */ + protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) + { + $this->write( + $defect->getExceptionAsString() . "\n" . + PHPUnit_Util_Filter::getFilteredStacktrace( + $defect->thrownException() + ) + ); + } + + /** + * @param PHPUnit_Framework_TestResult $result + */ + protected function printErrors(PHPUnit_Framework_TestResult $result) + { + $this->printDefects($result->errors(), $result->errorCount(), 'error'); + } + + /** + * @param PHPUnit_Framework_TestResult $result + */ + protected function printFailures(PHPUnit_Framework_TestResult $result) + { + $this->printDefects( + $result->failures(), + $result->failureCount(), + 'failure' + ); + } + + /** + * @param PHPUnit_Framework_TestResult $result + */ + protected function printIncompletes(PHPUnit_Framework_TestResult $result) + { + $this->printDefects( + $result->notImplemented(), + $result->notImplementedCount(), + 'incomplete test' + ); + } + + /** + * @param PHPUnit_Framework_TestResult $result + * @since Method available since Release 3.0.0 + */ + protected function printSkipped(PHPUnit_Framework_TestResult $result) + { + $this->printDefects( + $result->skipped(), + $result->skippedCount(), + 'skipped test' + ); + } + + protected function printHeader() + { + $this->write("\n\n" . PHP_Timer::resourceUsage() . "\n\n"); + } + + /** + * @param PHPUnit_Framework_TestResult $result + */ + protected function printFooter(PHPUnit_Framework_TestResult $result) + { + if ($result->wasSuccessful() && + $result->allCompletlyImplemented() && + $result->noneSkipped()) { + if ($this->colors) { + $this->write("\x1b[30;42m\x1b[2K"); + } + + $this->write( + sprintf( + "OK (%d test%s, %d assertion%s)\n", + + count($result), + (count($result) == 1) ? '' : 's', + $this->numAssertions, + ($this->numAssertions == 1) ? '' : 's' + ) + ); + + if ($this->colors) { + $this->write("\x1b[0m\x1b[2K"); + } + } + + else if ((!$result->allCompletlyImplemented() || + !$result->noneSkipped()) && + $result->wasSuccessful()) { + if ($this->colors) { + $this->write( + "\x1b[30;43m\x1b[2KOK, but incomplete or skipped tests!\n" . + "\x1b[0m\x1b[30;43m\x1b[2K" + ); + } else { + $this->write("OK, but incomplete or skipped tests!\n"); + } + + $this->write( + sprintf( + "Tests: %d, Assertions: %d%s%s.\n", + + count($result), + $this->numAssertions, + $this->getCountString( + $result->notImplementedCount(), 'Incomplete' + ), + $this->getCountString( + $result->skippedCount(), 'Skipped' + ) + ) + ); + + if ($this->colors) { + $this->write("\x1b[0m\x1b[2K"); + } + } + + else { + $this->write("\n"); + + if ($this->colors) { + $this->write( + "\x1b[37;41m\x1b[2KFAILURES!\n\x1b[0m\x1b[37;41m\x1b[2K" + ); + } else { + $this->write("FAILURES!\n"); + } + + $this->write( + sprintf( + "Tests: %d, Assertions: %s%s%s%s%s.\n", + + count($result), + $this->numAssertions, + $this->getCountString($result->failureCount(), 'Failures'), + $this->getCountString($result->errorCount(), 'Errors'), + $this->getCountString( + $result->notImplementedCount(), 'Incomplete' + ), + $this->getCountString($result->skippedCount(), 'Skipped') + ) + ); + + if ($this->colors) { + $this->write("\x1b[0m\x1b[2K"); + } + } + + if (!$this->verbose && + $result->deprecatedFeaturesCount() > 0) { + $message = sprintf( + "Warning: Deprecated PHPUnit features are being used %s times!\n" . + "Use --verbose for more information.\n", + $result->deprecatedFeaturesCount() + ); + + if ($this->colors) { + $message = "\x1b[37;41m\x1b[2K" . $message . + "\x1b[0m"; + } + + $this->write("\n" . $message); + } + } + + /** + * @param integer $count + * @param string $name + * @return string + * @since Method available since Release 3.0.0 + */ + protected function getCountString($count, $name) + { + $string = ''; + + if ($count > 0) { + $string = sprintf( + ', %s: %d', + + $name, + $count + ); + } + + return $string; + } + + /** + */ + public function printWaitPrompt() + { + $this->write("\n to continue\n"); + } + + /** + * An error occurred. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) + { + if ($this->colors) { + $this->writeProgress("\x1b[31;1mE\x1b[0m"); + } else { + $this->writeProgress('E'); + } + + $this->lastTestFailed = TRUE; + } + + /** + * A failure occurred. + * + * @param PHPUnit_Framework_Test $test + * @param PHPUnit_Framework_AssertionFailedError $e + * @param float $time + */ + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) + { + if ($this->colors) { + $this->writeProgress("\x1b[41;37mF\x1b[0m"); + } else { + $this->writeProgress('F'); + } + + $this->lastTestFailed = TRUE; + } + + /** + * Incomplete test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + if ($this->colors) { + $this->writeProgress("\x1b[33;1mI\x1b[0m"); + } else { + $this->writeProgress('I'); + } + + $this->lastTestFailed = TRUE; + } + + /** + * Skipped test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + * @since Method available since Release 3.0.0 + */ + public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + if ($this->colors) { + $this->writeProgress("\x1b[36;1mS\x1b[0m"); + } else { + $this->writeProgress('S'); + } + + $this->lastTestFailed = TRUE; + } + + /** + * A testsuite started. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit_Framework_TestSuite $suite) + { + if ($this->numTests == -1) { + $this->numTests = count($suite); + $this->numTestsWidth = strlen((string)$this->numTests); + $this->maxColumn = 69 - (2 * $this->numTestsWidth); + } + } + + /** + * A testsuite ended. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit_Framework_TestSuite $suite) + { + } + + /** + * A test started. + * + * @param PHPUnit_Framework_Test $test + */ + public function startTest(PHPUnit_Framework_Test $test) + { + if ($this->debug) { + $this->write( + sprintf( + "\nStarting test '%s'.\n", PHPUnit_Util_Test::describe($test) + ) + ); + } + } + + /** + * A test ended. + * + * @param PHPUnit_Framework_Test $test + * @param float $time + */ + public function endTest(PHPUnit_Framework_Test $test, $time) + { + if (!$this->lastTestFailed) { + $this->writeProgress('.'); + } + + if ($test instanceof PHPUnit_Framework_TestCase) { + $this->numAssertions += $test->getNumAssertions(); + } + + else if ($test instanceof PHPUnit_Extensions_PhptTestCase) { + $this->numAssertions++; + } + + $this->lastTestFailed = FALSE; + + if ($test instanceof PHPUnit_Framework_TestCase) { + if (!$test->hasPerformedExpectationsOnOutput()) { + $this->write($test->getActualOutput()); + } + } + } + + /** + * @param string $progress + */ + protected function writeProgress($progress) + { + $this->write($progress); + $this->column++; + $this->numTestsRun++; + + if ($this->column == $this->maxColumn) { + $this->write( + sprintf( + ' %' . $this->numTestsWidth . 'd / %' . + $this->numTestsWidth . 'd (%3s%%)', + + $this->numTestsRun, + $this->numTests, + floor(($this->numTestsRun / $this->numTests) * 100) + ) + ); + + $this->writeNewLine(); + } + } + + protected function writeNewLine() + { + $this->column = 0; + $this->write("\n"); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/TextUI/TestRunner.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/TextUI/TestRunner.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/TextUI/TestRunner.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/TextUI/TestRunner.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,809 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage TextUI + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * A TestRunner for the Command Line Interface (CLI) + * PHP SAPI Module. + * + * @package PHPUnit + * @subpackage TextUI + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_TextUI_TestRunner extends PHPUnit_Runner_BaseTestRunner +{ + const SUCCESS_EXIT = 0; + const FAILURE_EXIT = 1; + const EXCEPTION_EXIT = 2; + + /** + * @var PHP_CodeCoverage_Filter + */ + protected $codeCoverageFilter; + + /** + * @var PHPUnit_Runner_TestSuiteLoader + */ + protected $loader = NULL; + + /** + * @var PHPUnit_TextUI_ResultPrinter + */ + protected $printer = NULL; + + /** + * @var boolean + */ + protected static $versionStringPrinted = FALSE; + + /** + * @param PHPUnit_Runner_TestSuiteLoader $loader + * @param PHP_CodeCoverage_Filter $filter + * @since Method available since Release 3.4.0 + */ + public function __construct(PHPUnit_Runner_TestSuiteLoader $loader = NULL, PHP_CodeCoverage_Filter $filter = NULL) + { + if ($filter === NULL) { + $filter = new PHP_CodeCoverage_Filter; + } + + $this->codeCoverageFilter = $filter; + $this->loader = $loader; + } + + /** + * @param mixed $test + * @param array $arguments + * @throws InvalidArgumentException + */ + public static function run($test, array $arguments = array()) + { + if ($test instanceof ReflectionClass) { + $test = new PHPUnit_Framework_TestSuite($test); + } + + if ($test instanceof PHPUnit_Framework_Test) { + $aTestRunner = new PHPUnit_TextUI_TestRunner; + + return $aTestRunner->doRun( + $test, + $arguments + ); + } else { + throw new InvalidArgumentException( + 'No test case or test suite found.' + ); + } + } + + /** + * @return PHPUnit_Framework_TestResult + */ + protected function createTestResult() + { + return new PHPUnit_Framework_TestResult; + } + + /** + * @param PHPUnit_Framework_Test $suite + * @param array $arguments + * @return PHPUnit_Framework_TestResult + */ + public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) + { + $this->handleConfiguration($arguments); + + if (isset($arguments['bootstrap'])) { + $GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap']; + } + + if ($arguments['backupGlobals'] === FALSE) { + $suite->setBackupGlobals(FALSE); + } + + if ($arguments['backupStaticAttributes'] === TRUE) { + $suite->setBackupStaticAttributes(TRUE); + } + + if (is_integer($arguments['repeat'])) { + $suite = new PHPUnit_Extensions_RepeatedTest( + $suite, + $arguments['repeat'], + $arguments['filter'], + $arguments['groups'], + $arguments['excludeGroups'], + $arguments['processIsolation'] + ); + } + + $result = $this->createTestResult(); + + if (!$arguments['convertErrorsToExceptions']) { + $result->convertErrorsToExceptions(FALSE); + } + + if (!$arguments['convertNoticesToExceptions']) { + PHPUnit_Framework_Error_Notice::$enabled = FALSE; + } + + if (!$arguments['convertWarningsToExceptions']) { + PHPUnit_Framework_Error_Warning::$enabled = FALSE; + } + + if ($arguments['stopOnError']) { + $result->stopOnError(TRUE); + } + + if ($arguments['stopOnFailure']) { + $result->stopOnFailure(TRUE); + } + + if ($arguments['stopOnIncomplete']) { + $result->stopOnIncomplete(TRUE); + } + + if ($arguments['stopOnSkipped']) { + $result->stopOnSkipped(TRUE); + } + + if ($this->printer === NULL) { + if (isset($arguments['printer']) && + $arguments['printer'] instanceof PHPUnit_Util_Printer) { + $this->printer = $arguments['printer']; + } else { + $this->printer = new PHPUnit_TextUI_ResultPrinter( + NULL, + $arguments['verbose'], + $arguments['colors'], + $arguments['debug'] + ); + } + } + + if (!$this->printer instanceof PHPUnit_Util_Log_TAP && + !self::$versionStringPrinted) { + $this->printer->write( + PHPUnit_Runner_Version::getVersionString() . "\n\n" + ); + + if (isset($arguments['configuration'])) { + $this->printer->write( + sprintf( + "Configuration read from %s\n\n", + $arguments['configuration']->getFilename() + ) + ); + } + } + + foreach ($arguments['listeners'] as $listener) { + $result->addListener($listener); + } + + $result->addListener($this->printer); + + if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) { + $result->addListener(new PHPUnit_Util_DeprecatedFeature_Logger); + } + + if (isset($arguments['testdoxHTMLFile'])) { + $result->addListener( + new PHPUnit_Util_TestDox_ResultPrinter_HTML( + $arguments['testdoxHTMLFile'] + ) + ); + } + + if (isset($arguments['testdoxTextFile'])) { + $result->addListener( + new PHPUnit_Util_TestDox_ResultPrinter_Text( + $arguments['testdoxTextFile'] + ) + ); + } + + if ((isset($arguments['coverageClover']) || + isset($arguments['reportDirectory']) || + isset($arguments['coveragePHP']) || + isset($arguments['coverageText'])) && + extension_loaded('xdebug')) { + $codeCoverage = new PHP_CodeCoverage( + NULL, $this->codeCoverageFilter + ); + + $codeCoverage->setProcessUncoveredFilesFromWhitelist( + $arguments['addUncoveredFilesFromWhitelist'] + ); + + if (isset($arguments['cacheTokens'])) { + $codeCoverage->setCacheTokens($arguments['cacheTokens']); + } + + if (isset($arguments['forceCoversAnnotation'])) { + $codeCoverage->setForceCoversAnnotation( + $arguments['forceCoversAnnotation'] + ); + } + + if (isset($arguments['mapTestClassNameToCoveredClassName'])) { + $codeCoverage->setMapTestClassNameToCoveredClassName( + $arguments['mapTestClassNameToCoveredClassName'] + ); + } + + $result->setCodeCoverage($codeCoverage); + } + + if (isset($arguments['jsonLogfile'])) { + $result->addListener( + new PHPUnit_Util_Log_JSON($arguments['jsonLogfile']) + ); + } + + if (isset($arguments['tapLogfile'])) { + $result->addListener( + new PHPUnit_Util_Log_TAP($arguments['tapLogfile']) + ); + } + + if (isset($arguments['junitLogfile'])) { + $result->addListener( + new PHPUnit_Util_Log_JUnit( + $arguments['junitLogfile'], $arguments['logIncompleteSkipped'] + ) + ); + } + + if ($arguments['strict']) { + $result->strictMode(TRUE); + + $result->setTimeoutForSmallTests( + $arguments['timeoutForSmallTests'] + ); + + $result->setTimeoutForMediumTests( + $arguments['timeoutForMediumTests'] + ); + + $result->setTimeoutForLargeTests( + $arguments['timeoutForLargeTests'] + ); + } + + $suite->run( + $result, + $arguments['filter'], + $arguments['groups'], + $arguments['excludeGroups'], + $arguments['processIsolation'] + ); + + unset($suite); + $result->flushListeners(); + + if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) { + $this->printer->printResult($result); + } + + if (isset($codeCoverage)) { + $title = ''; + + if (isset($arguments['configuration'])) { + $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration(); + + if (isset($loggingConfiguration['title'])) { + $title = $loggingConfiguration['title']; + } + } + + if (isset($arguments['coverageClover'])) { + $this->printer->write( + "\nWriting code coverage data to XML file, this may take " . + 'a moment.' + ); + + $writer = new PHP_CodeCoverage_Report_Clover; + $writer->process($codeCoverage, $arguments['coverageClover']); + + $this->printer->write("\n"); + unset($writer); + } + + if (isset($arguments['reportDirectory'])) { + $this->printer->write( + "\nGenerating code coverage report, this may take a moment." + ); + + $writer = new PHP_CodeCoverage_Report_HTML( + $title, + $arguments['reportCharset'], + $arguments['reportYUI'], + $arguments['reportHighlight'], + $arguments['reportLowUpperBound'], + $arguments['reportHighLowerBound'], + ' and PHPUnit ' . PHPUnit_Runner_Version::id() + ); + + $writer->process($codeCoverage, $arguments['reportDirectory']); + + $this->printer->write("\n"); + unset($writer); + } + + if (isset($arguments['coveragePHP'])) { + $this->printer->write( + "\nSerializing PHP_CodeCoverage object to file, this may take a moment." + ); + + $writer = new PHP_CodeCoverage_Report_PHP; + $writer->process($codeCoverage, $arguments['coveragePHP']); + + $this->printer->write("\n"); + unset($writer); + } + + if (isset($arguments['coverageText'])) { + $this->printer->write( + "\nGenerating textual code coverage report, this may take a moment." + ); + + if ($arguments['coverageText'] == 'php://stdout') { + $outputStream = $this->printer; + $colors = (bool)$arguments['colors']; + } else { + $outputStream = new PHPUnit_Util_Printer($arguments['coverageText']); + $colors = FALSE; + } + + $writer = new PHP_CodeCoverage_Report_Text( + $outputStream, + $title, + $arguments['reportLowUpperBound'], + $arguments['reportHighLowerBound'], + $arguments['coverageTextShowUncoveredFiles'] + ); + + $writer->process($codeCoverage, $colors); + + $this->printer->write("\n"); + } + } + + return $result; + } + + /** + * @param PHPUnit_TextUI_ResultPrinter $resultPrinter + */ + public function setPrinter(PHPUnit_TextUI_ResultPrinter $resultPrinter) + { + $this->printer = $resultPrinter; + } + + /** + * Override to define how to handle a failed loading of + * a test suite. + * + * @param string $message + */ + protected function runFailed($message) + { + self::printVersionString(); + self::write($message); + exit(self::FAILURE_EXIT); + } + + /** + * @param string $buffer + * @since Method available since Release 3.1.0 + */ + protected static function write($buffer) + { + if (PHP_SAPI != 'cli') { + $buffer = htmlspecialchars($buffer); + } + + print $buffer; + } + + /** + * Returns the loader to be used. + * + * @return PHPUnit_Runner_TestSuiteLoader + * @since Method available since Release 2.2.0 + */ + public function getLoader() + { + if ($this->loader === NULL) { + $this->loader = new PHPUnit_Runner_StandardTestSuiteLoader; + } + + return $this->loader; + } + + /** + */ + public static function showError($message) + { + self::printVersionString(); + self::write($message . "\n"); + + exit(self::FAILURE_EXIT); + } + + /** + */ + public static function printVersionString() + { + if (!self::$versionStringPrinted) { + self::write(PHPUnit_Runner_Version::getVersionString() . "\n\n"); + self::$versionStringPrinted = TRUE; + } + } + + /** + * @param array $arguments + * @since Method available since Release 3.2.1 + */ + protected function handleConfiguration(array &$arguments) + { + if (isset($arguments['configuration']) && + !$arguments['configuration'] instanceof PHPUnit_Util_Configuration) { + $arguments['configuration'] = PHPUnit_Util_Configuration::getInstance( + $arguments['configuration'] + ); + } + + $arguments['debug'] = isset($arguments['debug']) ? $arguments['debug'] : FALSE; + $arguments['filter'] = isset($arguments['filter']) ? $arguments['filter'] : FALSE; + $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array(); + + if (isset($arguments['configuration'])) { + $arguments['configuration']->handlePHPConfiguration(); + + $phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration(); + + if (isset($phpunitConfiguration['backupGlobals']) && + !isset($arguments['backupGlobals'])) { + $arguments['backupGlobals'] = $phpunitConfiguration['backupGlobals']; + } + + if (isset($phpunitConfiguration['backupStaticAttributes']) && + !isset($arguments['backupStaticAttributes'])) { + $arguments['backupStaticAttributes'] = $phpunitConfiguration['backupStaticAttributes']; + } + + if (isset($phpunitConfiguration['bootstrap']) && + !isset($arguments['bootstrap'])) { + $arguments['bootstrap'] = $phpunitConfiguration['bootstrap']; + } + + if (isset($phpunitConfiguration['cacheTokens']) && + !isset($arguments['cacheTokens'])) { + $arguments['cacheTokens'] = $phpunitConfiguration['cacheTokens']; + } + + if (isset($phpunitConfiguration['colors']) && + !isset($arguments['colors'])) { + $arguments['colors'] = $phpunitConfiguration['colors']; + } + + if (isset($phpunitConfiguration['convertErrorsToExceptions']) && + !isset($arguments['convertErrorsToExceptions'])) { + $arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions']; + } + + if (isset($phpunitConfiguration['convertNoticesToExceptions']) && + !isset($arguments['convertNoticesToExceptions'])) { + $arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions']; + } + + if (isset($phpunitConfiguration['convertWarningsToExceptions']) && + !isset($arguments['convertWarningsToExceptions'])) { + $arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions']; + } + + if (isset($phpunitConfiguration['processIsolation']) && + !isset($arguments['processIsolation'])) { + $arguments['processIsolation'] = $phpunitConfiguration['processIsolation']; + } + + if (isset($phpunitConfiguration['stopOnFailure']) && + !isset($arguments['stopOnFailure'])) { + $arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure']; + } + + if (isset($phpunitConfiguration['timeoutForSmallTests']) && + !isset($arguments['timeoutForSmallTests'])) { + $arguments['timeoutForSmallTests'] = $phpunitConfiguration['timeoutForSmallTests']; + } + + if (isset($phpunitConfiguration['timeoutForMediumTests']) && + !isset($arguments['timeoutForMediumTests'])) { + $arguments['timeoutForMediumTests'] = $phpunitConfiguration['timeoutForMediumTests']; + } + + if (isset($phpunitConfiguration['timeoutForLargeTests']) && + !isset($arguments['timeoutForLargeTests'])) { + $arguments['timeoutForLargeTests'] = $phpunitConfiguration['timeoutForLargeTests']; + } + + if (isset($phpunitConfiguration['strict']) && + !isset($arguments['strict'])) { + $arguments['strict'] = $phpunitConfiguration['strict']; + } + + if (isset($phpunitConfiguration['verbose']) && + !isset($arguments['verbose'])) { + $arguments['verbose'] = $phpunitConfiguration['verbose']; + } + + if (isset($phpunitConfiguration['forceCoversAnnotation']) && + !isset($arguments['forceCoversAnnotation'])) { + $arguments['forceCoversAnnotation'] = $phpunitConfiguration['forceCoversAnnotation']; + } + + if (isset($phpunitConfiguration['mapTestClassNameToCoveredClassName']) && + !isset($arguments['mapTestClassNameToCoveredClassName'])) { + $arguments['mapTestClassNameToCoveredClassName'] = $phpunitConfiguration['mapTestClassNameToCoveredClassName']; + } + + $groupConfiguration = $arguments['configuration']->getGroupConfiguration(); + + if (!empty($groupConfiguration['include']) && + !isset($arguments['groups'])) { + $arguments['groups'] = $groupConfiguration['include']; + } + + if (!empty($groupConfiguration['exclude']) && + !isset($arguments['excludeGroups'])) { + $arguments['excludeGroups'] = $groupConfiguration['exclude']; + } + + foreach ($arguments['configuration']->getListenerConfiguration() as $listener) { + if (!class_exists($listener['class'], FALSE) && + $listener['file'] !== '') { + require_once $listener['file']; + } + + if (class_exists($listener['class'], FALSE)) { + if (count($listener['arguments']) == 0) { + $listener = new $listener['class']; + } else { + $listenerClass = new ReflectionClass( + $listener['class'] + ); + $listener = $listenerClass->newInstanceArgs( + $listener['arguments'] + ); + } + + if ($listener instanceof PHPUnit_Framework_TestListener) { + $arguments['listeners'][] = $listener; + } + } + } + + $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration(); + + if (isset($loggingConfiguration['coverage-html']) && + !isset($arguments['reportDirectory'])) { + if (isset($loggingConfiguration['charset']) && + !isset($arguments['reportCharset'])) { + $arguments['reportCharset'] = $loggingConfiguration['charset']; + } + + if (isset($loggingConfiguration['yui']) && + !isset($arguments['reportYUI'])) { + $arguments['reportYUI'] = $loggingConfiguration['yui']; + } + + if (isset($loggingConfiguration['highlight']) && + !isset($arguments['reportHighlight'])) { + $arguments['reportHighlight'] = $loggingConfiguration['highlight']; + } + + if (isset($loggingConfiguration['lowUpperBound']) && + !isset($arguments['reportLowUpperBound'])) { + $arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound']; + } + + if (isset($loggingConfiguration['highLowerBound']) && + !isset($arguments['reportHighLowerBound'])) { + $arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound']; + } + + $arguments['reportDirectory'] = $loggingConfiguration['coverage-html']; + } + + if (isset($loggingConfiguration['coverage-clover']) && + !isset($arguments['coverageClover'])) { + $arguments['coverageClover'] = $loggingConfiguration['coverage-clover']; + } + + if (isset($loggingConfiguration['coverage-php']) && + !isset($arguments['coveragePHP'])) { + $arguments['coveragePHP'] = $loggingConfiguration['coverage-php']; + } + + if (isset($loggingConfiguration['coverage-text']) && + !isset($arguments['coverageText'])) { + $arguments['coverageText'] = $loggingConfiguration['coverage-text']; + if (isset($loggingConfiguration['coverageTextShowUncoveredFiles'])) { + $arguments['coverageTextShowUncoveredFiles'] = $loggingConfiguration['coverageTextShowUncoveredFiles']; + } else { + $arguments['coverageTextShowUncoveredFiles'] = FALSE; + } + } + + if (isset($loggingConfiguration['json']) && + !isset($arguments['jsonLogfile'])) { + $arguments['jsonLogfile'] = $loggingConfiguration['json']; + } + + if (isset($loggingConfiguration['plain'])) { + $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter( + $loggingConfiguration['plain'], TRUE + ); + } + + if (isset($loggingConfiguration['tap']) && + !isset($arguments['tapLogfile'])) { + $arguments['tapLogfile'] = $loggingConfiguration['tap']; + } + + if (isset($loggingConfiguration['junit']) && + !isset($arguments['junitLogfile'])) { + $arguments['junitLogfile'] = $loggingConfiguration['junit']; + + if (isset($loggingConfiguration['logIncompleteSkipped']) && + !isset($arguments['logIncompleteSkipped'])) { + $arguments['logIncompleteSkipped'] = $loggingConfiguration['logIncompleteSkipped']; + } + } + + if (isset($loggingConfiguration['testdox-html']) && + !isset($arguments['testdoxHTMLFile'])) { + $arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html']; + } + + if (isset($loggingConfiguration['testdox-text']) && + !isset($arguments['testdoxTextFile'])) { + $arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text']; + } + + if ((isset($arguments['coverageClover']) || + isset($arguments['reportDirectory']) || + isset($arguments['coveragePHP']) || + isset($arguments['coverageText'])) && + extension_loaded('xdebug')) { + + $filterConfiguration = $arguments['configuration']->getFilterConfiguration(); + $arguments['addUncoveredFilesFromWhitelist'] = $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist']; + + foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) { + $this->codeCoverageFilter->addDirectoryToBlacklist( + $dir['path'], $dir['suffix'], $dir['prefix'], $dir['group'] + ); + } + + foreach ($filterConfiguration['blacklist']['include']['file'] as $file) { + $this->codeCoverageFilter->addFileToBlacklist($file); + } + + foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) { + $this->codeCoverageFilter->removeDirectoryFromBlacklist( + $dir['path'], $dir['suffix'], $dir['prefix'], $dir['group'] + ); + } + + foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) { + $this->codeCoverageFilter->removeFileFromBlacklist($file); + } + + foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) { + $this->codeCoverageFilter->addDirectoryToWhitelist( + $dir['path'], $dir['suffix'], $dir['prefix'] + ); + } + + foreach ($filterConfiguration['whitelist']['include']['file'] as $file) { + $this->codeCoverageFilter->addFileToWhitelist($file); + } + + foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) { + $this->codeCoverageFilter->removeDirectoryFromWhitelist( + $dir['path'], $dir['suffix'], $dir['prefix'] + ); + } + + foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) { + $this->codeCoverageFilter->removeFileFromWhitelist($file); + } + } + } + + $arguments['addUncoveredFilesFromWhitelist'] = isset($arguments['addUncoveredFilesFromWhitelist']) ? $arguments['addUncoveredFilesFromWhitelist'] : TRUE; + $arguments['backupGlobals'] = isset($arguments['backupGlobals']) ? $arguments['backupGlobals'] : NULL; + $arguments['backupStaticAttributes'] = isset($arguments['backupStaticAttributes']) ? $arguments['backupStaticAttributes'] : NULL; + $arguments['cacheTokens'] = isset($arguments['cacheTokens']) ? $arguments['cacheTokens'] : TRUE; + $arguments['colors'] = isset($arguments['colors']) ? $arguments['colors'] : FALSE; + $arguments['convertErrorsToExceptions'] = isset($arguments['convertErrorsToExceptions']) ? $arguments['convertErrorsToExceptions'] : TRUE; + $arguments['convertNoticesToExceptions'] = isset($arguments['convertNoticesToExceptions']) ? $arguments['convertNoticesToExceptions'] : TRUE; + $arguments['convertWarningsToExceptions'] = isset($arguments['convertWarningsToExceptions']) ? $arguments['convertWarningsToExceptions'] : TRUE; + $arguments['excludeGroups'] = isset($arguments['excludeGroups']) ? $arguments['excludeGroups'] : array(); + $arguments['groups'] = isset($arguments['groups']) ? $arguments['groups'] : array(); + $arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : FALSE; + $arguments['processIsolation'] = isset($arguments['processIsolation']) ? $arguments['processIsolation'] : FALSE; + $arguments['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : FALSE; + $arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'UTF-8'; + $arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE; + $arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70; + $arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35; + $arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : TRUE; + $arguments['stopOnError'] = isset($arguments['stopOnError']) ? $arguments['stopOnError'] : FALSE; + $arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE; + $arguments['stopOnIncomplete'] = isset($arguments['stopOnIncomplete']) ? $arguments['stopOnIncomplete'] : FALSE; + $arguments['stopOnSkipped'] = isset($arguments['stopOnSkipped']) ? $arguments['stopOnSkipped'] : FALSE; + $arguments['timeoutForSmallTests'] = isset($arguments['timeoutForSmallTests']) ? $arguments['timeoutForSmallTests'] : 1; + $arguments['timeoutForMediumTests'] = isset($arguments['timeoutForMediumTests']) ? $arguments['timeoutForMediumTests'] : 10; + $arguments['timeoutForLargeTests'] = isset($arguments['timeoutForLargeTests']) ? $arguments['timeoutForLargeTests'] : 60; + $arguments['strict'] = isset($arguments['strict']) ? $arguments['strict'] : FALSE; + $arguments['verbose'] = isset($arguments['verbose']) ? $arguments['verbose'] : FALSE; + + if ($arguments['filter'] !== FALSE && + preg_match('/^[a-zA-Z0-9_]/', $arguments['filter'])) { + // Escape delimiters in regular expression. Do NOT use preg_quote, + // to keep magic characters. + $arguments['filter'] = '/' . str_replace( + '/', '\\/', $arguments['filter'] + ) . '/'; + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Class.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Class.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Class.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Class.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,399 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.1.0 + */ + +if (!defined('T_NAMESPACE')) { + define('T_NAMESPACE', 377); +} + +/** + * Class helpers. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.1.0 + */ +class PHPUnit_Util_Class +{ + protected static $buffer = array(); + + /** + * Starts the collection of loaded classes. + * + */ + public static function collectStart() + { + self::$buffer = get_declared_classes(); + } + + /** + * Stops the collection of loaded classes and + * returns the names of the loaded classes. + * + * @return array + */ + public static function collectEnd() + { + return array_values( + array_diff(get_declared_classes(), self::$buffer) + ); + } + + /** + * Returns the class hierarchy for a given class. + * + * @param string $className + * @param boolean $asReflectionObjects + * @return array + */ + public static function getHierarchy($className, $asReflectionObjects = FALSE) + { + if ($asReflectionObjects) { + $classes = array(new ReflectionClass($className)); + } else { + $classes = array($className); + } + + $done = FALSE; + + while (!$done) { + if ($asReflectionObjects) { + $class = new ReflectionClass( + $classes[count($classes)-1]->getName() + ); + } else { + $class = new ReflectionClass($classes[count($classes)-1]); + } + + $parent = $class->getParentClass(); + + if ($parent !== FALSE) { + if ($asReflectionObjects) { + $classes[] = $parent; + } else { + $classes[] = $parent->getName(); + } + } else { + $done = TRUE; + } + } + + return $classes; + } + + /** + * Returns the parameters of a function or method. + * + * @param ReflectionFunction|ReflectionMethod $method + * @param boolean $forCall + * @return string + * @since Method available since Release 3.2.0 + */ + public static function getMethodParameters($method, $forCall = FALSE) + { + $parameters = array(); + + foreach ($method->getParameters() as $i => $parameter) { + $name = '$' . $parameter->getName(); + + if ($name === '$') { + $name .= 'arg' . $i; + } + + $default = ''; + $reference = ''; + $typeHint = ''; + + if (!$forCall) { + if ($parameter->isArray()) { + $typeHint = 'array '; + } else { + try { + $class = $parameter->getClass(); + } + + catch (ReflectionException $e) { + $class = FALSE; + } + + if ($class) { + $typeHint = $class->getName() . ' '; + } + } + + if ($parameter->isDefaultValueAvailable()) { + $value = $parameter->getDefaultValue(); + $default = ' = ' . var_export($value, TRUE); + } + else if ($parameter->isOptional()) { + $default = ' = null'; + } + + if ($parameter->isPassedByReference()) { + $reference = '&'; + } + } + + $parameters[] = $typeHint . $reference . $name . $default; + } + + return join(', ', $parameters); + } + + /** + * Returns the package information of a user-defined class. + * + * @param string $className + * @param string $docComment + * @return array + */ + public static function getPackageInformation($className, $docComment) + { + $result = array( + 'namespace' => '', + 'fullPackage' => '', + 'category' => '', + 'package' => '', + 'subpackage' => '' + ); + + if (strpos($className, '\\') !== FALSE) { + $result['namespace'] = self::arrayToName( + explode('\\', $className) + ); + } + + if (preg_match('/@category[\s]+([\.\w]+)/', $docComment, $matches)) { + $result['category'] = $matches[1]; + } + + if (preg_match('/@package[\s]+([\.\w]+)/', $docComment, $matches)) { + $result['package'] = $matches[1]; + $result['fullPackage'] = $matches[1]; + } + + if (preg_match('/@subpackage[\s]+([\.\w]+)/', $docComment, $matches)) { + $result['subpackage'] = $matches[1]; + $result['fullPackage'] .= '.' . $matches[1]; + } + + if (empty($result['fullPackage'])) { + $result['fullPackage'] = self::arrayToName( + explode('_', str_replace('\\', '_', $className)), '.' + ); + } + + return $result; + } + + /** + * Returns the value of a static attribute. + * This also works for attributes that are declared protected or private. + * + * @param string $className + * @param string $attributeName + * @return mixed + * @throws InvalidArgumentException + * @since Method available since Release 3.4.0 + */ + public static function getStaticAttribute($className, $attributeName) + { + if (!is_string($className)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!class_exists($className)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class name'); + } + + if (!is_string($attributeName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); + } + + $class = new ReflectionClass($className); + + while ($class) { + $attributes = $class->getStaticProperties(); + + if (array_key_exists($attributeName, $attributes)) { + return $attributes[$attributeName]; + } + + $class = $class->getParentClass(); + } + + throw new PHPUnit_Framework_Exception( + sprintf( + 'Attribute "%s" not found in class.', + + $attributeName + ) + ); + } + + /** + * Returns the value of an object's attribute. + * This also works for attributes that are declared protected or private. + * + * @param object $object + * @param string $attributeName + * @return mixed + * @throws InvalidArgumentException + * @since Method available since Release 3.4.0 + */ + public static function getObjectAttribute($object, $attributeName) + { + if (!is_object($object)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'object'); + } + + if (!is_string($attributeName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); + } + + try { + $attribute = new ReflectionProperty($object, $attributeName); + } + + catch (ReflectionException $e) { + $reflector = new ReflectionObject($object); + + while ($reflector = $reflector->getParentClass()) { + try { + $attribute = $reflector->getProperty($attributeName); + break; + } + + catch(ReflectionException $e) { + } + } + } + + if (isset($attribute)) { + if ($attribute == NULL || $attribute->isPublic()) { + return $object->$attributeName; + } else { + $array = (array)$object; + $protectedName = "\0*\0" . $attributeName; + + if (array_key_exists($protectedName, $array)) { + return $array[$protectedName]; + } else { + $classes = self::getHierarchy(get_class($object)); + + foreach ($classes as $class) { + $privateName = sprintf( + "\0%s\0%s", + + $class, + $attributeName + ); + + if (array_key_exists($privateName, $array)) { + return $array[$privateName]; + } + } + } + } + } + + throw new PHPUnit_Framework_Exception( + sprintf( + 'Attribute "%s" not found in object.', + + $attributeName + ) + ); + } + + /** + * + * + * @param string $className + * @return array + * @since Method available since Release 3.4.0 + */ + public static function parseFullyQualifiedClassName($className) + { + $result = array( + 'namespace' => '', + 'className' => $className, + 'fullyQualifiedClassName' => $className + ); + + if (strpos($className, '\\') !== FALSE) { + $tmp = explode('\\', $className); + $result['className'] = $tmp[count($tmp)-1]; + $result['namespace'] = self::arrayToName($tmp); + } + + return $result; + } + + /** + * Returns the package information of a user-defined class. + * + * @param array $parts + * @param string $join + * @return string + * @since Method available since Release 3.2.12 + */ + protected static function arrayToName(array $parts, $join = '\\') + { + $result = ''; + + if (count($parts) > 1) { + array_pop($parts); + + $result = join($join, $parts); + } + + return $result; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Configuration.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Configuration.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Configuration.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Configuration.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,1012 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.2.0 + */ + +/** + * Wrapper for the PHPUnit XML configuration file. + * + * Example XML configuration file: + * + * + * + * + * + * + * /path/to/files + * /path/to/MyTest.php + * /path/to/files/exclude + * + * + * + * + * + * name + * + * + * name + * + * + * + * + * + * /path/to/files + * /path/to/file + * + * /path/to/files + * /path/to/file + * + * + * + * /path/to/files + * /path/to/file + * + * /path/to/files + * /path/to/file + * + * + * + * + * + * + * + * + * + * Sebastian + * + * + * 22 + * April + * 19.78 + * + * + * MyRelativeFile.php + * MyRelativeDir + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * . + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.2.0 + */ +class PHPUnit_Util_Configuration +{ + private static $instances = array(); + + protected $document; + protected $xpath; + protected $filename; + + /** + * Loads a PHPUnit configuration file. + * + * @param string $filename + */ + protected function __construct($filename) + { + $this->filename = $filename; + $this->document = PHPUnit_Util_XML::loadFile($filename); + $this->xpath = new DOMXPath($this->document); + } + + /** + * @since Method available since Release 3.4.0 + */ + private final function __clone() + { + } + + /** + * Returns a PHPUnit configuration object. + * + * @param string $filename + * @return PHPUnit_Util_Configuration + * @since Method available since Release 3.4.0 + */ + public static function getInstance($filename) + { + $realpath = realpath($filename); + + if ($realpath === FALSE) { + throw new PHPUnit_Framework_Exception( + sprintf( + 'Could not read "%s".', + $filename + ) + ); + } + + if (!isset(self::$instances[$realpath])) { + self::$instances[$realpath] = new PHPUnit_Util_Configuration($realpath); + } + + return self::$instances[$realpath]; + } + + /** + * Returns the realpath to the configuration file. + * + * @return string + * @since Method available since Release 3.6.0 + */ + public function getFilename() + { + return $this->filename; + } + + /** + * Returns the configuration for SUT filtering. + * + * @return array + * @since Method available since Release 3.2.1 + */ + public function getFilterConfiguration() + { + $addUncoveredFilesFromWhitelist = TRUE; + + $tmp = $this->xpath->query('filter/whitelist'); + + if ($tmp->length == 1 && + $tmp->item(0)->hasAttribute('addUncoveredFilesFromWhitelist')) { + $addUncoveredFilesFromWhitelist = $this->getBoolean( + (string)$tmp->item(0)->getAttribute('addUncoveredFilesFromWhitelist'), + TRUE + ); + } + + return array( + 'blacklist' => array( + 'include' => array( + 'directory' => $this->readFilterDirectories( + 'filter/blacklist/directory' + ), + 'file' => $this->readFilterFiles( + 'filter/blacklist/file' + ) + ), + 'exclude' => array( + 'directory' => $this->readFilterDirectories( + 'filter/blacklist/exclude/directory' + ), + 'file' => $this->readFilterFiles( + 'filter/blacklist/exclude/file' + ) + ) + ), + 'whitelist' => array( + 'addUncoveredFilesFromWhitelist' => $addUncoveredFilesFromWhitelist, + 'include' => array( + 'directory' => $this->readFilterDirectories( + 'filter/whitelist/directory' + ), + 'file' => $this->readFilterFiles( + 'filter/whitelist/file' + ) + ), + 'exclude' => array( + 'directory' => $this->readFilterDirectories( + 'filter/whitelist/exclude/directory' + ), + 'file' => $this->readFilterFiles( + 'filter/whitelist/exclude/file' + ) + ) + ) + ); + } + + /** + * Returns the configuration for groups. + * + * @return array + * @since Method available since Release 3.2.1 + */ + public function getGroupConfiguration() + { + $groups = array( + 'include' => array(), + 'exclude' => array() + ); + + foreach ($this->xpath->query('groups/include/group') as $group) { + $groups['include'][] = (string)$group->nodeValue; + } + + foreach ($this->xpath->query('groups/exclude/group') as $group) { + $groups['exclude'][] = (string)$group->nodeValue; + } + + return $groups; + } + + /** + * Returns the configuration for listeners. + * + * @return array + * @since Method available since Release 3.4.0 + */ + public function getListenerConfiguration() + { + $result = array(); + + foreach ($this->xpath->query('listeners/listener') as $listener) { + $class = (string)$listener->getAttribute('class'); + $file = ''; + $arguments = array(); + + if ($listener->hasAttribute('file')) { + $file = $this->toAbsolutePath( + (string)$listener->getAttribute('file'), TRUE + ); + } + + if ($listener->childNodes->item(1) instanceof DOMElement && + $listener->childNodes->item(1)->tagName == 'arguments') { + foreach ($listener->childNodes->item(1)->childNodes as $argument) { + if ($argument instanceof DOMElement) { + if ($argument->tagName == 'file' || + $argument->tagName == 'directory') { + $arguments[] = $this->toAbsolutePath((string)$argument->nodeValue); + } else { + $arguments[] = PHPUnit_Util_XML::xmlToVariable($argument); + } + } + } + } + + $result[] = array( + 'class' => $class, + 'file' => $file, + 'arguments' => $arguments + ); + } + + return $result; + } + + /** + * Returns the logging configuration. + * + * @return array + */ + public function getLoggingConfiguration() + { + $result = array(); + + foreach ($this->xpath->query('logging/log') as $log) { + $type = (string)$log->getAttribute('type'); + + $target = $this->toAbsolutePath( + (string)$log->getAttribute('target') + ); + + if ($type == 'coverage-html') { + if ($log->hasAttribute('title')) { + $result['title'] = (string)$log->getAttribute('title'); + } + + if ($log->hasAttribute('charset')) { + $result['charset'] = (string)$log->getAttribute('charset'); + } + + if ($log->hasAttribute('lowUpperBound')) { + $result['lowUpperBound'] = (string)$log->getAttribute('lowUpperBound'); + } + + if ($log->hasAttribute('highLowerBound')) { + $result['highLowerBound'] = (string)$log->getAttribute('highLowerBound'); + } + + if ($log->hasAttribute('yui')) { + $result['yui'] = $this->getBoolean( + (string)$log->getAttribute('yui'), + TRUE + ); + } + + if ($log->hasAttribute('highlight')) { + $result['highlight'] = $this->getBoolean( + (string)$log->getAttribute('highlight'), + FALSE + ); + } + } + + else if ($type == 'junit') { + if ($log->hasAttribute('logIncompleteSkipped')) { + $result['logIncompleteSkipped'] = $this->getBoolean( + (string)$log->getAttribute('logIncompleteSkipped'), + FALSE + ); + } + } + + else if ($type == 'coverage-text') { + if ($log->hasAttribute('showUncoveredFiles')) { + $result['coverageTextShowUncoveredFiles'] = $this->getBoolean( + (string)$log->getAttribute('showUncoveredFiles'), + FALSE + ); + } + } + + $result[$type] = $target; + } + + return $result; + } + + /** + * Returns the PHP configuration. + * + * @return array + * @since Method available since Release 3.2.1 + */ + public function getPHPConfiguration() + { + $result = array( + 'include_path' => array(), + 'ini' => array(), + 'const' => array(), + 'var' => array(), + 'env' => array(), + 'post' => array(), + 'get' => array(), + 'cookie' => array(), + 'server' => array(), + 'files' => array(), + 'request' => array() + ); + + foreach ($this->xpath->query('php/includePath') as $includePath) { + $path = (string)$includePath->nodeValue; + + $result['include_path'][] = $this->toAbsolutePath($path); + } + + foreach ($this->xpath->query('php/ini') as $ini) { + $name = (string)$ini->getAttribute('name'); + $value = (string)$ini->getAttribute('value'); + + $result['ini'][$name] = $value; + } + + foreach ($this->xpath->query('php/const') as $const) { + $name = (string)$const->getAttribute('name'); + $value = (string)$const->getAttribute('value'); + + $result['const'][$name] = $this->getBoolean($value, $value); + } + + foreach (array('var', 'env', 'post', 'get', 'cookie', 'server', 'files', 'request') as $array) { + foreach ($this->xpath->query('php/' . $array) as $var) { + $name = (string)$var->getAttribute('name'); + $value = (string)$var->getAttribute('value'); + + $result[$array][$name] = $this->getBoolean($value, $value); + } + } + + return $result; + } + + /** + * Handles the PHP configuration. + * + * @since Method available since Release 3.2.20 + */ + public function handlePHPConfiguration() + { + $configuration = $this->getPHPConfiguration(); + + if (! empty($configuration['include_path'])) { + ini_set( + 'include_path', + implode(PATH_SEPARATOR, $configuration['include_path']) . + PATH_SEPARATOR . + ini_get('include_path') + ); + } + + foreach ($configuration['ini'] as $name => $value) { + if (defined($value)) { + $value = constant($value); + } + + ini_set($name, $value); + } + + foreach ($configuration['const'] as $name => $value) { + if (!defined($name)) { + define($name, $value); + } + } + + foreach (array('var', 'env', 'post', 'get', 'cookie', 'server', 'files', 'request') as $array) { + if ($array == 'var') { + $target = &$GLOBALS; + } else { + $target = &$GLOBALS['_' . strtoupper($array)]; + } + + foreach ($configuration[$array] as $name => $value) { + $target[$name] = $value; + } + } + + foreach ($configuration['env'] as $name => $value) { + putenv("$name=$value"); + } + } + + /** + * Returns the PHPUnit configuration. + * + * @return array + * @since Method available since Release 3.2.14 + */ + public function getPHPUnitConfiguration() + { + $result = array(); + $root = $this->document->documentElement; + + if ($root->hasAttribute('cacheTokens')) { + $result['cacheTokens'] = $this->getBoolean( + (string)$root->getAttribute('cacheTokens'), TRUE + ); + } + + if ($root->hasAttribute('colors')) { + $result['colors'] = $this->getBoolean( + (string)$root->getAttribute('colors'), FALSE + ); + } + + if ($root->hasAttribute('backupGlobals')) { + $result['backupGlobals'] = $this->getBoolean( + (string)$root->getAttribute('backupGlobals'), TRUE + ); + } + + if ($root->hasAttribute('backupStaticAttributes')) { + $result['backupStaticAttributes'] = $this->getBoolean( + (string)$root->getAttribute('backupStaticAttributes'), FALSE + ); + } + + if ($root->hasAttribute('bootstrap')) { + $result['bootstrap'] = $this->toAbsolutePath( + (string)$root->getAttribute('bootstrap') + ); + } + + if ($root->hasAttribute('convertErrorsToExceptions')) { + $result['convertErrorsToExceptions'] = $this->getBoolean( + (string)$root->getAttribute('convertErrorsToExceptions'), TRUE + ); + } + + if ($root->hasAttribute('convertNoticesToExceptions')) { + $result['convertNoticesToExceptions'] = $this->getBoolean( + (string)$root->getAttribute('convertNoticesToExceptions'), TRUE + ); + } + + if ($root->hasAttribute('convertWarningsToExceptions')) { + $result['convertWarningsToExceptions'] = $this->getBoolean( + (string)$root->getAttribute('convertWarningsToExceptions'), TRUE + ); + } + + if ($root->hasAttribute('forceCoversAnnotation')) { + $result['forceCoversAnnotation'] = $this->getBoolean( + (string)$root->getAttribute('forceCoversAnnotation'), FALSE + ); + } + + if ($root->hasAttribute('mapTestClassNameToCoveredClassName')) { + $result['mapTestClassNameToCoveredClassName'] = $this->getBoolean( + (string)$root->getAttribute('mapTestClassNameToCoveredClassName'), + FALSE + ); + } + + if ($root->hasAttribute('processIsolation')) { + $result['processIsolation'] = $this->getBoolean( + (string)$root->getAttribute('processIsolation'), FALSE + ); + } + + if ($root->hasAttribute('stopOnError')) { + $result['stopOnError'] = $this->getBoolean( + (string)$root->getAttribute('stopOnError'), FALSE + ); + } + + if ($root->hasAttribute('stopOnFailure')) { + $result['stopOnFailure'] = $this->getBoolean( + (string)$root->getAttribute('stopOnFailure'), FALSE + ); + } + + if ($root->hasAttribute('stopOnIncomplete')) { + $result['stopOnIncomplete'] = $this->getBoolean( + (string)$root->getAttribute('stopOnIncomplete'), FALSE + ); + } + + if ($root->hasAttribute('stopOnSkipped')) { + $result['stopOnSkipped'] = $this->getBoolean( + (string)$root->getAttribute('stopOnSkipped'), FALSE + ); + } + + if ($root->hasAttribute('testSuiteLoaderClass')) { + $result['testSuiteLoaderClass'] = (string)$root->getAttribute( + 'testSuiteLoaderClass' + ); + } + + if ($root->hasAttribute('testSuiteLoaderFile')) { + $result['testSuiteLoaderFile'] = (string)$root->getAttribute( + 'testSuiteLoaderFile' + ); + } + + if ($root->hasAttribute('printerClass')) { + $result['printerClass'] = (string)$root->getAttribute( + 'printerClass' + ); + } + + if ($root->hasAttribute('printerFile')) { + $result['printerFile'] = (string)$root->getAttribute( + 'printerFile' + ); + } + + if ($root->hasAttribute('timeoutForSmallTests')) { + $result['timeoutForSmallTests'] = $this->getInteger( + (string)$root->getAttribute('timeoutForSmallTests'), 1 + ); + } + + if ($root->hasAttribute('timeoutForMediumTests')) { + $result['timeoutForMediumTests'] = $this->getInteger( + (string)$root->getAttribute('timeoutForMediumTests'), 10 + ); + } + + if ($root->hasAttribute('timeoutForLargeTests')) { + $result['timeoutForLargeTests'] = $this->getInteger( + (string)$root->getAttribute('timeoutForLargeTests'), 60 + ); + } + + if ($root->hasAttribute('strict')) { + $result['strict'] = $this->getBoolean( + (string)$root->getAttribute('strict'), FALSE + ); + } + + if ($root->hasAttribute('verbose')) { + $result['verbose'] = $this->getBoolean( + (string)$root->getAttribute('verbose'), FALSE + ); + } + + return $result; + } + + /** + * Returns the SeleniumTestCase browser configuration. + * + * @return array + * @since Method available since Release 3.2.9 + */ + public function getSeleniumBrowserConfiguration() + { + $result = array(); + + foreach ($this->xpath->query('selenium/browser') as $config) { + $name = (string)$config->getAttribute('name'); + $browser = (string)$config->getAttribute('browser'); + + if ($config->hasAttribute('host')) { + $host = (string)$config->getAttribute('host'); + } else { + $host = 'localhost'; + } + + if ($config->hasAttribute('port')) { + $port = $this->getInteger( + (string)$config->getAttribute('port'), 4444 + ); + } else { + $port = 4444; + } + + if ($config->hasAttribute('timeout')) { + $timeout = $this->getInteger( + (string)$config->getAttribute('timeout'), 30000 + ); + } else { + $timeout = 30000; + } + + $result[] = array( + 'name' => $name, + 'browser' => $browser, + 'host' => $host, + 'port' => $port, + 'timeout' => $timeout + ); + } + + return $result; + } + + /** + * Returns the test suite configuration. + * + * @return PHPUnit_Framework_TestSuite + * @since Method available since Release 3.2.1 + */ + public function getTestSuiteConfiguration() + { + $testSuiteNodes = $this->xpath->query('testsuites/testsuite'); + + if ($testSuiteNodes->length == 0) { + $testSuiteNodes = $this->xpath->query('testsuite'); + } + + if ($testSuiteNodes->length == 1) { + return $this->getTestSuite($testSuiteNodes->item(0)); + } + + if ($testSuiteNodes->length > 1) { + $suite = new PHPUnit_Framework_TestSuite; + + foreach ($testSuiteNodes as $testSuiteNode) { + $suite->addTestSuite( + $this->getTestSuite($testSuiteNode) + ); + } + + return $suite; + } + } + + /** + * @param DOMElement $testSuiteNode + * @return PHPUnit_Framework_TestSuite + * @since Method available since Release 3.4.0 + */ + protected function getTestSuite(DOMElement $testSuiteNode) + { + if ($testSuiteNode->hasAttribute('name')) { + $suite = new PHPUnit_Framework_TestSuite( + (string)$testSuiteNode->getAttribute('name') + ); + } else { + $suite = new PHPUnit_Framework_TestSuite; + } + + $exclude = array(); + + foreach ($testSuiteNode->getElementsByTagName('exclude') as $excludeNode) { + $exclude[] = (string)$excludeNode->nodeValue; + } + + $fileIteratorFacade = new File_Iterator_Facade; + + foreach ($testSuiteNode->getElementsByTagName('directory') as $directoryNode) { + $directory = (string)$directoryNode->nodeValue; + + if (empty($directory)) { + continue; + } + + if ($directoryNode->hasAttribute('phpVersion')) { + $phpVersion = (string)$directoryNode->getAttribute('phpVersion'); + } else { + $phpVersion = PHP_VERSION; + } + + if ($directoryNode->hasAttribute('phpVersionOperator')) { + $phpVersionOperator = (string)$directoryNode->getAttribute('phpVersionOperator'); + } else { + $phpVersionOperator = '>='; + } + + if (!version_compare(PHP_VERSION, $phpVersion, $phpVersionOperator)) { + continue; + } + + if ($directoryNode->hasAttribute('prefix')) { + $prefix = (string)$directoryNode->getAttribute('prefix'); + } else { + $prefix = ''; + } + + if ($directoryNode->hasAttribute('suffix')) { + $suffix = (string)$directoryNode->getAttribute('suffix'); + } else { + $suffix = 'Test.php'; + } + + $files = $fileIteratorFacade->getFilesAsArray( + $this->toAbsolutePath($directory), + $suffix, + $prefix, + $exclude + ); + $suite->addTestFiles($files); + } + + foreach ($testSuiteNode->getElementsByTagName('file') as $fileNode) { + $file = (string)$fileNode->nodeValue; + + if (empty($file)) { + continue; + } + + // Get the absolute path to the file + $file = $fileIteratorFacade->getFilesAsArray($file); + + if (!isset($file[0])) { + continue; + } + + $file = $file[0]; + + if ($fileNode->hasAttribute('phpVersion')) { + $phpVersion = (string)$fileNode->getAttribute('phpVersion'); + } else { + $phpVersion = PHP_VERSION; + } + + if ($fileNode->hasAttribute('phpVersionOperator')) { + $phpVersionOperator = (string)$fileNode->getAttribute('phpVersionOperator'); + } else { + $phpVersionOperator = '>='; + } + + if (!version_compare(PHP_VERSION, $phpVersion, $phpVersionOperator)) { + continue; + } + + $suite->addTestFile($file); + } + + return $suite; + } + + /** + * @param string $value + * @param boolean $default + * @return boolean + * @since Method available since Release 3.2.3 + */ + protected function getBoolean($value, $default) + { + if (strtolower($value) == 'false') { + return FALSE; + } + + else if (strtolower($value) == 'true') { + return TRUE; + } + + return $default; + } + + /** + * @param string $value + * @param boolean $default + * @return boolean + * @since Method available since Release 3.6.0 + */ + protected function getInteger($value, $default) + { + if (is_numeric($value)) { + return (int)$value; + } + + return $default; + } + + /** + * @param string $query + * @return array + * @since Method available since Release 3.2.3 + */ + protected function readFilterDirectories($query) + { + $directories = array(); + + foreach ($this->xpath->query($query) as $directory) { + if ($directory->hasAttribute('prefix')) { + $prefix = (string)$directory->getAttribute('prefix'); + } else { + $prefix = ''; + } + + if ($directory->hasAttribute('suffix')) { + $suffix = (string)$directory->getAttribute('suffix'); + } else { + $suffix = '.php'; + } + + if ($directory->hasAttribute('group')) { + $group = (string)$directory->getAttribute('group'); + } else { + $group = 'DEFAULT'; + } + + $directories[] = array( + 'path' => $this->toAbsolutePath((string)$directory->nodeValue), + 'prefix' => $prefix, + 'suffix' => $suffix, + 'group' => $group + ); + } + + return $directories; + } + + /** + * @param string $query + * @return array + * @since Method available since Release 3.2.3 + */ + protected function readFilterFiles($query) + { + $files = array(); + + foreach ($this->xpath->query($query) as $file) { + $files[] = $this->toAbsolutePath((string)$file->nodeValue); + } + + return $files; + } + + /** + * @param string $path + * @param boolean $useIncludePath + * @return string + * @since Method available since Release 3.5.0 + */ + protected function toAbsolutePath($path, $useIncludePath = FALSE) + { + // Check whether the path is already absolute. + if ($path[0] === '/' || $path[0] === '\\' || + (strlen($path) > 3 && ctype_alpha($path[0]) && + $path[1] === ':' && ($path[2] === '\\' || $path[2] === '/'))) { + return $path; + } + + // Check whether a stream is used. + if (strpos($path, '://') !== FALSE) { + return $path; + } + + $file = dirname($this->filename) . DIRECTORY_SEPARATOR . $path; + + if ($useIncludePath && !file_exists($file)) { + $includePathFile = PHPUnit_Util_Filesystem::fileExistsInIncludePath( + $path + ); + + if ($includePathFile) { + $file = $includePathFile; + } + } + + return $file; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/DeprecatedFeature/Logger.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/DeprecatedFeature/Logger.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/DeprecatedFeature/Logger.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/DeprecatedFeature/Logger.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,202 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Ralph Schindler + * @author Sebastian Bergmann + * @copyright 2002-2010 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.5.7 + */ + +/** + * Test Listener that tracks the usage of deprecated features. + * + * @package PHPUnit + * @subpackage Framework + * @author Ralph Schindler + * @author Sebastian Bergmann + * @copyright 2002-2010 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.5.7 + */ +class PHPUnit_Util_DeprecatedFeature_Logger implements PHPUnit_Framework_TestListener +{ + /** + * @var PHPUnit_Framework_TestCase + */ + protected static $currentTest = NULL; + + /** + * This is the publically accessible API for notifying the system that a + * deprecated feature has been used. + * + * If it is run via a TestRunner and the test extends + * PHPUnit_Framework_TestCase, then this will inject the result into the + * test runner for display, if not, it will throw the notice to STDERR. + * + * @param string $message + * @param int|bool $backtraceDepth + */ + public static function log($message, $backtraceDepth = 2) + { + if ($backtraceDepth !== FALSE) { + $trace = debug_backtrace(FALSE); + + if (is_int($backtraceDepth)) { + $traceItem = $trace[$backtraceDepth]; + } + + if (!isset($traceItem['file'])) { + $reflectionClass = new ReflectionClass($traceItem['class']); + $traceItem['file'] = $reflectionClass->getFileName(); + } + + if (!isset($traceItem['line']) && + isset($traceItem['class']) && + isset($traceItem['function'])) { + if (!isset($reflectionClass)) { + $reflectionClass = new ReflectionClass($traceItem['class']); + } + + $method = $reflectionClass->getMethod($traceItem['function']); + $traceItem['line'] = '(between ' . $method->getStartLine() . + ' and ' . $method->getEndLine() . ')'; + } + } + + $deprecatedFeature = new PHPUnit_Util_DeprecatedFeature( + $message, $traceItem + ); + + if (self::$currentTest instanceof PHPUnit_Framework_TestCase) { + $result = self::$currentTest->getTestResultObject(); + $result->addDeprecatedFeature($deprecatedFeature); + } else { + file_put_contents('php://stderr', $deprecatedFeature); + } + } + + /** + * An error occurred. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) + { + } + + /** + * A failure occurred. + * + * @param PHPUnit_Framework_Test $test + * @param PHPUnit_Framework_AssertionFailedError $e + * @param float $time + */ + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) + { + } + + /** + * Incomplete test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + } + + /** + * Skipped test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + * @since Method available since Release 3.0.0 + */ + public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + } + + /** + * A test suite started. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit_Framework_TestSuite $suite) + { + } + + /** + * A test suite ended. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit_Framework_TestSuite $suite) + { + } + + /** + * A test started. + * + * @param PHPUnit_Framework_Test $test + */ + public function startTest(PHPUnit_Framework_Test $test) + { + self::$currentTest = $test; + } + + /** + * A test ended. + * + * @param PHPUnit_Framework_Test $test + * @param float $time + */ + public function endTest(PHPUnit_Framework_Test $test, $time) + { + self::$currentTest = NULL; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/DeprecatedFeature.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/DeprecatedFeature.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/DeprecatedFeature.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/DeprecatedFeature.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,103 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Framework + * @author Ralph Schindler + * @author Sebastian Bergmann + * @copyright 2002-2010 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.5.7 + */ + +/** + * Class to hold the information about a deprecated feature that was used + * + * @package PHPUnit + * @subpackage Framework + * @author Ralph Schindler + * @author Sebastian Bergmann + * @copyright 2002-2010 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Interface available since Release 3.5.7 + */ +class PHPUnit_Util_DeprecatedFeature +{ + /** + * @var array + */ + protected $traceInfo = array(); + + /** + * @var string + */ + protected $message = NULL; + + /** + * @param string $message + * @param array $traceInfo + */ + public function __construct($message, array $traceInfo = array()) + { + $this->message = $message; + $this->traceInfo = $traceInfo; + } + + /** + * Build a string representation of the deprecated feature that was raised + * + * @return string + */ + public function __toString() + { + $string = ''; + + if (isset($this->traceInfo['file'])) { + $string .= $this->traceInfo['file']; + + if (isset($this->traceInfo['line'])) { + $string .= ':' . $this->traceInfo['line'] . ' - '; + } + } + + $string .= $this->message; + + return $string; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Diff.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Diff.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Diff.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Diff.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,260 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @author Kore Nordmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.4.0 + */ + +/** + * Diff implementation. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @author Kore Nordmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.4.0 + */ +class PHPUnit_Util_Diff +{ + /** + * Returns the diff between two arrays or strings. + * + * @param array|string $from + * @param array|string $to + * @return string + */ + public static function diff($from, $to) + { + if (is_string($from)) { + $from = preg_split('(\r\n|\r|\n)', $from); + } + + if (is_string($to)) { + $to = preg_split('(\r\n|\r|\n)', $to); + } + + $buffer = "--- Expected\n+++ Actual\n"; + $start = array(); + $end = array(); + $fromLength = count($from); + $toLength = count($to); + $length = min($fromLength, $toLength); + + for ($i = 0; $i < $length; ++$i) { + if ($from[$i] === $to[$i]) { + $start[] = $from[$i]; + unset($from[$i], $to[$i]); + } else { + break; + } + } + + $length -= $i; + + for ($i = 1; $i < $length; ++$i) { + if ($from[$fromLength - $i] === $to[$toLength - $i]) { + array_unshift($end, $from[$fromLength - $i]); + unset($from[$fromLength - $i], $to[$toLength - $i]); + } else { + break; + } + } + + $common = self::longestCommonSubsequence( + array_values($from), array_values($to) + ); + + $diff = array(); + $line = 0; + + foreach ($start as $token) { + $diff[] = array($token, 0 /* OLD */); + } + + reset($from); + reset($to); + + foreach ($common as $token) { + while ((($fromToken = reset($from)) !== $token)) { + $diff[] = array(array_shift($from), 2 /* REMOVED */); + } + + while ((($toToken = reset($to)) !== $token)) { + $diff[] = array(array_shift($to), 1 /* ADDED */); + } + + $diff[] = array($token, 0 /* OLD */); + + array_shift($from); + array_shift($to); + } + + while (($token = array_shift($from)) !== NULL) { + $diff[] = array($token, 2 /* REMOVED */); + } + + while (($token = array_shift($to)) !== NULL) { + $diff[] = array($token, 1 /* ADDED */); + } + + foreach ($end as $token) { + $diff[] = array($token, 0 /* OLD */); + } + + $inOld = FALSE; + $i = 0; + $old = array(); + + foreach ($diff as $line) { + if ($line[1] === 0 /* OLD */) { + if ($inOld === FALSE) { + $inOld = $i; + } + } + + else if ($inOld !== FALSE) { + if (($i - $inOld) > 5) { + $old[$inOld] = $i - 1; + } + + $inOld = FALSE; + } + + ++$i; + } + + $start = isset($old[0]) ? $old[0] : 0; + $end = count($diff); + $i = 0; + + if ($tmp = array_search($end, $old)) { + $end = $tmp; + } + + $newChunk = TRUE; + + for ($i = $start; $i < $end; $i++) { + if (isset($old[$i])) { + $buffer .= "\n"; + $newChunk = TRUE; + $i = $old[$i]; + } + + if ($newChunk) { + $buffer .= "@@ @@\n"; + $newChunk = FALSE; + } + + if ($diff[$i][1] === 1 /* ADDED */) { + $buffer .= '+' . $diff[$i][0] . "\n"; + } + + else if ($diff[$i][1] === 2 /* REMOVED */) { + $buffer .= '-' . $diff[$i][0] . "\n"; + } + + else { + $buffer .= ' ' . $diff[$i][0] . "\n"; + } + } + + return $buffer; + } + + /** + * Calculates the longest common subsequence of two arrays. + * + * @param array $from + * @param array $to + * @return array + */ + protected static function longestCommonSubsequence(array $from, array $to) + { + $common = array(); + $matrix = array(); + $fromLength = count($from); + $toLength = count($to); + + for ($i = 0; $i <= $fromLength; ++$i) { + $matrix[$i][0] = 0; + } + + for ($j = 0; $j <= $toLength; ++$j) { + $matrix[0][$j] = 0; + } + + for ($i = 1; $i <= $fromLength; ++$i) { + for ($j = 1; $j <= $toLength; ++$j) { + $matrix[$i][$j] = max( + $matrix[$i-1][$j], + $matrix[$i][$j-1], + $from[$i-1] === $to[$j-1] ? $matrix[$i-1][$j-1] + 1 : 0 + ); + } + } + + $i = $fromLength; + $j = $toLength; + + while ($i > 0 && $j > 0) { + if ($from[$i-1] === $to[$j-1]) { + array_unshift($common, $from[$i-1]); + --$i; + --$j; + } + + else if ($matrix[$i][$j-1] > $matrix[$i-1][$j]) { + --$j; + } + + else { + --$i; + } + } + + return $common; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/ErrorHandler.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/ErrorHandler.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/ErrorHandler.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/ErrorHandler.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,133 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.3.0 + */ + +// Workaround for http://bugs.php.net/bug.php?id=47987, +// see https://github.com/sebastianbergmann/phpunit/issues#issue/125 for details +require_once 'PHPUnit/Framework/Error.php'; +require_once 'PHPUnit/Framework/Error/Notice.php'; +require_once 'PHPUnit/Framework/Error/Warning.php'; +require_once 'PHPUnit/Framework/Error/Deprecated.php'; + +/** + * Error handler that converts PHP errors and warnings to exceptions. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.3.0 + */ +class PHPUnit_Util_ErrorHandler +{ + protected static $errorStack = array(); + + /** + * Returns the error stack. + * + * @return array + */ + public static function getErrorStack() + { + return self::$errorStack; + } + + /** + * @param integer $errno + * @param string $errstr + * @param string $errfile + * @param integer $errline + * @throws PHPUnit_Framework_Error + */ + public static function handleError($errno, $errstr, $errfile, $errline) + { + if (!($errno & error_reporting())) { + return FALSE; + } + + self::$errorStack[] = array($errno, $errstr, $errfile, $errline); + + $trace = debug_backtrace(FALSE); + array_shift($trace); + + foreach ($trace as $frame) { + if ($frame['function'] == '__toString') { + return FALSE; + } + } + + if ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_STRICT) { + if (PHPUnit_Framework_Error_Notice::$enabled !== TRUE) { + return FALSE; + } + + $exception = 'PHPUnit_Framework_Error_Notice'; + } + + else if ($errno == E_WARNING || $errno == E_USER_WARNING) { + if (PHPUnit_Framework_Error_Warning::$enabled !== TRUE) { + return FALSE; + } + + $exception = 'PHPUnit_Framework_Error_Warning'; + } + + else if (version_compare(PHP_VERSION, '5.3', '>=') && ($errno == E_DEPRECATED || $errno == E_USER_DEPRECATED)) { + if (PHPUnit_Framework_Error_Deprecated::$enabled !== TRUE) { + return FALSE; + } + + $exception = 'PHPUnit_Framework_Error_Deprecated'; + } + + else { + $exception = 'PHPUnit_Framework_Error'; + } + + throw new $exception($errstr, $errno, $errfile, $errline, $trace); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/File.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/File.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/File.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/File.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,309 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.4.0 + */ + +if (!defined('T_NAMESPACE')) { + define('T_NAMESPACE', 377); +} + +/** + * File helpers. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.4.0 + */ +class PHPUnit_Util_File +{ + /** + * @var array + */ + protected static $cache = array(); + + /** + * Returns information on the classes declared in a sourcefile. + * + * @param string $filename + * @return array + */ + public static function getClassesInFile($filename) + { + if (!isset(self::$cache[$filename])) { + self::$cache[$filename] = self::parseFile($filename); + } + + return self::$cache[$filename]; + } + + /** + * Parses a file for class and method information. + * + * @param string $filename + * @return array + */ + protected static function parseFile($filename) + { + $result = array(); + + $tokens = token_get_all( + file_get_contents($filename) + ); + $numTokens = count($tokens); + $blocks = array(); + $line = 1; + $currentBlock = FALSE; + $currentNamespace = FALSE; + $currentClass = FALSE; + $currentFunction = FALSE; + $currentFunctionStartLine = FALSE; + $currentFunctionTokens = array(); + $currentDocComment = FALSE; + $currentSignature = FALSE; + $currentSignatureStartToken = FALSE; + + for ($i = 0; $i < $numTokens; $i++) { + if ($currentFunction !== FALSE) { + $currentFunctionTokens[] = $tokens[$i]; + } + + if (is_string($tokens[$i])) { + if ($tokens[$i] == '{') { + if ($currentBlock == T_CLASS) { + $block = $currentClass; + } + + else if ($currentBlock == T_FUNCTION) { + $currentSignature = ''; + + for ($j = $currentSignatureStartToken; $j < $i; $j++) { + if (is_string($tokens[$j])) { + $currentSignature .= $tokens[$j]; + } else { + $currentSignature .= $tokens[$j][1]; + } + } + + $currentSignature = trim($currentSignature); + + $block = $currentFunction; + $currentSignatureStartToken = FALSE; + } + + else { + $block = FALSE; + } + + array_push($blocks, $block); + + $currentBlock = FALSE; + } + + else if ($tokens[$i] == '}') { + $block = array_pop($blocks); + + if ($block !== FALSE && $block !== NULL) { + if ($block == $currentFunction) { + if ($currentDocComment !== FALSE) { + $docComment = $currentDocComment; + $currentDocComment = FALSE; + } else { + $docComment = ''; + } + + $tmp = array( + 'docComment' => $docComment, + 'signature' => $currentSignature, + 'startLine' => $currentFunctionStartLine, + 'endLine' => $line, + 'tokens' => $currentFunctionTokens + ); + + if ($currentClass !== FALSE) { + $result[$currentClass]['methods'][$currentFunction] = $tmp; + } + + $currentFunction = FALSE; + $currentFunctionStartLine = FALSE; + $currentFunctionTokens = array(); + $currentSignature = FALSE; + } + + else if ($block == $currentClass) { + $result[$currentClass]['endLine'] = $line; + + $currentClass = FALSE; + $currentClassStartLine = FALSE; + } + } + } + + continue; + } + + switch ($tokens[$i][0]) { + case T_HALT_COMPILER: { + return; + } + break; + + case T_NAMESPACE: { + $currentNamespace = $tokens[$i+2][1]; + + for ($j = $i+3; $j < $numTokens; $j += 2) { + if ($tokens[$j][0] == T_NS_SEPARATOR) { + $currentNamespace .= '\\' . $tokens[$j+1][1]; + } else { + break; + } + } + } + break; + + case T_CURLY_OPEN: { + $currentBlock = T_CURLY_OPEN; + array_push($blocks, $currentBlock); + } + break; + + case T_DOLLAR_OPEN_CURLY_BRACES: { + $currentBlock = T_DOLLAR_OPEN_CURLY_BRACES; + array_push($blocks, $currentBlock); + } + break; + + case T_CLASS: { + $currentBlock = T_CLASS; + + if ($currentNamespace === FALSE) { + $currentClass = $tokens[$i+2][1]; + } else { + $currentClass = $currentNamespace . '\\' . + $tokens[$i+2][1]; + } + + if ($currentDocComment !== FALSE) { + $docComment = $currentDocComment; + $currentDocComment = FALSE; + } else { + $docComment = ''; + } + + $result[$currentClass] = array( + 'methods' => array(), + 'docComment' => $docComment, + 'startLine' => $line + ); + } + break; + + case T_FUNCTION: { + if (!((is_array($tokens[$i+2]) && + $tokens[$i+2][0] == T_STRING) || + (is_string($tokens[$i+2]) && + $tokens[$i+2] == '&' && + is_array($tokens[$i+3]) && + $tokens[$i+3][0] == T_STRING))) { + continue; + } + + $currentBlock = T_FUNCTION; + $currentFunctionStartLine = $line; + + $done = FALSE; + $currentSignatureStartToken = $i - 1; + + do { + switch ($tokens[$currentSignatureStartToken][0]) { + case T_ABSTRACT: + case T_FINAL: + case T_PRIVATE: + case T_PUBLIC: + case T_PROTECTED: + case T_STATIC: + case T_WHITESPACE: { + $currentSignatureStartToken--; + } + break; + + default: { + $currentSignatureStartToken++; + $done = TRUE; + } + } + } while (!$done); + + if (isset($tokens[$i+2][1])) { + $functionName = $tokens[$i+2][1]; + } + + else if (isset($tokens[$i+3][1])) { + $functionName = $tokens[$i+3][1]; + } + + if ($currentNamespace === FALSE) { + $currentFunction = $functionName; + } else { + $currentFunction = $currentNamespace . '\\' . + $functionName; + } + } + break; + + case T_DOC_COMMENT: { + $currentDocComment = $tokens[$i][1]; + } + break; + } + + $line += substr_count($tokens[$i][1], "\n"); + } + + return $result; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Fileloader.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Fileloader.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Fileloader.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Fileloader.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,110 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.3.0 + */ + +/** + * Utility methods to load PHP sourcefiles. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://www.phpunit.de/ + * @since Class available since Release 2.3.0 + */ +class PHPUnit_Util_Fileloader +{ + /** + * Checks if a PHP sourcefile is readable. + * The sourcefile is loaded through the load() method. + * + * @param string $filename + * @throws RuntimeException + */ + public static function checkAndLoad($filename) + { + $includePathFilename = PHPUnit_Util_Filesystem::fileExistsInIncludePath( + $filename + ); + + if (!$includePathFilename || !is_readable($includePathFilename)) { + throw new RuntimeException( + sprintf('Cannot open file "%s".' . "\n", $filename) + ); + } + + self::load($includePathFilename); + + return $includePathFilename; + } + + /** + * Loads a PHP sourcefile. + * + * @param string $filename + * @return mixed + * @since Method available since Release 3.0.0 + */ + public static function load($filename) + { + $oldVariableNames = array_keys(get_defined_vars()); + + include_once $filename; + + $newVariables = get_defined_vars(); + $newVariableNames = array_diff( + array_keys($newVariables), $oldVariableNames + ); + + foreach ($newVariableNames as $variableName) { + if ($variableName != 'oldVariableNames') { + $GLOBALS[$variableName] = $newVariables[$variableName]; + } + } + + return $filename; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Filesystem.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Filesystem.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Filesystem.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Filesystem.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,114 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Filesystem helpers. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Util_Filesystem +{ + /** + * @var array + */ + protected static $buffer = array(); + + /** + * Maps class names to source file names: + * - PEAR CS: Foo_Bar_Baz -> Foo/Bar/Baz.php + * - Namespace: Foo\Bar\Baz -> Foo/Bar/Baz.php + * + * @param string $className + * @return string + * @since Method available since Release 3.4.0 + */ + public static function classNameToFilename($className) + { + return str_replace( + array('_', '\\'), + DIRECTORY_SEPARATOR, + $className + ) . '.php'; + } + + /** + * Implementation of stream_resolve_include_path() in PHP + * for version before PHP 5.3.2. + * + * @param string $file + * @return mixed + * @author Mattis Stordalen Flister + * @since Method available since Release 3.2.9 + */ + public static function fileExistsInIncludePath($file) + { + if (function_exists('stream_resolve_include_path')) { + return stream_resolve_include_path($file); + } + + if (file_exists($file)) { + return realpath($file); + } + + $paths = explode(PATH_SEPARATOR, get_include_path()); + + foreach ($paths as $path) { + $fullpath = $path . DIRECTORY_SEPARATOR . $file; + + if (file_exists($fullpath)) { + return realpath($fullpath); + } + } + + return FALSE; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Filter.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Filter.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Filter.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Filter.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,134 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * Utility class for code filtering. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_Util_Filter +{ + /** + * Filters stack frames from PHPUnit classes. + * + * @param Exception $e + * @param boolean $asString + * @return string + */ + public static function getFilteredStacktrace(Exception $e, $asString = TRUE) + { + if (!defined('PHPUNIT_TESTSUITE')) { + $blacklist = PHPUnit_Util_GlobalState::phpunitFiles(); + } else { + $blacklist = array(); + } + + if ($asString === TRUE) { + $filteredStacktrace = ''; + } else { + $filteredStacktrace = array(); + } + + if ($e instanceof PHPUnit_Framework_SyntheticError) { + $eTrace = $e->getSyntheticTrace(); + $eFile = $e->getSyntheticFile(); + $eLine = $e->getSyntheticLine(); + } else { + $eTrace = $e->getTrace(); + $eFile = $e->getFile(); + $eLine = $e->getLine(); + } + + if (!self::frameExists($eTrace, $eFile, $eLine)) { + array_unshift( + $eTrace, array('file' => $eFile, 'line' => $eLine) + ); + } + + foreach ($eTrace as $frame) { + if (isset($frame['file']) && is_file($frame['file']) && + !isset($blacklist[$frame['file']])) { + if ($asString === TRUE) { + $filteredStacktrace .= sprintf( + "%s:%s\n", + + $frame['file'], + isset($frame['line']) ? $frame['line'] : '?' + ); + } else { + $filteredStacktrace[] = $frame; + } + } + } + + return $filteredStacktrace; + } + + /** + * @param array $trace + * @param string $file + * @param int $line + * @return boolean + * @since Method available since Release 3.3.2 + */ + public static function frameExists(array $trace, $file, $line) + { + foreach ($trace as $frame) { + if (isset($frame['file']) && $frame['file'] == $file && + isset($frame['line']) && $frame['line'] == $line) { + return TRUE; + } + } + + return FALSE; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Getopt.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Getopt.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Getopt.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Getopt.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,208 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Command-line options parsing class. + * + * @package PHPUnit + * @subpackage Util + * @author Andrei Zmievski + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Util_Getopt +{ + public static function getopt(array $args, $short_options, $long_options = NULL) + { + if (empty($args)) { + return array(array(), array()); + } + + $opts = array(); + $non_opts = array(); + + if ($long_options) { + sort($long_options); + } + + if (isset($args[0][0]) && $args[0][0] != '-') { + array_shift($args); + } + + reset($args); + array_map('trim', $args); + + while (list($i, $arg) = each($args)) { + if ($arg == '') { + continue; + } + + if ($arg == '--') { + $non_opts = array_merge($non_opts, array_slice($args, $i + 1)); + break; + } + + if ($arg[0] != '-' || + (strlen($arg) > 1 && $arg[1] == '-' && !$long_options)) { + $non_opts = array_merge($non_opts, array_slice($args, $i)); + break; + } + + elseif (strlen($arg) > 1 && $arg[1] == '-') { + self::parseLongOption( + substr($arg, 2), $long_options, $opts, $args + ); + } + + else { + self::parseShortOption( + substr($arg, 1), $short_options, $opts, $args + ); + } + } + + return array($opts, $non_opts); + } + + protected static function parseShortOption($arg, $short_options, &$opts, &$args) + { + $argLen = strlen($arg); + + for ($i = 0; $i < $argLen; $i++) { + $opt = $arg[$i]; + $opt_arg = NULL; + + if (($spec = strstr($short_options, $opt)) === FALSE || + $arg[$i] == ':') { + throw new PHPUnit_Framework_Exception( + "unrecognized option -- $opt" + ); + } + + if (strlen($spec) > 1 && $spec[1] == ':') { + if (strlen($spec) > 2 && $spec[2] == ':') { + if ($i + 1 < $argLen) { + $opts[] = array($opt, substr($arg, $i + 1)); + break; + } + } else { + if ($i + 1 < $argLen) { + $opts[] = array($opt, substr($arg, $i + 1)); + break; + } + + else if (list(, $opt_arg) = each($args)) { + } + + else { + throw new PHPUnit_Framework_Exception( + "option requires an argument -- $opt" + ); + } + } + } + + $opts[] = array($opt, $opt_arg); + } + } + + protected static function parseLongOption($arg, $long_options, &$opts, &$args) + { + $count = count($long_options); + $list = explode('=', $arg); + $opt = $list[0]; + $opt_arg = NULL; + + if (count($list) > 1) { + $opt_arg = $list[1]; + } + + $opt_len = strlen($opt); + + for ($i = 0; $i < $count; $i++) { + $long_opt = $long_options[$i]; + $opt_start = substr($long_opt, 0, $opt_len); + + if ($opt_start != $opt) { + continue; + } + + $opt_rest = substr($long_opt, $opt_len); + + if ($opt_rest != '' && $opt[0] != '=' && $i + 1 < $count && + $opt == substr($long_options[$i+1], 0, $opt_len)) { + throw new PHPUnit_Framework_Exception( + "option --$opt is ambiguous" + ); + } + + if (substr($long_opt, -1) == '=') { + if (substr($long_opt, -2) != '==') { + if (!strlen($opt_arg) && + !(list(, $opt_arg) = each($args))) { + throw new PHPUnit_Framework_Exception( + "option --$opt requires an argument" + ); + } + } + } + + else if ($opt_arg) { + throw new PHPUnit_Framework_Exception( + "option --$opt doesn't allow an argument" + ); + } + + $opts[] = array('--' . $opt, $opt_arg); + return; + } + + throw new PHPUnit_Framework_Exception("unrecognized option --$opt"); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/GlobalState.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/GlobalState.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/GlobalState.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/GlobalState.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,421 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.4.0 + */ + +/** + * + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.4.0 + */ +class PHPUnit_Util_GlobalState +{ + /** + * @var array + */ + protected static $globals = array(); + + /** + * @var array + */ + protected static $staticAttributes = array(); + + /** + * @var array + */ + protected static $superGlobalArrays = array( + '_ENV', + '_POST', + '_GET', + '_COOKIE', + '_SERVER', + '_FILES', + '_REQUEST' + ); + + /** + * @var array + */ + protected static $superGlobalArraysLong = array( + 'HTTP_ENV_VARS', + 'HTTP_POST_VARS', + 'HTTP_GET_VARS', + 'HTTP_COOKIE_VARS', + 'HTTP_SERVER_VARS', + 'HTTP_POST_FILES' + ); + + /** + * @var array + */ + protected static $phpunitFiles; + + public static function backupGlobals(array $blacklist) + { + self::$globals = array(); + $superGlobalArrays = self::getSuperGlobalArrays(); + + foreach ($superGlobalArrays as $superGlobalArray) { + if (!in_array($superGlobalArray, $blacklist)) { + self::backupSuperGlobalArray($superGlobalArray); + } + } + + foreach (array_keys($GLOBALS) as $key) { + if ($key != 'GLOBALS' && + !in_array($key, $superGlobalArrays) && + !in_array($key, $blacklist) && + !$GLOBALS[$key] instanceof Closure) { + self::$globals['GLOBALS'][$key] = serialize($GLOBALS[$key]); + } + } + } + + public static function restoreGlobals(array $blacklist) + { + if (ini_get('register_long_arrays') == '1') { + $superGlobalArrays = array_merge( + self::$superGlobalArrays, self::$superGlobalArraysLong + ); + } else { + $superGlobalArrays = self::$superGlobalArrays; + } + + foreach ($superGlobalArrays as $superGlobalArray) { + if (!in_array($superGlobalArray, $blacklist)) { + self::restoreSuperGlobalArray($superGlobalArray); + } + } + + foreach (array_keys($GLOBALS) as $key) { + if ($key != 'GLOBALS' && + !in_array($key, $superGlobalArrays) && + !in_array($key, $blacklist)) { + if (isset(self::$globals['GLOBALS'][$key])) { + $GLOBALS[$key] = unserialize( + self::$globals['GLOBALS'][$key] + ); + } else { + unset($GLOBALS[$key]); + } + } + } + + self::$globals = array(); + } + + protected static function backupSuperGlobalArray($superGlobalArray) + { + self::$globals[$superGlobalArray] = array(); + + if (isset($GLOBALS[$superGlobalArray]) && + is_array($GLOBALS[$superGlobalArray])) { + foreach ($GLOBALS[$superGlobalArray] as $key => $value) { + self::$globals[$superGlobalArray][$key] = serialize($value); + } + } + } + + protected static function restoreSuperGlobalArray($superGlobalArray) + { + if (isset($GLOBALS[$superGlobalArray]) && + is_array($GLOBALS[$superGlobalArray]) && + isset(self::$globals[$superGlobalArray])) { + $keys = array_keys( + array_merge( + $GLOBALS[$superGlobalArray], self::$globals[$superGlobalArray] + ) + ); + + foreach ($keys as $key) { + if (isset(self::$globals[$superGlobalArray][$key])) { + $GLOBALS[$superGlobalArray][$key] = unserialize( + self::$globals[$superGlobalArray][$key] + ); + } else { + unset($GLOBALS[$superGlobalArray][$key]); + } + } + } + + self::$globals[$superGlobalArray] = array(); + } + + public static function getIncludedFilesAsString() + { + $blacklist = self::phpunitFiles(); + $files = get_included_files(); + $result = ''; + + for ($i = count($files) - 1; $i > 0; $i--) { + if (!isset($blacklist[$files[$i]]) && is_file($files[$i])) { + $result = 'require_once \'' . $files[$i] . "';\n" . $result; + } + } + + return $result; + } + + public static function getConstantsAsString() + { + $constants = get_defined_constants(TRUE); + $result = ''; + + if (isset($constants['user'])) { + foreach ($constants['user'] as $name => $value) { + $result .= sprintf( + 'if (!defined(\'%s\')) define(\'%s\', %s);' . "\n", + $name, + $name, + self::exportVariable($value) + ); + } + } + + return $result; + } + + public static function getGlobalsAsString() + { + $result = ''; + $superGlobalArrays = self::getSuperGlobalArrays(); + + foreach ($superGlobalArrays as $superGlobalArray) { + if (isset($GLOBALS[$superGlobalArray]) && + is_array($GLOBALS[$superGlobalArray])) { + foreach (array_keys($GLOBALS[$superGlobalArray]) as $key) { + if ($GLOBALS[$superGlobalArray][$key] instanceof Closure) { + continue; + } + + $result .= sprintf( + '$GLOBALS[\'%s\'][\'%s\'] = %s;' . "\n", + $superGlobalArray, + $key, + self::exportVariable($GLOBALS[$superGlobalArray][$key]) + ); + } + } + } + + $blacklist = $superGlobalArrays; + $blacklist[] = 'GLOBALS'; + $blacklist[] = '_PEAR_Config_instance'; + + foreach (array_keys($GLOBALS) as $key) { + if (!in_array($key, $blacklist) && !$GLOBALS[$key] instanceof Closure) { + $result .= sprintf( + '$GLOBALS[\'%s\'] = %s;' . "\n", + $key, + self::exportVariable($GLOBALS[$key]) + ); + } + } + + return $result; + } + + protected static function getSuperGlobalArrays() + { + if (ini_get('register_long_arrays') == '1') { + return array_merge( + self::$superGlobalArrays, self::$superGlobalArraysLong + ); + } else { + return self::$superGlobalArrays; + } + } + + public static function backupStaticAttributes(array $blacklist) + { + self::$staticAttributes = array(); + $declaredClasses = get_declared_classes(); + $declaredClassesNum = count($declaredClasses); + + for ($i = $declaredClassesNum - 1; $i >= 0; $i--) { + if (strpos($declaredClasses[$i], 'PHPUnit') !== 0 && + strpos($declaredClasses[$i], 'File_Iterator') !== 0 && + strpos($declaredClasses[$i], 'PHP_CodeCoverage') !== 0 && + strpos($declaredClasses[$i], 'PHP_Invoker') !== 0 && + strpos($declaredClasses[$i], 'PHP_Timer') !== 0 && + strpos($declaredClasses[$i], 'PHP_TokenStream') !== 0 && + strpos($declaredClasses[$i], 'sfYaml') !== 0 && + strpos($declaredClasses[$i], 'Text_Template') !== 0 && + !$declaredClasses[$i] instanceof PHPUnit_Framework_Test) { + $class = new ReflectionClass($declaredClasses[$i]); + + if (!$class->isUserDefined()) { + break; + } + + $backup = array(); + + foreach ($class->getProperties() as $attribute) { + if ($attribute->isStatic()) { + $name = $attribute->getName(); + + if (!isset($blacklist[$declaredClasses[$i]]) || + !in_array($name, $blacklist[$declaredClasses[$i]])) { + $attribute->setAccessible(TRUE); + $value = $attribute->getValue(); + + if (!$value instanceof Closure) { + $backup[$name] = serialize($value); + } + } + } + } + + if (!empty($backup)) { + self::$staticAttributes[$declaredClasses[$i]] = $backup; + } + } + } + } + + public static function restoreStaticAttributes() + { + foreach (self::$staticAttributes as $className => $staticAttributes) { + foreach ($staticAttributes as $name => $value) { + $reflector = new ReflectionProperty($className, $name); + $reflector->setAccessible(TRUE); + $reflector->setValue(unserialize($value)); + } + } + + self::$staticAttributes = array(); + } + + protected static function exportVariable($variable) + { + if (is_scalar($variable) || is_null($variable) || + (is_array($variable) && self::arrayOnlyContainsScalars($variable))) { + return var_export($variable, TRUE); + } + + return 'unserialize(\'' . + str_replace("'", "\'", serialize($variable)) . + '\')'; + } + + protected static function arrayOnlyContainsScalars(array $array) + { + $result = TRUE; + + foreach ($array as $element) { + if (is_array($element)) { + $result = self::arrayOnlyContainsScalars($element); + } + + else if (!is_scalar($element) && !is_null($element)) { + $result = FALSE; + } + + if ($result === FALSE) { + break; + } + } + + return $result; + } + + /** + * @return array + * @since Method available since Release 3.6.0 + */ + public static function phpunitFiles() + { + if (self::$phpunitFiles === NULL) { + self::$phpunitFiles = array_merge( + phpunit_autoload(), + phpunit_mockobject_autoload(), + file_iterator_autoload(), + php_codecoverage_autoload(), + php_timer_autoload(), + php_tokenstream_autoload(), + text_template_autoload() + ); + + if (function_exists('phpunit_dbunit_autoload')) { + self::$phpunitFiles = array_merge( + self::$phpunitFiles, phpunit_dbunit_autoload() + ); + } + + if (function_exists('phpunit_selenium_autoload')) { + self::$phpunitFiles = array_merge( + self::$phpunitFiles, phpunit_selenium_autoload() + ); + } + + if (function_exists('phpunit_story_autoload')) { + self::$phpunitFiles = array_merge( + self::$phpunitFiles, phpunit_story_autoload() + ); + } + + if (function_exists('php_invoker_autoload')) { + self::$phpunitFiles = array_merge( + self::$phpunitFiles, php_invoker_autoload() + ); + } + + foreach (self::$phpunitFiles as $key => $value) { + self::$phpunitFiles[$key] = str_replace( + '/', DIRECTORY_SEPARATOR, $value + ); + } + + self::$phpunitFiles = array_flip(self::$phpunitFiles); + } + + return self::$phpunitFiles; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/InvalidArgumentHelper.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/InvalidArgumentHelper.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/InvalidArgumentHelper.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/InvalidArgumentHelper.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,80 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.4.0 + */ + +/** + * Factory for InvalidArgumentException objects. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.4.0 + */ +class PHPUnit_Util_InvalidArgumentHelper +{ + /** + * @param integer $argument + * @param string $type + * @param mixed $value + */ + public static function factory($argument, $type, $value = NULL) + { + $stack = debug_backtrace(FALSE); + + return new InvalidArgumentException( + sprintf( + 'Argument #%d%sof %s::%s() must be a %s', + $argument, + $value !== NULL ? ' (' . $value . ')' : ' ', + $stack[1]['class'], + $stack[1]['function'], + $type + ) + ); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Log/JSON.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Log/JSON.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Log/JSON.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Log/JSON.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,239 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util_Log + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * A TestListener that generates JSON messages. + * + * @package PHPUnit + * @subpackage Util_Log + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Util_Log_JSON extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener +{ + /** + * @var string + */ + protected $currentTestSuiteName = ''; + + /** + * @var string + */ + protected $currentTestName = ''; + + /** + * @var boolean + * @access private + */ + protected $currentTestPass = TRUE; + + /** + * An error occurred. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) + { + $this->writeCase( + 'error', + $time, + PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE), + $e->getMessage(), + $test + ); + + $this->currentTestPass = FALSE; + } + + /** + * A failure occurred. + * + * @param PHPUnit_Framework_Test $test + * @param PHPUnit_Framework_AssertionFailedError $e + * @param float $time + */ + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) + { + $this->writeCase( + 'fail', + $time, + PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE), + $e->getMessage(), + $test + ); + + $this->currentTestPass = FALSE; + } + + /** + * Incomplete test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + $this->writeCase('error', $time, array(), 'Incomplete Test', $test); + + $this->currentTestPass = FALSE; + } + + /** + * Skipped test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + $this->writeCase('error', $time, array(), 'Skipped Test', $test); + + $this->currentTestPass = FALSE; + } + + /** + * A testsuite started. + * + * @param PHPUnit_Framework_TestSuite $suite + */ + public function startTestSuite(PHPUnit_Framework_TestSuite $suite) + { + $this->currentTestSuiteName = $suite->getName(); + $this->currentTestName = ''; + + $this->write( + array( + 'event' => 'suiteStart', + 'suite' => $this->currentTestSuiteName, + 'tests' => count($suite) + ) + ); + } + + /** + * A testsuite ended. + * + * @param PHPUnit_Framework_TestSuite $suite + */ + public function endTestSuite(PHPUnit_Framework_TestSuite $suite) + { + $this->currentTestSuiteName = ''; + $this->currentTestName = ''; + } + + /** + * A test started. + * + * @param PHPUnit_Framework_Test $test + */ + public function startTest(PHPUnit_Framework_Test $test) + { + $this->currentTestName = PHPUnit_Util_Test::describe($test); + $this->currentTestPass = TRUE; + + $this->write( + array( + 'event' => 'testStart', + 'suite' => $this->currentTestSuiteName, + 'test' => $this->currentTestName + ) + ); + } + + /** + * A test ended. + * + * @param PHPUnit_Framework_Test $test + * @param float $time + */ + public function endTest(PHPUnit_Framework_Test $test, $time) + { + if ($this->currentTestPass) { + $this->writeCase('pass', $time, array(), '', $test); + } + } + + /** + * @param string $status + * @param float $time + * @param array $trace + * @param string $message + */ + protected function writeCase($status, $time, array $trace = array(), $message = '', $test = NULL) + { + $output = ''; + if ($test !== NULL && $test->hasOutput()) { + $output = $test->getActualOutput(); + } + $this->write( + array( + 'event' => 'test', + 'suite' => $this->currentTestSuiteName, + 'test' => $this->currentTestName, + 'status' => $status, + 'time' => $time, + 'trace' => $trace, + 'message' => PHPUnit_Util_String::convertToUtf8($message), + 'output' => $output, + ) + ); + } + + /** + * @param string $buffer + */ + public function write($buffer) + { + parent::write(json_encode($buffer)); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Log/JUnit.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Log/JUnit.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Log/JUnit.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Log/JUnit.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,483 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util_Log + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.3.0 + */ + +/** + * A TestListener that generates a logfile of the test execution in XML markup. + * + * The XML markup used is the same as the one that is used by the JUnit Ant task. + * + * @package PHPUnit + * @subpackage Util_Log + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.1.0 + */ +class PHPUnit_Util_Log_JUnit extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener +{ + /** + * @var DOMDocument + */ + protected $document; + + /** + * @var DOMElement + */ + protected $root; + + /** + * @var boolean + */ + protected $logIncompleteSkipped = FALSE; + + /** + * @var boolean + */ + protected $writeDocument = TRUE; + + /** + * @var DOMElement[] + */ + protected $testSuites = array(); + + /** + * @var integer[] + */ + protected $testSuiteTests = array(0); + + /** + * @var integer[] + */ + protected $testSuiteAssertions = array(0); + + /** + * @var integer[] + */ + protected $testSuiteErrors = array(0); + + /** + * @var integer[] + */ + protected $testSuiteFailures = array(0); + + /** + * @var integer[] + */ + protected $testSuiteTimes = array(0); + + /** + * @var integer + */ + protected $testSuiteLevel = 0; + + /** + * @var DOMElement + */ + protected $currentTestCase = NULL; + + /** + * @var boolean + */ + protected $attachCurrentTestCase = TRUE; + + /** + * Constructor. + * + * @param mixed $out + * @param boolean $logIncompleteSkipped + */ + public function __construct($out = NULL, $logIncompleteSkipped = FALSE) + { + $this->document = new DOMDocument('1.0', 'UTF-8'); + $this->document->formatOutput = TRUE; + + $this->root = $this->document->createElement('testsuites'); + $this->document->appendChild($this->root); + + parent::__construct($out); + + $this->logIncompleteSkipped = $logIncompleteSkipped; + } + + /** + * Flush buffer and close output. + * + */ + public function flush() + { + if ($this->writeDocument === TRUE) { + $this->write($this->getXML()); + } + + parent::flush(); + } + + /** + * An error occurred. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) + { + if ($this->currentTestCase !== NULL) { + if ($test instanceof PHPUnit_Framework_SelfDescribing) { + $buffer = $test->toString() . "\n"; + } else { + $buffer = ''; + } + + $buffer .= PHPUnit_Framework_TestFailure::exceptionToString($e) . + "\n" . + PHPUnit_Util_Filter::getFilteredStacktrace($e); + + $error = $this->document->createElement( + 'error', PHPUnit_Util_XML::prepareString($buffer) + ); + + $error->setAttribute('type', get_class($e)); + + $this->currentTestCase->appendChild($error); + + $this->testSuiteErrors[$this->testSuiteLevel]++; + } + } + + /** + * A failure occurred. + * + * @param PHPUnit_Framework_Test $test + * @param PHPUnit_Framework_AssertionFailedError $e + * @param float $time + */ + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) + { + if ($this->currentTestCase !== NULL) { + if (!$test instanceof PHPUnit_Framework_Warning) { + if ($test instanceof PHPUnit_Framework_SelfDescribing) { + $buffer = $test->toString() . "\n"; + } else { + $buffer = ''; + } + + $buffer .= PHPUnit_Framework_TestFailure::exceptionToString($e) . + "\n" . + PHPUnit_Util_Filter::getFilteredStacktrace($e); + + $failure = $this->document->createElement( + 'failure', PHPUnit_Util_XML::prepareString($buffer) + ); + + $failure->setAttribute('type', get_class($e)); + + $this->currentTestCase->appendChild($failure); + + $this->testSuiteFailures[$this->testSuiteLevel]++; + } + } + } + + /** + * Incomplete test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + if ($this->logIncompleteSkipped && $this->currentTestCase !== NULL) { + $error = $this->document->createElement( + 'error', + PHPUnit_Util_XML::prepareString( + "Incomplete Test\n" . + PHPUnit_Util_Filter::getFilteredStacktrace($e) + ) + ); + + $error->setAttribute('type', get_class($e)); + + $this->currentTestCase->appendChild($error); + + $this->testSuiteErrors[$this->testSuiteLevel]++; + } else { + $this->attachCurrentTestCase = FALSE; + } + } + + /** + * Skipped test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + * @since Method available since Release 3.0.0 + */ + public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + if ($this->logIncompleteSkipped && $this->currentTestCase !== NULL) { + $error = $this->document->createElement( + 'error', + PHPUnit_Util_XML::prepareString( + "Skipped Test\n" . + PHPUnit_Util_Filter::getFilteredStacktrace($e) + ) + ); + + $error->setAttribute('type', get_class($e)); + + $this->currentTestCase->appendChild($error); + + $this->testSuiteErrors[$this->testSuiteLevel]++; + } else { + $this->attachCurrentTestCase = FALSE; + } + } + + /** + * A testsuite started. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit_Framework_TestSuite $suite) + { + $testSuite = $this->document->createElement('testsuite'); + $testSuite->setAttribute('name', $suite->getName()); + + if (class_exists($suite->getName(), FALSE)) { + try { + $class = new ReflectionClass($suite->getName()); + + $testSuite->setAttribute('file', $class->getFileName()); + + $packageInformation = PHPUnit_Util_Class::getPackageInformation( + $suite->getName(), $class->getDocComment() + ); + + if (!empty($packageInformation['namespace'])) { + $testSuite->setAttribute( + 'namespace', $packageInformation['namespace'] + ); + } + + if (!empty($packageInformation['fullPackage'])) { + $testSuite->setAttribute( + 'fullPackage', $packageInformation['fullPackage'] + ); + } + + if (!empty($packageInformation['category'])) { + $testSuite->setAttribute( + 'category', $packageInformation['category'] + ); + } + + if (!empty($packageInformation['package'])) { + $testSuite->setAttribute( + 'package', $packageInformation['package'] + ); + } + + if (!empty($packageInformation['subpackage'])) { + $testSuite->setAttribute( + 'subpackage', $packageInformation['subpackage'] + ); + } + } + + catch (ReflectionException $e) { + } + } + + if ($this->testSuiteLevel > 0) { + $this->testSuites[$this->testSuiteLevel]->appendChild($testSuite); + } else { + $this->root->appendChild($testSuite); + } + + $this->testSuiteLevel++; + $this->testSuites[$this->testSuiteLevel] = $testSuite; + $this->testSuiteTests[$this->testSuiteLevel] = 0; + $this->testSuiteAssertions[$this->testSuiteLevel] = 0; + $this->testSuiteErrors[$this->testSuiteLevel] = 0; + $this->testSuiteFailures[$this->testSuiteLevel] = 0; + $this->testSuiteTimes[$this->testSuiteLevel] = 0; + } + + /** + * A testsuite ended. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit_Framework_TestSuite $suite) + { + $this->testSuites[$this->testSuiteLevel]->setAttribute( + 'tests', $this->testSuiteTests[$this->testSuiteLevel] + ); + + $this->testSuites[$this->testSuiteLevel]->setAttribute( + 'assertions', $this->testSuiteAssertions[$this->testSuiteLevel] + ); + + $this->testSuites[$this->testSuiteLevel]->setAttribute( + 'failures', $this->testSuiteFailures[$this->testSuiteLevel] + ); + + $this->testSuites[$this->testSuiteLevel]->setAttribute( + 'errors', $this->testSuiteErrors[$this->testSuiteLevel] + ); + + $this->testSuites[$this->testSuiteLevel]->setAttribute( + 'time', sprintf('%F', $this->testSuiteTimes[$this->testSuiteLevel]) + ); + + if ($this->testSuiteLevel > 1) { + $this->testSuiteTests[$this->testSuiteLevel - 1] += $this->testSuiteTests[$this->testSuiteLevel]; + $this->testSuiteAssertions[$this->testSuiteLevel - 1] += $this->testSuiteAssertions[$this->testSuiteLevel]; + $this->testSuiteErrors[$this->testSuiteLevel - 1] += $this->testSuiteErrors[$this->testSuiteLevel]; + $this->testSuiteFailures[$this->testSuiteLevel - 1] += $this->testSuiteFailures[$this->testSuiteLevel]; + $this->testSuiteTimes[$this->testSuiteLevel - 1] += $this->testSuiteTimes[$this->testSuiteLevel]; + } + + $this->testSuiteLevel--; + } + + /** + * A test started. + * + * @param PHPUnit_Framework_Test $test + */ + public function startTest(PHPUnit_Framework_Test $test) + { + if (!$test instanceof PHPUnit_Framework_Warning) { + $testCase = $this->document->createElement('testcase'); + $testCase->setAttribute('name', $test->getName()); + + if ($test instanceof PHPUnit_Framework_TestCase) { + $class = new ReflectionClass($test); + $methodName = $test->getName(); + + if ($class->hasMethod($methodName)) { + $method = $class->getMethod($test->getName()); + + $testCase->setAttribute('class', $class->getName()); + $testCase->setAttribute('file', $class->getFileName()); + $testCase->setAttribute('line', $method->getStartLine()); + } + } + + $this->currentTestCase = $testCase; + } + } + + /** + * A test ended. + * + * @param PHPUnit_Framework_Test $test + * @param float $time + */ + public function endTest(PHPUnit_Framework_Test $test, $time) + { + if (!$test instanceof PHPUnit_Framework_Warning) { + if ($this->attachCurrentTestCase) { + if ($test instanceof PHPUnit_Framework_TestCase) { + $numAssertions = $test->getNumAssertions(); + $this->testSuiteAssertions[$this->testSuiteLevel] += $numAssertions; + + $this->currentTestCase->setAttribute( + 'assertions', $numAssertions + ); + } + + $this->currentTestCase->setAttribute( + 'time', sprintf('%F', $time) + ); + + $this->testSuites[$this->testSuiteLevel]->appendChild( + $this->currentTestCase + ); + + $this->testSuiteTests[$this->testSuiteLevel]++; + $this->testSuiteTimes[$this->testSuiteLevel] += $time; + } + } + + $this->attachCurrentTestCase = TRUE; + $this->currentTestCase = NULL; + } + + /** + * Returns the XML as a string. + * + * @return string + * @since Method available since Release 2.2.0 + */ + public function getXML() + { + return $this->document->saveXML(); + } + + /** + * Enables or disables the writing of the document + * in flush(). + * + * This is a "hack" needed for the integration of + * PHPUnit with Phing. + * + * @return string + * @since Method available since Release 2.2.0 + */ + public function setWriteDocument($flag) + { + if (is_bool($flag)) { + $this->writeDocument = $flag; + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Log/TAP.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Log/TAP.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Log/TAP.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Log/TAP.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,255 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util_Log + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +if (!class_exists('sfYamlDumper', FALSE)) { + require_once 'SymfonyComponents/YAML/sfYamlDumper.php'; +} + +/** + * A TestListener that generates a logfile of the + * test execution using the Test Anything Protocol (TAP). + * + * @package PHPUnit + * @subpackage Util_Log + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Util_Log_TAP extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener +{ + /** + * @var integer + */ + protected $testNumber = 0; + + /** + * @var integer + */ + protected $testSuiteLevel = 0; + + /** + * @var boolean + */ + protected $testSuccessful = TRUE; + + /** + * Constructor. + * + * @param mixed $out + * @throws InvalidArgumentException + * @since Method available since Release 3.3.4 + */ + public function __construct($out = NULL) + { + parent::__construct($out); + $this->write("TAP version 13\n"); + } + + /** + * An error occurred. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) + { + $this->writeNotOk($test, 'Error'); + } + + /** + * A failure occurred. + * + * @param PHPUnit_Framework_Test $test + * @param PHPUnit_Framework_AssertionFailedError $e + * @param float $time + */ + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) + { + $this->writeNotOk($test, 'Failure'); + + $message = explode( + "\n", PHPUnit_Framework_TestFailure::exceptionToString($e) + ); + + $diagnostic = array( + 'message' => $message[0], + 'severity' => 'fail' + ); + + if ($e instanceof PHPUnit_Framework_ExpectationFailedException) { + $cf = $e->getComparisonFailure(); + + if ($cf !== NULL) { + $diagnostic['data'] = array( + 'got' => $cf->getActual(), + 'expected' => $cf->getExpected() + ); + } + } + + $yaml = new sfYamlDumper(); + + $this->write( + sprintf( + " ---\n%s ...\n", + $yaml->dump($diagnostic, 2, 2) + ) + ); + } + + /** + * Incomplete test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + $this->writeNotOk($test, '', 'TODO Incomplete Test'); + } + + /** + * Skipped test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + * @since Method available since Release 3.0.0 + */ + public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + $this->write( + sprintf( + "ok %d - # SKIP%s\n", + + $this->testNumber, + $e->getMessage() != '' ? ' ' . $e->getMessage() : '' + ) + ); + + $this->testSuccessful = FALSE; + } + + /** + * A testsuite started. + * + * @param PHPUnit_Framework_TestSuite $suite + */ + public function startTestSuite(PHPUnit_Framework_TestSuite $suite) + { + $this->testSuiteLevel++; + } + + /** + * A testsuite ended. + * + * @param PHPUnit_Framework_TestSuite $suite + */ + public function endTestSuite(PHPUnit_Framework_TestSuite $suite) + { + $this->testSuiteLevel--; + + if ($this->testSuiteLevel == 0) { + $this->write(sprintf("1..%d\n", $this->testNumber)); + } + } + + /** + * A test started. + * + * @param PHPUnit_Framework_Test $test + */ + public function startTest(PHPUnit_Framework_Test $test) + { + $this->testNumber++; + $this->testSuccessful = TRUE; + } + + /** + * A test ended. + * + * @param PHPUnit_Framework_Test $test + * @param float $time + */ + public function endTest(PHPUnit_Framework_Test $test, $time) + { + if ($this->testSuccessful === TRUE) { + $this->write( + sprintf( + "ok %d - %s\n", + + $this->testNumber, + PHPUnit_Util_Test::describe($test) + ) + ); + } + } + + /** + * @param PHPUnit_Framework_Test $test + * @param string $prefix + * @param string $directive + */ + protected function writeNotOk(PHPUnit_Framework_Test $test, $prefix = '', $directive = '') + { + $this->write( + sprintf( + "not ok %d - %s%s%s\n", + + $this->testNumber, + $prefix != '' ? $prefix . ': ' : '', + PHPUnit_Util_Test::describe($test), + $directive != '' ? ' # ' . $directive : '' + ) + ); + + $this->testSuccessful = FALSE; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/PHP/Default.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/PHP/Default.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/PHP/Default.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/PHP/Default.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,68 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.5.12 + */ + +/** + * Default utility for PHP sub-processes. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.5.12 + */ +class PHPUnit_Util_PHP_Default extends PHPUnit_Util_PHP +{ + /** + * @param resource $pipe + * @since Method available since Release 3.5.12 + */ + protected function process($pipe, $job) + { + fwrite($pipe, $job); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/PHP/Windows.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/PHP/Windows.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/PHP/Windows.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/PHP/Windows.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,91 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.5.12 + */ + +/** + * Windows utility for PHP sub-processes. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.5.12 + */ +class PHPUnit_Util_PHP_Windows extends PHPUnit_Util_PHP +{ + /** + * @var string + */ + protected $tempFile; + + /** + * @param resource $pipe + * @since Method available since Release 3.5.12 + */ + protected function process($pipe, $job) + { + if (!($this->tempFile = tempnam(sys_get_temp_dir(), 'PHPUnit')) || + file_put_contents($this->tempFile, $job) === FALSE) { + throw new PHPUnit_Framework_Exception( + 'Unable to write temporary files for process isolation.' + ); + } + + fwrite( + $pipe, + "tempFile, "'") . "'; ?>" + ); + } + + /** + * @since Method available since Release 3.5.12 + */ + protected function cleanup() + { + unlink($this->tempFile); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/PHP.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/PHP.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/PHP.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/PHP.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,325 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.4.0 + */ + +/** + * Utility methods for PHP sub-processes. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://www.phpunit.de/ + * @since Class available since Release 3.4.0 + */ +abstract class PHPUnit_Util_PHP +{ + /** + * @var string $phpBinary + */ + protected $phpBinary; + + /** + * Returns the path to a PHP interpreter. + * + * PHPUnit_Util_PHP::$phpBinary contains the path to the PHP + * interpreter. + * + * When not set, the following assumptions will be made: + * + * 1. When PHPUnit is run using the CLI SAPI and the $_SERVER['_'] + * variable does not contain the string "PHPUnit", $_SERVER['_'] + * is assumed to contain the path to the current PHP interpreter + * and that will be used. + * + * 2. When PHPUnit is run using the CLI SAPI and the $_SERVER['_'] + * variable contains the string "PHPUnit", the file that $_SERVER['_'] + * points to is assumed to be the PHPUnit TextUI CLI wrapper script + * "phpunit" and the binary set up using #! on that file's first + * line of code is assumed to contain the path to the current PHP + * interpreter and that will be used. + * + * 3. When the PHP CLI/CGI binary configured with the PEAR Installer + * (php_bin configuration value) is readable, it will be used. + * + * 4. The current PHP interpreter is assumed to be in the $PATH and + * to be invokable through "php". + * + * @return string + */ + protected function getPhpBinary() + { + if ($this->phpBinary === NULL) { + if (defined("PHP_BINARY")) { + $this->phpBinary = PHP_BINARY; + } else if (PHP_SAPI == 'cli' && isset($_SERVER['_'])) { + if (strpos($_SERVER['_'], 'phpunit') !== FALSE) { + $file = file($_SERVER['_']); + + if (strpos($file[0], ' ') !== FALSE) { + $tmp = explode(' ', $file[0]); + $this->phpBinary = trim($tmp[1]); + } else { + $this->phpBinary = ltrim(trim($file[0]), '#!'); + } + } else if (strpos(basename($_SERVER['_']), 'php') !== FALSE) { + $this->phpBinary = $_SERVER['_']; + } + } + + if ($this->phpBinary === NULL) { + $possibleBinaryLocations = array( + PHP_BINDIR . '/php', + PHP_BINDIR . '/php-cli.exe', + PHP_BINDIR . '/php.exe', + '@php_bin@', + ); + foreach ($possibleBinaryLocations as $binary) { + if (is_readable($binary)) { + $this->phpBinary = $binary; + break; + } + } + } + + if (!is_readable($this->phpBinary)) { + $this->phpBinary = 'php'; + } else { + $this->phpBinary = escapeshellcmd($this->phpBinary); + } + } + + return $this->phpBinary; + } + + /** + * @return PHPUnit_Util_PHP + * @since Method available since Release 3.5.12 + */ + public static function factory() + { + if (DIRECTORY_SEPARATOR == '\\') { + return new PHPUnit_Util_PHP_Windows; + } + + return new PHPUnit_Util_PHP_Default; + } + + /** + * Runs a single job (PHP code) using a separate PHP process. + * + * @param string $job + * @param PHPUnit_Framework_TestCase $test + * @param PHPUnit_Framework_TestResult $result + * @return array|null + * @throws PHPUnit_Framework_Exception + */ + public function runJob($job, PHPUnit_Framework_Test $test = NULL, PHPUnit_Framework_TestResult $result = NULL) + { + $process = proc_open( + $this->getPhpBinary(), + array( + 0 => array('pipe', 'r'), + 1 => array('pipe', 'w'), + 2 => array('pipe', 'w') + ), + $pipes + ); + + if (!is_resource($process)) { + throw new PHPUnit_Framework_Exception( + 'Unable to create process for process isolation.' + ); + } + + if ($result !== NULL) { + $result->startTest($test); + } + + $this->process($pipes[0], $job); + fclose($pipes[0]); + + $stdout = stream_get_contents($pipes[1]); + fclose($pipes[1]); + + $stderr = stream_get_contents($pipes[2]); + fclose($pipes[2]); + + proc_close($process); + $this->cleanup(); + + if ($result !== NULL) { + $this->processChildResult($test, $result, $stdout, $stderr); + } else { + return array('stdout' => $stdout, 'stderr' => $stderr); + } + } + + /** + * @param resource $pipe + * @param string $job + * @since Method available since Release 3.5.12 + */ + abstract protected function process($pipe, $job); + + /** + * @since Method available since Release 3.5.12 + */ + protected function cleanup() + { + } + + /** + * Processes the TestResult object from an isolated process. + * + * @param PHPUnit_Framework_TestCase $test + * @param PHPUnit_Framework_TestResult $result + * @param string $stdout + * @param string $stderr + * @since Method available since Release 3.5.0 + */ + protected function processChildResult(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result, $stdout, $stderr) + { + if (!empty($stderr)) { + $time = 0; + $result->addError( + $test, + new RuntimeException(trim($stderr)), $time + ); + } else { + $childResult = @unserialize($stdout); + + if ($childResult !== FALSE) { + if (!empty($childResult['output'])) { + print $childResult['output']; + } + + $test->setResult($childResult['testResult']); + $test->addToAssertionCount($childResult['numAssertions']); + + $childResult = $childResult['result']; + + if ($result->getCollectCodeCoverageInformation()) { + $result->getCodeCoverage()->merge( + $childResult->getCodeCoverage() + ); + } + + $time = $childResult->time(); + $notImplemented = $childResult->notImplemented(); + $skipped = $childResult->skipped(); + $errors = $childResult->errors(); + $failures = $childResult->failures(); + + if (!empty($notImplemented)) { + $result->addError( + $test, $this->getException($notImplemented[0]), $time + ); + } + + else if (!empty($skipped)) { + $result->addError( + $test, $this->getException($skipped[0]), $time + ); + } + + else if (!empty($errors)) { + $result->addError( + $test, $this->getException($errors[0]), $time + ); + } + + else if (!empty($failures)) { + $result->addFailure( + $test, $this->getException($failures[0]), $time + ); + } + } else { + $time = 0; + + $result->addError( + $test, new RuntimeException(trim($stdout)), $time + ); + } + } + + $result->endTest($test, $time); + } + + /** + * Gets the thrown exception from a PHPUnit_Framework_TestFailure. + * + * @param PHPUnit_Framework_TestFailure $error + * @since Method available since Release 3.6.0 + * @see https://github.com/sebastianbergmann/phpunit/issues/74 + */ + protected function getException(PHPUnit_Framework_TestFailure $error) + { + $exception = $error->thrownException(); + + if ($exception instanceof __PHP_Incomplete_Class) { + $exceptionArray = array(); + foreach ((array)$exception as $key => $value) { + $key = substr($key, strrpos($key, "\0") + 1); + $exceptionArray[$key] = $value; + } + + $exception = new PHPUnit_Framework_SyntheticError( + sprintf( + '%s: %s', + $exceptionArray['_PHP_Incomplete_Class_Name'], + $exceptionArray['message'] + ), + $exceptionArray['code'], + $exceptionArray['file'], + $exceptionArray['line'], + $exceptionArray['trace'] + ); + } + + return $exception; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Printer.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Printer.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Printer.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Printer.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,209 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.0.0 + */ + +/** + * Utility class that can print to STDOUT or write to a file. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.0.0 + */ +class PHPUnit_Util_Printer +{ + /** + * If TRUE, flush output after every write. + * + * @var boolean + */ + protected $autoFlush = FALSE; + + /** + * @var resource + */ + protected $out; + + /** + * @var string + */ + protected $outTarget; + + /** + * @var boolean + */ + protected $printsHTML = FALSE; + + /** + * Constructor. + * + * @param mixed $out + * @throws InvalidArgumentException + */ + public function __construct($out = NULL) + { + if ($out !== NULL) { + if (is_string($out)) { + if (strpos($out, 'socket://') === 0) { + $out = explode(':', str_replace('socket://', '', $out)); + + if (sizeof($out) != 2) { + throw new InvalidArgumentException; + } + + $this->out = fsockopen($out[0], $out[1]); + } else { + if (strpos($out, 'php://') === FALSE && + !is_dir(dirname($out))) { + mkdir(dirname($out), 0777, TRUE); + } + + $this->out = fopen($out, 'wt'); + } + + $this->outTarget = $out; + } else { + $this->out = $out; + } + } + } + + /** + * Flush buffer, optionally tidy up HTML, and close output if it's not to a php stream + */ + public function flush() + { + if ($this->out && strncmp($this->outTarget, 'php://', 6) !== 0) { + fclose($this->out); + } + + if ($this->printsHTML === TRUE && + $this->outTarget !== NULL && + strpos($this->outTarget, 'php://') !== 0 && + strpos($this->outTarget, 'socket://') !== 0 && + extension_loaded('tidy')) { + file_put_contents( + $this->outTarget, + tidy_repair_file( + $this->outTarget, array('indent' => TRUE, 'wrap' => 0), 'utf8' + ) + ); + } + } + + /** + * Performs a safe, incremental flush. + * + * Do not confuse this function with the flush() function of this class, + * since the flush() function may close the file being written to, rendering + * the current object no longer usable. + * + * @since Method available since Release 3.3.0 + */ + public function incrementalFlush() + { + if ($this->out) { + fflush($this->out); + } else { + flush(); + } + } + + /** + * @param string $buffer + */ + public function write($buffer) + { + if ($this->out) { + fwrite($this->out, $buffer); + + if ($this->autoFlush) { + $this->incrementalFlush(); + } + } else { + if (PHP_SAPI != 'cli') { + $buffer = htmlspecialchars($buffer); + } + + print $buffer; + + if ($this->autoFlush) { + $this->incrementalFlush(); + } + } + } + + /** + * Check auto-flush mode. + * + * @return boolean + * @since Method available since Release 3.3.0 + */ + public function getAutoFlush() + { + return $this->autoFlush; + } + + /** + * Set auto-flushing mode. + * + * If set, *incremental* flushes will be done after each write. This should + * not be confused with the different effects of this class' flush() method. + * + * @param boolean $autoFlush + * @since Method available since Release 3.3.0 + */ + public function setAutoFlush($autoFlush) + { + if (is_bool($autoFlush)) { + $this->autoFlush = $autoFlush; + } else { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Class.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Class.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Class.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Class.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,325 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util_Skeleton + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.3.0 + */ + +/** + * Generator for class skeletons from test classes. + * + * @package PHPUnit + * @subpackage Util_Skeleton + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.3.0 + */ +class PHPUnit_Util_Skeleton_Class extends PHPUnit_Util_Skeleton +{ + /** + * Constructor. + * + * @param string $inClassName + * @param string $inSourceFile + * @param string $outClassName + * @param string $outSourceFile + * @throws RuntimeException + */ + public function __construct($inClassName, $inSourceFile = '', $outClassName = '', $outSourceFile = '') + { + if (empty($inSourceFile)) { + $inSourceFile = $inClassName . '.php'; + } + + if (!is_file($inSourceFile)) { + throw new PHPUnit_Framework_Exception( + sprintf( + '"%s" could not be opened.', + + $inSourceFile + ) + ); + } + + if (empty($outClassName)) { + $outClassName = substr($inClassName, 0, strlen($inClassName) - 4); + } + + if (empty($outSourceFile)) { + $outSourceFile = dirname($inSourceFile) . DIRECTORY_SEPARATOR . + $outClassName . '.php'; + } + + parent::__construct( + $inClassName, $inSourceFile, $outClassName, $outSourceFile + ); + } + + /** + * Generates the class' source. + * + * @return mixed + */ + public function generate() + { + $methods = ''; + + foreach ($this->findTestedMethods() as $method) { + $methodTemplate = new Text_Template( + sprintf( + '%s%sTemplate%sMethod.tpl', + + dirname(__FILE__), + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR + ) + ); + + $methodTemplate->setVar( + array( + 'methodName' => $method, + ) + ); + + $methods .= $methodTemplate->render(); + } + + $classTemplate = new Text_Template( + sprintf( + '%s%sTemplate%sClass.tpl', + + dirname(__FILE__), + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR + ) + ); + + $classTemplate->setVar( + array( + 'className' => $this->outClassName['fullyQualifiedClassName'], + 'methods' => $methods, + 'date' => date('Y-m-d'), + 'time' => date('H:i:s') + ) + ); + + return $classTemplate->render(); + } + + /** + * Returns the methods of the class under test + * that are called from the test methods. + * + * @return array + */ + protected function findTestedMethods() + { + $setUpVariables = array(); + $testedMethods = array(); + $classes = PHPUnit_Util_File::getClassesInFile( + $this->inSourceFile + ); + $testMethods = $classes[$this->inClassName['fullyQualifiedClassName']]['methods']; + unset($classes); + + foreach ($testMethods as $name => $testMethod) { + if (strtolower($name) == 'setup') { + $setUpVariables = $this->findVariablesThatReferenceClass( + $testMethod['tokens'] + ); + + break; + } + } + + foreach ($testMethods as $name => $testMethod) { + $argVariables = array(); + + if (strtolower($name) == 'setup') { + continue; + } + + $start = strpos($testMethod['signature'], '(') + 1; + $end = strlen($testMethod['signature']) - $start - 1; + $args = substr($testMethod['signature'], $start, $end); + + foreach (explode(',', $args) as $arg) { + $arg = explode(' ', trim($arg)); + + if (count($arg) == 2) { + $type = $arg[0]; + $var = $arg[1]; + } else { + $type = NULL; + $var = $arg[0]; + } + + if ($type == $this->outClassName['fullyQualifiedClassName']) { + $argVariables[] = $var; + } + } + + $variables = array_unique( + array_merge( + $setUpVariables, + $argVariables, + $this->findVariablesThatReferenceClass($testMethod['tokens']) + ) + ); + + foreach ($testMethod['tokens'] as $i => $token) { + // Class::method() + if (is_array($token) && $token[0] == T_DOUBLE_COLON && + is_array($testMethod['tokens'][$i-1]) && + $testMethod['tokens'][$i-1][0] == T_STRING && + $testMethod['tokens'][$i-1][1] == $this->outClassName['fullyQualifiedClassName'] && + is_array($testMethod['tokens'][$i+1]) && + $testMethod['tokens'][$i+1][0] == T_STRING && + $testMethod['tokens'][$i+2] == '(') { + $testedMethods[] = $testMethod['tokens'][$i+1][1]; + } + + // $this->object->method() + else if (is_array($token) && $token[0] == T_OBJECT_OPERATOR && + in_array($this->findVariableName($testMethod['tokens'], $i), $variables) && + is_array($testMethod['tokens'][$i+2]) && + $testMethod['tokens'][$i+2][0] == T_OBJECT_OPERATOR && + is_array($testMethod['tokens'][$i+3]) && + $testMethod['tokens'][$i+3][0] == T_STRING && + $testMethod['tokens'][$i+4] == '(') { + $testedMethods[] = $testMethod['tokens'][$i+3][1]; + } + + // $object->method() + else if (is_array($token) && $token[0] == T_OBJECT_OPERATOR && + in_array($this->findVariableName($testMethod['tokens'], $i), $variables) && + is_array($testMethod['tokens'][$i+1]) && + $testMethod['tokens'][$i+1][0] == T_STRING && + $testMethod['tokens'][$i+2] == '(') { + $testedMethods[] = $testMethod['tokens'][$i+1][1]; + } + } + } + + $testedMethods = array_unique($testedMethods); + sort($testedMethods); + + return $testedMethods; + } + + /** + * Returns the variables used in test methods + * that reference the class under test. + * + * @param array $tokens + * @return array + */ + protected function findVariablesThatReferenceClass(array $tokens) + { + $inNew = FALSE; + $variables = array(); + + foreach ($tokens as $i => $token) { + if (is_string($token)) { + if (trim($token) == ';') { + $inNew = FALSE; + } + + continue; + } + + list ($token, $value) = $token; + + switch ($token) { + case T_NEW: { + $inNew = TRUE; + } + break; + + case T_STRING: { + if ($inNew) { + if ($value == $this->outClassName['fullyQualifiedClassName']) { + $variables[] = $this->findVariableName( + $tokens, $i + ); + } + } + + $inNew = FALSE; + } + break; + } + } + + return $variables; + } + + /** + * Finds the variable name of the object for the method call + * that is currently being processed. + * + * @param array $tokens + * @param integer $start + * @return mixed + */ + protected function findVariableName(array $tokens, $start) + { + for ($i = $start - 1; $i >= 0; $i--) { + if (is_array($tokens[$i]) && $tokens[$i][0] == T_VARIABLE) { + $variable = $tokens[$i][1]; + + if (is_array($tokens[$i+1]) && + $tokens[$i+1][0] == T_OBJECT_OPERATOR && + $tokens[$i+2] != '(' && + $tokens[$i+3] != '(') { + $variable .= '->' . $tokens[$i+2][1]; + } + + return $variable; + } + } + + return FALSE; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/Class.tpl.dist phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/Class.tpl.dist --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/Class.tpl.dist 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/Class.tpl.dist 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,7 @@ + diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/IncompleteTestMethod.tpl.dist phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/IncompleteTestMethod.tpl.dist --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/IncompleteTestMethod.tpl.dist 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/IncompleteTestMethod.tpl.dist 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,12 @@ + + /** + * @covers {className}::{origMethodName} + * @todo Implement test{methodName}(). + */ + public function test{methodName}() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/Method.tpl.dist phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/Method.tpl.dist --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/Method.tpl.dist 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/Method.tpl.dist 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,9 @@ + + /** + * @todo Implement {methodName}(). + */ + public function {methodName}() + { + // Remove the following line when you implement this method. + throw new RuntimeException('Not yet implemented.'); + } diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestClass.tpl.dist phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestClass.tpl.dist --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestClass.tpl.dist 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestClass.tpl.dist 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,31 @@ +object = new {className}; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } +{methods}} +?> diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethod.tpl.dist phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethod.tpl.dist --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethod.tpl.dist 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethod.tpl.dist 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,13 @@ + + /** + * Generated from @assert {annotation}. + * + * @covers {className}::{origMethodName} + */ + public function test{methodName}() + { + $this->assert{assertion}( + {expected}, + $this->object->{origMethodName}({arguments}) + ); + } diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodBool.tpl.dist phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodBool.tpl.dist --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodBool.tpl.dist 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodBool.tpl.dist 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,12 @@ + + /** + * Generated from @assert {annotation}. + * + * @covers {className}::{origMethodName} + */ + public function test{methodName}() + { + $this->assert{assertion}( + $this->object->{origMethodName}({arguments}) + ); + } diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodBoolStatic.tpl.dist phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodBoolStatic.tpl.dist --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodBoolStatic.tpl.dist 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodBoolStatic.tpl.dist 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,12 @@ + + /** + * Generated from @assert {annotation}. + * + * @covers {className}::{origMethodName} + */ + public function test{methodName}() + { + $this->assert{assertion}( + {className}::{origMethodName}({arguments}) + ); + } diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodException.tpl.dist phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodException.tpl.dist --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodException.tpl.dist 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodException.tpl.dist 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,11 @@ + + /** + * Generated from @assert {annotation}. + * + * @covers {className}::{origMethodName} + * @expectedException {expected} + */ + public function test{methodName}() + { + $this->object->{origMethodName}({arguments}); + } diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodExceptionStatic.tpl.dist phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodExceptionStatic.tpl.dist --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodExceptionStatic.tpl.dist 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodExceptionStatic.tpl.dist 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,11 @@ + + /** + * Generated from @assert {annotation}. + * + * @covers {className}::{origMethodName} + * @expectedException {expected} + */ + public function test{methodName}() + { + {className}::{origMethodName}({arguments}); + } diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodStatic.tpl.dist phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodStatic.tpl.dist --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodStatic.tpl.dist 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Template/TestMethodStatic.tpl.dist 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,13 @@ + + /** + * Generated from @assert {annotation}. + * + * @covers {className}::{origMethodName} + */ + public function test{methodName}() + { + $this->assert{assertion}( + {expected}, + {className}::{origMethodName}({arguments}) + ); + } diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Test.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Test.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Test.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton/Test.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,379 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util_Skeleton + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.3.0 + */ + +/** + * Generator for test class skeletons from classes. + * + * @package PHPUnit + * @subpackage Util_Skeleton + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.3.0 + */ +class PHPUnit_Util_Skeleton_Test extends PHPUnit_Util_Skeleton +{ + /** + * @var array + */ + protected $methodNameCounter = array(); + + /** + * Constructor. + * + * @param string $inClassName + * @param string $inSourceFile + * @param string $outClassName + * @param string $outSourceFile + * @throws RuntimeException + */ + public function __construct($inClassName, $inSourceFile = '', $outClassName = '', $outSourceFile = '') + { + if (class_exists($inClassName)) { + $reflector = new ReflectionClass($inClassName); + $inSourceFile = $reflector->getFileName(); + + if ($inSourceFile === FALSE) { + $inSourceFile = ''; + } + + unset($reflector); + } else { + if (empty($inSourceFile)) { + $possibleFilenames = array( + $inClassName . '.php', + PHPUnit_Util_Filesystem::classNameToFilename($inClassName) + ); + + foreach ($possibleFilenames as $possibleFilename) { + if (is_file($possibleFilename)) { + $inSourceFile = $possibleFilename; + } + } + } + + if (empty($inSourceFile)) { + throw new PHPUnit_Framework_Exception( + sprintf( + 'Neither "%s" nor "%s" could be opened.', + $possibleFilenames[0], + $possibleFilenames[1] + ) + ); + } + + if (!is_file($inSourceFile)) { + throw new PHPUnit_Framework_Exception( + sprintf( + '"%s" could not be opened.', + + $inSourceFile + ) + ); + } + + $inSourceFile = realpath($inSourceFile); + include_once $inSourceFile; + + if (!class_exists($inClassName)) { + throw new PHPUnit_Framework_Exception( + sprintf( + 'Could not find class "%s" in "%s".', + + $inClassName, + $inSourceFile + ) + ); + } + } + + if (empty($outClassName)) { + $outClassName = $inClassName . 'Test'; + } + + if (empty($outSourceFile)) { + $outSourceFile = dirname($inSourceFile) . DIRECTORY_SEPARATOR . $outClassName . '.php'; + } + + parent::__construct( + $inClassName, $inSourceFile, $outClassName, $outSourceFile + ); + } + + /** + * Generates the test class' source. + * + * @param boolean $verbose + * @return mixed + */ + public function generate($verbose = FALSE) + { + $class = new ReflectionClass( + $this->inClassName['fullyQualifiedClassName'] + ); + $methods = ''; + $incompleteMethods = ''; + + foreach ($class->getMethods() as $method) { + if (!$method->isConstructor() && + !$method->isAbstract() && + $method->isPublic() && + $method->getDeclaringClass()->getName() == $this->inClassName['fullyQualifiedClassName']) { + $assertAnnotationFound = FALSE; + + if (preg_match_all('/@assert(.*)$/Um', $method->getDocComment(), $annotations)) { + foreach ($annotations[1] as $annotation) { + if (preg_match('/\((.*)\)\s+([^\s]*)\s+(.*)/', $annotation, $matches)) { + switch ($matches[2]) { + case '==': { + $assertion = 'Equals'; + } + break; + + case '!=': { + $assertion = 'NotEquals'; + } + break; + + case '===': { + $assertion = 'Same'; + } + break; + + case '!==': { + $assertion = 'NotSame'; + } + break; + + case '>': { + $assertion = 'GreaterThan'; + } + break; + + case '>=': { + $assertion = 'GreaterThanOrEqual'; + } + break; + + case '<': { + $assertion = 'LessThan'; + } + break; + + case '<=': { + $assertion = 'LessThanOrEqual'; + } + break; + + case 'throws': { + $assertion = 'exception'; + } + break; + + default: { + throw new PHPUnit_Framework_Exception( + sprintf( + 'Token "%s" could not be parsed in @assert annotation.', + $matches[2] + ) + ); + } + } + + if ($assertion == 'exception') { + $template = 'TestMethodException'; + } + + else if ($assertion == 'Equals' && + strtolower($matches[3]) == 'true') { + $assertion = 'True'; + $template = 'TestMethodBool'; + } + + else if ($assertion == 'NotEquals' && + strtolower($matches[3]) == 'true') { + $assertion = 'False'; + $template = 'TestMethodBool'; + } + + else if ($assertion == 'Equals' && + strtolower($matches[3]) == 'false') { + $assertion = 'False'; + $template = 'TestMethodBool'; + } + + else if ($assertion == 'NotEquals' && + strtolower($matches[3]) == 'false') { + $assertion = 'True'; + $template = 'TestMethodBool'; + } + + else { + $template = 'TestMethod'; + } + + if ($method->isStatic()) { + $template .= 'Static'; + } + + $methodTemplate = new Text_Template( + sprintf( + '%s%sTemplate%s%s.tpl', + + dirname(__FILE__), + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR, + $template + ) + ); + + $origMethodName = $method->getName(); + $methodName = ucfirst($origMethodName); + + if (isset($this->methodNameCounter[$methodName])) { + $this->methodNameCounter[$methodName]++; + } else { + $this->methodNameCounter[$methodName] = 1; + } + + if ($this->methodNameCounter[$methodName] > 1) { + $methodName .= $this->methodNameCounter[$methodName]; + } + + $methodTemplate->setVar( + array( + 'annotation' => trim($annotation), + 'arguments' => $matches[1], + 'assertion' => isset($assertion) ? $assertion : '', + 'expected' => $matches[3], + 'origMethodName' => $origMethodName, + 'className' => $this->inClassName['fullyQualifiedClassName'], + 'methodName' => $methodName + ) + ); + + $methods .= $methodTemplate->render(); + + $assertAnnotationFound = TRUE; + } + } + } + + if (!$assertAnnotationFound) { + $methodTemplate = new Text_Template( + sprintf( + '%s%sTemplate%sIncompleteTestMethod.tpl', + + dirname(__FILE__), + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR + ) + ); + + $methodTemplate->setVar( + array( + 'className' => $this->inClassName['fullyQualifiedClassName'], + 'methodName' => ucfirst($method->getName()), + 'origMethodName' => $method->getName() + ) + ); + + $incompleteMethods .= $methodTemplate->render(); + } + } + } + + $classTemplate = new Text_Template( + sprintf( + '%s%sTemplate%sTestClass.tpl', + + dirname(__FILE__), + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR + ) + ); + + if ($this->inSourceFile != '') { + $requireClassFile = sprintf( + "\n\nrequire_once '%s';", + + $this->inSourceFile + ); + } else { + $requireClassFile = ''; + } + + if ($this->outClassName['namespace'] != '') { + $namespace = "\nnamespace " . + $this->outClassName['namespace'] . ";\n"; + } else { + $namespace = ''; + } + + $classTemplate->setVar( + array( + 'namespace' => $namespace, + 'namespaceSeparator' => !empty($namespace) ? '\\' : '', + 'className' => $this->inClassName['className'], + 'testClassName' => $this->outClassName['className'], + 'requireClassFile' => $requireClassFile, + 'methods' => $methods . $incompleteMethods, + 'date' => date('Y-m-d'), + 'time' => date('H:i:s') + ) + ); + + if (!$verbose) { + return $classTemplate->render(); + } else { + return array( + 'code' => $classTemplate->render(), + 'incomplete' => empty($methods) + ); + } + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Skeleton.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Skeleton.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,146 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.1.0 + */ + +/** + * Generator for skeletons. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.1.0 + */ +abstract class PHPUnit_Util_Skeleton +{ + /** + * @var array + */ + protected $inClassName; + + /** + * @var string + */ + protected $inSourceFile; + + /** + * @var array + */ + protected $outClassName; + + /** + * @var string + */ + protected $outSourceFile; + + /** + * Constructor. + * + * @param string $inClassName + * @param string $inSourceFile + * @param string $outClassName + * @param string $outSourceFile + * @since Method available since Release 3.4.0 + */ + public function __construct($inClassName, $inSourceFile = '', $outClassName = '', $outSourceFile = '') + { + $this->inClassName = PHPUnit_Util_Class::parseFullyQualifiedClassName( + $inClassName + ); + + $this->outClassName = PHPUnit_Util_Class::parseFullyQualifiedClassName( + $outClassName + ); + + $this->inSourceFile = str_replace( + $this->inClassName['fullyQualifiedClassName'], + $this->inClassName['className'], + $inSourceFile + ); + + $this->outSourceFile = str_replace( + $this->outClassName['fullyQualifiedClassName'], + $this->outClassName['className'], + $outSourceFile + ); + } + + /** + * @return string + */ + public function getOutClassName() + { + return $this->outClassName['fullyQualifiedClassName']; + } + + /** + * @return string + */ + public function getOutSourceFile() + { + return $this->outSourceFile; + } + + /** + * Generates the code and writes it to a source file. + * + * @param string $file + */ + public function write($file = '') + { + if ($file == '') { + $file = $this->outSourceFile; + } + + if ($fp = fopen($file, 'wt')) { + fwrite($fp, $this->generate()); + fclose($fp); + } + } + + abstract public function generate(); +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/String.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/String.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/String.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/String.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,119 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.6.0 + */ + +/** + * String helpers. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.6.0 + */ +class PHPUnit_Util_String +{ + /** + * Converts a string to UTF-8 encoding. + * + * @param string $string + * @return string + */ + public static function convertToUtf8($string) + { + if (!self::isUtf8($string)) { + if (function_exists('mb_convert_encoding')) { + $string = mb_convert_encoding($string, 'UTF-8'); + } else { + $string = utf8_encode($string); + } + } + + return $string; + } + + /** + * Checks a string for UTF-8 encoding. + * + * @param string $string + * @return boolean + */ + protected static function isUtf8($string) + { + $length = strlen($string); + + for ($i = 0; $i < $length; $i++) { + if (ord($string[$i]) < 0x80) { + $n = 0; + } + + else if ((ord($string[$i]) & 0xE0) == 0xC0) { + $n = 1; + } + + else if ((ord($string[$i]) & 0xF0) == 0xE0) { + $n = 2; + } + + else if ((ord($string[$i]) & 0xF0) == 0xF0) { + $n = 3; + } + + else { + return FALSE; + } + + for ($j = 0; $j < $n; $j++) { + if ((++$i == $length) || ((ord($string[$i]) & 0xC0) != 0x80)) { + return FALSE; + } + } + } + + return TRUE; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Test.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Test.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Test.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Test.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,561 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Test helpers. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Util_Test +{ + const REGEX_DATA_PROVIDER = '/@dataProvider\s+([a-zA-Z0-9._:-\\\\x7f-\xff]+)/'; + const REGEX_EXPECTED_EXCEPTION = '(@expectedException\s+([:.\w\\\\x7f-\xff]+)(?:[\t ]+(\S*))?(?:[\t ]+(\S*))?\s*$)m'; + const REGEX_REQUIRES = '/@requires\s+(?PPHP(?:Unit)?)\s+(?P[\d\.]+)[ \t]*\r?$/m'; + + const SMALL = 0; + const MEDIUM = 1; + const LARGE = 2; + + private static $annotationCache = array(); + + protected static $templateMethods = array( + 'setUp', 'assertPreConditions', 'assertPostConditions', 'tearDown' + ); + + /** + * @param PHPUnit_Framework_Test $test + * @param boolean $asString + * @return mixed + */ + public static function describe(PHPUnit_Framework_Test $test, $asString = TRUE) + { + if ($asString) { + if ($test instanceof PHPUnit_Framework_SelfDescribing) { + return $test->toString(); + } else { + return get_class($test); + } + } else { + if ($test instanceof PHPUnit_Framework_TestCase) { + return array( + get_class($test), $test->getName() + ); + } + + else if ($test instanceof PHPUnit_Framework_SelfDescribing) { + return array('', $test->toString()); + } + + else { + return array('', get_class($test)); + } + } + } + + /** + * Returns the requirements for a test. + * + * @param string $className + * @param string $methodName + * @return array + * @since Method available since Release 3.6.0 + */ + public static function getRequirements($className, $methodName) + { + $reflector = new ReflectionMethod($className, $methodName); + $docComment = $reflector->getDocComment(); + $requires = array(); + + if ($count = preg_match_all(self::REGEX_REQUIRES, $docComment, $matches)) { + for ($i = 0; $i < $count; $i++) { + $requires[$matches['name'][$i]] = $matches['value'][$i]; + } + } + + return $requires; + } + + /** + * Returns the expected exception for a test. + * + * @param string $className + * @param string $methodName + * @return array + * @since Method available since Release 3.3.6 + */ + public static function getExpectedException($className, $methodName) + { + $reflector = new ReflectionMethod($className, $methodName); + $docComment = $reflector->getDocComment(); + + if (preg_match(self::REGEX_EXPECTED_EXCEPTION, $docComment, $matches)) { + $annotations = self::parseTestMethodAnnotations( + $className, $methodName + ); + + $class = $matches[1]; + $code = NULL; + $message = ''; + + if (isset($matches[2])) { + $message = trim($matches[2]); + } + + else if (isset($annotations['method']['expectedExceptionMessage'])) { + $message = $annotations['method']['expectedExceptionMessage'][0]; + } + + if (isset($matches[3])) { + $code = $matches[3]; + } + + else if (isset($annotations['method']['expectedExceptionCode'])) { + $code = $annotations['method']['expectedExceptionCode'][0]; + } + + if (is_numeric($code)) { + $code = (int)$code; + } + + else if (is_string($code) && defined($code)) { + $code = (int)constant($code); + } + + return array( + 'class' => $class, 'code' => $code, 'message' => $message + ); + } + + return FALSE; + } + + /** + * Returns the provided data for a method. + * + * @param string $className + * @param string $methodName + * @param string $docComment + * @return mixed array|Iterator when a data provider is specified and exists + * false when a data provider is specified and does not exist + * null when no data provider is specified + * @since Method available since Release 3.2.0 + */ + public static function getProvidedData($className, $methodName) + { + $reflector = new ReflectionMethod($className, $methodName); + $docComment = $reflector->getDocComment(); + $data = NULL; + + if (preg_match(self::REGEX_DATA_PROVIDER, $docComment, $matches)) { + $dataProviderMethodNameNamespace = explode('\\', $matches[1]); + $leaf = explode('::', array_pop($dataProviderMethodNameNamespace)); + $dataProviderMethodName = array_pop($leaf); + + if (!empty($dataProviderMethodNameNamespace)) { + $dataProviderMethodNameNamespace = join('\\', $dataProviderMethodNameNamespace) . '\\'; + } else { + $dataProviderMethodNameNamespace = ''; + } + + if (!empty($leaf)) { + $dataProviderClassName = $dataProviderMethodNameNamespace . array_pop($leaf); + } else { + $dataProviderClassName = $className; + } + + $dataProviderClass = new ReflectionClass($dataProviderClassName); + $dataProviderMethod = $dataProviderClass->getMethod( + $dataProviderMethodName + ); + + if ($dataProviderMethod->isStatic()) { + $object = NULL; + } else { + $object = $dataProviderClass->newInstance(); + } + + if ($dataProviderMethod->getNumberOfParameters() == 0) { + $data = $dataProviderMethod->invoke($object); + } else { + $data = $dataProviderMethod->invoke($object, $methodName); + } + } + + if ($data !== NULL) { + foreach ($data as $key => $value) { + if (!is_array($value)) { + throw new InvalidArgumentException( + sprintf( + 'Data set %s is invalid.', + is_int($key) ? '#' . $key : '"' . $key . '"' + ) + ); + } + } + } + + return $data; + } + + /** + * @param string $className + * @param string $methodName + * @return array + * @throws ReflectionException + * @since Method available since Release 3.4.0 + */ + public static function parseTestMethodAnnotations($className, $methodName = '') + { + if (!isset(self::$annotationCache[$className])) { + $class = new ReflectionClass($className); + self::$annotationCache[$className] = self::parseAnnotations($class->getDocComment()); + } + + if (!empty($methodName) && !isset(self::$annotationCache[$className . '::' . $methodName])) { + $method = new ReflectionMethod($className, $methodName); + self::$annotationCache[$className . '::' . $methodName] = self::parseAnnotations($method->getDocComment()); + } + + return array( + 'class' => self::$annotationCache[$className], + 'method' => !empty($methodName) ? self::$annotationCache[$className . '::' . $methodName] : array() + ); + } + + /** + * @param string $docblock + * @return array + * @since Method available since Release 3.4.0 + */ + private static function parseAnnotations($docblock) + { + $annotations = array(); + // Strip away the docblock header and footer to ease parsing of one line annotations + $docblock = substr($docblock, 3, -2); + + if (preg_match_all('/@(?P[A-Za-z_-]+)(?:[ \t]+(?P.*?))?[ \t]*\r?$/m', $docblock, $matches)) { + $numMatches = count($matches[0]); + + for ($i = 0; $i < $numMatches; ++$i) { + $annotations[$matches['name'][$i]][] = $matches['value'][$i]; + } + } + + return $annotations; + } + + /** + * Returns the backup settings for a test. + * + * @param string $className + * @param string $methodName + * @return array + * @since Method available since Release 3.4.0 + */ + public static function getBackupSettings($className, $methodName) + { + return array( + 'backupGlobals' => self::getBooleanAnnotationSetting( + $className, $methodName, 'backupGlobals' + ), + 'backupStaticAttributes' => self::getBooleanAnnotationSetting( + $className, $methodName, 'backupStaticAttributes' + ) + ); + } + + /** + * Returns the dependencies for a test class or method. + * + * @param string $className + * @param string $methodName + * @return array + * @since Method available since Release 3.4.0 + */ + public static function getDependencies($className, $methodName) + { + $annotations = self::parseTestMethodAnnotations( + $className, $methodName + ); + + $dependencies = array(); + + if (isset($annotations['class']['depends'])) { + $dependencies = $annotations['class']['depends']; + } + + if (isset($annotations['method']['depends'])) { + $dependencies = array_merge( + $dependencies, $annotations['method']['depends'] + ); + } + + return array_unique($dependencies); + } + + /** + * Returns the error handler settings for a test. + * + * @param string $className + * @param string $methodName + * @return boolean + * @since Method available since Release 3.4.0 + */ + public static function getErrorHandlerSettings($className, $methodName) + { + return self::getBooleanAnnotationSetting( + $className, $methodName, 'errorHandler' + ); + } + + /** + * Returns the groups for a test class or method. + * + * @param string $className + * @param string $methodName + * @return array + * @since Method available since Release 3.2.0 + */ + public static function getGroups($className, $methodName = '') + { + $annotations = self::parseTestMethodAnnotations( + $className, $methodName + ); + + $groups = array(); + + if (isset($annotations['method']['author'])) { + $groups = $annotations['method']['author']; + } + + else if (isset($annotations['class']['author'])) { + $groups = $annotations['class']['author']; + } + + if (isset($annotations['class']['group'])) { + $groups = array_merge($groups, $annotations['class']['group']); + } + + if (isset($annotations['method']['group'])) { + $groups = array_merge($groups, $annotations['method']['group']); + } + + if (isset($annotations['class']['ticket'])) { + $groups = array_merge($groups, $annotations['class']['ticket']); + } + + if (isset($annotations['method']['ticket'])) { + $groups = array_merge($groups, $annotations['method']['ticket']); + } + + foreach (array('small', 'medium', 'large') as $size) { + if (isset($annotations['method'][$size])) { + $groups[] = $size; + } + + else if (isset($annotations['class'][$size])) { + $groups[] = $size; + } + } + + return array_unique($groups); + } + + /** + * Returns the size of the test. + * + * @param string $className + * @param string $methodName + * @return integer + * @since Method available since Release 3.6.0 + */ + public static function getSize($className, $methodName) + { + $groups = array_flip(self::getGroups($className, $methodName)); + $size = self::SMALL; + $class = new ReflectionClass($className); + + if ((class_exists('PHPUnit_Extensions_Database_TestCase', FALSE) && + $class->isSubclassOf('PHPUnit_Extensions_Database_TestCase')) || + (class_exists('PHPUnit_Extensions_SeleniumTestCase', FALSE) && + $class->isSubclassOf('PHPUnit_Extensions_SeleniumTestCase'))) { + $size = self::LARGE; + } + + else if (isset($groups['medium'])) { + $size = self::MEDIUM; + } + + else if (isset($groups['large'])) { + $size = self::LARGE; + } + + return $size; + } + + /** + * Returns the tickets for a test class or method. + * + * @param string $className + * @param string $methodName + * @return array + * @since Method available since Release 3.4.0 + */ + public static function getTickets($className, $methodName) + { + $annotations = self::parseTestMethodAnnotations( + $className, $methodName + ); + + $tickets = array(); + + if (isset($annotations['class']['ticket'])) { + $tickets = $annotations['class']['ticket']; + } + + if (isset($annotations['method']['ticket'])) { + $tickets = array_merge($tickets, $annotations['method']['ticket']); + } + + return array_unique($tickets); + } + + /** + * Returns the output buffering settings for a test. + * + * @param string $className + * @param string $methodName + * @return boolean + * @since Method available since Release 3.4.0 + */ + public static function getOutputBufferingSettings($className, $methodName) + { + return self::getBooleanAnnotationSetting( + $className, $methodName, 'outputBuffering' + ); + } + + /** + * Returns the process isolation settings for a test. + * + * @param string $className + * @param string $methodName + * @return boolean + * @since Method available since Release 3.4.1 + */ + public static function getProcessIsolationSettings($className, $methodName) + { + $annotations = self::parseTestMethodAnnotations( + $className, $methodName + ); + + if (isset($annotations['class']['runTestsInSeparateProcesses']) || + isset($annotations['method']['runInSeparateProcess'])) { + return TRUE; + } else { + return FALSE; + } + } + + /** + * Returns the preserve global state settings for a test. + * + * @param string $className + * @param string $methodName + * @return boolean + * @since Method available since Release 3.4.0 + */ + public static function getPreserveGlobalStateSettings($className, $methodName) + { + return self::getBooleanAnnotationSetting( + $className, $methodName, 'preserveGlobalState' + ); + } + + /** + * @param string $className + * @param string $methodName + * @param string $settingName + * @return boolean + * @since Method available since Release 3.4.0 + */ + private static function getBooleanAnnotationSetting($className, $methodName, $settingName) + { + $annotations = self::parseTestMethodAnnotations( + $className, $methodName + ); + + $result = NULL; + + if (isset($annotations['class'][$settingName])) { + if ($annotations['class'][$settingName][0] == 'enabled') { + $result = TRUE; + } + + else if ($annotations['class'][$settingName][0] == 'disabled') { + $result = FALSE; + } + } + + if (isset($annotations['method'][$settingName])) { + if ($annotations['method'][$settingName][0] == 'enabled') { + $result = TRUE; + } + + else if ($annotations['method'][$settingName][0] == 'disabled') { + $result = FALSE; + } + } + + return $result; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/TestDox/NamePrettifier.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/TestDox/NamePrettifier.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/TestDox/NamePrettifier.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/TestDox/NamePrettifier.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,178 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util_TestDox + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.3.0 + */ + +/** + * Prettifies class and method names for use in TestDox documentation. + * + * @package PHPUnit + * @subpackage Util_TestDox + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.1.0 + */ +class PHPUnit_Util_TestDox_NamePrettifier +{ + /** + * @var string + */ + protected $prefix = 'Test'; + + /** + * @var string + */ + protected $suffix = 'Test'; + + /** + * @var array + */ + protected $strings = array(); + + /** + * Prettifies the name of a test class. + * + * @param string $name + * @return string + */ + public function prettifyTestClass($name) + { + $title = $name; + + if ($this->suffix !== NULL && + $this->suffix == substr($name, -1 * strlen($this->suffix))) { + $title = substr($title, 0, strripos($title, $this->suffix)); + } + + if ($this->prefix !== NULL && + $this->prefix == substr($name, 0, strlen($this->prefix))) { + $title = substr($title, strlen($this->prefix)); + } + + return $title; + } + + /** + * Prettifies the name of a test method. + * + * @param string $name + * @return string + */ + public function prettifyTestMethod($name) + { + $buffer = ''; + + if (!is_string($name) || strlen($name) == 0) { + return $buffer; + } + + $string = preg_replace('#\d+$#', '', $name, -1, $count); + + if (in_array($string, $this->strings)) { + $name = $string; + } else if ($count == 0) { + $this->strings[] = $string; + } + + if (strpos($name, '_') !== FALSE) { + return str_replace('_', ' ', $name); + } + + $max = strlen($name); + + if (substr($name, 0, 4) == 'test') { + $offset = 4; + } else { + $offset = 0; + $name[0] = strtoupper($name[0]); + } + + $wasNumeric = FALSE; + + for ($i = $offset; $i < $max; $i++) { + if ($i > $offset && + ord($name[$i]) >= 65 && + ord($name[$i]) <= 90) { + $buffer .= ' ' . strtolower($name[$i]); + } else { + $isNumeric = is_numeric($name[$i]); + + if (!$wasNumeric && $isNumeric) { + $buffer .= ' '; + $wasNumeric = TRUE; + } + + if ($wasNumeric && !$isNumeric) { + $wasNumeric = FALSE; + } + + $buffer .= $name[$i]; + } + } + + return $buffer; + } + + /** + * Sets the prefix of test names. + * + * @param string $prefix + */ + public function setPrefix($prefix) + { + $this->prefix = $prefix; + } + + /** + * Sets the suffix of test names. + * + * @param string $prefix + */ + public function setSuffix($suffix) + { + $this->suffix = $suffix; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/TestDox/ResultPrinter/HTML.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/TestDox/ResultPrinter/HTML.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/TestDox/ResultPrinter/HTML.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/TestDox/ResultPrinter/HTML.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,124 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util_TestDox + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.3.0 + */ + +/** + * Prints TestDox documentation in HTML format. + * + * @package PHPUnit + * @subpackage Util_TestDox + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.1.0 + */ +class PHPUnit_Util_TestDox_ResultPrinter_HTML extends PHPUnit_Util_TestDox_ResultPrinter +{ + /** + * @var boolean + */ + protected $printsHTML = TRUE; + + /** + * Handler for 'start run' event. + * + */ + protected function startRun() + { + $this->write(''); + } + + /** + * Handler for 'start class' event. + * + * @param string $name + */ + protected function startClass($name) + { + $this->write( + '

' . $this->currentTestClassPrettified . + '

    ' + ); + } + + /** + * Handler for 'on test' event. + * + * @param string $name + * @param boolean $success + */ + protected function onTest($name, $success = TRUE) + { + if (!$success) { + $strikeOpen = ''; + $strikeClose = ''; + } else { + $strikeOpen = ''; + $strikeClose = ''; + } + + $this->write('
  • ' . $strikeOpen . $name . $strikeClose . '
  • '); + } + + /** + * Handler for 'end class' event. + * + * @param string $name + */ + protected function endClass($name) + { + $this->write('
'); + } + + /** + * Handler for 'end run' event. + * + */ + protected function endRun() + { + $this->write(''); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/TestDox/ResultPrinter/Text.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/TestDox/ResultPrinter/Text.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/TestDox/ResultPrinter/Text.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/TestDox/ResultPrinter/Text.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,96 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util_TestDox + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.3.0 + */ + +/** + * Prints TestDox documentation in text format. + * + * @package PHPUnit + * @subpackage Util_TestDox + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.1.0 + */ +class PHPUnit_Util_TestDox_ResultPrinter_Text extends PHPUnit_Util_TestDox_ResultPrinter +{ + /** + * Handler for 'start class' event. + * + * @param string $name + */ + protected function startClass($name) + { + $this->write($this->currentTestClassPrettified . "\n"); + } + + /** + * Handler for 'on test' event. + * + * @param string $name + * @param boolean $success + */ + protected function onTest($name, $success = TRUE) + { + if ($success) { + $this->write(' [x] '); + } else { + $this->write(' [ ] '); + } + + $this->write($name . "\n"); + } + + /** + * Handler for 'end class' event. + * + * @param string $name + */ + protected function endClass($name) + { + $this->write("\n"); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/TestDox/ResultPrinter.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/TestDox/ResultPrinter.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/TestDox/ResultPrinter.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/TestDox/ResultPrinter.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,348 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util_TestDox + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 2.3.0 + */ + +/** + * Base class for printers of TestDox documentation. + * + * @package PHPUnit + * @subpackage Util_TestDox + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 2.1.0 + */ +abstract class PHPUnit_Util_TestDox_ResultPrinter extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener +{ + /** + * @var PHPUnit_Util_TestDox_NamePrettifier + */ + protected $prettifier; + + /** + * @var string + */ + protected $testClass = ''; + + /** + * @var integer + */ + protected $testStatus = FALSE; + + /** + * @var array + */ + protected $tests = array(); + + /** + * @var integer + */ + protected $successful = 0; + + /** + * @var integer + */ + protected $failed = 0; + + /** + * @var integer + */ + protected $skipped = 0; + + /** + * @var integer + */ + protected $incomplete = 0; + + /** + * @var string + */ + protected $testTypeOfInterest = 'PHPUnit_Framework_TestCase'; + + /** + * @var string + */ + protected $currentTestClassPrettified; + + /** + * @var string + */ + protected $currentTestMethodPrettified; + + /** + * Constructor. + * + * @param resource $out + */ + public function __construct($out = NULL) + { + parent::__construct($out); + + $this->prettifier = new PHPUnit_Util_TestDox_NamePrettifier; + $this->startRun(); + } + + /** + * Flush buffer and close output. + * + */ + public function flush() + { + $this->doEndClass(); + $this->endRun(); + + parent::flush(); + } + + /** + * An error occurred. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) + { + if ($test instanceof $this->testTypeOfInterest) { + $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_ERROR; + $this->failed++; + } + } + + /** + * A failure occurred. + * + * @param PHPUnit_Framework_Test $test + * @param PHPUnit_Framework_AssertionFailedError $e + * @param float $time + */ + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) + { + if ($test instanceof $this->testTypeOfInterest) { + $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE; + $this->failed++; + } + } + + /** + * Incomplete test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + if ($test instanceof $this->testTypeOfInterest) { + $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE; + $this->incomplete++; + } + } + + /** + * Skipped test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + * @since Method available since Release 3.0.0 + */ + public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + if ($test instanceof $this->testTypeOfInterest) { + $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED; + $this->skipped++; + } + } + + /** + * A testsuite started. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit_Framework_TestSuite $suite) + { + } + + /** + * A testsuite ended. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit_Framework_TestSuite $suite) + { + } + + /** + * A test started. + * + * @param PHPUnit_Framework_Test $test + */ + public function startTest(PHPUnit_Framework_Test $test) + { + if ($test instanceof $this->testTypeOfInterest) { + $class = get_class($test); + + if ($this->testClass != $class) { + if ($this->testClass != '') { + $this->doEndClass(); + } + + $this->currentTestClassPrettified = $this->prettifier->prettifyTestClass($class); + $this->startClass($class); + + $this->testClass = $class; + $this->tests = array(); + } + + $prettified = FALSE; + + if ($test instanceof PHPUnit_Framework_TestCase && + !$test instanceof PHPUnit_Framework_Warning) { + $annotations = $test->getAnnotations(); + + if (isset($annotations['method']['testdox'][0])) { + $this->currentTestMethodPrettified = $annotations['method']['testdox'][0]; + $prettified = TRUE; + } + } + + if (!$prettified) { + $this->currentTestMethodPrettified = $this->prettifier->prettifyTestMethod($test->getName(FALSE)); + } + + $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_PASSED; + } + } + + /** + * A test ended. + * + * @param PHPUnit_Framework_Test $test + * @param float $time + */ + public function endTest(PHPUnit_Framework_Test $test, $time) + { + if ($test instanceof $this->testTypeOfInterest) { + if (!isset($this->tests[$this->currentTestMethodPrettified])) { + if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) { + $this->tests[$this->currentTestMethodPrettified]['success'] = 1; + $this->tests[$this->currentTestMethodPrettified]['failure'] = 0; + } else { + $this->tests[$this->currentTestMethodPrettified]['success'] = 0; + $this->tests[$this->currentTestMethodPrettified]['failure'] = 1; + } + } else { + if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) { + $this->tests[$this->currentTestMethodPrettified]['success']++; + } else { + $this->tests[$this->currentTestMethodPrettified]['failure']++; + } + } + + $this->currentTestClassPrettified = NULL; + $this->currentTestMethodPrettified = NULL; + } + } + + /** + * @since Method available since Release 2.3.0 + */ + protected function doEndClass() + { + foreach ($this->tests as $name => $data) { + $this->onTest($name, $data['failure'] == 0); + } + + $this->endClass($this->testClass); + } + + /** + * Handler for 'start run' event. + * + */ + protected function startRun() + { + } + + /** + * Handler for 'start class' event. + * + * @param string $name + */ + protected function startClass($name) + { + } + + /** + * Handler for 'on test' event. + * + * @param string $name + * @param boolean $success + */ + protected function onTest($name, $success = TRUE) + { + } + + /** + * Handler for 'end class' event. + * + * @param string $name + */ + protected function endClass($name) + { + } + + /** + * Handler for 'end run' event. + * + */ + protected function endRun() + { + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/TestSuiteIterator.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/TestSuiteIterator.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/TestSuiteIterator.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/TestSuiteIterator.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,149 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.1.0 + */ + +/** + * Iterator for test suites. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.1.0 + */ +class PHPUnit_Util_TestSuiteIterator implements RecursiveIterator +{ + /** + * @var integer + */ + protected $position; + + /** + * @var PHPUnit_Framework_Test[] + */ + protected $tests; + + /** + * Constructor. + * + * @param PHPUnit_Framework_TestSuite $suite + */ + public function __construct(PHPUnit_Framework_TestSuite $testSuite) + { + $this->tests = $testSuite->tests(); + } + + /** + * Rewinds the Iterator to the first element. + * + */ + public function rewind() + { + $this->position = 0; + } + + /** + * Checks if there is a current element after calls to rewind() or next(). + * + * @return boolean + */ + public function valid() + { + return $this->position < count($this->tests); + } + + /** + * Returns the key of the current element. + * + * @return integer + */ + public function key() + { + return $this->position; + } + + /** + * Returns the current element. + * + * @return PHPUnit_Framework_Test + */ + public function current() + { + return $this->valid() ? $this->tests[$this->position] : NULL; + } + + /** + * Moves forward to next element. + * + */ + public function next() + { + $this->position++; + } + + /** + * Returns the sub iterator for the current element. + * + * @return PHPUnit_Util_TestSuiteIterator + */ + public function getChildren() + { + return new PHPUnit_Util_TestSuiteIterator( + $this->tests[$this->position] + ); + } + + /** + * Checks whether the current element has children. + * + * @return boolean + */ + public function hasChildren() + { + return $this->tests[$this->position] instanceof PHPUnit_Framework_TestSuite; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Type.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Type.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/Type.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/Type.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,304 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.0.0 + */ + +/** + * Utility class for textual type (and value) representation. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class PHPUnit_Util_Type +{ + public static function isType($type) + { + return in_array( + $type, + array( + 'numeric', + 'integer', + 'int', + 'float', + 'string', + 'boolean', + 'bool', + 'null', + 'array', + 'object', + 'resource', + 'scalar' + ) + ); + } + + /** + * Exports a value into a string + * + * The output of this method is similar to the output of print_r(), but + * improved in various aspects: + * + * - NULL is rendered as "null" (instead of "") + * - TRUE is rendered as "true" (instead of "1") + * - FALSE is rendered as "false" (instead of "") + * - Strings are always quoted with single quotes + * - Carriage returns and newlines are normalized to \n + * - Recursion and repeated rendering is treated properly + * + * @param mixed $value The value to export + * @param integer $indentation The indentation level of the 2nd+ line + * @return string + * @since Method available since Release 3.6.0 + */ + public static function export($value, $indentation = 0) + { + return self::recursiveExport($value, $indentation); + } + + /** + * Recursive implementation of export + * + * @param mixed $value The value to export + * @param integer $indentation The indentation level of the 2nd+ line + * @param array $processedObjects Contains all objects that were already + * rendered + * @return string + * @since Method available since Release 3.6.0 + * @see PHPUnit_Util_Type::export + */ + protected static function recursiveExport($value, $indentation, &$processedObjects = array()) + { + if ($value === NULL) { + return 'null'; + } + + if ($value === TRUE) { + return 'true'; + } + + if ($value === FALSE) { + return 'false'; + } + + if (is_string($value)) { + // Match for most non printable chars somewhat taking multibyte chars into account + if (preg_match('/[^\x09-\x0d\x20-\xff]/', $value)) { + return 'Binary String: 0x' . bin2hex($value); + } + + return "'" . + str_replace(array("\n\r", "\r"), array("\n", "\n"), $value) . + "'"; + } + + $origValue = $value; + + if (is_object($value)) { + if (in_array($value, $processedObjects, TRUE)) { + return sprintf( + '%s Object (*RECURSION*)', + + get_class($value) + ); + } + + $processedObjects[] = $value; + + // Convert object to array + $value = self::toArray($value); + } + + if (is_array($value)) { + $whitespace = str_repeat(' ', $indentation); + + // There seems to be no other way to check arrays for recursion + // http://www.php.net/manual/en/language.types.array.php#73936 + preg_match_all('/\n \[(\w+)\] => Array\s+\*RECURSION\*/', print_r($value, TRUE), $matches); + $recursiveKeys = array_unique($matches[1]); + + // Convert to valid array keys + // Numeric integer strings are automatically converted to integers + // by PHP + foreach ($recursiveKeys as $key => $recursiveKey) { + if ((string)(integer)$recursiveKey === $recursiveKey) { + $recursiveKeys[$key] = (integer)$recursiveKey; + } + } + + $content = ''; + + foreach ($value as $key => $val) { + if (in_array($key, $recursiveKeys, TRUE)) { + $val = 'Array (*RECURSION*)'; + } + + else { + $val = self::recursiveExport($val, $indentation+1, $processedObjects); + } + + $content .= $whitespace . ' ' . self::export($key) . ' => ' . $val . "\n"; + } + + if (strlen($content) > 0) { + $content = "\n" . $content . $whitespace; + } + + return sprintf( + "%s (%s)", + + is_object($origValue) ? get_class($origValue) . ' Object' : 'Array', + $content + ); + } + + if (is_double($value) && (double)(integer)$value === $value) { + return $value . '.0'; + } + + return (string)$value; + } + + /** + * Exports a value into a single-line string + * + * The output of this method is similar to the output of + * PHPUnit_Util_Type::export. This method guarantees thought that the + * result contains now newlines. + * + * Newlines are replaced by the visible string '\n'. Contents of arrays + * and objects (if any) are replaced by '...'. + * + * @param mixed $value The value to export + * @param integer $indentation The indentation level of the 2nd+ line + * @return string + * @see PHPUnit_Util_Type::export + */ + public static function shortenedExport($value) + { + if (is_string($value)) { + return self::shortenedString($value); + } + + $origValue = $value; + + if (is_object($value)) { + $value = self::toArray($value); + } + + if (is_array($value)) { + return sprintf( + "%s (%s)", + + is_object($origValue) ? get_class($origValue) . ' Object' : 'Array', + count($value) > 0 ? '...' : '' + ); + } + + return self::export($value); + } + + /** + * Shortens a string and converts all new lines to '\n' + * + * @param string $string The string to shorten + * @param integer $max The maximum length for the string + * @return string + */ + public static function shortenedString($string, $maxLength = 40) + { + $string = self::export($string); + + if (strlen($string) > $maxLength) { + $string = substr($string, 0, $maxLength - 10) . '...' . substr($string, -7); + } + + return str_replace("\n", '\n', $string); + } + + /** + * Converts an object to an array containing all of its private, protected + * and public properties. + * + * @param object $object + * @return array + * @since Method available since Release 3.6.0 + */ + public static function toArray($object) + { + $array = array(); + + foreach ((array)$object as $key => $value) { + // properties are transformed to keys in the following way: + + // private $property => "\0Classname\0property" + // protected $property => "\0*\0property" + // public $property => "property" + + if (preg_match('/^\0.+\0(.+)$/', $key, $matches)) { + $key = $matches[1]; + } + + $array[$key] = $value; + } + + // Some internal classes like SplObjectStorage don't work with the + // above (fast) mechanism nor with reflection + // Format the output similarly to print_r() in this case + if ($object instanceof SplObjectStorage) { + foreach ($object as $key => $value) { + $array[spl_object_hash($value)] = array( + 'obj' => $value, + 'inf' => $object->getInfo(), + ); + } + } + + return $array; + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/XML.php phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/XML.php --- phpunit-3.5.5/PHPUnit-3.6.10/PHPUnit/Util/XML.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/Util/XML.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,895 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.phpunit.de/ + * @since File available since Release 3.2.0 + */ + +/** + * XML helpers. + * + * @package PHPUnit + * @subpackage Util + * @author Sebastian Bergmann + * @copyright 2001-2012 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 3.6.10 + * @link http://www.phpunit.de/ + * @since Class available since Release 3.2.0 + */ +class PHPUnit_Util_XML +{ + /** + * @param string $string + * @return string + * @author Kore Nordmann + * @since Method available since Release 3.4.6 + */ + public static function prepareString($string) + { + return preg_replace( + '([\\x00-\\x04\\x0b\\x0c\\x0e-\\x1f\\x7f])e', + 'sprintf( "&#x%02x;", ord( "\\1" ) )', + htmlspecialchars( + PHPUnit_Util_String::convertToUtf8($string), ENT_COMPAT, 'UTF-8' + ) + ); + } + + /** + * Loads an XML (or HTML) file into a DOMDocument object. + * + * @param string $filename + * @param boolean $isHtml + * @return DOMDocument + * @since Method available since Release 3.3.0 + */ + public static function loadFile($filename, $isHtml = FALSE) + { + $reporting = error_reporting(0); + $contents = file_get_contents($filename); + error_reporting($reporting); + + if ($contents === FALSE) { + throw new PHPUnit_Framework_Exception( + sprintf( + 'Could not read "%s".', + $filename + ) + ); + } + + return self::load($contents, $isHtml, $filename); + } + + /** + * Load an $actual document into a DOMDocument. This is called + * from the selector assertions. + * + * If $actual is already a DOMDocument, it is returned with + * no changes. Otherwise, $actual is loaded into a new DOMDocument + * as either HTML or XML, depending on the value of $isHtml. + * + * Note: prior to PHPUnit 3.3.0, this method loaded a file and + * not a string as it currently does. To load a file into a + * DOMDocument, use loadFile() instead. + * + * @param string|DOMDocument $actual + * @param boolean $isHtml + * @param string $filename + * @return DOMDocument + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ + public static function load($actual, $isHtml = FALSE, $filename = '') + { + if ($actual instanceof DOMDocument) { + return $actual; + } + + $document = new DOMDocument; + $internal = libxml_use_internal_errors(TRUE); + $message = ''; + $reporting = error_reporting(0); + + if ($isHtml) { + $loaded = $document->loadHTML($actual); + } else { + $loaded = $document->loadXML($actual); + } + + foreach (libxml_get_errors() as $error) { + $message .= $error->message; + } + + libxml_use_internal_errors($internal); + error_reporting($reporting); + + if ($loaded === FALSE) { + if ($filename != '') { + throw new PHPUnit_Framework_Exception( + sprintf( + 'Could not load "%s".%s', + + $filename, + $message != '' ? "\n" . $message : '' + ) + ); + } else { + throw new PHPUnit_Framework_Exception($message); + } + } + + return $document; + } + + /** + * + * + * @param DOMNode $node + * @return string + * @since Method available since Release 3.4.0 + */ + public static function nodeToText(DOMNode $node) + { + if ($node->childNodes->length == 1) { + return $node->nodeValue; + } + + $result = ''; + + foreach ($node->childNodes as $childNode) { + $result .= $node->ownerDocument->saveXML($childNode); + } + + return $result; + } + + /** + * + * + * @param DOMNode $node + * @since Method available since Release 3.3.0 + * @author Mattis Stordalen Flister + */ + public static function removeCharacterDataNodes(DOMNode $node) + { + if ($node->hasChildNodes()) { + for ($i = $node->childNodes->length - 1; $i >= 0; $i--) { + if (($child = $node->childNodes->item($i)) instanceof DOMCharacterData) { + $node->removeChild($child); + } + } + } + } + + /** + * "Convert" a DOMElement object into a PHP variable. + * + * @param DOMElement $element + * @return mixed + * @since Method available since Release 3.4.0 + */ + public static function xmlToVariable(DOMElement $element) + { + $variable = NULL; + + switch ($element->tagName) { + case 'array': { + $variable = array(); + + foreach ($element->getElementsByTagName('element') as $element) { + $value = self::xmlToVariable($element->childNodes->item(1)); + + if ($element->hasAttribute('key')) { + $variable[(string)$element->getAttribute('key')] = $value; + } else { + $variable[] = $value; + } + } + } + break; + + case 'object': { + $className = $element->getAttribute('class'); + + if ($element->hasChildNodes()) { + $arguments = $element->childNodes->item(1)->childNodes; + $constructorArgs = array(); + + foreach ($arguments as $argument) { + if ($argument instanceof DOMElement) { + $constructorArgs[] = self::xmlToVariable($argument); + } + } + + $class = new ReflectionClass($className); + $variable = $class->newInstanceArgs($constructorArgs); + } else { + $variable = new $className; + } + } + break; + + case 'boolean': { + $variable = $element->nodeValue == 'true' ? TRUE : FALSE; + } + break; + + case 'integer': + case 'double': + case 'string': { + $variable = $element->nodeValue; + + settype($variable, $element->tagName); + } + break; + } + + return $variable; + } + + /** + * Validate list of keys in the associative array. + * + * @param array $hash + * @param array $validKeys + * @return array + * @throws InvalidArgumentException + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ + public static function assertValidKeys(array $hash, array $validKeys) + { + $valids = array(); + + // Normalize validation keys so that we can use both indexed and + // associative arrays. + foreach ($validKeys as $key => $val) { + is_int($key) ? $valids[$val] = NULL : $valids[$key] = $val; + } + + $validKeys = array_keys($valids); + + // Check for invalid keys. + foreach ($hash as $key => $value) { + if (!in_array($key, $validKeys)) { + $unknown[] = $key; + } + } + + if (!empty($unknown)) { + throw new InvalidArgumentException( + 'Unknown key(s): ' . implode(', ', $unknown) + ); + } + + // Add default values for any valid keys that are empty. + foreach ($valids as $key => $value) { + if (!isset($hash[$key])) { + $hash[$key] = $value; + } + } + + return $hash; + } + + /** + * Parse a CSS selector into an associative array suitable for + * use with findNodes(). + * + * @param string $selector + * @param mixed $content + * @return array + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ + public static function convertSelectToTag($selector, $content = TRUE) + { + $selector = trim(preg_replace("/\s+/", " ", $selector)); + + // substitute spaces within attribute value + while (preg_match('/\[[^\]]+"[^"]+\s[^"]+"\]/', $selector)) { + $selector = preg_replace( + '/(\[[^\]]+"[^"]+)\s([^"]+"\])/', "$1__SPACE__$2", $selector + ); + } + + if (strstr($selector, ' ')) { + $elements = explode(' ', $selector); + } else { + $elements = array($selector); + } + + $previousTag = array(); + + foreach (array_reverse($elements) as $element) { + $element = str_replace('__SPACE__', ' ', $element); + + // child selector + if ($element == '>') { + $previousTag = array('child' => $previousTag['descendant']); + continue; + } + + $tag = array(); + + // match element tag + preg_match("/^([^\.#\[]*)/", $element, $eltMatches); + + if (!empty($eltMatches[1])) { + $tag['tag'] = $eltMatches[1]; + } + + // match attributes (\[[^\]]*\]*), ids (#[^\.#\[]*), + // and classes (\.[^\.#\[]*)) + preg_match_all( + "/(\[[^\]]*\]*|#[^\.#\[]*|\.[^\.#\[]*)/", $element, $matches + ); + + if (!empty($matches[1])) { + $classes = array(); + $attrs = array(); + + foreach ($matches[1] as $match) { + // id matched + if (substr($match, 0, 1) == '#') { + $tag['id'] = substr($match, 1); + } + + // class matched + else if (substr($match, 0, 1) == '.') { + $classes[] = substr($match, 1); + } + + // attribute matched + else if (substr($match, 0, 1) == '[' && + substr($match, -1, 1) == ']') { + $attribute = substr($match, 1, strlen($match) - 2); + $attribute = str_replace('"', '', $attribute); + + // match single word + if (strstr($attribute, '~=')) { + list($key, $value) = explode('~=', $attribute); + $value = "regexp:/.*\b$value\b.*/"; + } + + // match substring + else if (strstr($attribute, '*=')) { + list($key, $value) = explode('*=', $attribute); + $value = "regexp:/.*$value.*/"; + } + + // exact match + else { + list($key, $value) = explode('=', $attribute); + } + + $attrs[$key] = $value; + } + } + + if ($classes) { + $tag['class'] = join(' ', $classes); + } + + if ($attrs) { + $tag['attributes'] = $attrs; + } + } + + // tag content + if (is_string($content)) { + $tag['content'] = $content; + } + + // determine previous child/descendants + if (!empty($previousTag['descendant'])) { + $tag['descendant'] = $previousTag['descendant']; + } + + else if (!empty($previousTag['child'])) { + $tag['child'] = $previousTag['child']; + } + + $previousTag = array('descendant' => $tag); + } + + return $tag; + } + + /** + * Parse an $actual document and return an array of DOMNodes + * matching the CSS $selector. If an error occurs, it will + * return FALSE. + * + * To only return nodes containing a certain content, give + * the $content to match as a string. Otherwise, setting + * $content to TRUE will return all nodes matching $selector. + * + * The $actual document may be a DOMDocument or a string + * containing XML or HTML, identified by $isHtml. + * + * @param array $selector + * @param string $content + * @param mixed $actual + * @param boolean $isHtml + * @return false|array + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + * @author Tobias Schlitt + */ + public static function cssSelect($selector, $content, $actual, $isHtml = TRUE) + { + $matcher = self::convertSelectToTag($selector, $content); + $dom = self::load($actual, $isHtml); + $tags = self::findNodes($dom, $matcher, $isHtml); + + return $tags; + } + + /** + * Parse out the options from the tag using DOM object tree. + * + * @param DOMDocument $dom + * @param array $options + * @param boolean $isHtml + * @return array + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + * @author Tobias Schlitt + */ + public static function findNodes(DOMDocument $dom, array $options, $isHtml = TRUE) + { + $valid = array( + 'id', 'class', 'tag', 'content', 'attributes', 'parent', + 'child', 'ancestor', 'descendant', 'children' + ); + + $filtered = array(); + $options = self::assertValidKeys($options, $valid); + + // find the element by id + if ($options['id']) { + $options['attributes']['id'] = $options['id']; + } + + if ($options['class']) { + $options['attributes']['class'] = $options['class']; + } + + // find the element by a tag type + if ($options['tag']) { + if ($isHtml) { + $elements = self::getElementsByCaseInsensitiveTagName( + $dom, $options['tag'] + ); + } else { + $elements = $dom->getElementsByTagName($options['tag']); + } + + foreach ($elements as $element) { + $nodes[] = $element; + } + + if (empty($nodes)) { + return FALSE; + } + } + + // no tag selected, get them all + else { + $tags = array( + 'a', 'abbr', 'acronym', 'address', 'area', 'b', 'base', 'bdo', + 'big', 'blockquote', 'body', 'br', 'button', 'caption', 'cite', + 'code', 'col', 'colgroup', 'dd', 'del', 'div', 'dfn', 'dl', + 'dt', 'em', 'fieldset', 'form', 'frame', 'frameset', 'h1', 'h2', + 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'html', 'i', 'iframe', + 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'link', + 'map', 'meta', 'noframes', 'noscript', 'object', 'ol', 'optgroup', + 'option', 'p', 'param', 'pre', 'q', 'samp', 'script', 'select', + 'small', 'span', 'strong', 'style', 'sub', 'sup', 'table', + 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title', + 'tr', 'tt', 'ul', 'var' + ); + + foreach ($tags as $tag) { + if ($isHtml) { + $elements = self::getElementsByCaseInsensitiveTagName( + $dom, $tag + ); + } else { + $elements = $dom->getElementsByTagName($tag); + } + + foreach ($elements as $element) { + $nodes[] = $element; + } + } + + if (empty($nodes)) { + return FALSE; + } + } + + // filter by attributes + if ($options['attributes']) { + foreach ($nodes as $node) { + $invalid = FALSE; + + foreach ($options['attributes'] as $name => $value) { + // match by regexp if like "regexp:/foo/i" + if (preg_match('/^regexp\s*:\s*(.*)/i', $value, $matches)) { + if (!preg_match($matches[1], $node->getAttribute($name))) { + $invalid = TRUE; + } + } + + // class can match only a part + else if ($name == 'class') { + // split to individual classes + $findClasses = explode( + ' ', preg_replace("/\s+/", " ", $value) + ); + + $allClasses = explode( + ' ', + preg_replace("/\s+/", " ", $node->getAttribute($name)) + ); + + // make sure each class given is in the actual node + foreach ($findClasses as $findClass) { + if (!in_array($findClass, $allClasses)) { + $invalid = TRUE; + } + } + } + + // match by exact string + else { + if ($node->getAttribute($name) != $value) { + $invalid = TRUE; + } + } + } + + // if every attribute given matched + if (!$invalid) { + $filtered[] = $node; + } + } + + $nodes = $filtered; + $filtered = array(); + + if (empty($nodes)) { + return FALSE; + } + } + + // filter by content + if ($options['content'] !== NULL) { + foreach ($nodes as $node) { + $invalid = FALSE; + + // match by regexp if like "regexp:/foo/i" + if (preg_match('/^regexp\s*:\s*(.*)/i', $options['content'], $matches)) { + if (!preg_match($matches[1], self::getNodeText($node))) { + $invalid = TRUE; + } + } + + // match by exact string + else if (strstr(self::getNodeText($node), $options['content']) === FALSE) { + $invalid = TRUE; + } + + if (!$invalid) { + $filtered[] = $node; + } + } + + $nodes = $filtered; + $filtered = array(); + + if (empty($nodes)) { + return FALSE; + } + } + + // filter by parent node + if ($options['parent']) { + $parentNodes = self::findNodes($dom, $options['parent'], $isHtml); + $parentNode = isset($parentNodes[0]) ? $parentNodes[0] : NULL; + + foreach ($nodes as $node) { + if ($parentNode !== $node->parentNode) { + break; + } + + $filtered[] = $node; + } + + $nodes = $filtered; + $filtered = array(); + + if (empty($nodes)) { + return FALSE; + } + } + + // filter by child node + if ($options['child']) { + $childNodes = self::findNodes($dom, $options['child'], $isHtml); + $childNodes = !empty($childNodes) ? $childNodes : array(); + + foreach ($nodes as $node) { + foreach ($node->childNodes as $child) { + foreach ($childNodes as $childNode) { + if ($childNode === $child) { + $filtered[] = $node; + } + } + } + } + + $nodes = $filtered; + $filtered = array(); + + if (empty($nodes)) { + return FALSE; + } + } + + // filter by ancestor + if ($options['ancestor']) { + $ancestorNodes = self::findNodes($dom, $options['ancestor'], $isHtml); + $ancestorNode = isset($ancestorNodes[0]) ? $ancestorNodes[0] : NULL; + + foreach ($nodes as $node) { + $parent = $node->parentNode; + + while ($parent->nodeType != XML_HTML_DOCUMENT_NODE) { + if ($parent === $ancestorNode) { + $filtered[] = $node; + } + + $parent = $parent->parentNode; + } + } + + $nodes = $filtered; + $filtered = array(); + + if (empty($nodes)) { + return FALSE; + } + } + + // filter by descendant + if ($options['descendant']) { + $descendantNodes = self::findNodes($dom, $options['descendant'], $isHtml); + $descendantNodes = !empty($descendantNodes) ? $descendantNodes : array(); + + foreach ($nodes as $node) { + foreach (self::getDescendants($node) as $descendant) { + foreach ($descendantNodes as $descendantNode) { + if ($descendantNode === $descendant) { + $filtered[] = $node; + } + } + } + } + + $nodes = $filtered; + $filtered = array(); + + if (empty($nodes)) { + return FALSE; + } + } + + // filter by children + if ($options['children']) { + $validChild = array('count', 'greater_than', 'less_than', 'only'); + $childOptions = self::assertValidKeys( + $options['children'], $validChild + ); + + foreach ($nodes as $node) { + $childNodes = $node->childNodes; + + foreach ($childNodes as $childNode) { + if ($childNode->nodeType !== XML_CDATA_SECTION_NODE && + $childNode->nodeType !== XML_TEXT_NODE) { + $children[] = $childNode; + } + } + + // we must have children to pass this filter + if (!empty($children)) { + // exact count of children + if ($childOptions['count'] !== NULL) { + if (count($children) !== $childOptions['count']) { + break; + } + } + + // range count of children + else if ($childOptions['less_than'] !== NULL && + $childOptions['greater_than'] !== NULL) { + if (count($children) >= $childOptions['less_than'] || + count($children) <= $childOptions['greater_than']) { + break; + } + } + + // less than a given count + else if ($childOptions['less_than'] !== NULL) { + if (count($children) >= $childOptions['less_than']) { + break; + } + } + + // more than a given count + else if ($childOptions['greater_than'] !== NULL) { + if (count($children) <= $childOptions['greater_than']) { + break; + } + } + + // match each child against a specific tag + if ($childOptions['only']) { + $onlyNodes = self::findNodes( + $dom, $childOptions['only'], $isHtml + ); + + // try to match each child to one of the 'only' nodes + foreach ($children as $child) { + $matched = FALSE; + + foreach ($onlyNodes as $onlyNode) { + if ($onlyNode === $child) { + $matched = TRUE; + } + } + + if (!$matched) { + break(2); + } + } + } + + $filtered[] = $node; + } + } + + $nodes = $filtered; + $filtered = array(); + + if (empty($nodes)) { + return; + } + } + + // return the first node that matches all criteria + return !empty($nodes) ? $nodes : array(); + } + + /** + * Recursively get flat array of all descendants of this node. + * + * @param DOMNode $node + * @return array + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ + protected static function getDescendants(DOMNode $node) + { + $allChildren = array(); + $childNodes = $node->childNodes ? $node->childNodes : array(); + + foreach ($childNodes as $child) { + if ($child->nodeType === XML_CDATA_SECTION_NODE || + $child->nodeType === XML_TEXT_NODE) { + continue; + } + + $children = self::getDescendants($child); + $allChildren = array_merge($allChildren, $children, array($child)); + } + + return isset($allChildren) ? $allChildren : array(); + } + + /** + * Gets elements by case insensitive tagname. + * + * @param DOMDocument $dom + * @param string $tag + * @return DOMNodeList + * @since Method available since Release 3.4.0 + */ + protected static function getElementsByCaseInsensitiveTagName(DOMDocument $dom, $tag) + { + $elements = $dom->getElementsByTagName(strtolower($tag)); + + if ($elements->length == 0) { + $elements = $dom->getElementsByTagName(strtoupper($tag)); + } + + return $elements; + } + + /** + * Get the text value of this node's child text node. + * + * @param DOMNode $node + * @return string + * @since Method available since Release 3.3.0 + * @author Mike Naberezny + * @author Derek DeVries + */ + protected static function getNodeText(DOMNode $node) + { + if (!$node->childNodes instanceof DOMNodeList) { + return ''; + } + + $result = ''; + + foreach ($node->childNodes as $childNode) { + if ($childNode->nodeType === XML_TEXT_NODE) { + $result .= trim($childNode->data) . ' '; + } else { + $result .= self::getNodeText($childNode); + } + } + + return str_replace(' ', ' ', $result); + } +} diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/README.markdown phpunit-3.6.10/PHPUnit-3.6.10/README.markdown --- phpunit-3.5.5/PHPUnit-3.6.10/README.markdown 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/README.markdown 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,73 @@ +PHPUnit +======= + +PHPUnit is the de-facto standard for unit testing in PHP projects. It provides both a framework that makes the writing of tests easy as well as the functionality to easily run the tests and analyse their results. + +Requirements +------------ + +* PHPUnit 3.6 requires PHP 5.2.7 (or later) but PHP 5.3.9 (or later) is highly recommended. +* [PHP_CodeCoverage](http://github.com/sebastianbergmann/php-code-coverage), the library that is used by PHPUnit to collect and process code coverage information, depends on [Xdebug](http://xdebug.org/) 2.0.5 (or later) but Xdebug 2.1.3 (or later) is highly recommended. + +Installation +------------ + +PHPUnit should be installed using the PEAR Installer, the backbone of the [PHP Extension and Application Repository](http://pear.php.net/) that provides a distribution system for PHP packages. + +Depending on your OS distribution and/or your PHP environment, you may need to install PEAR or update your existing PEAR installation before you can proceed with the following instructions. `sudo pear upgrade PEAR` usually suffices to upgrade an existing PEAR installation. The [PEAR Manual ](http://pear.php.net/manual/en/installation.getting.php) explains how to perform a fresh installation of PEAR. + +The following two commands (which you may have to run as `root`) are all that is required to install PHPUnit using the PEAR Installer: + + pear config-set auto_discover 1 + pear install pear.phpunit.de/PHPUnit + +After the installation you can find the PHPUnit source files inside your local PEAR directory; the path is usually `/usr/lib/php/PHPUnit`. + +Documentation +------------- + +The documentation for PHPUnit is available in different formats: + +* [English, multiple HTML files](http://www.phpunit.de/manual/3.6/en/index.html) +* [English, single HTML file](http://www.phpunit.de/manual/3.6/en/phpunit-book.html) +* [English, PDF](http://www.phpunit.de/manual/3.6/en/phpunit-book.pdf) +* [English, ePub](http://www.phpunit.de/manual/3.6/en/phpunit-book.epub) +* [Japanese, multiple HTML files](http://www.phpunit.de/manual/3.6/ja/index.html) +* [Japanese, single HTML file](http://www.phpunit.de/manual/3.6/ja/phpunit-book.html) +* [Japanese, PDF](http://www.phpunit.de/manual/3.6/ja/phpunit-book.pdf) +* [Japanese, ePub](http://www.phpunit.de/manual/3.6/ja/phpunit-book.epub) + +IRC +--- + +The [#phpunit channel on the Freenode IRC network](irc://freenode.net/phpunit) is a place to chat about PHPUnit. + +Using PHPUnit From a Git Checkout +--------------------------------- + +The following commands can be used to perform the initial checkout of PHPUnit and its dependencies from Git: + + mkdir phpunit && cd phpunit + git clone git://github.com/sebastianbergmann/phpunit.git + git clone git://github.com/sebastianbergmann/dbunit.git + git clone git://github.com/sebastianbergmann/php-file-iterator.git + git clone git://github.com/sebastianbergmann/php-text-template.git + git clone git://github.com/sebastianbergmann/php-code-coverage.git + git clone git://github.com/sebastianbergmann/php-token-stream.git + git clone git://github.com/sebastianbergmann/php-timer.git + git clone git://github.com/sebastianbergmann/phpunit-mock-objects.git + git clone git://github.com/sebastianbergmann/phpunit-selenium.git + git clone git://github.com/sebastianbergmann/phpunit-story.git + git clone git://github.com/sebastianbergmann/php-invoker.git + +The `dbunit`, `php-code-coverage`, `php-file-iterator`, `php-text-template`, `php-timer`, `php-token-stream`, `phpunit`, `phpunit-mock-objects`, `phpunit-selenium`, `phpunit-story`, and `php-invoker` directories need to be added to the `include_path`. + +The `phpunit/phpunit.php` script can be used to invoke the PHPUnit test runner. + +The following commands can be used to check out the appropriate branches for PHPUnit 3.6: + + cd phpunit && git checkout 3.6 && cd .. + cd dbunit && git checkout 1.1 && cd .. + cd php-code-coverage && git checkout 1.1 && cd .. + cd phpunit-mock-objects && git checkout 1.1 && cd .. + cd phpunit-selenium && git checkout 1.1 && cd .. diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/phpunit.bat phpunit-3.6.10/PHPUnit-3.6.10/phpunit.bat --- phpunit-3.5.5/PHPUnit-3.6.10/phpunit.bat 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/phpunit.bat 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,43 @@ +@echo off +REM PHPUnit +REM +REM Copyright (c) 2002-2010, Sebastian Bergmann . +REM All rights reserved. +REM +REM Redistribution and use in source and binary forms, with or without +REM modification, are permitted provided that the following conditions +REM are met: +REM +REM * Redistributions of source code must retain the above copyright +REM notice, this list of conditions and the following disclaimer. +REM +REM * Redistributions in binary form must reproduce the above copyright +REM notice, this list of conditions and the following disclaimer in +REM the documentation and/or other materials provided with the +REM distribution. +REM +REM * Neither the name of Sebastian Bergmann nor the names of his +REM contributors may be used to endorse or promote products derived +REM from this software without specific prior written permission. +REM +REM THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +REM "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +REM LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +REM FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +REM COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +REM INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +REM BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +REM LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +REM CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC +REM LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +REM ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +REM POSSIBILITY OF SUCH DAMAGE. +REM + +if "%PHPBIN%" == "" set PHPBIN=@php_bin@ +if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH +GOTO RUN +:USE_PEAR_PATH +set PHPBIN=%PHP_PEAR_PHP_BIN% +:RUN +"%PHPBIN%" "@bin_dir@\phpunit" %* diff -Nru phpunit-3.5.5/PHPUnit-3.6.10/phpunit.php phpunit-3.6.10/PHPUnit-3.6.10/phpunit.php --- phpunit-3.5.5/PHPUnit-3.6.10/phpunit.php 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/PHPUnit-3.6.10/phpunit.php 2012-01-27 10:49:19.000000000 +0000 @@ -0,0 +1,46 @@ +#!/usr/bin/env php +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * 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 + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main'); + +if (strpos('@php_bin@', '@php_bin') === 0) { + require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'PHPUnit' . DIRECTORY_SEPARATOR . 'Autoload.php'; +} else { + require '@php_dir@' . DIRECTORY_SEPARATOR . 'PHPUnit' . DIRECTORY_SEPARATOR . 'Autoload.php'; +} + +PHPUnit_TextUI_Command::main(); diff -Nru phpunit-3.5.5/debian/README.Debian phpunit-3.6.10/debian/README.Debian --- phpunit-3.5.5/debian/README.Debian 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/README.Debian 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -phpunit for Debian ------------------- - -Documentation for PHPUnit is available from: -http://www.phpunit.de/manual/3.4/en/index.html - -wget -r -c -np -l0 -N -k http://www.phpunit.de/manual/3.4/en/index.html - - -- Ivan Borzenkov Mon, 25 May 2009 10:55:05 +0400 - -Man file was created with command -help2man --no-info --name "Unit testing suite for PHP" /usr/bin/phpunit > debian/phpunit.1 - - -- Bart Martens Sun, 10 Sep 2006 17:15:59 +0200 diff -Nru phpunit-3.5.5/debian/README.source phpunit-3.6.10/debian/README.source --- phpunit-3.5.5/debian/README.source 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/debian/README.source 2012-05-13 13:29:53.000000000 +0000 @@ -0,0 +1,10 @@ +Previous source packages included a copy of the HTML documentation +from from phpunit.de into the original tar.gz, which was downloaded +from the site using getDoc.sh. +This has been removed as source-based / compiled doc packaging is +preferrable. + +Man file was created with command +help2man --no-info --name "Unit testing suite for PHP" /usr/bin/phpunit > debian/phpunit.1 + + -- Olivier Berger , Wed, 16 Feb 2011 18:10:28 +0100 diff -Nru phpunit-3.5.5/debian/README.sources phpunit-3.6.10/debian/README.sources --- phpunit-3.5.5/debian/README.sources 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/README.sources 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -Add documentation from phpunit.de into original tar.gz -Documentation may by get from site using getDoc.sh diff -Nru phpunit-3.5.5/debian/changelog phpunit-3.6.10/debian/changelog --- phpunit-3.5.5/debian/changelog 2010-12-11 15:20:04.000000000 +0000 +++ phpunit-3.6.10/debian/changelog 2013-01-17 15:03:07.000000000 +0000 @@ -1,3 +1,38 @@ +phpunit (3.6.10-1~precise1~ppa1) precise; urgency=low + + * No-change backport to precise + + -- Daniel Hahler Thu, 17 Jan 2013 16:03:07 +0100 + +phpunit (3.6.10-1) unstable; urgency=low + + * New upstream version. + * Adopting the package (Closes: #607393). + + [ Thomas Goirand ] + * Fixed debian/watch file to use the github tags. + * Added a debian/gbp.conf (and renamed branches on Alioth). + * Added Vcs fields. + * Switching package to pkg-php-tools. + * Standards-Version is now 3.9.3 (no change). + * Switched debian/copyright to format 1.0. + * Added a channel.xml file (as a quilt patch). + * Removed useless debian/phpunit-doc.doc-base, debian/docs, debian/dirs, + and debian/install (we are now using "pear install" with the package.xml...). + * Removed useless debian/README.Debian that was advising to get stuff + outside debian. + * Removed versions from Suggests:, removed double Section: in debian/control. + * Maintainer: is now PKG-PHP-PEAR team + * Patches package.xml to remove unwanted LICENSE file from binaries. + * Reviewed (new) dependencies of the binary package. + + [ Olivier Berger ] + * Add dependency on php-codecoverage (Closes: #607372), and so many missing + dependencies. + * Remove phpunit-doc generation, as may not be rebuildable from sources. + + -- Thomas Goirand Sun, 22 Apr 2012 12:53:21 +0800 + phpunit (3.5.5-2) unstable; urgency=low * fix doc-base-file-references-missing-file diff -Nru phpunit-3.5.5/debian/compat phpunit-3.6.10/debian/compat --- phpunit-3.5.5/debian/compat 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/compat 2012-05-13 13:29:53.000000000 +0000 @@ -1 +1 @@ -7 +8 diff -Nru phpunit-3.5.5/debian/control phpunit-3.6.10/debian/control --- phpunit-3.5.5/debian/control 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/control 2012-05-13 13:29:53.000000000 +0000 @@ -1,17 +1,20 @@ Source: phpunit Section: php Priority: optional -Maintainer: Ivan Borzenkov -Build-Depends: debhelper (>= 7), cdbs -Standards-Version: 3.9.1 +Maintainer: PKG-PHP-PEAR team +Uploaders: Olivier Berger , Olivier Berger , Thomas Goirand +Build-Depends: debhelper (>= 8), pkg-php-tools, pear-phpunit-channel +Standards-Version: 3.9.3 +Vcs-Git: git://git.debian.org/pkg-php/phpunit.git +Vcs-Browser: http://git.debian.org/?p=pkg-php/phpunit.git Homepage: http://www.phpunit.de/ Package: phpunit Architecture: all -Section: php -Depends: php-pear, php5-cli, php-benchmark, ${misc:Depends} +Depends: php-pear, php5-cli, pear-phpunit-channel, php-file-iterator, php-text-template, php-codecoverage, php-timer, phpunit-mock-object, php-symfony-yaml, ${misc:Depends} Replaces: phpunit2 -Suggests: phpunit-doc +Suggests: phpunit-selenium, phpunit-dbunit +Recommends: phpunit-story, php-invoker, php-token-stream Description: Unit testing suite for PHP5 Unit testing allows you to write small test methods which verify units of functionality in your program. It is a powerful technique for improving the @@ -25,11 +28,3 @@ fairly familiar. If you've never written unit tests before, the PHPUnit API is simple to learn and use. -Package: phpunit-doc -Architecture: all -Section: doc -Depends: ${misc:Depends} -Description: Manual for phpunit - This package contents manual for phpunit in html - . - Manual is in /usr/share/doc/phpunit-doc/html/ diff -Nru phpunit-3.5.5/debian/copyright phpunit-3.6.10/debian/copyright --- phpunit-3.5.5/debian/copyright 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/copyright 2012-05-13 13:29:53.000000000 +0000 @@ -1,446 +1,61 @@ -This phpunit package was debianized by Matthew Palmer - in November 2004. - -It was downloaded from: - http://pear.phpunit.de/get/ - http://www.phpunit.de/ - -Upstream Author: Sebastian Bergmann - -Copyright (c) 2002-2009, Sebastian Bergmann - -License: - - Redistribution and use in source and binary forms, with or without - modification, are permitted under the terms of the BSD License. - - THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - - Use yahoo-dom-event.js and container-min.js from - Yahoo User Interface Library to generate report - Copyright (c) 2008, Yahoo! Inc. All rights reserved. - You may download it from http://developer.yahoo.com/yui/ - or get in libjs-yui package. - -Documentation under the Creative Commons Attribution 3.0 Unported License. - --------------------------------------------------------------------- - -You are free: - - * to Share - to copy, distribute and transmit the work - * to Remix - to adapt the work - -Under the following conditions: - -Attribution. You must attribute the work in the manner specified by -the author or licensor (but not in any way that suggests that they -endorse you or your use of the work). - - * For any reuse or distribution, you must make clear to others - the license terms of this work. The best way to do this is with - a link to this web page. - - * Any of the above conditions can be waived if you get - permission from the copyright holder. - - * Nothing in this license impairs or restricts the author's moral - rights. - -Your fair dealing and other rights are in no way affected by the -above. - -This is a human-readable summary of the Legal Code (the full -license) below. - -==================================================================== - -Creative Commons Legal Code -Attribution 3.0 Unported - -CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE -LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN -ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS -INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO -WARRANTIES REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS -LIABILITY FOR DAMAGES RESULTING FROM ITS USE. - -License - -THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS -CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS -PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE -WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW -IS PROHIBITED. - -BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND -AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS -LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU -THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF -SUCH TERMS AND CONDITIONS. - -1. Definitions - - a. "Adaptation" means a work based upon the Work, or upon the - Work and other pre-existing works, such as a translation, - adaptation, derivative work, arrangement of music or other - alterations of a literary or artistic work, or phonogram or - performance and includes cinematographic adaptations or any - other form in which the Work may be recast, transformed, or - adapted including in any form recognizably derived from the - original, except that a work that constitutes a Collection - will not be considered an Adaptation for the purpose of this - License. For the avoidance of doubt, where the Work is a - musical work, performance or phonogram, the synchronization of - the Work in timed-relation with a moving image ("synching") - will be considered an Adaptation for the purpose of this - License. - - b. "Collection" means a collection of literary or artistic works, - such as encyclopedias and anthologies, or performances, - phonograms or broadcasts, or other works or subject matter - other than works listed in Section 1(f) below, which, by - reason of the selection and arrangement of their contents, - constitute intellectual creations, in which the Work is - included in its entirety in unmodified form along with one or - more other contributions, each constituting separate and - independent works in themselves, which together are assembled - into a collective whole. A work that constitutes a Collection - will not be considered an Adaptation (as defined above) for - the purposes of this License. - - c. "Distribute" means to make available to the public the - original and copies of the Work or Adaptation, as appropriate, - through sale or other transfer of ownership. - - d. "Licensor" means the individual, individuals, entity or - entities that offer(s) the Work under the terms of this License. - - e. "Original Author" means, in the case of a literary or artistic - work, the individual, individuals, entity or entities who - created the Work or if no individual or entity can be - identified, the publisher; and in addition (i) in the case of - a performance the actors, singers, musicians, dancers, and - other persons who act, sing, deliver, declaim, play in, - interpret or otherwise perform literary or artistic works or - expressions of folklore; (ii) in the case of a phonogram the - producer being the person or legal entity who first fixes the - sounds of a performance or other sounds; and, (iii) in the - case of broadcasts, the organization that transmits the - broadcast. - - f. "Work" means the literary and/or artistic work offered under - the terms of this License including without limitation any - production in the literary, scientific and artistic domain, - whatever may be the mode or form of its expression including - digital form, such as a book, pamphlet and other writing; a - lecture, address, sermon or other work of the same nature; a - dramatic or dramatico-musical work; a choreographic work or - entertainment in dumb show; a musical composition with or - without words; a cinematographic work to which are assimilated - works expressed by a process analogous to cinematography; a - work of drawing, painting, architecture, sculpture, engraving - or lithography; a photographic work to which are assimilated - works expressed by a process analogous to photography; a work - of applied art; an illustration, map, plan, sketch or three- - dimensional work relative to geography, topography, - architecture or science; a performance; a broadcast; a - phonogram; a compilation of data to the extent it is protected - as a copyrightable work; or a work performed by a variety or - circus performer to the extent it is not otherwise considered - a literary or artistic work. - - g. "You" means an individual or entity exercising rights under - this License who has not previously violated the terms of - this License with respect to the Work, or who has received - express permission from the Licensor to exercise rights under - this License despite a previous violation. - - h. "Publicly Perform" means to perform public recitations of the - Work and to communicate to the public those public - recitations, by any means or process, including by wire or - wireless means or public digital performances; to make - available to the public Works in such a way that members of - the public may access these Works from a place and at a place - individually chosen by them; to perform the Work to the public - by any means or process and the communication to the public of - the performances of the Work, including by public digital - performance; to broadcast and rebroadcast the Work by any - means including signs, sounds or images. - - i. "Reproduce" means to make copies of the Work by any means - including without limitation by sound or visual recordings and - the right of fixation and reproducing fixations of the Work, - including storage of a protected performance or phonogram in - digital form or other electronic medium. - -2. Fair Dealing Rights. Nothing in this License is intended to - reduce, limit, or restrict any uses free from copyright or rights - arising from limitations or exceptions that are provided for in - connection with the copyright protection under copyright law or - other applicable laws. - -3. License Grant. Subject to the terms and conditions of this - License, Licensor hereby grants You a worldwide, royalty-free, - non-exclusive, perpetual (for the duration of the applicable - copyright) license to exercise the rights in the Work as stated - below: - - a. to Reproduce the Work, to incorporate the Work into one or - more Collections, and to Reproduce the Work as incorporated - in the Collections; - - b. to create and Reproduce Adaptations provided that any such - Adaptation, including any translation in any medium, takes - reasonable steps to clearly label, demarcate or otherwise - identify that changes were made to the original Work. For - example, a translation could be marked "The original work was - translated from English to Spanish," or a modification could - indicate "The original work has been modified."; - - c. to Distribute and Publicly Perform the Work including as - incorporated in Collections; and, - - d. to Distribute and Publicly Perform Adaptations. - - e. For the avoidance of doubt: - - i. Non-waivable Compulsory License Schemes. In those - jurisdictions in which the right to collect royalties - through any statutory or compulsory licensing scheme cannot - be waived, the Licensor reserves the exclusive right to - collect such royalties for any exercise by You of the - rights granted under this License; - - ii. Waivable Compulsory License Schemes. In those - jurisdictions in which the right to collect royalties - through any statutory or compulsory licensing scheme can - be waived, the Licensor waives the exclusive right to - collect such royalties for any exercise by You of the - rights granted under this License; and, - - iii. Voluntary License Schemes. The Licensor waives the right - to collect royalties, whether individually or, in the - event that the Licensor is a member of a collecting - society that administers voluntary licensing schemes, via - that society, from any exercise by You of the rights - granted under this License. - -The above rights may be exercised in all media and formats whether -now known or hereafter devised. The above rights include the right -to make such modifications as are technically necessary to exercise -the rights in other media and formats. Subject to Section 8(f), all -rights not expressly granted by Licensor are hereby reserved. - -4. Restrictions. The license granted in Section 3 above is expressly - made subject to and limited by the following restrictions: - - a. You may Distribute or Publicly Perform the Work only under the - terms of this License. You must include a copy of, or the - Uniform Resource Identifier (URI) for, this License with every - copy of the Work You Distribute or Publicly Perform. You may - not offer or impose any terms on the Work that restrict the - terms of this License or the ability of the recipient of the - Work to exercise the rights granted to that recipient under - the terms of the License. You may not sublicense the Work. You - must keep intact all notices that refer to this License and to - the disclaimer of warranties with every copy of the Work You - Distribute or Publicly Perform. When You Distribute or - Publicly Perform the Work, You may not impose any effective - technological measures on the Work that restrict the ability - of a recipient of the Work from You to exercise the rights - granted to that recipient under the terms of the License. This - Section 4(a) applies to the Work as incorporated in a - Collection, but this does not require the Collection apart - from the Work itself to be made subject to the terms of this - License. If You create a Collection, upon notice from any - Licensor You must, to the extent practicable, remove from the - Collection any credit as required by Section 4(b), as - requested. If You create an Adaptation, upon notice from any - Licensor You must, to the extent practicable, remove from the - Adaptation any credit as required by Section 4(b), as requested. - - b. If You Distribute, or Publicly Perform the Work or any - Adaptations or Collections, You must, unless a request has - been made pursuant to Section 4(a), keep intact all copyright - notices for the Work and provide, reasonable to the medium or - means You are utilizing: (i) the name of the Original Author - (or pseudonym, if applicable) if supplied, and/or if the - Original Author and/or Licensor designate another party or - parties (e.g., a sponsor institute, publishing entity, - journal) for attribution ("Attribution Parties") in Licensor's - copyright notice, terms of service or by other reasonable - means, the name of such party or parties; (ii) the title of - the Work if supplied; (iii) to the extent reasonably - practicable, the URI, if any, that Licensor specifies to be - associated with the Work, unless such URI does not refer to - the copyright notice or licensing information for the Work; - and (iv), consistent with Section 3(b), in the case of an - Adaptation, a credit identifying the use of the Work in the - Adaptation (e.g., "French translation of the Work by Original - Author," or "Screenplay based on original Work by Original - Author"). The credit required by this Section 4 (b) may be - implemented in any reasonable manner; provided, however, that - in the case of a Adaptation or Collection, at a minimum such - credit will appear, if a credit for all contributing authors - of the Adaptation or Collection appears, then as part of these - credits and in a manner at least as prominent as the credits - for the other contributing authors. For the avoidance of - doubt, You may only use the credit required by this Section - for the purpose of attribution in the manner set out above - and, by exercising Your rights under this License, You may not - implicitly or explicitly assert or imply any connection with, - sponsorship or endorsement by the Original Author, Licensor - and/or Attribution Parties, as appropriate, of You or Your use - of the Work, without the separate, express prior written - permission of the Original Author, Licensor and/or - Attribution Parties. - - c. Except as otherwise agreed in writing by the Licensor or as - may be otherwise permitted by applicable law, if You - Reproduce, Distribute or Publicly Perform the Work either by - itself or as part of any Adaptations or Collections, You must - not distort, mutilate, modify or take other derogatory action - in relation to the Work which would be prejudicial to the - Original Author's honor or reputation. Licensor agrees that in - those jurisdictions (e.g. Japan), in which any exercise of the - right granted in Section 3(b) of this License (the right to - make Adaptations) would be deemed to be a distortion, - mutilation, modification or other derogatory action - prejudicial to the Original Author's honor and reputation, the - Licensor will waive or not assert, as appropriate, this - Section, to the fullest extent permitted by the applicable - national law, to enable You to reasonably exercise Your right - under Section 3(b) of this License (right to make Adaptations) - but not otherwise. - -5. Representations, Warranties and Disclaimer - -UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, -LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR -WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, -STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF -TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, -NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, -ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT -DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF -IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. - -6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY - APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY - LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE - OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF - THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY - OF SUCH DAMAGES. - -7. Termination - - a. This License and the rights granted hereunder will terminate - automatically upon any breach by You of the terms of this - License. Individuals or entities who have received Adaptations - or Collections from You under this License, however, will not - have their licenses terminated provided such individuals or - entities remain in full compliance with those licenses. - Sections 1, 2, 5, 6, 7, and 8 will survive any termination of - this License. - - b. Subject to the above terms and conditions, the license granted - here is perpetual (for the duration of the applicable - copyright in the Work). Notwithstanding the above, Licensor - reserves the right to release the Work under different license - terms or to stop distributing the Work at any time; provided, - however that any such election will not serve to withdraw this - License (or any other license that has been, or is required to - be, granted under the terms of this License), and this License - will continue in full force and effect unless terminated as - stated above. - -8. Miscellaneous - - a. Each time You Distribute or Publicly Perform the Work or a - Collection, the Licensor offers to the recipient a license to - the Work on the same terms and conditions as the license - granted to You under this License. - - b. Each time You Distribute or Publicly Perform an Adaptation, - Licensor offers to the recipient a license to the original - Work on the same terms and conditions as the license granted - to You under this License. - - c. If any provision of this License is invalid or unenforceable - under applicable law, it shall not affect the validity or - enforceability of the remainder of the terms of this License, - and without further action by the parties to this agreement, - such provision shall be reformed to the minimum extent - necessary to make such provision valid and enforceable. - - d. No term or provision of this License shall be deemed waived - and no breach consented to unless such waiver or consent shall - be in writing and signed by the party to be charged with such - waiver or consent. - - e. This License constitutes the entire agreement between the - parties with respect to the Work licensed here. There are no - understandings, agreements or representations with respect to - the Work not specified here. Licensor shall not be bound by - any additional provisions that may appear in any communication - from You. This License may not be modified without the mutual - written agreement of the Licensor and You. - - f. The rights granted under, and the subject matter referenced, - in this License were drafted utilizing the terminology of the - Berne Convention for the Protection of Literary and Artistic - Works (as amended on September 28, 1979), the Rome Convention - of 1961, the WIPO Copyright Treaty of 1996, the WIPO - Performances and Phonograms Treaty of 1996 and the Universal - Copyright Convention (as revised on July 24, 1971). These - rights and subject matter take effect in the relevant - jurisdiction in which the License terms are sought to be - enforced according to the corresponding provisions of the - implementation of those treaty provisions in the applicable - national law. If the standard suite of rights granted under - applicable copyright law includes additional rights not - granted under this License, such additional rights are deemed - to be included in the License; this License is not intended to - restrict the license of any rights under applicable law. - -Creative Commons is not a party to this License, and makes no -warranty whatsoever in connection with the Work. Creative Commons -will not be liable to You or any party on any legal theory for any -damages whatsoever, including without limitation any general, -special, incidental or consequential damages arising in connection -to this license. Notwithstanding the foregoing two (2) sentences, -if Creative Commons has expressly identified itself as the Licensor -hereunder, it shall have all rights and obligations of Licensor. - -Except for the limited purpose of indicating to the public that the -Work is licensed under the CCPL, Creative Commons does not authorize -the use by either party of the trademark "Creative Commons" or any -related trademark or logo of Creative Commons without the prior -written consent of Creative Commons. Any permitted use will be in -compliance with Creative Commons' then-current trademark usage -guidelines, as may be published on its website or otherwise made -available upon request from time to time. For the avoidance of -doubt, this trademark restriction does not form part of this -License. - -Creative Commons may be contacted at http://creativecommons.org/. - -==================================================================== - -The Debian packaging is -Copyright 2004-2006, Matthew Palmer -Copyright 2006-2007, Bart Martens -Copyright 2007-2009, Jose Carlos Medeiros -Copyright 2009, Ivan Borzenkov -and is licensed under the GPL, see `/usr/share/common-licenses/GPL-2'. +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: PHPUnit +Upstream-Contact: Sebastian Bergmann +Source: http://pear.phpunit.de/ + +Files: debian/* +Copyright: 2004-2006, Matthew Palmer + 2006-2007, Bart Martens + 2007-2009, Jose Carlos Medeiros + 2009, Ivan Borzenkov + 2012, Thomas Goirand +License: GPL-2 + +Files: * +Copyright: (c) 2009-2012, Sebastian Bergmann +License: BSD-3-clause + +License: BSD-3-clause + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + . + * 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 + distribution. + . + * Neither the name of Sebastian Bergmann nor the names of his + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +License: GPL-2 + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + . + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + St, Fifth Floor, Boston, MA 02110-1301 USA + . + On Debian systems, the complete text of the GNU General Public License v2 + (GPL) can be found in /usr/share/common-licenses/GPL-2. diff -Nru phpunit-3.5.5/debian/dirs phpunit-3.6.10/debian/dirs --- phpunit-3.5.5/debian/dirs 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/dirs 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -usr/share/php diff -Nru phpunit-3.5.5/debian/gbp.conf phpunit-3.6.10/debian/gbp.conf --- phpunit-3.5.5/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/debian/gbp.conf 2012-05-13 13:29:53.000000000 +0000 @@ -0,0 +1,6 @@ +[DEFAULT] +upstream-branch = upstream-sid +debian-branch = debian-sid + +[git-buildpackage] +export-dir = ../build-area/ diff -Nru phpunit-3.5.5/debian/getDoc.sh phpunit-3.6.10/debian/getDoc.sh --- phpunit-3.5.5/debian/getDoc.sh 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/getDoc.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -#!/bin/sh -wget -r -c -np -l0 -N -k http://www.phpunit.de/manual/3.5/en/index.html -mv www.phpunit.de/manual/3.5/en html -rm -rf www.phpunit.de -sed -i -e's|.*http://www.phpunit.de/manual/3.5/en/index.html.*||' html/*.html -mkdir doc -mv html doc/ -tar -cjf phpunit_ver.orig-doc.tar.bz2 doc diff -Nru phpunit-3.5.5/debian/install phpunit-3.6.10/debian/install --- phpunit-3.5.5/debian/install 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/install 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -PHPUnit-*/PHPUnit usr/share/php/ -PHPUnit-*/phpunit /usr/bin/ diff -Nru phpunit-3.5.5/debian/patches/01_channel.patch phpunit-3.6.10/debian/patches/01_channel.patch --- phpunit-3.5.5/debian/patches/01_channel.patch 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/debian/patches/01_channel.patch 2012-05-13 13:29:53.000000000 +0000 @@ -0,0 +1,24 @@ +Description: pear.phpunit.de channel info. PEAR needs to install this channel before install the PEAR package +Author: Luis Uribe +Index: php-text-template/channel.xml +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ php-text-template/channel.xml 2012-03-26 11:43:13.000000000 -0500 +@@ -0,0 +1,16 @@ ++ ++ ++ pear.phpunit.de ++ PHPUnit PEAR Channel ++ phpunit ++ ++ ++ ++ http://pear.phpunit.de/rest/ ++ http://pear.phpunit.de/rest/ ++ http://pear.phpunit.de/rest/ ++ http://pear.phpunit.de/rest/ ++ ++ ++ ++ +\ No newline at end of file diff -Nru phpunit-3.5.5/debian/patches/Removes-YUI-repport phpunit-3.6.10/debian/patches/Removes-YUI-repport --- phpunit-3.5.5/debian/patches/Removes-YUI-repport 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/debian/patches/Removes-YUI-repport 2012-05-13 13:29:53.000000000 +0000 @@ -0,0 +1,19 @@ +Description: Removes YUI repport +Author: Thomas Goirand +Forwarded: not-needed + +--- phpunit-3.6.10.orig/PHPUnit-3.6.10/PHPUnit/TextUI/TestRunner.php ++++ phpunit-3.6.10/PHPUnit-3.6.10/PHPUnit/TextUI/TestRunner.php +@@ -783,10 +783,10 @@ class PHPUnit_TextUI_TestRunner extends + $arguments['processIsolation'] = isset($arguments['processIsolation']) ? $arguments['processIsolation'] : FALSE; + $arguments['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : FALSE; + $arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'UTF-8'; +- $arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE; ++ $arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : TRUE; + $arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70; + $arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35; +- $arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : TRUE; ++ $arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : FALSE; + $arguments['stopOnError'] = isset($arguments['stopOnError']) ? $arguments['stopOnError'] : FALSE; + $arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE; + $arguments['stopOnIncomplete'] = isset($arguments['stopOnIncomplete']) ? $arguments['stopOnIncomplete'] : FALSE; diff -Nru phpunit-3.5.5/debian/patches/remove_yui.diff phpunit-3.6.10/debian/patches/remove_yui.diff --- phpunit-3.5.5/debian/patches/remove_yui.diff 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/patches/remove_yui.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ ---- a/PHPUnit-3.5.5/PHPUnit/TextUI/TestRunner.php -+++ b/PHPUnit-3.5.5/PHPUnit/TextUI/TestRunner.php -@@ -751,10 +751,10 @@ - $arguments['processIsolation'] = isset($arguments['processIsolation']) ? $arguments['processIsolation'] : FALSE; - $arguments['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : FALSE; - $arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'UTF-8'; -- $arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE; -+ $arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : TRUE; - $arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70; - $arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35; -- $arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : TRUE; -+ $arguments['reportYUI'] = FALSE; - $arguments['stopOnError'] = isset($arguments['stopOnError']) ? $arguments['stopOnError'] : FALSE; - $arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE; - $arguments['stopOnIncomplete'] = isset($arguments['stopOnIncomplete']) ? $arguments['stopOnIncomplete'] : FALSE; diff -Nru phpunit-3.5.5/debian/patches/removes-LICENSE-file-from-binary-packages phpunit-3.6.10/debian/patches/removes-LICENSE-file-from-binary-packages --- phpunit-3.5.5/debian/patches/removes-LICENSE-file-from-binary-packages 1970-01-01 00:00:00.000000000 +0000 +++ phpunit-3.6.10/debian/patches/removes-LICENSE-file-from-binary-packages 2012-05-13 13:29:53.000000000 +0000 @@ -0,0 +1,14 @@ +Description: Removes LICENSE file from binary package +Author: Thomas Goirand +Forwarded: no + +--- phpunit-3.6.10.orig/package.xml ++++ phpunit-3.6.10/package.xml +@@ -428,7 +428,6 @@ http://github.com/sebastianbergmann/phpu + + + +- + + + diff -Nru phpunit-3.5.5/debian/patches/series phpunit-3.6.10/debian/patches/series --- phpunit-3.5.5/debian/patches/series 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/patches/series 2012-05-13 13:29:53.000000000 +0000 @@ -1 +1,2 @@ -remove_yui.diff +Removes-YUI-repport +removes-LICENSE-file-from-binary-packages diff -Nru phpunit-3.5.5/debian/phpunit-doc.doc-base phpunit-3.6.10/debian/phpunit-doc.doc-base --- phpunit-3.5.5/debian/phpunit-doc.doc-base 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/phpunit-doc.doc-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -Document: phpunit-doc -Title: Phpunit Manual -Author: Sebastian Bergmann -Section: Text - -Format: HTML -Index: /usr/share/doc/phpunit-doc/html/index.html -Files: /usr/share/doc/phpunit-doc/html/*.html diff -Nru phpunit-3.5.5/debian/phpunit-doc.docs phpunit-3.6.10/debian/phpunit-doc.docs --- phpunit-3.5.5/debian/phpunit-doc.docs 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/phpunit-doc.docs 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -doc/* diff -Nru phpunit-3.5.5/debian/phpunit.1 phpunit-3.6.10/debian/phpunit.1 --- phpunit-3.5.5/debian/phpunit.1 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/phpunit.1 2012-05-13 13:29:53.000000000 +0000 @@ -1,20 +1,13 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.38.2. -.TH PHPUNIT "1" "June 2010" "PHPUnit 3.4.13 by Sebastian Bergmann." "User Commands" +.TH PHPUNIT "1" "February 2011" "PHPUnit 3.4.14 by Sebastian Bergmann." "User Commands" .SH NAME PHPUnit \- Unit testing suite for PHP .SH SYNOPSIS .B phpunit [\fIswitches\fR] \fIUnitTest \fR[\fIUnitTest.php\fR] .SH DESCRIPTION -PHPUnit is a unit testing suite for the PHP language, modelled on the xUnit -esting framework, designed by Kent Beck and Erich Gamma. If you've used -JUnit (for Java), PyUnit (for Python), CxxUnit (for C++), or any of the -other equivalents for other languages, the API for this package should seem -fairly familiar. If you've never written unit tests before, the PHPUnit -API is simple to learn and use. - -Detailed documentation can be found in the package phpunit-doc (/usr/share/doc/phpunit-doc/html/index.html) or visit http://www.phpunit.de/manual/3.4/en/index.html -.SH OPTIONS +PHPUnit 3.4.14 by Sebastian Bergmann. +.IP phpunit [switches] .TP \fB\-\-log\-junit\fR @@ -125,15 +118,3 @@ .TP \fB\-\-version\fR Prints the version and exits. -.SH "SEE ALSO" -The full documentation for -.B PHPUnit -is maintained as a Texinfo manual. If the -.B info -and -.B PHPUnit -programs are properly installed at your site, the command -.IP -.B info PHPUnit -.PP -should give you access to the complete manual. diff -Nru phpunit-3.5.5/debian/rules phpunit-3.6.10/debian/rules --- phpunit-3.5.5/debian/rules 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/rules 2012-05-13 13:29:53.000000000 +0000 @@ -1,17 +1,3 @@ #!/usr/bin/make -f - -include /usr/share/cdbs/1/rules/debhelper.mk - -pear_pkg = $(shell ls |grep PHPUnit-) - -update-config:: - cp $(pear_pkg)/phpunit.php $(pear_pkg)/phpunit - -reverse-config:: - rm -f $(pear_pkg)/phpunit - -common-binary-predeb-arch:: - find ./ | xargs touch $1 - -common-binary-predeb-indep:: - find ./ | xargs touch $1 +%: + dh $@ --buildsystem=phppear --with phppear diff -Nru phpunit-3.5.5/debian/watch phpunit-3.6.10/debian/watch --- phpunit-3.5.5/debian/watch 2010-12-11 15:19:06.000000000 +0000 +++ phpunit-3.6.10/debian/watch 2012-05-13 13:29:53.000000000 +0000 @@ -1,2 +1,2 @@ version=3 -http://pear.phpunit.de/ http://pear.phpunit.de/get/PHPUnit-([\d\.]+)\.tgz +https://github.com/sebastianbergmann/phpunit/tags /sebastianbergmann/phpunit/tarball/(.+) diff -Nru phpunit-3.5.5/doc/html/api.html phpunit-3.6.10/doc/html/api.html --- phpunit-3.5.5/doc/html/api.html 2010-09-27 16:52:12.000000000 +0000 +++ phpunit-3.6.10/doc/html/api.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,908 +0,0 @@ - - - - Chapter 21. PHPUnit API - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 21. PHPUnit API

- For most uses, PHPUnit has a simple API: subclass - PHPUnit_Framework_TestCase for your test cases and - call assertTrue() or assertEquals(). - However, for those of you who would like to look deeper into PHPUnit, - here are all of its published methods and classes. -

Overview

- Most of the time, you will encounter five classes or interfaces when you - are using PHPUnit: -

PHPUnit_Framework_Assert

- A collection of static methods for checking actual values against - expected values. -

PHPUnit_Framework_Test

- The interface of all objects that act like tests. -

PHPUnit_Framework_TestCase

- A single test. -

PHPUnit_Framework_TestSuite

- A collection of tests. -

PHPUnit_Framework_TestResult

- A summary of the results of running one or more tests. -

- Figure 21.1 - shows the relationship of the five basic classes and interfaces - in PHPUnit: PHPUnit_Framework_Assert, - PHPUnit_Framework_Test, - PHPUnit_Framework_TestCase, - PHPUnit_Framework_TestSuite, and - PHPUnit_Framework_TestResult. -

Figure 21.1. The five basic classes and interfaces in PHPUnit

The five basic classes and interfaces in PHPUnit


PHPUnit_Framework_Assert

- - - - Most test cases written for PHPUnit are derived indirectly from the class - PHPUnit_Framework_Assert, which contains methods for - automatically checking values and reporting discrepancies. The methods - are declared static, so you can write design-by-contract style - assertions in your methods and have them reported through PHPUnit - (Example 21.1). -

Example 21.1: Design-by-Contract Style Assertions

<?php
class Sample
{
    public function aSampleMethod($object)
    {
        PHPUnit_Framework_Assert::assertNotNull($object);
    }
}
 
$sample = new Sample;
$sample->aSampleMethod(NULL);
?>
Fatal error: Uncaught exception 'PHPUnit_Framework_ExpectationFailedException'
-with message 'Failed asserting that <null> is not identical to <null>.'


- Most of the time, though, you'll be checking the assertions inside of - tests. -

- There are two variants of each of the assertion methods: one takes a - message to be displayed with the error as a parameter, and one does not. - The optional message is typically displayed when a failure is displayed, - which can make debugging easier. -

Example 21.2: Using assertions with messages

<?php
class MessageTest extends PHPUnit_Framework_TestCase
{
    public function testMessage()
    {
        $this->assertTrue(FALSE, 'This is a custom message.');
    }
}
?>


- The following example shows the output you get when you run the - testMessage() test from - Example 21.2, using - assertions with messages: -

phpunit MessageTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) testMessage(MessageTest)
-This is a custom message.
-Failed asserting that <boolean:false> is true.
-/home/sb/MessageTest.php:8
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.

- Below are all the varieties of assertions. -

assertArrayHasKey()

assertArrayHasKey(mixed $key, array $array[, string $message = ''])

Reports an error identified by $message if $array does not have the $key.

assertArrayNotHasKey() is the inverse of this assertion and takes the same arguments.

Example 21.3: Usage of assertArrayHasKey()

<?php
class ArrayHasKeyTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertArrayHasKey('foo', array('bar' => 'baz'));
    }
}
?>
phpunit ArrayHasKeyTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) ArrayHasKeyTest::testFailure
-Failed asserting that an array has the key <string:foo>.
-/home/sb/ArrayHasKeyTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertClassHasAttribute()

assertClassHasAttribute(string $attributeName, string $className[, string $message = ''])

Reports an error identified by $message if $className::attributeName does not exist.

assertClassNotHasAttribute() is the inverse of this assertion and takes the same arguments.

Example 21.4: Usage of assertClassHasAttribute()

<?php
class ClassHasAttributeTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertClassHasAttribute('foo', 'stdClass');
    }
}
?>
phpunit ClassHasAttributeTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) ClassHasAttributeTest::testFailure
-Failed asserting that class "stdClass" has attribute "foo".
-/home/sb/ClassHasAttributeTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertClassHasStaticAttribute()

assertClassHasStaticAttribute(string $attributeName, string $className[, string $message = ''])

Reports an error identified by $message if $className::attributeName does not exist.

assertClassNotHasStaticAttribute() is the inverse of this assertion and takes the same arguments.

Example 21.5: Usage of assertClassHasStaticAttribute()

<?php
class ClassHasStaticAttributeTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertClassHasStaticAttribute('foo', 'stdClass');
    }
}
?>
phpunit ClassHasStaticAttributeTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) ClassHasStaticAttributeTest::testFailure
-Failed asserting that class "stdClass" has static attribute "foo".
-/home/sb/ClassHasStaticAttributeTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertContains()

assertContains(mixed $needle, Iterator|array $haystack[, string $message = ''])

Reports an error identified by $message if $needle is not an element of $haystack.

assertNotContains() is the inverse of this assertion and takes the same arguments.

assertAttributeContains() and assertAttributeNotContains() are convenience wrappers that use a public, protected, or private attribute of a class or object as the haystack.

Example 21.6: Usage of assertContains()

<?php
class ContainsTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertContains(4, array(1, 2, 3));
    }
}
?>
phpunit ContainsTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) ContainsTest::testFailure
-Failed asserting that an array contains <integer:4>.
-/home/sb/ContainsTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertContains(string $needle, string $haystack[, string $message = ''])

Reports an error identified by $message if $needle is not a substring of $haystack.

Example 21.7: Usage of assertContains()

<?php
class ContainsTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertContains('baz', 'foobar');
    }
}
?>
phpunit ContainsTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) ContainsTest::testFailure
-Failed asserting that <string:foobar> contains "baz".
-/home/sb/ContainsTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertContainsOnly()

assertContainsOnly(string $type, Iterator|array $haystack[, boolean $isNativeType = NULL, string $message = ''])

Reports an error identified by $message if $haystack does not contain only variables of type $type.

$isNativeType is a flag used to indicate whether $type is a native PHP type or not.

assertNotContainsOnly() is the inverse of this assertion and takes the same arguments.

assertAttributeContainsOnly() and assertAttributeNotContainsOnly() are convenience wrappers that use a public, protected, or private attribute of a class or object as the actual value.

Example 21.8: Usage of assertContainsOnly()

<?php
class ContainsOnlyTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertContainsOnly('string', array('1', '2', 3));
    }
}
?>
phpunit ContainsOnlyTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) ContainsOnlyTest::testFailure
-Failed asserting that 
-Array
-(
-    [0] => 1
-    [1] => 2
-    [2] => 3
-)
- contains only values of type "string".
-/home/sb/ContainsOnlyTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertEmpty()

assertEmpty(mixed $actual[, string $message = ''])

Reports an error identified by $message if $actual is not empty.

assertNotEmpty() is the inverse of this assertion and takes the same arguments.

assertAttributeEmpty() and assertAttributeNotEmpty() are convenience wrappers that can be applied to a public, protected, or private attribute of a class or object.

Example 21.9: Usage of assertEmpty()

<?php
class EmptyTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertEmpty(array('foo'));
    }
}
?>
phpunit EmptyTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) EmptyTest::testFailure
-Failed asserting that
-Array
-(
-    [0] => foo
-)
- is empty.
-
-/home/sb/EmptyTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertEqualXMLStructure()

assertEqualXMLStructure(DOMNode $expectedNode, DOMNode $actualNode[, boolean $checkAttributes = FALSE, string $message = ''])

XXX

Example 21.10: Usage of assertEqualXMLStructure()

<?php
?>
phpunit EqualXMLStructureTest
-


assertEquals()

assertEquals(mixed $expected, mixed $actual[, string $message = ''])

Reports an error identified by $message if the two variables $expected and $actual are not equal.

assertNotEquals() is the inverse of this assertion and takes the same arguments.

assertAttributeEquals() and assertAttributeNotEquals() are convenience wrappers that use a public, protected, or private attribute of a class or object as the actual value.

Example 21.11: Usage of assertEquals()

<?php
class EqualsTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertEquals(1, 0);
    }
 
    public function testFailure2()
    {
        $this->assertEquals('bar', 'baz');
    }
 
    public function testFailure3()
    {
        $this->assertEquals("foo\nbar\nbaz\n", "foo\nbah\nbaz\n");
    }
}
?>
phpunit EqualsTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-FFF
-
-Time: 0 seconds
-
-There were 3 failures:
-
-1) EqualsTest::testFailure
-Failed asserting that <integer:0> matches expected value <integer:1>.
-/home/sb/EqualsTest.php:11
-
-2) EqualsTest::testFailure2
-Failed asserting that two strings are equal.
-expected string <bar>
-difference      <  x>
-got string      <baz>
-/home/sb/EqualsTest.php:16
-
-3) EqualsTest::testFailure3
-Failed asserting that two strings are equal.
---- Expected
-+++ Actual
-@@ -1,3 +1,3 @@
- foo
--bar
-+bah
- baz
-
-/home/sb/EqualsTest.php:21
-
-FAILURES!
-Tests: 3, Assertions: 3, Failures: 3.


More specialized comparisons are used for specific argument types for $expected and $actual, see below.

assertEquals(float $expected, float $actual[, string $message = '', float $delta = 0])

Reports an error identified by $message if the two floats $expected and $actual are not within $delta of each other.

Please read about comparing floating-point numbers to understand why $delta is neccessary.

Example 21.12: Usage of assertEquals() with floats

<?php
class EqualsTest extends PHPUnit_Framework_TestCase
{
    public function testSuccess()
    {
        $this->assertEquals(1.0, 1.1, '', 0.2);
    }
 
    public function testFailure()
    {
        $this->assertEquals(1.0, 1.1);
    }
}
?>
phpunit EqualsTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-.F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) EqualsTest::testFailure
-Failed asserting that <double:1.1> matches expected value <double:1>.
-/home/sb/EqualsTest.php:11
-
-FAILURES!
-Tests: 2, Assertions: 2, Failures: 1.


assertEquals(DOMDocument $expected, DOMDocument $actual[, string $message = ''])

Reports an error identified by $message if the XML documents represented by the two DOMDocument objects $expected and $actual are not equal.

Example 21.13: Usage of assertEquals() with DOMDocument objects

<?php
class EqualsTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $expected = new DOMDocument;
        $expected->loadXML('<foo><bar/></foo>');
 
        $actual = new DOMDocument;
        $actual->loadXML('<bar><foo/></bar>');
 
        $this->assertEquals($expected, $actual);
    }
}
?>
phpunit EqualsTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) EqualsTest::testFailure
-Failed asserting that two strings are equal.
---- Expected
-+++ Actual
-@@ -1,4 +1,4 @@
- <?xml version="1.0"?>
--<foo>
--  <bar/>
--</foo>
-+<bar>
-+  <foo/>
-+</bar>
-
-/home/sb/EqualsTest.php:12
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertEquals(object $expected, object $actual[, string $message = ''])

Reports an error identified by $message if the two objects $expected and $actual do not have equal attribute values.

Example 21.14: Usage of assertEquals() with objects

<?php
class EqualsTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $expected = new stdClass;
        $expected->foo = 'foo';
        $expected->bar = 'bar';
 
        $actual = new stdClass;
        $actual->foo = 'bar';
        $actual->baz = 'bar';
 
        $this->assertEquals($expected, $actual);
    }
}
?>
phpunit EqualsTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) EqualsTest::testFailure
-Failed asserting that two objects are equal.
---- Expected
-+++ Actual
-@@ -1,5 +1,5 @@
- stdClass Object
- (
--    [foo] => foo
--    [bar] => bar
-+    [foo] => bar
-+    [baz] => bar
- )
-
-/home/sb/EqualsTest.php:14
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertEquals(array $expected, array $actual[, string $message = ''])

Reports an error identified by $message if the two arrays $expected and $actual are not equal.

Example 21.15: Usage of assertEquals() with arrays

<?php
class EqualsTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertEquals(array('a', 'b', 'c'), array('a', 'c', 'd'));
    }
}
?>
phpunit EqualsTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) EqualsTest::testFailure
-Failed asserting that two arrays are equal.
---- Expected
-+++ Actual
-@@ -1,6 +1,6 @@
- Array
- (
-     [0] => a
--    [1] => b
--    [2] => c
-+    [1] => c
-+    [2] => d
- )
-
-/home/sb/EqualsTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertFalse()

assertFalse(bool $condition[, string $message = ''])

Reports an error identified by $message if $condition is TRUE.

Example 21.16: Usage of assertFalse()

<?php
class FalseTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertFalse(TRUE);
    }
}
?>
phpunit FalseTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) FalseTest::testFailure
-Failed asserting that <boolean:true> is false.
-/home/sb/FalseTest.php:11
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertFileEquals()

assertFileEquals(string $expected, string $actual[, string $message = ''])

Reports an error identified by $message if the file specified by $expected does not have the same contents as the file specified by $actual.

assertFileNotEquals() is the inverse of this assertion and takes the same arguments.

Example 21.17: Usage of assertFileEquals()

<?php
class FileEqualsTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertFileEquals('/home/sb/expected', '/home/sb/actual');
    }
}
?>
phpunit FileEqualsTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) FileEqualsTest::testFailure
-Failed asserting that two strings are equal.
---- Expected
-+++ Actual
-@@ -1,2 +1,2 @@
--expected
-+actual
- 
-
-/home/sb/FileEqualsTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 3, Failures: 1.


assertFileExists()

assertFileExists(string $filename[, string $message = ''])

Reports an error identified by $message if the file specified by $filename does not exist.

assertFileNotExists() is the inverse of this assertion and takes the same arguments.

Example 21.18: Usage of assertFileExists()

<?php
class FileExistsTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertFileExists('/path/to/file');
    }
}
?>
phpunit FileExistsTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) FileExistsTest::testFailure
-Failed asserting that file "/path/to/file" exists.
-/home/sb/FileExistsTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertGreaterThan()

assertGreaterThan(mixed $expected, mixed $actual[, string $message = ''])

Reports an error identified by $message if the value of $actual is not greater than the value of $expected.

assertAttributeGreaterThan() is a convenience wrapper that uses a public, protected, or private attribute of a class or object as the actual value.

Example 21.19: Usage of assertGreaterThan()

<?php
class GreaterThanTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertGreaterThan(2, 1);
    }
}
?>
phpunit GreaterThanTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) GreaterThanTest::testFailure
-Failed asserting that <integer:1> is greater than <integer:2>.
-/home/sb/GreaterThanTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertGreaterThanOrEqual()

assertGreaterThanOrEqual(mixed $expected, mixed $actual[, string $message = ''])

Reports an error identified by $message if the value of $actual is not greater than or equal to the value of $expected.

assertAttributeGreaterThanOrEqual() is a convenience wrapper that uses a public, protected, or private attribute of a class or object as the actual value.

Example 21.20: Usage of assertGreaterThanOrEqual()

<?php
class GreatThanOrEqualTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertGreaterThanOrEqual(2, 1);
    }
}
?>
phpunit GreaterThanOrEqualTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) GreatThanOrEqualTest::testFailure
-Failed asserting that <integer:1> is equal to <integer:2> or is greater than <integer:2>.
-/home/sb/GreaterThanOrEqualTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertInstanceOf()

assertInstanceOf($expected, $actual[, $message = ''])

Reports an error identified by $message if $actual is not an instance of $expected.

assertNotInstanceOf() is the inverse of this assertion and takes the same arguments.

assertAttributeInstanceOf() and assertAttributeNotInstanceOf() are convenience wrappers that can be applied to a public, protected, or private attribute of a class or object.

Example 21.21: Usage of assertInstanceOf()

<?php
class InstanceOfTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertInstanceOf('RuntimeException', new Exception);
    }
}
?>
phpunit InstanceOfTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) InstanceOfTest::testFailure
-Failed asserting that <Exception> is an instance of class "RuntimeException".
-/home/sb/InstanceOfTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertInternalType()

assertInternalType($expected, $actual[, $message = ''])

Reports an error identified by $message if $actual is not of the $expected type.

assertNotInternalType() is the inverse of this assertion and takes the same arguments.

assertAttributeInternalType() and assertAttributeNotInternalType() are convenience wrappers that can be applied to a public, protected, or private attribute of a class or object.

Example 21.22: Usage of assertInternalType()

<?php
class InternalTypeTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertInternalType('string', 42);
    }
}
?>
phpunit InternalTypeTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) InternalTypeTest::testFailure
-Failed asserting that <integer:42> is of type "string".
-/home/sb/InstanceOfTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertLessThan()

assertLessThan(mixed $expected, mixed $actual[, string $message = ''])

Reports an error identified by $message if the value of $actual is not less than the value of $expected.

assertAttributeLessThan() is a convenience wrapper that uses a public, protected, or private attribute of a class or object as the actual value.

Example 21.23: Usage of assertLessThan()

<?php
class LessThanTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertLessThan(1, 2);
    }
}
?>
phpunit LessThanTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) LessThanTest::testFailure
-Failed asserting that <integer:2> is less than <integer:1>.
-/home/sb/LessThanTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertLessThanOrEqual()

assertLessThanOrEqual(mixed $expected, mixed $actual[, string $message = ''])

Reports an error identified by $message if the value of $actual is not less than or equal to the value of $expected.

assertAttributeLessThanOrEqual() is a convenience wrapper that uses a public, protected, or private attribute of a class or object as the actual value.

Example 21.24: Usage of assertLessThanOrEqual()

<?php
class LessThanOrEqualTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertLessThanOrEqual(1, 2);
    }
}
?>
phpunit LessThanOrEqualTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) LessThanOrEqualTest::testFailure
-Failed asserting that <integer:2> is equal to <integer:1> or is less than <integer:1>.
-/home/sb/LessThanOrEqualTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertNull()

assertNull(mixed $variable[, string $message = ''])

Reports an error identified by $message if $variable is not NULL.

assertNotNull() is the inverse of this assertion and takes the same arguments.

Example 21.25: Usage of assertNull()

<?php
class NullTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertNull('foo');
    }
}
?>
phpunit NotNullTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) NullTest::testFailure
-Failed asserting that <string:foo> is null.
-/home/sb/NullTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertObjectHasAttribute()

assertObjectHasAttribute(string $attributeName, object $object[, string $message = ''])

Reports an error identified by $message if $object->attributeName does not exist.

assertObjectNotHasAttribute() is the inverse of this assertion and takes the same arguments.

Example 21.26: Usage of assertObjectHasAttribute()

<?php
class ObjectHasAttributeTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertObjectHasAttribute('foo', new stdClass);
    }
}
?>
phpunit ObjectHasAttributeTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) ObjectHasAttributeTest::testFailure
-Failed asserting that object of class "stdClass" has attribute "foo".
-/home/sb/ObjectHasAttributeTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertRegExp()

assertRegExp(string $pattern, string $string[, string $message = ''])

Reports an error identified by $message if $string does not match the regular expression $pattern.

assertNotRegExp() is the inverse of this assertion and takes the same arguments.

Example 21.27: Usage of assertRegExp()

<?php
class RegExpTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertRegExp('/foo/', 'bar');
    }
}
?>
phpunit RegExpTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) RegExpTest::testFailure
-Failed asserting that <string:bar> matches PCRE pattern "/foo/".
-/home/sb/RegExpTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertStringMatchesFormat()

assertStringMatchesFormat(string $format, string $string[, string $message = ''])

Reports an error identified by $message if the $string does not match the $format string.

assertStringNotMatchesFormat() is the inverse of this assertion and takes the same arguments.

Example 21.28: Usage of assertStringMatchesFormat()

<?php
class StringMatchesFormatTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertStringMatchesFormat('%i', 'foo');
    }
}
?>
phpunit StringMatchesFormatTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) StringMatchesFormatTest::testFailure
-Failed asserting that two strings are equal.
---- Expected
-+++ Actual
-@@ @@
--%i
-+foo
-
-/home/sb/StringMatchesFormatTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


The format string may contain the following placeholders:

  • %e: Represents a directory separator, for example / on Linux.

  • %s: One or more of anything (character or white space) except the end of line character.

  • %S: Zero or more of anything (character or white space) except the end of line character.

  • %a: One or more of anything (character or white space) including the end of line character.

  • %A: Zero or more of anything (character or white space) including the end of line character.

  • %w: Zero or more white space characters.

  • %i: A signed integer value, for example +3142, -3142.

  • %d: An unsigned integer value, for example 123456.

  • %x: One or more hexadecimal character. That is, characters in the range 0-9, a-f, A-F.

  • %f: A floating point number, for example: 3.142, -3.142, 3.142E-10, 3.142e+10.

  • %c: A single character of any sort.

assertStringMatchesFormatFile()

assertStringMatchesFormatFile(string $formatFile, string $string[, string $message = ''])

Reports an error identified by $message if the $string does not match the contents of the $formatFile.

assertStringNotMatchesFormatFile() is the inverse of this assertion and takes the same arguments.

Example 21.29: Usage of assertStringMatchesFormatFile()

<?php
class StringMatchesFormatFileTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertStringMatchesFormatFile('/path/to/expected.txt', 'foo');
    }
}
?>
phpunit StringMatchesFormatFileTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) StringMatchesFormatFileTest::testFailure
-Failed asserting that two strings are equal.
---- Expected
-+++ Actual
-@@ @@
--%i
-+foo
-
-/home/sb/StringMatchesFormatFileTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertSame()

assertSame(mixed $expected, mixed $actual[, string $message = ''])

Reports an error identified by $message if the two variables $expected and $actual do not have the same type and value.

assertNotSame() is the inverse of this assertion and takes the same arguments.

assertAttributeSame() and assertAttributeNotSame() are convenience wrappers that use a public, protected, or private attribute of a class or object as the actual value.

Example 21.30: Usage of assertSame()

<?php
class SameTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertSame('2204', 2204);
    }
}
?>
phpunit SameTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) SameTest::testFailure
-<integer:2204> does not match expected type "string".
-/home/sb/SameTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertSame(object $expected, object $actual[, string $message = ''])

Reports an error identified by $message if the two variables $expected and $actual do not reference the same object.

Example 21.31: Usage of assertSame() with objects

<?php
class SameTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertSame(new stdClass, new stdClass);
    }
}
?>
phpunit SameTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) SameTest::testFailure
-Failed asserting that two variables reference the same object.
-/home/sb/SameTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertSelectCount()

assertSelectCount(array $selector, integer $count, mixed $actual[, string $message = '', boolean $isHtml = TRUE])

XXX

Example 21.32: Usage of assertSelectCount()

<?php
?>
phpunit SelectCountTest
-


assertSelectEquals()

assertSelectEquals(array $selector, string $content, integer $count, mixed $actual[, string $message = '', boolean $isHtml = TRUE])

XXX

Example 21.33: Usage of assertSelectEquals()

<?php
?>
phpunit SelectEqualsTest
-


assertSelectRegExp()

assertSelectRegExp(array $selector, string $pattern, integer $count, mixed $actual[, string $message = '', boolean $isHtml = TRUE])

XXX

Example 21.34: Usage of assertSelectRegExp()

<?php
?>
phpunit SelectRegExpTest
-


assertStringEndsWith()

assertStringEndsWith(string $suffix, string $string[, string $message = ''])

Reports an error identified by $message if the $string does not end with $suffix.

assertStringEndsNotWith() is the inverse of this assertion and takes the same arguments.

Example 21.35: Usage of assertStringEndsWith()

<?php
class StringEndsWithTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertStringEndsWith('suffix', 'foo');
    }
}
?>
phpunit StringEndsWithTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) StringEndsWithTest::testFailure
-Failed asserting that <string:foo> ends with "suffix".
-/home/sb/StringEndsWithTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertStringEqualsFile()

assertStringEqualsFile(string $expectedFile, string $actualString[, string $message = ''])

Reports an error identified by $message if the file specified by $expectedFile does not have $actualString as its contents.

assertStringNotEqualsFile() is the inverse of this assertion and takes the same arguments.

Example 21.36: Usage of assertStringEqualsFile()

<?php
class StringEqualsFileTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertStringEqualsFile('/home/sb/expected', 'actual');
    }
}
?>
phpunit StringEqualsFileTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) StringEqualsFileTest::testFailure
-Failed asserting that two strings are equal.
---- Expected
-+++ Actual
-@@ -1,2 +1 @@
--expected
--
-+actual
-\ No newline at end of file
-
-/home/sb/StringEqualsFileTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 2, Failures: 1.


assertStringStartsWith()

assertStringStartsWith(string $prefix, string $string[, string $message = ''])

Reports an error identified by $message if the $string does not start with $prefix.

assertStringStartsNotWith() is the inverse of this assertion and takes the same arguments.

Example 21.37: Usage of assertStringStartsWith()

<?php
class StringStartsWithTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertStringStartsWith('prefix', 'foo');
    }
}
?>
phpunit StringStartsWithTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) StringStartsWithTest::testFailure
-Failed asserting that <string:foo> starts with "prefix".
-/home/sb/StringStartsWithTest.php:6
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertTag()

assertTag(array $matcher, string $actual[, string $message = '', boolean $isHtml = TRUE])

Reports an error identified by $message if $actual is not matched by the $matcher.

$matcher is an associative array that specifies the match criteria for the assertion:

  • id: The node with the given id attribute must match the corresponsing value.
  • tags: The node type must match the corresponding value.
  • attributes: The node's attributes must match the corresponsing values in the $attributes associative array.
  • content: The text content must match the given value.
  • parent: The node's parent must match the $parent associative array.
  • child: At least one of the node's immediate children must meet the criteria described by the $child associative array.
  • ancestor: At least one of the node's ancestors must meet the criteria described by the $ancestor associative array.
  • descendant: At least one of the node's descendants must meet the criteria described by the $descendant associative array.
  • children: Associative array for counting children of a node. -
    • count: The number of matching children must be equal to this number.
    • less_than: The number of matching children must be less than this number.
    • greater_than: The number of matching children must be greater than this number.
    • only: Another associative array consisting of the keys to use to match on the children, and only matching children will be counted.

assertNotTag() is the inverse of this assertion and takes the same arguments.

Example 21.38: Usage of assertTag()

<?php
// Matcher that asserts that there is an element with an id="my_id".
$matcher = array('id' => 'my_id');
 
// Matcher that asserts that there is a "span" tag.
$matcher = array('tag' => 'span');
 
// Matcher that asserts that there is a "span" tag with the content
// "Hello World".
$matcher = array('tag' => 'span', 'content' => 'Hello World');
 
// Matcher that asserts that there is a "span" tag with content matching the
// regular expression pattern.
$matcher = array('tag' => 'span', 'content' => '/Try P(HP|ython)/');
 
// Matcher that asserts that there is a "span" with an "list" class attribute.
$matcher = array(
  'tag'        => 'span',
  'attributes' => array('class' => 'list')
);
 
// Matcher that asserts that there is a "span" inside of a "div".
$matcher = array(
  'tag'    => 'span',
  'parent' => array('tag' => 'div')
);
 
// Matcher that asserts that there is a "span" somewhere inside a "table".
$matcher = array(
  'tag'      => 'span',
  'ancestor' => array('tag' => 'table')
);
 
// Matcher that asserts that there is a "span" with at least one "em" child.
$matcher = array(
  'tag'   => 'span',
  'child' => array('tag' => 'em')
);
 
// Matcher that asserts that there is a "span" containing a (possibly nested)
// "strong" tag.
$matcher = array(
  'tag'        => 'span',
  'descendant' => array('tag' => 'strong')
);
 
// Matcher that asserts that there is a "span" containing 5-10 "em" tags as
// immediate children.
$matcher = array(
  'tag'      => 'span',
  'children' => array(
    'less_than'    => 11,
    'greater_than' => 4,
    'only'         => array('tag' => 'em')
  )
);
 
// Matcher that asserts that there is a "div", with an "ul" ancestor and a "li"
// parent (with class="enum"), and containing a "span" descendant that contains
// an element with id="my_test" and the text "Hello World".
$matcher = array(
  'tag'        => 'div',
  'ancestor'   => array('tag' => 'ul'),
  'parent'     => array(
    'tag'        => 'li',
    'attributes' => array('class' => 'enum')
  ),
  'descendant' => array(
    'tag'   => 'span',
    'child' => array(
      'id'      => 'my_test',
      'content' => 'Hello World'
    )
  )
);
 
// Use assertTag() to apply a $matcher to a piece of $html.
$this->assertTag($matcher, $html);
 
// Use assertTag() to apply a $matcher to a piece of $xml.
$this->assertTag($matcher, $xml, '', FALSE);
?>


assertThat()

- More complex assertions can be formulated using the - PHPUnit_Framework_Constraint classes. They can be - evaluated using the assertThat() method. - Example 21.39 shows how the - logicalNot() and equalTo() - constraints can be used to express the same assertion as - assertNotEquals(). -

assertThat(mixed $value, PHPUnit_Framework_Constraint $constraint[, $message = ''])

Reports an error identified by $message if the $value does not match the $constraint.

Example 21.39: Usage of assertThat()

<?php
class BiscuitTest extends PHPUnit_Framework_TestCase
{
    public function testEquals()
    {
        $theBiscuit = new Biscuit('Ginger');
        $myBiscuit  = new Biscuit('Ginger');
 
        $this->assertThat(
          $theBiscuit,
          $this->logicalNot(
            $this->equalTo($myBiscuit)
          )
        );
    }
}
?>


- Table 21.1 shows the - available PHPUnit_Framework_Constraint classes. -

Table 21.1. Constraints

ConstraintMeaning
PHPUnit_Framework_Constraint_Attribute attribute(PHPUnit_Framework_Constraint $constraint, $attributeName)Constraint that applies another constraint to an attribute of a class or an object.
PHPUnit_Framework_Constraint_IsAnything anything()Constraint that accepts any input value.
PHPUnit_Framework_Constraint_ArrayHasKey arrayHasKey(mixed $key)Constraint that asserts that the array it is evaluated for has a given key.
PHPUnit_Framework_Constraint_TraversableContains contains(mixed $value)Constraint that asserts that the array or object that implements the Iterator interface it is evaluated for contains a given value.
PHPUnit_Framework_Constraint_IsEqual equalTo($value, $delta = 0, $maxDepth = 10)Constraint that checks if one value is equal to another.
PHPUnit_Framework_Constraint_Attribute attributeEqualTo($attributeName, $value, $delta = 0, $maxDepth = 10)Constraint that checks if a value is equal to an attribute of a class or of an object.
PHPUnit_Framework_Constraint_FileExists fileExists()Constraint that checks if the file(name) that it is evaluated for exists.
PHPUnit_Framework_Constraint_GreaterThan greaterThan(mixed $value)Constraint that asserts that the value it is evaluated for is greater than a given value.
PHPUnit_Framework_Constraint_Or greaterThanOrEqual(mixed $value)Constraint that asserts that the value it is evaluated for is greater than or equal to a given value.
PHPUnit_Framework_Constraint_ClassHasAttribute classHasAttribute(string $attributeName)Constraint that asserts that the class it is evaluated for has a given attribute.
PHPUnit_Framework_Constraint_ClassHasStaticAttribute classHasStaticAttribute(string $attributeName)Constraint that asserts that the class it is evaluated for has a given static attribute.
PHPUnit_Framework_Constraint_ObjectHasAttribute hasAttribute(string $attributeName)Constraint that asserts that the object it is evaluated for has a given attribute.
PHPUnit_Framework_Constraint_IsIdentical identicalTo(mixed $value)Constraint that asserts that one value is identical to another.
PHPUnit_Framework_Constraint_IsFalse isFalse()Constraint that asserts that the value it is evaluated is FALSE.
PHPUnit_Framework_Constraint_IsInstanceOf isInstanceOf(string $className)Constraint that asserts that the object it is evaluated for is an instance of a given class.
PHPUnit_Framework_Constraint_IsNull isNull()Constraint that asserts that the value it is evaluated is NULL.
PHPUnit_Framework_Constraint_IsTrue isTrue()Constraint that asserts that the value it is evaluated is TRUE.
PHPUnit_Framework_Constraint_IsType isType(string $type)Constraint that asserts that the value it is evaluated for is of a specified type.
PHPUnit_Framework_Constraint_LessThan lessThan(mixed $value)Constraint that asserts that the value it is evaluated for is smaller than a given value.
PHPUnit_Framework_Constraint_Or lessThanOrEqual(mixed $value)Constraint that asserts that the value it is evaluated for is smaller than or equal to a given value.
logicalAnd()Logical AND.
logicalNot(PHPUnit_Framework_Constraint $constraint)Logical NOT.
logicalOr()Logical OR.
logicalXor()Logical XOR.
PHPUnit_Framework_Constraint_PCREMatch matchesRegularExpression(string $pattern)Constraint that asserts that the string it is evaluated for matches a regular expression.
PHPUnit_Framework_Constraint_StringContains stringContains(string $string, bool $case)Constraint that asserts that the string it is evaluated for contains a given string.
PHPUnit_Framework_Constraint_StringEndsWith stringEndsWith(string $suffix)Constraint that asserts that the string it is evaluated for ends with a given suffix.
PHPUnit_Framework_Constraint_StringStartsWith stringStartsWith(string $prefix)Constraint that asserts that the string it is evaluated for starts with a given prefix.


assertTrue()

assertTrue(bool $condition[, string $message = ''])

Reports an error identified by $message if $condition is FALSE.

Example 21.40: Usage of assertTrue()

<?php
class TrueTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertTrue(FALSE);
    }
}
?>
phpunit TrueTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) TrueTest::testFailure
-Failed asserting that <boolean:false> is true.
-/home/sb/TrueTest.php:11
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


assertType()

assertType(string $expected, mixed $actual[, string $message = ''])

Reports an error identified by $message if the variable $actual is not of type $expected.

$expected can be one of these constants:

  • PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY ("array")
  • PHPUnit_Framework_Constraint_IsType::TYPE_BOOL ("bool")
  • PHPUnit_Framework_Constraint_IsType::TYPE_FLOAT ("float")
  • PHPUnit_Framework_Constraint_IsType::TYPE_INT ("int")
  • PHPUnit_Framework_Constraint_IsType::TYPE_NULL ("null")
  • PHPUnit_Framework_Constraint_IsType::TYPE_NUMERIC ("numeric")
  • PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT ("object")
  • PHPUnit_Framework_Constraint_IsType::TYPE_RESOURCE ("resource")
  • PHPUnit_Framework_Constraint_IsType::TYPE_STRING ("string")

assertNotType() is the inverse of this assertion and takes the same arguments.

assertAttributeType() and assertAttributeNotType() are convenience wrappers that use a public, protected, or private attribute of a class or object as the actual value.

Example 21.41: Usage of assertType()

<?php
class TypeTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, 2204);
    }
 
    public function testFailure2()
    {
        $this->assertType('string', 2204);
    }
 
    public function testFailure3()
    {
        $this->assertType('Exception', new stdClass);
    }
}
?>
phpunit TypeTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-FFF
-
-Time: 0 seconds
-
-There were 3 failures:
-
-1) TypeTest::testFailure
-Failed asserting that <integer:2204> is of type "string".
-/home/sb/TypeTest.php:6
-
-2) TypeTest::testFailure2
-Failed asserting that <integer:2204> is of type "string".
-/home/sb/TypeTest.php:11
-
-3) TypeTest::testFailure3
-Failed asserting that <stdClass> is an instance of class "Exception".
-/home/sb/TypeTest.php:16
-
-FAILURES!
-Tests: 3, Assertions: 3, Failures: 3.


assertXmlFileEqualsXmlFile()

assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile[, string $message = ''])

Reports an error identified by $message if the XML document in $actualFile is not equal to the XML document in $expectedFile.

assertXmlFileNotEqualsXmlFile() is the inverse of this assertion and takes the same arguments.

Example 21.42: Usage of assertXmlFileEqualsXmlFile()

<?php
class XmlFileEqualsXmlFileTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertXmlFileEqualsXmlFile(
          '/home/sb/expected.xml', '/home/sb/actual.xml');
    }
}
?>
phpunit XmlFileEqualsXmlFileTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) XmlFileEqualsXmlFileTest::testFailure
-Failed asserting that two strings are equal.
---- Expected
-+++ Actual
-@@ -1,4 +1,4 @@
- <?xml version="1.0"?>
- <foo>
--  <bar/>
-+  <baz/>
- </foo>
-
-/home/sb/XmlFileEqualsXmlFileTest.php:7
-
-FAILURES!
-Tests: 1, Assertions: 3, Failures: 1.


assertXmlStringEqualsXmlFile()

assertXmlStringEqualsXmlFile(string $expectedFile, string $actualXml[, string $message = ''])

Reports an error identified by $message if the XML document in $actualXml is not equal to the XML document in $expectedFile.

assertXmlStringNotEqualsXmlFile() is the inverse of this assertion and takes the same arguments.

Example 21.43: Usage of assertXmlStringEqualsXmlFile()

<?php
class XmlStringEqualsXmlFileTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertXmlStringEqualsXmlFile(
          '/home/sb/expected.xml', '<foo><baz/></foo>');
    }
}
?>
phpunit XmlStringEqualsXmlFileTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) XmlStringEqualsXmlFileTest::testFailure
-Failed asserting that two strings are equal.
---- Expected
-+++ Actual
-@@ -1,4 +1,4 @@
- <?xml version="1.0"?>
- <foo>
--  <bar/>
-+  <baz/>
- </foo>
-
-/home/sb/XmlStringEqualsXmlFileTest.php:7
-
-FAILURES!
-Tests: 1, Assertions: 2, Failures: 1.


assertXmlStringEqualsXmlString()

assertXmlStringEqualsXmlString(string $expectedXml, string $actualXml[, string $message = ''])

Reports an error identified by $message if the XML document in $actualXml is not equal to the XML document in $expectedXml.

assertXmlStringNotEqualsXmlString() is the inverse of this assertion and takes the same arguments.

Example 21.44: Usage of assertXmlStringEqualsXmlString()

<?php
class XmlStringEqualsXmlStringTest extends PHPUnit_Framework_TestCase
{
    public function testFailure()
    {
        $this->assertXmlStringEqualsXmlString(
          '<foo><bar/></foo>', '<foo><baz/></foo>');
    }
}
?>
phpunit XmlStringEqualsXmlStringTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) XmlStringEqualsXmlStringTest::testFailure
-Failed asserting that two strings are equal.
---- Expected
-+++ Actual
-@@ -1,4 +1,4 @@
- <?xml version="1.0"?>
- <foo>
--  <bar/>
-+  <baz/>
- </foo>
-
-/home/sb/XmlStringEqualsXmlStringTest.php:7
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


- You may find that you need other assertions than these to compare - objects specific to your project. Create your own Assert - class to contain these assertions to simplify your tests. -

- Failing assertions all call a single bottleneck method, - fail(string $message), which throws an - PHPUnit_Framework_AssertionFailedError. There is - also a variant which takes no parameters. Call fail() - explicitly when your test encounters an error. The test for an expected - exception is an example. - Table 21.2 lists the - bottlenext methods in PHPUnit. -

Table 21.2. Bottleneck Methods

MethodMeaning
void fail()Reports an error.
void fail(string $message)Reports an error identified by $message.


- - - - markTestIncomplete() and markTestSkipped() - are convenience methods for marking a test as being incomplete or skipped. -

Table 21.3. Marking a test as being incomplete or skipped

MethodMeaning
void markTestIncomplete(string $message)Marks the current test as being incomplete, $message is optional.
void markTestSkipped(string $message)Marks the current test as being skipped, $message is optional.


- Although unit tests are about testing the public interface of a class, you - may sometimes want to test the values of non-public attributes. The - readAttribute() method enables you to do this and - returns the value of a given (static) attribute from a given class or - object. -

Table 21.4. Accessing non-public attributes

MethodMeaning
Mixed readAttribute($classOrObject, $attributeName)Returns the value of a given (static) attribute ($attributeName) of a class or of an object. This also works for attributes that are declared protected or private.


PHPUnit_Framework_Test

- PHPUnit_Framework_Test is the generic interface - used by all objects that can act as tests. Implementors may represent - one or more tests. The two methods are shown in - Table 21.5. -

Table 21.5. Implementor Methods

MethodMeaning
int count()Return the number of tests.
void run(PHPUnit_Framework_TestResult $result)Run the tests and report the results on $result.


- PHPUnit_Framework_TestCase and - PHPUnit_Framework_TestSuite are the two most - prominent implementors of PHPUnit_Framework_Test. - You can implement PHPUnit_Framework_Test yourself. - The interface is kept small intentionally so it will be easy to - implement. -

PHPUnit_Framework_TestCase

- Your test case classes will inherit from - PHPUnit_Framework_TestCase. Most of the time, you - will run tests from automatically created test suites. In this case, - each of your tests should be represented by a method named - test* (by convention). -

- PHPUnit_Framework_TestCase implements - PHPUnit_Framework_Test::count() so that it - always returns 1. The implementation of - PHPUnit_Framework_Test::run(PHPUnit_Framework_TestResult $result) - in this class runs setUp(), runs the test method, - and then runs tearDown(), reporting any exceptions - to the PHPUnit_Framework_TestResult. -

- Table 21.6 shows the - methods provided by PHPUnit_Framework_TestCase. -

Table 21.6. TestCase

MethodMeaning
__construct()Creates a test case.
__construct(string $name)Creates a named test case. Names are used to print the test case and often as the name of the test method to be run by reflection.
string getName()Return the name of the test case.
void setName($name)Set the name of the test case.
PHPUnit_Framework_TestResult run(PHPUnit_Framework_TestResult $result)Convenience method to run the test case and report it in $result.
void runTest()Override with a testing method if you do not want the testing method to be invoked by reflection.
object getMock($originalClassName, [array $methods, [array $arguments, [string $mockClassName, [boolean $callOriginalConstructor, [boolean $callOriginalClone, [boolean $callAutoload]]]]]])Returns a mock object (see Chapter 11) for the class specified by $originalClassName. By default, all methods of the given class are mocked. When the second (optional) parameter is provided, only the methods whose names are in the array are mocked. The third (optional) parameter may hold a parameter array that is passed to the mock object's constructor. The fourth (optional) parameter can be used to specify a class name for the mock object. The fifth (optional) parameter can be used to disable the call to the original object's __construct() method. The sixth (optional) parameter can be used to disable the call to the original object's __clone() method. The seventh (optional) parameter can be used to disable __autoload() during mock object creation.
object getMockForAbstractClass($originalClassName, [array $arguments, [string $mockClassName, [boolean $callOriginalConstructor, [boolean $callOriginalClone, [boolean $callAutoload]]]]])Returns a mock object (see Chapter 11) for the abstract class specified by $originalClassName. All abstract methods of the given abstract class are mocked. This allows for testing the concrete methods of an abstract class.
object getMockFromWsdl($wsdlFile, [string $originalClassName, [string $mockClassName, [array $methods, [boolean $callOriginalConstructor)Returns a mock object (see Chapter 11) for the SOAP web services described in $wsdlFile.
void iniSet(string $varName, mixed $newValue)This method is a wrapper for the ini_set() function that automatically resets the modified php.ini setting to its original value after the test is run.
void setLocale(integer $category, string $locale, ...)This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.


- There are two template methods -- setUp() and - tearDown() -- you can override to create and - dispose of the objects against which you are going to test. - Table 21.7 shows - these methods. The template methods assertPreConditions() - and assertPostConditions() can be used to define - assertions that should be performed by all tests of a test case class. -

Table 21.7. Template Methods

MethodMeaning
void setUp()Override to set up the fixture, for example create an object graph.
void assertPreConditions()Override to perform assertions shared by all tests of a test case class. This method is called before the execution of a test starts and after setUp() is called.
void assertPostConditions()Override to perform assertions shared by all tests of a test case class. This method is called before the execution of a test ends and before tearDown() is called.
void tearDown()Override to tear down the fixture, for example clean up an object graph.


PHPUnit_Framework_TestSuite

- A PHPUnit_Framework_TestSuite is a composite of - PHPUnit_Framework_Tests. At its simplest, it - contains a bunch of test cases, all of which are run when the suite is - run. Since it is a composite, however, a suite can contain suites which - can contain suites and so on, making it easy to combine tests from - various sources and run them together. -

- In addition to the PHPUnit_Framework_Test methods -- - run(PHPUnit_Framework_TestResult $result) and - count() -- PHPUnit_Framework_TestSuite - provides methods to create named or unnamed instances. - Table 21.8 shows the - methods to create PHPUnit_Framework_TestSuite - instances. -

Table 21.8. Creating named or unnamed instances

MethodMeaning
__construct()Return an empty test suite.
__construct(string $theClass)Return a test suite containing an instance of the class named $theClass for each method in the class named test*. If no class of name $theClass exists an empty test suite named $theClass is returned.
__construct(string $theClass, string $name)Return a test suite named $name containing an instance of the class named $theClass for each method in the class named test*.
__construct(ReflectionClass $theClass)Return a test suite containing an instance of the class represented by $theClass for each method in the class named test*.
__construct(ReflectionClass $theClass, $name)Return a test suite named $name containing an instance of the class represented by $theClass for each method in the class named test*.
string getName()Return the name of the test suite.
void setName(string $name)Set the name of the test suite.
void markTestSuiteSkipped(string $message)Marks the current test suite as being skipped, $message is optional.


- PHPUnit_Framework_TestSuite also provides methods - for adding and retrieving PHPUnit_Framework_Tests, - as shown in Table 21.9. -

Table 21.9. Adding and retrieving tests

MethodMeaning
void addTestSuite(PHPUnit_Framework_TestSuite $suite)Add another test suite to the test suite.
void addTestSuite(string $theClass)Add a test suite containing an instance of the class named $theClass for each method in the class named test* to the test suite.
void addTestSuite(ReflectionClass $theClass)Add a test suite containing an instance of the class represented by $theClass for each method in the class named test* to the test suite.
void addTest(PHPUnit_Framework_Test $test)Add $test to the suite.
void addTestFile(string $filename)Add the tests that are defined in the class(es) of a given sourcefile to the suite.
void addTestFiles(array $filenames)Add the tests that are defined in the classes of the given sourcefiles to the suite.
int testCount()Return the number of tests directly (not recursively) in this suite.
PHPUnit_Framework_Test[] tests()Return the tests directly in this suite.
PHPUnit_Framework_Test testAt(int $index)Return the test at the $index.


- Example 21.45 shows - how to create and run a test suite. -

Example 21.45: Creating and running a test suite

<?php
require_once 'ArrayTest.php';
 
// Create a test suite that contains the tests
// from the ArrayTest class.
$suite = new PHPUnit_Framework_TestSuite('ArrayTest');
 
// Run the tests.
$suite->run();
?>


- Chapter 7 shows how to use the - PHPUnit_Framework_TestSuite class to - organize test suites by hierarchically composing test cases. -

- The PHPUnit_Framework_TestSuite class provides two - template methods -- setUp() and - tearDown() -- that are called before and after the - tests of a test suite are run, respectively. -

Table 21.10. Template Methods

MethodMeaning
void setUp()Called before the first test of the test suite is run.
void tearDown()Called after the last test of the test suite has been run.


PHPUnit_Framework_TestResult

- While you are running all these tests, you need somewhere to store all - the results: how many tests ran, which failed, and how long they took. - PHPUnit_Framework_TestResult collects these results. - A single PHPUnit_Framework_TestResult is passed - around the whole tree of tests; when a test runs or fails, the fact is - noted in the PHPUnit_Framework_TestResult. At the - end of the run, PHPUnit_Framework_TestResult - contains a summary of all the tests. -

- PHPUnit_Framework_TestResult is also a subject than - can be observed by other objects wanting to report test progress. For - example, a graphical test runner might observe the - PHPUnit_Framework_TestResult and update a progress - bar every time a test starts. -

- Table 21.11 summarizes - the API of PHPUnit_Framework_TestResult. -

Table 21.11. TestResult

MethodMeaning
void addError(PHPUnit_Framework_Test $test, Exception $e)Record that running $test caused $e to be thrown unexpectedly.
void addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e)Record that running $test caused $e to be thrown unexpectedly.
PHPUnit_Framework_TestFailure[] errors()Return the errors recorded.
PHPUnit_Framework_TestFailure[] failures()Return the failures recorded.
PHPUnit_Framework_TestFailure[] notImplemented()Return the incomplete test cases recorded.
int errorCount()Return the number of errors.
int failureCount()Return the number of failures.
int notImplementedCount()Return the number of incomplete test cases.
int count()Return the total number of test cases run.
boolean wasSuccessful()Return whether or not all tests ran successfully.
boolean allCompletlyImplemented()Return whether or not all tests were completely implemented.
void collectCodeCoverageInformation(bool $flag)Enables or disables the collection of Code Coverage information.
array getCodeCoverageInformation()Return the code coverage information collected.


- - - - If you want to register as an observer of a - PHPUnit_Framework_TestResult, you need to implement - PHPUnit_Framework_TestListener. To register, call - addListener(), as shown in - Table 21.12. -

Table 21.12. TestResult and TestListener

MethodMeaning
void addListener(PHPUnit_Framework_TestListener $listener)Register $listener to receive updates as results are recorded in the test result.
void removeListener(PHPUnit_Framework_TestListener $listener)Unregister $listener from receiving updates.


- Table 21.13 shows the methods - that test listeners implement; also see - Example 22.3. -

Table 21.13. TestListener Callbacks

MethodMeaning
void addError(PHPUnit_Framework_Test $test, Exception $e)$test has thrown $e.
void addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e)$test has failed an assertion, throwing a kind of PHPUnit_Framework_AssertionFailedError.
void addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e)$test is an incomplete test.
void addSkippedTest(PHPUnit_Framework_Test $test, Exception $e)$test is a test that has been skipped.
void startTestSuite(PHPUnit_Framework_TestSuite $suite)$suite is about to be run.
void endTestSuite(PHPUnit_Framework_TestSuite $suite)$suite has finished running.
void startTest(PHPUnit_Framework_Test $test)$test is about to be run.
void endTest(PHPUnit_Framework_Test $test)$test has finished running.


Package Structure

- Many of the classes mentioned so far in this book come from - PHPUnit/Framework. Here are all the packages in - PHPUnit: -

  • PHPUnit/Framework

    - The basic classes in PHPUnit. -

  • PHPUnit/Extensions

    - Extensions to the PHPUnit framework. -

  • PHPUnit/Runner

    - Abstract support for running tests. -

  • PHPUnit/TextUI

    - The text-based test runner. -

  • PHPUnit/Util

    - Utility classes used by the other packages. -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/appendixes.annotations.html phpunit-3.6.10/doc/html/appendixes.annotations.html --- phpunit-3.5.5/doc/html/appendixes.annotations.html 2010-09-27 16:52:12.000000000 +0000 +++ phpunit-3.6.10/doc/html/appendixes.annotations.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,288 +0,0 @@ - - - - Appendix B. Annotations - - - - - - -
-
-
- - - - - -
PrevNext
-

Appendix B. Annotations

- - - An annotation is a special form of syntactic metadata that can be added to - the source code of some programming languages. While PHP has no dedicated - language feature for annotating source code, the usage of tags such as - @annotation arguments in documentation block has been - established in the PHP community to annotate source code. In PHP - documentation blocks are reflective: they can be accessed through the - Reflection API's getDocComment() method on the function, - class, method, and attribute level. Applications such as PHPUnit use this - information at runtime to configure their behaviour. -

- This appendix shows all the varieties of annotations supported by PHPUnit. -

@assert

- - - - You can use the @assert annotation in the - documentation block of a method to automatically generate simple, - yet meaningful tests instead of incomplete test cases when using the - Skeleton Generator (see Chapter 16):

/**
- * @assert (0, 0) == 0
- */
-public function add($a, $b)
-{
-    return $a + $b;
-}

These annotations are transformed into test code such as

/**
- * Generated from @assert (0, 0) == 0.
- */
-public function testAdd() {
-    $o = new Calculator;
-    $this->assertEquals(0, $o->add(0, 0));
-}

-

@author

- - - The @author annotation is an alias for the - @group annotation (see the section called “@group) and allows to filter tests based - on their authors. -

@backupGlobals

- - - The backup and restore operations for global variables can be completely - disabled for all tests of a test case class like this

/**
- * @backupGlobals disabled
- */
-class MyTest extends PHPUnit_Framework_TestCase
-{
-    // ...
-}

-

- - - The @backupGlobals annotation can also be used on the - test method level. This allows for a fine-grained configuration of the - backup and restore operations:

/**
- * @backupGlobals disabled
- */
-class MyTest extends PHPUnit_Framework_TestCase
-{
-    /**
-     * @backupGlobals enabled
-     */
-    public function testThatInteractsWithGlobalVariables()
-    {
-        // ...
-    }
-}

-

@backupStaticAttributes

- - - The backup and restore operations for static attributes of classes can be - completely disabled for all tests of a test case class like this -

/**
- * @backupStaticAttributes disabled
- */
-class MyTest extends PHPUnit_Framework_TestCase
-{
-    // ...
-}

-

- - - The @backupStaticAttributes annotation can also be used - on the test method level. This allows for a fine-grained configuration of - the backup and restore operations:

/**
- * @backupStaticAttributes disabled
- */
-class MyTest extends PHPUnit_Framework_TestCase
-{
-    /**
-     * @backupStaticAttributes enabled
-     */
-    public function testThatInteractsWithStaticAttributes()
-    {
-        // ...
-    }
-}

-

@covers

- - - - The @covers annotation can be used in the test code to - specify which method(s) a test method wants to test:

/**
- * @covers BankAccount::getBalance
- */
-public function testBalanceIsInitiallyZero()
-{
-    $this->assertEquals(0, $this->ba->getBalance());
-}

-

- If provided, only the code coverage information for the specified - method(s) will be considered. -

- Table B.1 shows - the syntax of the @covers annotation. -

Table B.1. Annotations for specifying which methods are covered by a test

AnnotationDescription
@covers ClassName::methodNameSpecifies that the annotated test method covers the specified method.
@covers ClassNameSpecifies that the annotated test method covers all methods of a given class.
@covers ClassName<extended>Specifies that the annotated test method covers all methods of a given class and its parent class(es) and interface(s).
@covers ClassName::<public>Specifies that the annotated test method covers all public methods of a given class.
@covers ClassName::<protected>Specifies that the annotated test method covers all protected methods of a given class.
@covers ClassName::<private>Specifies that the annotated test method covers all private methods of a given class.
@covers ClassName::<!public>Specifies that the annotated test method covers all methods of a given class that are not public.
@covers ClassName::<!protected>Specifies that the annotated test method covers all methods of a given class that are not protected.
@covers ClassName::<!private>Specifies that the annotated test method covers all methods of a given class that are not private.


@dataProvider

- - - A test method can accept arbitrary arguments. These arguments are to be - provided by a data provider method (provider() in - Example 4.4). - The data provider method to be used is specified using the - @dataProvider annotation. -

- See the section called “Data Providers” for more - details. -

@depends

- - - PHPUnit supports the declaration of explicit dependencies between test - methods. Such dependencies do not define the order in which the test - methods are to be executed but they allow the returning of an instance of - the test fixture by a producer and passing it to the dependent consumers. - Example 4.2 shows - how to use the @depends annotation to express - dependencies between test methods. -

- See the section called “Test Dependencies” for more - details. -

@expectedException

- - - Example 4.5 - shows how to use the @expectedException annotation to - test whether an exception is thrown inside the tested code. -

- See the section called “Testing Exceptions” for more - details. -

@expectedExceptionCode

- - - ... -

@expectedExceptionMessage

- - - ... -

@group

- - - A test can be tagged as belonging to one or more groups using the - @group annotation like this

class MyTest extends PHPUnit_Framework_TestCase
-{
-    /**
-     * @group specification
-     */
-    public function testSomething()
-    {
-    }
-
-    /**
-     * @group regresssion
-     * @group bug2204
-     */
-    public function testSomethingElse()
-    {
-    }
-}

-

- Tests can be selected for execution based on groups using the - --group and --exclude-group switches - of the command-line test runner or using the respective directives of the - XML configuration file. -

@outputBuffering

- - - The @outputBuffering annotation can be used to control - PHP's output buffering - like this

/**
- * @outputBuffering enabled
- */
-class MyTest extends PHPUnit_Framework_TestCase
-{
-    // ...
-}

-

- - - The @outputBuffering annotation can also be used on the - test method level. This allows for fine-grained control over the output - buffering:

/**
- * @outputBuffering disabled
- */
-class MyTest extends PHPUnit_Framework_TestCase
-{
-    /**
-     * @outputBuffering enabled
-     */
-    public function testThatPrintsSomething()
-    {
-        // ...
-    }
-}

-

@runTestsInSeparateProcesses

- -

@runInSeparateProcess

- -

@test

- - - As an alternative to prefixing your test method names with - test, you can use the @test - annotation in a method's docblock to mark it as a test method.

/**
- * @test
- */
-public function initialBalanceShouldBe0()
-{
-    $this->assertEquals(0, $this->ba->getBalance());
-}

-

@testdox

- - -

@ticket

- -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/appendixes.assertions.html phpunit-3.6.10/doc/html/appendixes.assertions.html --- phpunit-3.5.5/doc/html/appendixes.assertions.html 2010-09-27 16:52:13.000000000 +0000 +++ phpunit-3.6.10/doc/html/appendixes.assertions.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ - - - - Appendix A. Assertions - - - - - - -
-
-
- - - - - -
PrevNext
-

Appendix A. Assertions

- Table A.1 shows all the - varieties of assertions. -

Table A.1. Assertions

Assertion
assertArrayHasKey($key, array $array, $message = '')
assertArrayNotHasKey($key, array $array, $message = '')
assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = FALSE)
assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '')
assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message = '')
assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE)
assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message = '')
assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '')
assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '')
assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '')
assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message = '')
assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '')
assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = FALSE)
assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '')
assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message = '')
assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE)
assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '')
assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '')
assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message = '')
assertAttributeNotType($expected, $attributeName, $classOrObject, $message = '')
assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message = '')
assertAttributeType($expected, $attributeName, $classOrObject, $message = '')
assertClassHasAttribute($attributeName, $className, $message = '')
assertClassHasStaticAttribute($attributeName, $className, $message = '')
assertClassNotHasAttribute($attributeName, $className, $message = '')
assertClassNotHasStaticAttribute($attributeName, $className, $message = '')
assertContains($needle, $haystack, $message = '', $ignoreCase = FALSE)
assertContainsOnly($type, $haystack, $isNativeType = NULL, $message = '')
assertEmpty($actual, $message = '')
assertEqualXMLStructure(DOMNode $expectedNode, DOMNode $actualNode, $checkAttributes = FALSE, $message = '')
assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE)
assertFalse($condition, $message = '')
assertFileEquals($expected, $actual, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE)
assertFileExists($filename, $message = '')
assertFileNotEquals($expected, $actual, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE)
assertFileNotExists($filename, $message = '')
assertGreaterThan($expected, $actual, $message = '')
assertGreaterThanOrEqual($expected, $actual, $message = '')
assertInstanceOf($expected, $actual, $message = '')
assertInternalType($expected, $actual, $message = '')
assertLessThan($expected, $actual, $message = '')
assertLessThanOrEqual($expected, $actual, $message = '')
assertNotContains($needle, $haystack, $message = '', $ignoreCase = FALSE)
assertNotContainsOnly($type, $haystack, $isNativeType = NULL, $message = '')
assertNotEmpty($actual, $message = '')
assertNotEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE)
assertNotInstanceOf($expected, $actual, $message = '')
assertNotInternalType($expected, $actual, $message = '')
assertNotNull($actual, $message = '')
assertNotRegExp($pattern, $string, $message = '')
assertNotSame($expected, $actual, $message = '')
assertNotTag($matcher, $actual, $message = '', $isHtml = TRUE)
assertNotType($expected, $actual, $message = '')
assertNull($actual, $message = '')
assertObjectHasAttribute($attributeName, $object, $message = '')
assertObjectNotHasAttribute($attributeName, $object, $message = '')
assertRegExp($pattern, $string, $message = '')
assertSame($expected, $actual, $message = '')
assertSelectCount($selector, $count, $actual, $message = '', $isHtml = TRUE)
assertSelectEquals($selector, $content, $count, $actual, $message = '', $isHtml = TRUE)
assertSelectRegExp($selector, $pattern, $count, $actual, $message = '', $isHtml = TRUE)
assertStringEndsNotWith($suffix, $string, $message = '')
assertStringEndsWith($suffix, $string, $message = '')
assertStringEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE)
assertStringMatchesFormat($format, $string, $message = '')
assertStringMatchesFormatFile($formatFile, $string, $message = '')
assertStringNotEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = FALSE, $ignoreCase = FALSE)
assertStringNotMatchesFormat($format, $string, $message = '')
assertStringNotMatchesFormatFile($formatFile, $string, $message = '')
assertStringStartsNotWith($prefix, $string, $message = '')
assertStringStartsWith($prefix, $string, $message = '')
assertTag($matcher, $actual, $message = '', $isHtml = TRUE)
assertThat($value, PHPUnit_Framework_Constraint $constraint, $message = '')
assertTrue($condition, $message = '')
assertType($expected, $actual, $message = '')
assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = '')
assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = '')
assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = '')
assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '')
assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = '')
assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = '')


- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/appendixes.bibliography.html phpunit-3.6.10/doc/html/appendixes.bibliography.html --- phpunit-3.5.5/doc/html/appendixes.bibliography.html 2010-09-27 16:52:14.000000000 +0000 +++ phpunit-3.6.10/doc/html/appendixes.bibliography.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ - - - - Appendix E. Bibliography - - - - - - -
-
-
- - - - - -
PrevNext
-

Appendix E. Bibliography

[Astels2003] Test Driven Development. David Astels. Copyright © 2003. Prentice Hall. ISBN 0131016490.

[Astels2006] A New Look at Test-Driven Development. David Astels. Copyright © 2006. http://blog.daveastels.com/files/BDD_Intro.pdf.

[Beck2002] Test Driven Development by Example. Kent Beck. Copyright © 2002. Addison-Wesley. ISBN 0-321-14653-0.

[Meszaros2007] xUnit Test Patterns: Refactoring Test Code. Gerard Meszaros. Copyright © 2007. Addison-Wesley. ISBN 978-0131495050.

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/appendixes.configuration.html phpunit-3.6.10/doc/html/appendixes.configuration.html --- phpunit-3.5.5/doc/html/appendixes.configuration.html 2010-09-27 16:52:15.000000000 +0000 +++ phpunit-3.6.10/doc/html/appendixes.configuration.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,272 +0,0 @@ - - - - Appendix C. The XML Configuration File - - - - - - -
-
-
- - - - - -
PrevNext
-

Appendix C. The XML Configuration File

PHPUnit

- The attributes of the <phpunit> element can - be used to configure PHPUnit's core functionality. -

<phpunit backupGlobals="false"
-         backupStaticAttributes="true"
-         bootstrap="/path/to/bootstrap.php"
-         colors="false"
-         convertErrorsToExceptions="true"
-         convertNoticesToExceptions="true"
-         convertWarningsToExceptions="true"
-         processIsolation="true"
-         stopOnFailure="true"
-         syntaxCheck="false"
-         testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
-         verbose="true"
-         strict="true">
-  <!-- ... -->
-</phpunit>

- The XML configuration above corresponds to invoking the TextUI test runner - with the following switches: -

  • --no-globals-backup

  • --static-backup

  • --bootstrap /path/to/bootstrap.php

  • --colors

  • --process-isolation

  • --stop-on-failure

  • --no-syntax-check

  • --loader PHPUnit_Runner_StandardTestSuiteLoader

  • --verbose

  • --strict

- The convertErrorsToExceptions, - convertNoticesToExceptions, and - convertWarningsToExceptions attributes have no - equivalent TextUI test runner switch. -

Test Suites

- - - The <testsuites> element and its - one or more <testsuite> children can be - used to compose a test suite out of test suites and test cases. -

<testsuites>
-  <testsuite name="My Test Suite">
-    <directory>/path/to/*Test.php files</directory>
-    <file>/path/to/MyTest.php</file>
-  </testsuite>
-</testsuites>

Groups

- - - The <groups> element and its - <include>, - <exclude>, and - <group> children can be used to select - groups of tests from a suite of tests that should (not) be run. -

<groups>
-  <include>
-    <group>name</group>
-  </include>
-  <exclude>
-    <group>name</group>
-  </exclude>
-</groups>

- The XML configuration above corresponds to invoking the TextUI test runner - with the following switches: -

  • --group name

  • --exclude-group name

Including and Excluding Files for Code Coverage

- - - - - - The <filter> element and its children can - be used to configure the blacklist and whitelist for the code coverage - reporting. -

<filter>
-  <blacklist>
-    <directory suffix=".php">/path/to/files</directory>
-    <file>/path/to/file</file>
-    <exclude>
-      <directory suffix=".php">/path/to/files</directory>
-      <file>/path/to/file</file>
-    </exclude>
-  </blacklist>
-  <whitelist>
-    <directory suffix=".php">/path/to/files</directory>
-    <file>/path/to/file</file>
-    <exclude>
-      <directory suffix=".php">/path/to/files</directory>
-      <file>/path/to/file</file>
-    </exclude>
-  </whitelist>
-</filter>

- The XML configuration above corresponds to using the - PHP_CodeCoverage_Filter class as follows: -

PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(
-  '/path/to/files', '.php'
-);
-
-PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist('/path/to/file');
-
-PHP_CodeCoverage_Filter::getInstance()->removeDirectoryFromBlacklist(
-  '/path/to/files', '.php'
-);
-
-PHP_CodeCoverage_Filter::getInstance()->removeFileFromBlacklist('/path/to/file');
-
-PHP_CodeCoverage_Filter::getInstance()->addDirectoryToWhitelist(
-  '/path/to/files', '.php'
-);
-
-PHP_CodeCoverage_Filter::getInstance()->addFileToWhitelist('/path/to/file');
-
-PHP_CodeCoverage_Filter::getInstance()->removeDirectoryFromWhitelist(
-  '/path/to/files', '.php'
-);
-
-PHP_CodeCoverage_Filter::getInstance()->removeFileFromWhitelist('/path/to/file');

Logging

- - - The <logging> element and its - <log> children can be used to configure the - logging of the test execution. -

<logging>
-  <log type="coverage-html" target="/tmp/report" charset="UTF-8"
-       yui="true" highlight="false"
-       lowUpperBound="35" highLowerBound="70"/>
-  <log type="coverage-xml" target="/tmp/coverage.xml"/>
-  <log type="json" target="/tmp/logfile.json"/>
-  <log type="tap" target="/tmp/logfile.tap"/>
-  <log type="junit" target="/tmp/logfile.xml" logIncompleteSkipped="false"/>
-  <log type="testdox-html" target="/tmp/testdox.html"/>
-  <log type="testdox-text" target="/tmp/testdox.txt"/>
-</logging>

- The XML configuration above corresponds to invoking the TextUI test runner - with the following switches: -

  • --coverage-html /tmp/report

  • --coverage-xml /tmp/coverage.xml

  • --log-json /tmp/logfile.json

  • > /tmp/logfile.txt

  • --log-tap /tmp/logfile.tap

  • --log-junit /tmp/logfile.xml

  • --testdox-html /tmp/testdox.html

  • --testdox-text /tmp/testdox.txt

- The charset, yui, - highlight, lowUpperBound, - highLowerBound, and logIncompleteSkipped - attributes have no equivalent TextUI test runner switch. -

Test Listeners

- - - - The <listeners> element and its - <listener> children can be used to attach - additional test listeners to the test execution. -

<listeners>
-  <listener class="MyListener" file="/optional/path/to/MyListener.php">
-    <arguments>
-      <array>
-        <element key="0">
-          <string>Sebastian</string>
-        </element>
-      </array>
-      <integer>22</integer>
-      <string>April</string>
-      <double>19.78</double>
-      <null/>
-      <object class="stdClass"/>
-    </arguments>
-  </listener>
-</listeners>

- The XML configuration above corresponds to attaching the - $listener object (see below) to the test execution: -

$listener = new MyListener(
-  array('Sebastian'),
-  22,
-  'April',
-  19.78,
-  NULL,
-  new stdClass
-);

Setting PHP INI settings, Constants and Global Variables

- - - - - The <php> element and its children can be - used to configure PHP settings, constants, and global variables. It can - also be used to prepend the include_path. -

<php>
-  <includePath>.</includePath>
-  <ini name="foo" value="bar"/>
-  <const name="foo" value="bar"/>
-  <var name="foo" value="bar"/>
-  <env name="foo" value="bar"/>
-  <post name="foo" value="bar"/>
-  <get name="foo" value="bar"/>
-  <cookie name="foo" value="bar"/>
-  <server name="foo" value="bar"/>
-  <files name="foo" value="bar"/>
-  <request name="foo" value="bar"/>
-</php>

- The XML configuration above corresponds to the following PHP code: -

ini_set('foo', 'bar');
-define('foo', 'bar');
-$GLOBALS['foo'] = 'bar';
-$_ENV['foo'] = 'bar';
-$_POST['foo'] = 'bar';
-$_GET['foo'] = 'bar';
-$_COOKIE['foo'] = 'bar';
-$_SERVER['foo'] = 'bar';
-$_FILES['foo'] = 'bar';
-$_REQUEST['foo'] = 'bar';

Configuring Browsers for Selenium RC

- - - The <selenium> element and its - <browser> children can be used to - configure a list of Selenium RC servers. -

<selenium>
-  <browser name="Firefox on Linux"
-           browser="*firefox /usr/lib/firefox/firefox-bin"
-           host="my.linux.box"
-           port="4444"
-           timeout="30000"/>
-</selenium>

- The XML configuration above corresponds to the following PHP code: -

class WebTest extends PHPUnit_Extensions_SeleniumTestCase
-{
-    public static $browsers = array(
-      array(
-        'name'    => 'Firefox on Linux',
-        'browser' => '*firefox /usr/lib/firefox/firefox-bin',
-        'host'    => 'my.linux.box',
-        'port'    => 4444,
-        'timeout' => 30000
-      )
-    );
-
-    // ...
-}
- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/appendixes.copyright.html phpunit-3.6.10/doc/html/appendixes.copyright.html --- phpunit-3.5.5/doc/html/appendixes.copyright.html 2010-09-27 16:52:16.000000000 +0000 +++ phpunit-3.6.10/doc/html/appendixes.copyright.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,463 +0,0 @@ - - - - Appendix F. Copyright - - - - - - -
-
-
- - - - - -
Prev
-

Appendix F. Copyright

Copyright (c) 2005-2009 Sebastian Bergmann.
-
-This work is licensed under the Creative Commons Attribution 3.0
-Unported License.
-
-A summary of the license is given below, followed by the full legal
-text.
-
---------------------------------------------------------------------
-
-You are free:
-
-    * to Share - to copy, distribute and transmit the work
-    * to Remix - to adapt the work
-
-Under the following conditions:
-
-Attribution. You must attribute the work in the manner specified by
-the author or licensor (but not in any way that suggests that they
-endorse you or your use of the work).
-
-    * For any reuse or distribution, you must make clear to others
-      the license terms of this work. The best way to do this is with
-      a link to this web page.
-
-    * Any of the above conditions can be waived if you get
-      permission from the copyright holder.
-
-    * Nothing in this license impairs or restricts the author's moral
-      rights.
-
-Your fair dealing and other rights are in no way affected by the
-above.
-
-This is a human-readable summary of the Legal Code (the full
-license) below.
-
-====================================================================
-
-Creative Commons Legal Code
-Attribution 3.0 Unported
-
-CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
-LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
-ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
-INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO
-WARRANTIES REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS
-LIABILITY FOR DAMAGES RESULTING FROM ITS USE. 
-
-License
-
-THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS
-CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS
-PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE
-WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW
-IS PROHIBITED.
-
-BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND
-AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS
-LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU
-THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF
-SUCH TERMS AND CONDITIONS.
-
-1. Definitions
-
-   a. "Adaptation" means a work based upon the Work, or upon the
-      Work and other pre-existing works, such as a translation,
-      adaptation, derivative work, arrangement of music or other
-      alterations of a literary or artistic work, or phonogram or
-      performance and includes cinematographic adaptations or any
-      other form in which the Work may be recast, transformed, or
-      adapted including in any form recognizably derived from the
-      original, except that a work that constitutes a Collection
-      will not be considered an Adaptation for the purpose of this
-      License. For the avoidance of doubt, where the Work is a
-      musical work, performance or phonogram, the synchronization of
-      the Work in timed-relation with a moving image ("synching")
-      will be considered an Adaptation for the purpose of this
-      License.
-
-   b. "Collection" means a collection of literary or artistic works,
-      such as encyclopedias and anthologies, or performances,
-      phonograms or broadcasts, or other works or subject matter
-      other than works listed in Section 1(f) below, which, by
-      reason of the selection and arrangement of their contents,
-      constitute intellectual creations, in which the Work is
-      included in its entirety in unmodified form along with one or
-      more other contributions, each constituting separate and
-      independent works in themselves, which together are assembled
-      into a collective whole. A work that constitutes a Collection
-      will not be considered an Adaptation (as defined above) for
-      the purposes of this License.
-
-   c. "Distribute" means to make available to the public the
-      original and copies of the Work or Adaptation, as appropriate,
-      through sale or other transfer of ownership.
-
-   d. "Licensor" means the individual, individuals, entity or
-      entities that offer(s) the Work under the terms of this License.
-
-   e. "Original Author" means, in the case of a literary or artistic
-      work, the individual, individuals, entity or entities who
-      created the Work or if no individual or entity can be
-      identified, the publisher; and in addition (i) in the case of
-      a performance the actors, singers, musicians, dancers, and
-      other persons who act, sing, deliver, declaim, play in,
-      interpret or otherwise perform literary or artistic works or
-      expressions of folklore; (ii) in the case of a phonogram the
-      producer being the person or legal entity who first fixes the
-      sounds of a performance or other sounds; and, (iii) in the
-      case of broadcasts, the organization that transmits the
-      broadcast.
-
-   f. "Work" means the literary and/or artistic work offered under
-      the terms of this License including without limitation any
-      production in the literary, scientific and artistic domain,
-      whatever may be the mode or form of its expression including
-      digital form, such as a book, pamphlet and other writing; a
-      lecture, address, sermon or other work of the same nature; a
-      dramatic or dramatico-musical work; a choreographic work or
-      entertainment in dumb show; a musical composition with or
-      without words; a cinematographic work to which are assimilated
-      works expressed by a process analogous to cinematography; a
-      work of drawing, painting, architecture, sculpture, engraving
-      or lithography; a photographic work to which are assimilated
-      works expressed by a process analogous to photography; a work
-      of applied art; an illustration, map, plan, sketch or three-
-      dimensional work relative to geography, topography,
-      architecture or science; a performance; a broadcast; a
-      phonogram; a compilation of data to the extent it is protected
-      as a copyrightable work; or a work performed by a variety or
-      circus performer to the extent it is not otherwise considered
-      a literary or artistic work.
-
-   g. "You" means an individual or entity exercising rights under
-      this License who has not previously violated the terms of
-      this License with respect to the Work, or who has received
-      express permission from the Licensor to exercise rights under
-      this License despite a previous violation.
-
-   h. "Publicly Perform" means to perform public recitations of the
-      Work and to communicate to the public those public
-      recitations, by any means or process, including by wire or
-      wireless means or public digital performances; to make
-      available to the public Works in such a way that members of
-      the public may access these Works from a place and at a place
-      individually chosen by them; to perform the Work to the public
-      by any means or process and the communication to the public of
-      the performances of the Work, including by public digital
-      performance; to broadcast and rebroadcast the Work by any
-      means including signs, sounds or images.
-
-   i. "Reproduce" means to make copies of the Work by any means
-      including without limitation by sound or visual recordings and
-      the right of fixation and reproducing fixations of the Work,
-      including storage of a protected performance or phonogram in
-      digital form or other electronic medium.
-
-2. Fair Dealing Rights. Nothing in this License is intended to
-   reduce, limit, or restrict any uses free from copyright or rights
-   arising from limitations or exceptions that are provided for in
-   connection with the copyright protection under copyright law or
-   other applicable laws.
-
-3. License Grant. Subject to the terms and conditions of this
-   License, Licensor hereby grants You a worldwide, royalty-free,
-   non-exclusive, perpetual (for the duration of the applicable
-   copyright) license to exercise the rights in the Work as stated
-   below:
-
-   a. to Reproduce the Work, to incorporate the Work into one or
-      more Collections, and to Reproduce the Work as incorporated
-      in the Collections;
-
-   b. to create and Reproduce Adaptations provided that any such
-      Adaptation, including any translation in any medium, takes
-      reasonable steps to clearly label, demarcate or otherwise
-      identify that changes were made to the original Work. For
-      example, a translation could be marked "The original work was
-      translated from English to Spanish," or a modification could
-      indicate "The original work has been modified.";
-
-   c. to Distribute and Publicly Perform the Work including as
-      incorporated in Collections; and,
-
-   d. to Distribute and Publicly Perform Adaptations.
-
-   e. For the avoidance of doubt:
-
-      i. Non-waivable Compulsory License Schemes. In those
-         jurisdictions in which the right to collect royalties
-         through any statutory or compulsory licensing scheme cannot
-         be waived, the Licensor reserves the exclusive right to
-         collect such royalties for any exercise by You of the
-         rights granted under this License;
-
-      ii. Waivable Compulsory License Schemes. In those
-          jurisdictions in which the right to collect royalties
-          through any statutory or compulsory licensing scheme can
-          be waived, the Licensor waives the exclusive right to
-          collect such royalties for any exercise by You of the
-          rights granted under this License; and,
-
-      iii. Voluntary License Schemes. The Licensor waives the right
-           to collect royalties, whether individually or, in the
-           event that the Licensor is a member of a collecting
-           society that administers voluntary licensing schemes, via
-           that society, from any exercise by You of the rights
-           granted under this License.
-
-The above rights may be exercised in all media and formats whether
-now known or hereafter devised. The above rights include the right
-to make such modifications as are technically necessary to exercise
-the rights in other media and formats. Subject to Section 8(f), all
-rights not expressly granted by Licensor are hereby reserved.
-
-4. Restrictions. The license granted in Section 3 above is expressly
-   made subject to and limited by the following restrictions:
-
-   a. You may Distribute or Publicly Perform the Work only under the
-      terms of this License. You must include a copy of, or the
-      Uniform Resource Identifier (URI) for, this License with every
-      copy of the Work You Distribute or Publicly Perform. You may
-      not offer or impose any terms on the Work that restrict the
-      terms of this License or the ability of the recipient of the
-      Work to exercise the rights granted to that recipient under
-      the terms of the License. You may not sublicense the Work. You
-      must keep intact all notices that refer to this License and to
-      the disclaimer of warranties with every copy of the Work You
-      Distribute or Publicly Perform. When You Distribute or
-      Publicly Perform the Work, You may not impose any effective
-      technological measures on the Work that restrict the ability
-      of a recipient of the Work from You to exercise the rights
-      granted to that recipient under the terms of the License. This
-      Section 4(a) applies to the Work as incorporated in a
-      Collection, but this does not require the Collection apart
-      from the Work itself to be made subject to the terms of this
-      License. If You create a Collection, upon notice from any
-      Licensor You must, to the extent practicable, remove from the
-      Collection any credit as required by Section 4(b), as
-      requested. If You create an Adaptation, upon notice from any
-      Licensor You must, to the extent practicable, remove from the
-      Adaptation any credit as required by Section 4(b), as requested.
-
-   b. If You Distribute, or Publicly Perform the Work or any
-      Adaptations or Collections, You must, unless a request has
-      been made pursuant to Section 4(a), keep intact all copyright
-      notices for the Work and provide, reasonable to the medium or
-      means You are utilizing: (i) the name of the Original Author
-      (or pseudonym, if applicable) if supplied, and/or if the
-      Original Author and/or Licensor designate another party or
-      parties (e.g., a sponsor institute, publishing entity,
-      journal) for attribution ("Attribution Parties") in Licensor's
-      copyright notice, terms of service or by other reasonable
-      means, the name of such party or parties; (ii) the title of
-      the Work if supplied; (iii) to the extent reasonably
-      practicable, the URI, if any, that Licensor specifies to be
-      associated with the Work, unless such URI does not refer to
-      the copyright notice or licensing information for the Work;
-      and (iv), consistent with Section 3(b), in the case of an
-      Adaptation, a credit identifying the use of the Work in the
-      Adaptation (e.g., "French translation of the Work by Original
-      Author," or "Screenplay based on original Work by Original
-      Author"). The credit required by this Section 4 (b) may be
-      implemented in any reasonable manner; provided, however, that
-      in the case of a Adaptation or Collection, at a minimum such
-      credit will appear, if a credit for all contributing authors
-      of the Adaptation or Collection appears, then as part of these
-      credits and in a manner at least as prominent as the credits
-      for the other contributing authors. For the avoidance of
-      doubt, You may only use the credit required by this Section
-      for the purpose of attribution in the manner set out above
-      and, by exercising Your rights under this License, You may not
-      implicitly or explicitly assert or imply any connection with,
-      sponsorship or endorsement by the Original Author, Licensor
-      and/or Attribution Parties, as appropriate, of You or Your use
-      of the Work, without the separate, express prior written
-      permission of the Original Author, Licensor and/or
-      Attribution Parties.
-
-   c. Except as otherwise agreed in writing by the Licensor or as
-      may be otherwise permitted by applicable law, if You
-      Reproduce, Distribute or Publicly Perform the Work either by
-      itself or as part of any Adaptations or Collections, You must
-      not distort, mutilate, modify or take other derogatory action
-      in relation to the Work which would be prejudicial to the
-      Original Author's honor or reputation. Licensor agrees that in
-      those jurisdictions (e.g. Japan), in which any exercise of the
-      right granted in Section 3(b) of this License (the right to
-      make Adaptations) would be deemed to be a distortion,
-      mutilation, modification or other derogatory action
-      prejudicial to the Original Author's honor and reputation, the
-      Licensor will waive or not assert, as appropriate, this
-      Section, to the fullest extent permitted by the applicable
-      national law, to enable You to reasonably exercise Your right
-      under Section 3(b) of this License (right to make Adaptations)
-      but not otherwise.
-
-5. Representations, Warranties and Disclaimer
-
-UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING,
-LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR
-WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED,
-STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF
-TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE,
-NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS,
-ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT
-DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF
-IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
-
-6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY
-   APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY
-   LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE
-   OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF
-   THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY
-   OF SUCH DAMAGES.
-
-7. Termination
-
-   a. This License and the rights granted hereunder will terminate
-      automatically upon any breach by You of the terms of this
-      License. Individuals or entities who have received Adaptations
-      or Collections from You under this License, however, will not
-      have their licenses terminated provided such individuals or
-      entities remain in full compliance with those licenses.
-      Sections 1, 2, 5, 6, 7, and 8 will survive any termination of
-      this License.
-
-   b. Subject to the above terms and conditions, the license granted
-      here is perpetual (for the duration of the applicable
-      copyright in the Work). Notwithstanding the above, Licensor
-      reserves the right to release the Work under different license
-      terms or to stop distributing the Work at any time; provided,
-      however that any such election will not serve to withdraw this
-      License (or any other license that has been, or is required to
-      be, granted under the terms of this License), and this License
-      will continue in full force and effect unless terminated as
-      stated above.
-
-8. Miscellaneous
-
-   a. Each time You Distribute or Publicly Perform the Work or a
-      Collection, the Licensor offers to the recipient a license to
-      the Work on the same terms and conditions as the license
-      granted to You under this License.
-
-   b. Each time You Distribute or Publicly Perform an Adaptation,
-      Licensor offers to the recipient a license to the original
-      Work on the same terms and conditions as the license granted
-      to You under this License.
-
-   c. If any provision of this License is invalid or unenforceable
-      under applicable law, it shall not affect the validity or
-      enforceability of the remainder of the terms of this License,
-      and without further action by the parties to this agreement,
-      such provision shall be reformed to the minimum extent
-      necessary to make such provision valid and enforceable.
-
-   d. No term or provision of this License shall be deemed waived
-      and no breach consented to unless such waiver or consent shall
-      be in writing and signed by the party to be charged with such
-      waiver or consent.
-
-   e. This License constitutes the entire agreement between the
-      parties with respect to the Work licensed here. There are no
-      understandings, agreements or representations with respect to
-      the Work not specified here. Licensor shall not be bound by
-      any additional provisions that may appear in any communication
-      from You. This License may not be modified without the mutual
-      written agreement of the Licensor and You.
-
-   f. The rights granted under, and the subject matter referenced,
-      in this License were drafted utilizing the terminology of the
-      Berne Convention for the Protection of Literary and Artistic
-      Works (as amended on September 28, 1979), the Rome Convention
-      of 1961, the WIPO Copyright Treaty of 1996, the WIPO
-      Performances and Phonograms Treaty of 1996 and the Universal
-      Copyright Convention (as revised on July 24, 1971). These
-      rights and subject matter take effect in the relevant
-      jurisdiction in which the License terms are sought to be
-      enforced according to the corresponding provisions of the
-      implementation of those treaty provisions in the applicable
-      national law. If the standard suite of rights granted under
-      applicable copyright law includes additional rights not
-      granted under this License, such additional rights are deemed
-      to be included in the License; this License is not intended to
-      restrict the license of any rights under applicable law.
-
-Creative Commons is not a party to this License, and makes no
-warranty whatsoever in connection with the Work. Creative Commons
-will not be liable to You or any party on any legal theory for any
-damages whatsoever, including without limitation any general,
-special, incidental or consequential damages arising in connection
-to this license. Notwithstanding the foregoing two (2) sentences,
-if Creative Commons has expressly identified itself as the Licensor
-hereunder, it shall have all rights and obligations of Licensor.
-
-Except for the limited purpose of indicating to the public that the
-Work is licensed under the CCPL, Creative Commons does not authorize
-the use by either party of the trademark "Creative Commons" or any
-related trademark or logo of Creative Commons without the prior
-written consent of Creative Commons. Any permitted use will be in
-compliance with Creative Commons' then-current trademark usage
-guidelines, as may be published on its website or otherwise made
-available upon request from time to time. For the avoidance of
-doubt, this trademark restriction does not form part of this
-License.
-
-Creative Commons may be contacted at http://creativecommons.org/.
-
-====================================================================
- - - - - -
Prev
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/appendixes.index.html phpunit-3.6.10/doc/html/appendixes.index.html --- phpunit-3.5.5/doc/html/appendixes.index.html 2010-09-27 16:52:21.000000000 +0000 +++ phpunit-3.6.10/doc/html/appendixes.index.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ - - - - Appendix D. Index - - - - - - -
-
-
- - - - - -
PrevNext
-

Appendix D. Index

Symbols

$backupGlobalsBlacklist, Global State
$backupStaticAttributesBlacklist, Global State
@assert, Generating a Test Case Class Skeleton, @assert
@author, The Command-Line Test Runner, @author
@backupGlobals, Global State, @backupGlobals
@backupStaticAttributes, Global State, @backupStaticAttributes
@codeCoverageIgnore, Ignoring Code Blocks
@codeCoverageIgnoreEnd, Ignoring Code Blocks
@codeCoverageIgnoreStart, Ignoring Code Blocks
@covers, Specifying Covered Methods, @covers
@dataProvider, Data Providers, @dataProvider
@depends, Test Dependencies, Data Providers, @depends
@expectedException, Testing Exceptions, @expectedException
@expectedExceptionCode, @expectedExceptionCode
@expectedExceptionMessage, @expectedExceptionMessage
@group, The Command-Line Test Runner, @group
@outputBuffering, @outputBuffering
@runInSeparateProcess, @runInSeparateProcess
@runTestsInSeparateProcesses, @runTestsInSeparateProcesses
@test, Writing Tests for PHPUnit, @test
@testdox, @testdox
@ticket, @ticket

A

addTest(), PHPUnit_Framework_TestSuite
addTestFile(), PHPUnit_Framework_TestSuite
addTestFiles(), PHPUnit_Framework_TestSuite
addTestSuite(), PHPUnit_Framework_TestSuite
Agile Documentation, The Command-Line Test Runner, Agile Documentation
Annotation, Writing Tests for PHPUnit, Test Dependencies, Data Providers, Testing Exceptions, The Command-Line Test Runner, Specifying Covered Methods, Ignoring Code Blocks, Generating a Test Case Class Skeleton, Annotations
anything(), assertThat()
Apache Ant, Apache Ant, Phing, CruiseControl
Apache Maven, Apache Maven
arrayHasKey(), assertThat()
assertArrayHasKey(), assertArrayHasKey(), Assertions
assertArrayNotHasKey(), assertArrayHasKey(), Assertions
assertAttributeContains(), assertContains(), Assertions
assertAttributeContainsOnly(), assertContainsOnly(), Assertions
assertAttributeEmpty(), assertEmpty(), Assertions
assertAttributeEquals(), assertEquals(), Assertions
assertAttributeGreaterThan(), assertGreaterThan(), Assertions
assertAttributeGreaterThanOrEqual(), assertGreaterThanOrEqual(), Assertions
assertAttributeInstanceOf(), assertInstanceOf(), Assertions
assertAttributeInternalType(), assertInternalType(), Assertions
assertAttributeLessThan(), assertLessThan(), Assertions
assertAttributeLessThanOrEqual(), assertLessThanOrEqual(), Assertions
assertAttributeNotContains(), assertContains(), Assertions
assertAttributeNotContainsOnly(), assertContainsOnly(), Assertions
assertAttributeNotEmpty(), assertEmpty(), Assertions
assertAttributeNotEquals(), assertEquals(), Assertions
assertAttributeNotInstanceOf(), assertInstanceOf(), Assertions
assertAttributeNotInternalType(), assertInternalType(), Assertions
assertAttributeNotSame(), assertSame(), Assertions
assertAttributeNotType(), assertType(), Assertions
assertAttributeSame(), assertSame(), Assertions
assertAttributeType(), assertType(), Assertions
assertClassHasAttribute(), assertClassHasAttribute(), Assertions
assertClassHasStaticAttribute(), assertClassHasStaticAttribute(), Assertions
assertClassNotHasAttribute(), assertClassHasAttribute(), Assertions
assertClassNotHasStaticAttribute(), assertClassHasStaticAttribute(), Assertions
assertContains(), assertContains(), Assertions
assertContainsOnly(), assertContainsOnly(), Assertions
assertEmpty(), assertEmpty(), Assertions
assertEquals(), assertEquals(), Assertions
assertEqualXMLStructure(), assertEqualXMLStructure(), Assertions
assertFalse(), assertFalse(), Assertions
assertFileEquals(), assertFileEquals(), Assertions
assertFileExists(), assertFileExists(), Assertions
assertFileNotEquals(), assertFileEquals(), Assertions
assertFileNotExists(), assertFileExists(), Assertions
assertGreaterThan(), assertGreaterThan(), Assertions
assertGreaterThanOrEqual(), assertGreaterThanOrEqual(), Assertions
assertInstanceOf(), assertInstanceOf(), Assertions
assertInternalType(), assertInternalType(), Assertions
Assertion, @assert
Assertions, Automating Tests, PHPUnit_Framework_Assert, Assert Classes
assertLessThan(), assertLessThan(), Assertions
assertLessThanOrEqual(), assertLessThanOrEqual(), Assertions
assertNotContains(), assertContains(), Assertions
assertNotContainsOnly(), assertContainsOnly(), Assertions
assertNotEmpty(), assertEmpty(), Assertions
assertNotEquals(), assertEquals(), Assertions
assertNotInstanceOf(), assertInstanceOf(), Assertions
assertNotInternalType(), assertInternalType(), Assertions
assertNotNull(), assertNull(), Assertions
assertNotRegExp(), assertRegExp(), Assertions
assertNotSame(), assertSame(), Assertions
assertNotTag(), assertTag(), Assertions
assertNotType(), assertType(), Assertions
assertNull(), assertNull(), Assertions
assertObjectHasAttribute(), assertObjectHasAttribute(), Assertions
assertObjectNotHasAttribute(), assertObjectHasAttribute(), Assertions
assertPostConditions(), Fixtures, PHPUnit_Framework_TestCase
assertPreConditions(), Fixtures, PHPUnit_Framework_TestCase
assertRegExp(), assertRegExp(), Assertions
assertSame(), assertSame(), Assertions
assertSelectCount(), assertSelectCount(), Assertions
assertSelectEquals(), assertSelectEquals(), Assertions
assertSelectRegExp(), assertSelectRegExp(), Assertions
assertStringEndsNotWith(), assertStringEndsWith(), Assertions
assertStringEndsWith(), assertStringEndsWith(), Assertions
assertStringEqualsFile(), assertStringEqualsFile(), Assertions
assertStringMatchesFormat(), assertStringMatchesFormat(), Assertions
assertStringMatchesFormatFile(), assertStringMatchesFormatFile(), Assertions
assertStringNotEqualsFile(), assertStringEqualsFile(), Assertions
assertStringNotMatchesFormat(), assertStringMatchesFormat(), Assertions
assertStringNotMatchesFormatFile(), assertStringMatchesFormatFile(), Assertions
assertStringStartsNotWith(), assertStringStartsWith(), Assertions
assertStringStartsWith(), assertStringStartsWith(), Assertions
assertTag(), assertTag(), Assertions
assertThat(), assertThat(), Assertions
assertTrue(), assertTrue(), Assertions
assertType(), assertType(), Assertions
assertXmlFileEqualsXmlFile(), assertXmlFileEqualsXmlFile(), Assertions
assertXmlFileNotEqualsXmlFile(), assertXmlFileEqualsXmlFile(), Assertions
assertXmlStringEqualsXmlFile(), assertXmlStringEqualsXmlFile(), Assertions
assertXmlStringEqualsXmlString(), assertXmlStringEqualsXmlString(), Assertions
assertXmlStringNotEqualsXmlFile(), assertXmlStringEqualsXmlFile(), Assertions
assertXmlStringNotEqualsXmlString(), assertXmlStringEqualsXmlString(), Assertions
Atlassian Bamboo, Atlassian Bamboo
attribute(), assertThat()
attributeEqualTo(), assertThat()
Automated Documentation, Agile Documentation
Automated Test, Automating Tests

D

Data-Driven Tests, Implement PHPUnit_Framework_Test
Database, Database Testing
DbUnit, Database Testing
DBUS, The Command-Line Test Runner
Defect Localization, Test Dependencies
Depended-On Component, Test Doubles
Design-by-Contract, Test-Driven Development, PHPUnit_Framework_Assert
Documenting Assumptions, Agile Documentation

F

fail(), PHPUnit_Framework_Assert
Failure, The Command-Line Test Runner
fileExists(), assertThat()
Fixture, Fixtures
Fluent Interface, Stubs

G

getMock(), Stubs
getMockForAbstractClass(), Mock Objects
getMockFromWsdl(), Stubbing and Mocking Web Services
Global Variable, Global State, Setting PHP INI settings, Constants and Global Variables
greaterThan(), assertThat()
greaterThanOrEqual(), assertThat()

H

hasAttribute(), assertThat()

L

lessThan(), assertThat()
lessThanOrEqual(), assertThat()
Logfile, The Command-Line Test Runner
Logging, Logging, Logging
logicalAnd(), assertThat()
logicalNot(), assertThat()
logicalOr(), assertThat()
logicalXor(), assertThat()

M

markTestIncomplete(), PHPUnit_Framework_Assert
markTestSkipped(), PHPUnit_Framework_Assert
matchesRegularExpression(), assertThat()
method(), Stubs
Mock Object, Mock Objects

O

Observer Pattern, PHPUnit_Framework_TestResult
onNotSuccessfulTest(), Fixtures

P

Phing, Phing
PHP Error, Testing PHP Errors
PHP Notice, Testing PHP Errors
PHP Warning, Testing PHP Errors
php.ini, Setting PHP INI settings, Constants and Global Variables
phpUnderControl, phpUnderControl
PHPUnit_Extensions_OutputTestCase, Testing Output
PHPUnit_Extensions_RepeatedTest, Subclass PHPUnit_Extensions_TestDecorator
PHPUnit_Extensions_SeleniumTestCase, PHPUnit_Extensions_SeleniumTestCase
PHPUnit_Extensions_TestDecorator, Subclass PHPUnit_Extensions_TestDecorator
PHPUnit_Extensions_TestSetup, Subclass PHPUnit_Extensions_TestDecorator
PHPUnit_Framework_Assert, BankAccount Example, PHPUnit_Framework_Assert, Assert Classes
PHPUnit_Framework_Error, Testing PHP Errors
PHPUnit_Framework_Error_Notice, Testing PHP Errors
PHPUnit_Framework_Error_Warning, Testing PHP Errors
PHPUnit_Framework_IncompleteTest, Incomplete Tests
PHPUnit_Framework_IncompleteTestError, Incomplete Tests
PHPUnit_Framework_Test, PHPUnit_Framework_Test, Implement PHPUnit_Framework_Test
PHPUnit_Framework_TestCase, Writing Tests for PHPUnit, PHPUnit_Framework_TestCase, Subclass PHPUnit_Framework_TestCase
PHPUnit_Framework_TestListener, PHPUnit_Framework_TestResult, Implement PHPUnit_Framework_TestListener, Test Listeners
PHPUnit_Framework_TestResult, PHPUnit_Framework_TestResult, Subclass PHPUnit_Framework_TestResult, Implement PHPUnit_Framework_TestListener
PHPUnit_Framework_TestSuite, Using the TestSuite Class, PHPUnit_Framework_TestSuite, Implement PHPUnit_Framework_TestListener
PHPUnit_Runner_TestSuiteLoader, The Command-Line Test Runner
PHP_CodeCoverage_Filter, Including and Excluding Files, Including and Excluding Files for Code Coverage
Process Isolation, The Command-Line Test Runner

R

readAttribute(), PHPUnit_Framework_Assert
Refactoring, During Development
Report, The Command-Line Test Runner
returnArgument(), Stubs
returnCallback(), Stubs
returnValue(), Stubs

T

tearDown(), Fixtures, Using the TestSuite Class, PHPUnit_Framework_TestCase, PHPUnit_Framework_TestSuite
tearDownAfterClass, Sharing Fixture
tearDownAfterClass(), Fixtures
Template Method, Fixtures, Using the TestSuite Class
Test Dependencies, Test Dependencies
Test Double, Test Doubles
Test Groups, The Command-Line Test Runner, Groups
Test Isolation, The Command-Line Test Runner, Global State
Test Listener, Test Listeners
Test Suite, Organizing Tests, Test Suites
Test-Driven Development, Test-Driven Development
Test-First Programming, Test-Driven Development
TestDox, Agile Documentation, @testdox
throwException(), Stubs
- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/automating-tests.html phpunit-3.6.10/doc/html/automating-tests.html --- phpunit-3.5.5/doc/html/automating-tests.html 2010-09-27 16:52:22.000000000 +0000 +++ phpunit-3.6.10/doc/html/automating-tests.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ - - - - Chapter 1. Automating Tests - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 1. Automating Tests

- Even good programmers make mistakes. The difference between a good - programmer and a bad programmer is that the good programmer uses tests - to detect his mistakes as soon as possible. The sooner you test for a - mistake the greater your chance of finding it and the less it will cost - to find and fix. This explains why leaving testing until just before - releasing software is so problematic. Most errors do not get caught at - all, and the cost of fixing the ones you do catch is so high that you - have to perform triage with the errors because you just cannot afford - to fix them all. -

- - - Testing with PHPUnit is not a totally different activity from what you - should already be doing. It is just a different way of doing it. The - difference is between testing, that is, checking - that your program behaves as expected, and performing a battery - of tests, runnable code-fragments that automatically test the - correctness of parts (units) of the software. These runnable - code-fragments are called unit tests. -

- In this chapter we will go from simple print-based - testing code to a fully automated test. Imagine that we have been asked - to test PHP's built-in array. One bit of functionality - to test is the function count(). For a newly created - array we expect the count() function to return - 0. After we add an element, count() - should return 1. - Example 1.1 shows what - we want to test. -

Example 1.1: Testing array operations

<?php
$fixture = array();
// $fixture is expected to be empty.
 
$fixture[] = 'element';
// $fixture is expected to contain one element.
?>


- A really simple way to check whether we are getting the results we - expect is to print the result of count() before - and after adding the element (see - Example 1.2). - If we get 0 and then 1, - array and count() behave as - expected. -

Example 1.2: Using print to test array operations

<?php
$fixture = array();
print count($fixture) . "\n";
 
$fixture[] = 'element';
print count($fixture) . "\n";
?>
0
-1


- Now, we would like to move from tests that require manual interpretation - to tests that can run automatically. In - Example 1.3, we write - the comparison of the expected and actual values into the test code and - print ok if the values are equal. If we ever see a - not ok message, we know something is wrong. -

Example 1.3: Comparing expected and actual values to test array operations

<?php
$fixture = array();
print count($fixture) == 0 ? "ok\n" : "not ok\n";
 
$fixture[] = 'element';
print count($fixture) == 1 ? "ok\n" : "not ok\n";
?>
ok
-ok


- - - We now factor out the comparison of expected and actual values into a - function that raises an Exception when there is a discrepancy - (Example 1.4). This - gives us two benefits: the writing of tests becomes easier and we only - get output when something is wrong. -

Example 1.4: Using an assertion function to test array operations

<?php
$fixture = array();
assertTrue(count($fixture) == 0);
 
$fixture[] = 'element';
assertTrue(count($fixture) == 1);
 
function assertTrue($condition)
{
    if (!$condition) {
        throw new Exception('Assertion failed.');
    }
}
?>


- - - The test is now completely automated. Instead of just - testing as we did with our first version, - with this version we have an automated test. -

- The goal of using automated tests is to make fewer mistakes. While your - code will still not be perfect, even with excellent tests, you will - likely see a dramatic reduction in defects once you start automating - tests. Automated tests give you justified confidence in your code. You - can use this confidence to take more daring leaps in design - (Refactoring), get along with your teammates better (Cross-Team Tests), - improve relations with your customers, and go home every night with - proof that the system is better now than it was this morning because of - your efforts. -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/build-automation.html phpunit-3.6.10/doc/html/build-automation.html --- phpunit-3.5.5/doc/html/build-automation.html 2010-09-27 16:52:23.000000000 +0000 +++ phpunit-3.6.10/doc/html/build-automation.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,175 +0,0 @@ - - - - Chapter 19. Build Automation - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 19. Build Automation

- This chapter provides an overview of build automation tools that are - commonly used with PHPUnit. -

Apache Ant

- - - Apache Ant is a Java-based - build tool. In theory, it is kind of like make, - without make's wrinkles. Build files for Apache Ant - are XML-based, calling out a target tree where various tasks get executed. -

- Example 19.1 shows an - Apache Ant build.xml file that invokes PHPUnit using the built-in - <exec> task. The build process is aborted - if a test fails (failonerror="true"). -

Example 19.1: Apache Ant build.xml file that invokes PHPUnit

<project name="Money" default="build">
- <target name="clean">
-  <delete dir="${basedir}/build"/>
- </target>
-
- <target name="prepare">
-  <mkdir dir="${basedir}/build/logs"/>
- </target>
-
- <target name="phpunit">
-  <exec dir="${basedir}" executable="phpunit" failonerror="true">
-   <arg line="--log-xml ${basedir}/build/logs/phpunit.xml MoneyTest" />
-  </exec>
- </target>
-
- <target name="build" depends="clean,prepare,phpunit"/>
-</project>


ant
-Buildfile: build.xml
-
-clean:
-
-prepare:
-    [mkdir] Created dir: /home/sb/Money/build/logs
-
-phpunit:
-     [exec] PHPUnit 3.5.0 by Sebastian Bergmann.
-     [exec] 
-     [exec] ......................
-     [exec] 
-     [exec] Time: 0 seconds
-     [exec] 
-     [exec] OK (22 tests, 34 assertions)
-
-build:
-
-BUILD SUCCESSFUL
-Total time: 0 seconds

- The XML logfile for test results produced by PHPUnit (see the section called “Test Results (XML)”) is based upon the one used by the <junit> - task that comes with Apache Ant. -

Apache Maven

- - - Apache Maven is a software - project management and comprehension tool. Based on the concept of a - Project Object Model (POM), Apache Maven can manage a project's build, - reporting and documentation from a central place of information. - Maven for PHP uses the - power of Maven for building, testing, and documenting PHP projects. -

Phing

- - - - Phing (PHing Is Not GNU make) - is a project build system based on Apache Ant. You can do anything with it - that you could do with a traditional build system such as GNU make, and - its use of simple XML build files and extensible PHP "task" classes make - it an easy-to-use and highly flexible build framework. Features include - file transformations (e.g. token replacement, XSLT transformation, Smarty - template transformations), file system operations, interactive build - support, SQL execution, CVS operations, tools for creating PEAR packages, - and much more. -

- Example 19.2 shows a Phing - build.xml file that invokes PHPUnit using the built-in - <phpunit> task. The build process is - aborted if a test fails (haltonfailure="true"). -

Example 19.2: Phing build.xml file that invokes PHPUnit

<project name="Money" default="build">
- <target name="clean">
-  <delete dir="build"/>
- </target>
-
- <target name="prepare">
-  <mkdir dir="build/logs"/>
- </target>
-
- <target name="phpunit">
-  <phpunit printsummary="true" haltonfailure="true">
-    <formatter todir="build/logs" type="xml"/>
-    <batchtest>
-      <fileset dir=".">
-        <include name="*Test.php"/>
-      </fileset>
-    </batchtest>
-  </phpunit>
- </target>
-
- <target name="build" depends="clean,prepare,phpunit"/>
-</project>


phing
-Buildfile: /home/sb/Money/build.xml
-
-Money > clean:
-
-
-Money > prepare:
-
-    [mkdir] Created dir: /home/sb/Money/build/logs
-
-Money > phpunit:
-
-  [phpunit] Test: MoneyTest, Run: 22, Failures: 0, Errors: 0,
-            Incomplete: 0, Skipped: 0, Time elapsed: 0.06887 s
-
-Money > build:
-
-
-BUILD FINISHED
-
-Total time: 0.2632 seconds
- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/code-coverage-analysis.html phpunit-3.6.10/doc/html/code-coverage-analysis.html --- phpunit-3.5.5/doc/html/code-coverage-analysis.html 2010-09-27 16:52:24.000000000 +0000 +++ phpunit-3.6.10/doc/html/code-coverage-analysis.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ - - - - Chapter 14. Code Coverage Analysis - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 14. Code Coverage Analysis

 

- The beauty of testing is found not in the effort but in the effiency. -

- Knowing what should be tested is beautiful, and knowing what is being - tested is beautiful. -

 
 --Murali Nandigama

- - - In this chapter you will learn all about PHPUnit's code coverage - functionality that provides an insight into what parts of the production - code are executed when the tests are run. It helps answering questions such - as: -

  • - How do you find code that is not yet tested -- or, in other words, not - yet covered by a test? -

  • How do you measure testing completeness?

- An example of what code coverage statistics can mean is that if there is a - method with 100 lines of code, and only 75 of these lines are actually - executed when tests are being run, then the method is considered to have a - code coverage of 75 percent. -

- - - PHPUnit's code coverage functionality makes use of the - PHP_CodeCoverage - component, which in turn leverages the statement coverage functionality - provided by the Xdebug - extension for PHP. -

- Let us generate a code coverage report for the BankAccount - class from Example 13.3. -

phpunit --coverage-html ./report BankAccountTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-...
-
-Time: 0 seconds
-
-OK (3 tests, 3 assertions)
-
-Generating report, this may take a moment.

- Figure 14.1 shows - an excerpt from a Code Coverage report. Lines of code that were executed - while running the tests are highlighted green, lines of code that are - executable but were not executed are highlighted red, and "dead code" is - highlighted grey. The number left to the actual line of code indicates - how many tests cover that line. -

Figure 14.1. Code Coverage for setBalance()

Code Coverage for setBalance()


- Clicking on the line number of a covered line will open a panel (see - Figure 14.2) that - shows the test cases that cover this line. -

Figure 14.2. Panel with information on covering tests

Panel with information on covering tests


- The code coverage report for our BankAccount example - shows that we do not have any tests yet that call the - setBalance(), depositMoney(), and - withdrawMoney() methods with legal values. - Example 14.1 - shows a test that can be added to the BankAccountTest - test case class to completely cover the BankAccount - class. -

Example 14.1: Test missing to achieve complete code coverage

<?php
require_once 'BankAccount.php';
 
class BankAccountTest extends PHPUnit_Framework_TestCase
{
    // ...
 
    public function testDepositWithdrawMoney()
    {
        $this->assertEquals(0, $this->ba->getBalance());
        $this->ba->depositMoney(1);
        $this->assertEquals(1, $this->ba->getBalance());
        $this->ba->withdrawMoney(1);
        $this->assertEquals(0, $this->ba->getBalance());
    }
}
?>


- Figure 14.3 shows - the code coverage of the setBalance() method with the - additional test. -

Figure 14.3. Code Coverage for setBalance() with additional test

Code Coverage for setBalance() with additional test


Specifying Covered Methods

- - - - The @covers annotation (see - Table B.1) can be - used in the test code to specify which method(s) a test method wants to - test. If provided, only the code coverage information for the specified - method(s) will be considered. - Example 14.2 - shows an example. -

Example 14.2: Tests that specify which method they want to cover

<?php
require_once 'BankAccount.php';
 
class BankAccountTest extends PHPUnit_Framework_TestCase
{
    protected $ba;
 
    protected function setUp()
    {
        $this->ba = new BankAccount;
    }
 
    /**
     * @covers BankAccount::getBalance
     */
    public function testBalanceIsInitiallyZero()
    {
        $this->assertEquals(0, $this->ba->getBalance());
    }
 
    /**
     * @covers BankAccount::withdrawMoney
     */
    public function testBalanceCannotBecomeNegative()
    {
        try {
            $this->ba->withdrawMoney(1);
        }
 
        catch (BankAccountException $e) {
            $this->assertEquals(0, $this->ba->getBalance());
 
            return;
        }
 
        $this->fail();
    }
 
    /**
     * @covers BankAccount::depositMoney
     */
    public function testBalanceCannotBecomeNegative2()
    {
        try {
            $this->ba->depositMoney(-1);
        }
 
        catch (BankAccountException $e) {
            $this->assertEquals(0, $this->ba->getBalance());
 
            return;
        }
 
        $this->fail();
    }
 
    /**
     * @covers BankAccount::getBalance
     * @covers BankAccount::depositMoney
     * @covers BankAccount::withdrawMoney
     */
 
    public function testDepositWithdrawMoney()
    {
        $this->assertEquals(0, $this->ba->getBalance());
        $this->ba->depositMoney(1);
        $this->assertEquals(1, $this->ba->getBalance());
        $this->ba->withdrawMoney(1);
        $this->assertEquals(0, $this->ba->getBalance());
    }
}
?>


Ignoring Code Blocks

- - - - - - Sometimes you have blocks of code that you cannot test and that you may - want to ignore during code coverage analysis. PHPUnit lets you do this - using the @codeCoverageIgnore, - @codeCoverageIgnoreStart and - @codeCoverageIgnoreEnd annotations as shown in - Example 14.3. -

Example 14.3: Using the @codeCoverageIgnore, @codeCoverageIgnoreStart and @codeCoverageIgnoreEnd annotations

<?php
/**
 * @codeCoverageIgnore
 */
class Foo
{
    public function bar()
    {
    }
}
 
class Bar
{
    /**
     * @codeCoverageIgnore
     */
    public function foo()
    {
    }
}
 
if (FALSE) {
    // @codeCoverageIgnoreStart
    print '*';
    // @codeCoverageIgnoreEnd
}
?>


- The lines of code that are markes as to be ignored using the annotations - are counted as executed (if they are executable) and will not be - highlighted. -

Including and Excluding Files

- - - - - By default, all sourcecode files that contain at least one line of code - that has been executed (and only these files) are included in the report. - The sourcecode files that are included in the report can be filtered by - using a blacklist or a whitelist approach. -

- The blacklist is pre-filled with all sourcecode files of PHPUnit itself - as well as the tests. When the whitelist is empty (default), blacklisting - is used. When the whitelist is not empty, whitelisting is used. When - whitelisting is used, each file on the whitelist is optionally added to - the code coverage report regardless of whether or not it was executed. -

- PHPUnit's XML configuration file (see the section called “Including and Excluding Files for Code Coverage”) - can be used to control the blacklist and the whitelist. Using a whitelist - is the recommended best practice to control the list of files included in - the code coverage report. -

- - - Alternatively, you can configure the sourcecode files that are included in - the report using the PHP_CodeCoverage_Filter API. -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/continuous-integration.html phpunit-3.6.10/doc/html/continuous-integration.html --- phpunit-3.5.5/doc/html/continuous-integration.html 2010-09-27 16:52:24.000000000 +0000 +++ phpunit-3.6.10/doc/html/continuous-integration.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,225 +0,0 @@ - - - - Chapter 20. Continuous Integration - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 20. Continuous Integration

- This chapter provides an overview of Continuous Integration summarizing - the technique and its application with PHPUnit. -

 

- Continuous Integration - is a software development practice where members of a team integrate - their work frequently, usually each person integrates at least daily, - leading to multiple integrations per day. Each integration is verified - by an automated build (including test) to detect integration errors as - quickly as possible. Many teams find that this approach leads to - significantly reduced integration problems and allows a team to develop - cohesive software more rapidly. -

 
 --Martin Fowler

- Continuous Integration demands a fully automated and reproducible build, - including testing, that runs many times a day. This allows each developer - to integrate daily thus reducing integration problems. While this can - be achieved by setting up a - cronjob that - makes a fresh checkout from the project's - source - code repository at regular intervals, runs the tests, and - publishes the results, a more comfortable solution may be desired. -

Atlassian Bamboo

- - - Atlassian Bamboo - is a Continuous Integration (CI) server that assists software development - teams by providing automated building and testing of software source-code - status, updates on successful/failed builds, and reporting tools for - statistical analysis. -

- The following example assumes that the Bamboo distribution archive has - been unpacked into /usr/local/Bamboo. -

  1. cd /usr/local/Bamboo
  2. Edit the webapp/WEB-INF/classes/bamboo-init.properties file.

  3. Optionally install the bamboo-checkstyle plugin.

Example 20.1: bamboo-init.properties

bamboo.home=/usr/local/Bamboo


  1. ./bamboo.sh start
  2. Open http://localhost:8085/ in your webbrowser.

  3. Follow the guided installation instructions.

  4. Configure Apache Ant as a Builder in the Administration panel.

- Bamboo is now configured and we can set up a project plan. First we need - a project, though. For the purpose of this example lets assume we have a - copy of the Money sample that ships with PHPUnit in a - Subversion repository (file:///var/svn/money). - Together with the *.php files we also have the - following Apache Ant build script (build.xml) in the - repository. -

Example 20.2: build.xml

<project name="Money" default="build">
- <target name="clean">
-  <delete dir="${basedir}/build"/>
- </target>
-
- <target name="prepare">
-  <mkdir dir="${basedir}/build"/>
-  <mkdir dir="${basedir}/build/logs"/>
- </target>
-
- <target name="phpcs">
-  <exec dir="${basedir}"
-        executable="phpcs"
-        output="${basedir}/build/logs/checkstyle.xml"
-        failonerror="false">
-   <arg line="--report=checkstyle ." />
-  </exec>
- </target>
-
- <target name="phpunit">
-  <exec dir="${basedir}" executable="phpunit" failonerror="true">
-   <arg line="--log-xml         ${basedir}/build/logs/phpunit.xml
-              --coverage-clover ${basedir}/build/logs/clover.xml
-              --coverage-html   ${basedir}/build/coverage
-              MoneyTest" />
-  </exec>
- </target>
-
- <target name="build" depends="clean,prepare,phpcs,phpunit"/>
-</project>


- Now that we have a project, we can create a plan for it in Bamboo. -

  1. Open http://localhost:8080/ in your webbrowser.

  2. Follow the guided "Create a Plan" instructions.

  3. In step 3 of "Create a Plan", check the "The build will produce test results" and "Clover output will be produced" options and provide the paths to the XML files produced by PHPUnit.

    If you installed the bamboo-checkstyle plugin also check the "CheckStyle output will be produced" option and provide the path of the XML file produced by PHP_CodeSniffer.

  4. In step 5 of "Create a Plan", set up an artifact for the HTML files (*.*, build/coverage) that PHPUnit produces.

CruiseControl

- - - - CruiseControl - is a framework for continuous build processes and includes, but is not - limited to, plugins for email notification, Apache Ant, and various source - control tools. A web interface is provided to view the details of the - current and previous builds. -

- The following example assumes that CruiseControl has been installed into - /usr/local/cruisecontrol. -

  1. cd /usr/local/cruisecontrol
  2. mkdir -p projects/Money/build/logs
  3. cd projects/Money
  4. svn co file:///var/svn/money source
  5. Edit the build.xml file.

Example 20.3: projects/Money/build.xml

<project name="Money" default="build" basedir=".">
- <target name="checkout">
-  <exec dir="${basedir}/source/" executable="svn">
-   <arg line="up"/>
-  </exec>
- </target>
-
- <target name="test">
-  <exec dir="${basedir}/source" executable="phpunit" failonerror="true">
-   <arg line="--log-xml ${basedir}/build/logs/phpunit.xml MoneyTest"/>
-  </exec>
- </target>
-
- <target name="build" depends="checkout,test"/>
-</project>


  1. cd /usr/local/cruisecontrol
  2. Edit the config.xml file.

Example 20.4: config.xml

<cruisecontrol>
-  <project name="Money" buildafterfailed="false">
-    <plugin
-    name="svnbootstrapper"
-    classname="net.sourceforge.cruisecontrol.bootstrappers.SVNBootstrapper"/>
-    <plugin
-    name="svn"
-    classname="net.sourceforge.cruisecontrol.sourcecontrols.SVN"/>
-
-    <listeners>
-      <currentbuildstatuslistener file="logs/${project.name}/status.txt"/>
-    </listeners>
-
-    <bootstrappers>
-      <svnbootstrapper localWorkingCopy="projects/${project.name}/source/"/>
-    </bootstrappers>
-
-    <modificationset>
-      <svn localWorkingCopy="projects/${project.name}/source/"/>
-    </modificationset>
-
-    <schedule interval="300">
-      <ant
-      anthome="apache-ant-1.7.0"
-      buildfile="projects/${project.name}/build.xml"/>
-    </schedule>
-
-    <log dir="logs/${project.name}">
-      <merge dir="projects/${project.name}/build/logs/"/>
-    </log>
-
-    <publishers>
-      <currentbuildstatuspublisher
-      file="logs/${project.name}/buildstatus.txt"/>
-
-      <email
-      mailhost="localhost"
-      buildresultsurl="http://cruise.example.com/buildresults/${project.name}"
-      skipusers="true"
-      spamwhilebroken="true"
-      returnaddress="project@example.com">
-        <failure address="dev@lists.example.com" reportWhenFixed="true"/>
-      </email>
-    </publishers>
-  </project>
-</cruisecontrol>


- Now we can (re)start the CruiseControl server. -

  1. ./cruisecontrol.sh
  2. Open http://localhost:8080/ in your webbrowser.

phpUnderControl

- - - phpUnderControl is an - extension for CruiseControl that integrates several PHP development tools, - such as PHPUnit for testing, - PHP_CodeSniffer - for static - code analysis, and PHPDocumentor - for API - documentation generation. It comes with a powerful command-line - tool that can, among other things, automatically create CruiseControl's - XML configuration files for your project. The following example assumes - that CruiseControl has been installed into - /usr/local/cruisecontrol. -

  1. pear install --alldeps phpunit/phpUnderControl
  2. phpuc install /usr/local/cruisecontrol
  3. phpuc project --version-control svn
    -              --version-control-url file:///var/svn/money
    -              --test-case MoneyTest
    -              --test-file MoneyTest.php
    -              --test-dir .
    -              --project-name Money
    -              /usr/local/cruisecontrol

- The above command creates the project directory and the project's - build.xml configuration file, performs the initial - checkout from the source repository, and adds the new project to the - global config.xml configuration file. Now we can - (re)start the CruiseControl server. -

  1. cd /usr/local/cruisecontrol
  2. ./cruisecontrol.sh
  3. Open http://localhost:8080/ in your webbrowser.

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/database.html phpunit-3.6.10/doc/html/database.html --- phpunit-3.5.5/doc/html/database.html 2010-09-27 16:52:25.000000000 +0000 +++ phpunit-3.6.10/doc/html/database.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,321 +0,0 @@ - - - - Chapter 9. Database Testing - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 9. Database Testing

- - - - While creating tests for your software you may come across database code - that needs to be unit tested. The database extension has been created to - provide an easy way to place your database in a known state, execute your - database-effecting code, and ensure that the expected data is found in the - database. -

- The quickest way to create a new Database Unit Test is to extend the - PHPUnit_Extensions_Database_TestCase class. This class - provides the functionality to create a database connection, seed your - database with data, and after executing a test comparing the contents of - your database with a data set that can be built in a variety of formats. In - Example 9.1 you can see - examples of getConnection() and getDataSet() - implementations. -

Example 9.1: Setting up a database test case

<?php
require_once 'PHPUnit/Extensions/Database/TestCase.php';
 
class DatabaseTest extends PHPUnit_Extensions_Database_TestCase
{
    protected function getConnection()
    {
        $pdo = new PDO('mysql:host=localhost;dbname=testdb', 'root', '');
        return $this->createDefaultDBConnection($pdo, 'testdb');
    }
 
    protected function getDataSet()
    {
        return $this->createFlatXMLDataSet(dirname(__FILE__).'/_files/bank-account-seed.xml');
    }
}
?>


- The getConnection() method must return an - implementation of the PHPUnit_Extensions_Database_DB_IDatabaseConnection - interface. The createDefaultDBConnection() method can - be used to return a database connection. It accepts a PDO - object as the first parameter and the name of the schema you are testing - against as the second parameter. -

- The getDataSet() method must return an implementation of - the PHPUnit_Extensions_Database_DataSet_IDataSet - interface. There are currently three different data sets available in - PHPUnit. These data sets are discussed in the section called “Data Sets” -

Table 9.1. Database Test Case Methods

MethodMeaning
PHPUnit_Extensions_Database_DB_IDatabaseConnection getConnection()Implement to return the database connection that will be checked for expected data sets and tables.
PHPUnit_Extensions_Database_DataSet_IDataSet getDataSet()Implement to return the data set that will be used in in database set up and tear down operations.
PHPUnit_Extensions_Database_Operation_DatabaseOperation getSetUpOperation()Override to return a specific operation that should be performed on the test database at the beginning of each test. The various operations are detailed in the section called “Operations”.
PHPUnit_Extensions_Database_Operation_DatabaseOperation getTearDownOperation()Override to return a specific operation that should be performed on the test database at the end of each test. The various operations are detailed in the section called “Operations”.
PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection createDefaultDBConnection(PDO $connection, string $schema)Return a database connection wrapper around the $connection PDO object. The database schema being tested against should be specified by $schema. The result of this method can be returned from getConnection().
PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet createFlatXMLDataSet(string $xmlFile)Returns a flat XML data set that is created from the XML file located at the absolute path specified in $xmlFile. More details about flat XML files can be found in the section called “Flat XML Data Set”. The result of this method can be returned from getDataSet().
PHPUnit_Extensions_Database_DataSet_XmlDataSet createXMLDataSet(string $xmlFile)Returns a XML data set that is created from the XML file located at the absolute path specified in $xmlFile. More details about XML files can be found in the section called “XML Data Set”. The result of this method can be returned from getDataSet().
void assertTablesEqual(PHPUnit_Extensions_Database_DataSet_ITable $expected, PHPUnit_Extensions_Database_DataSet_ITable $actual)Reports an error if the contents of the $expected table do not match the contents in the $actual table.
void assertDataSetsEqual(PHPUnit_Extensions_Database_DataSet_IDataSet $expected, PHPUnit_Extensions_Database_DataSet_IDataSet $actual)Reports an error if the contents of the $expected data set do not match the contents in the $actual data set.


Data Sets

- Data sets are the basic building blocks for both your database fixture as - well as the assertions you may make at the end of your test. When - returning a data set as a fixture from the PHPUnit_Extensions_Database_TestCase::getDataSet() - method, the default implementation in PHPUnit will automatically truncate - all tables specified and then insert the data from your data set in the - order specified by the data set. For your convenience there are several - different types of data sets that can be used at your convenience. -

Flat XML Data Set

- The flat XML data set is a very simple XML format that uses a single - XML element for each row in your data set. An example of a flat XML - data set is shown in Example 9.2. -

Example 9.2: A Flat XML Data Set

<?xml version="1.0" encoding="UTF-8" ?>
-<dataset>
-  <post 
-    post_id="1" 
-    title="My First Post" 
-    date_created="2008-12-01 12:30:29" 
-    contents="This is my first post" rating="5"
-  />
-  <post 
-    post_id="2" 
-    title="My Second Post" 
-    date_created="2008-12-04 15:35:25" 
-    contents="This is my second post" 
-  />
-  <post 
-    post_id="3" 
-    title="My Third Post" 
-    date_created="2008-12-09 03:17:05" 
-    contents="This is my third post" 
-    rating="3" 
-  />
-
-  <post_comment 
-    post_comment_id="2" 
-    post_id="2" 
-    author="Frank" 
-    content="That is because this is simply an example." 
-    url="http://phpun.it/" 
-  />
-  <post_comment 
-    post_comment_id="1" 
-    post_id="2" 
-    author="Tom" 
-    content="While the topic seemed interesting the content was lacking." 
-  />
-
-  <current_visitors />
-</dataset>
-


- As you can see the formatting is extremely simple. Each of the elements - within the root <dataset> element represents a - row in the test database with the exception of the last - <current_visitors /> element (this will be - discussed shortly.) The name of the element is the equivalent of a - table name in your database. The name of each attribute is the - equivalent of a column name in your databases. The value of each - attribute is the equivalent of the value of that column in that row. -

- This format, while simple, does have some special considerations. The - first of these is how you deal with empty tables. With the default - operation of CLEAN_INSERT you can specify that you - want to truncate a table and not insert any values by listing that - table as an element without any attributes. This can be seen in - Example 9.2 with the - <current_visitors /> element. The most common - reason you would want to ensure an empty table as a part of your - fixture is when your test should be inserting data to that table. The - less data your database has, the quicker your tests will run. So if I - where testing my simple blogging software's ability to add comments to - a post, I would likely change - Example 9.2 to specify - post_comment as an empty table. When dealing with - assertions it is often useful to ensure that a table is not being - unexpectedly written to, which could also be accomplished in FlatXML - using the empty table format. -

- The second consideration is how NULL values are - defined. The nature of the flat XML format only allows you to - explicitly specify strings for column values. Of course your database - will convert a string representation of a number or date into the - appropriate data type. However, there are no string representations of - NULL. You can imply a NULL value - by leaving a column out of your element's attribute list. This will - cause a NULL value to be inserted into the database for that column. - This leads me right into my next consideration that makes implicit - NULL values somewhat difficult to deal with. -

- The third consideration is how columns are defined. The column list for - a given table is determined by the attributes in the first element for - any given table. - In Example 9.2 the - post table would be considered to have the columns - post_id, title, - date_created, contents and - rating. If the first <post> - were removed then the post would no longer be - considered to have the rating column. This means that the first element - of a given name defines the structure of that table. In the simplest of - examples, this means that your first defined row must have a value for - every column that you expect to have values for in the rest of rows for - that table. If an element further into your data set specifies a column - that was not specified in the first element then that value will be - ignored. You can see how this influenced the order of elements in my - dataset in Example 9.2. - I had to specify the second <post_comment> - element first due to the non-NULL value in the url - column. -

- There is a way to work around the inability to explicitly set - NULL in a flat XML data using the Replacement data - set type. This will be discussed further in - the section called “Replacement Data Set”. -

XML Data Set

- While the flat XML data set is simple it also proves to be limiting. A - more powerful xml alternative is the XML data set. It is a more - structured xml format that allows you to be much more explicit with - your data set. An example of the XML data set equivalent to the previous - flat XML example is shown in - Example 9.3. -

Example 9.3: A XML Data Set

<?xml version="1.0" encoding="UTF-8" ?>
-<dataset>
-  <table name="post">
-    <column>post_id</column>
-    <column>title</column>
-    <column>date_created</column>
-    <column>contents</column>
-    <column>rating</column>
-    <row>
-      <value>1</value>
-      <value>My First Post</value>
-      <value>2008-12-01 12:30:29</value>
-      <value>This is my first post</value>
-      <value>5</value>
-    </row>
-    <row>
-      <value>2</value>
-      <value>My Second Post</value>
-      <value>2008-12-04 15:35:25</value>
-      <value>This is my second post</value>
-      <null />
-    </row>
-    <row>
-      <value>3</value>
-      <value>My Third Post</value>
-      <value>2008-12-09 03:17:05</value>
-      <value>This is my third post</value>
-      <value>3</value>
-    </row>
-  </table>
-  <table name="post_comment">
-    <column>post_comment_id</column>
-    <column>post_id</column>
-    <column>author</column>
-    <column>content</column>
-    <column>url</column>
-    <row>
-      <value>1</value>
-      <value>2</value>
-      <value>Tom</value>
-      <value>While the topic seemed interesting the content was lacking.</value>
-      <null />
-    </row>
-    <row>
-      <value>2</value>
-      <value>2</value>
-      <value>Frank</value>
-      <value>That is because this is simply an example.</value>
-      <value>http://phpun.it</value>
-    </row>
-  </table>
-  <table name="current_visitors">
-    <column>current_visitors_id</column>
-    <column>ip</column>
-  </table>
-</dataset>
-


- The formatting is more verbose than that of the Flat XML data set but - in some ways much easier to understand. The root element is again the - <dataset> element. Then directly under that - element you will have one or more <table> - elements. Each <table> element must have a - name attribute with a value equivalent to the name - of the table being represented. The <table> - element will then include one or more <column> - elements containing the name of a column in that table. The - <table> element will also include any number - (including zero) of <row> elements. The - <row> element will be what ultimately - specifies the data to store/remove/update in the database or to check - the current database against. The <row> - element must have the same number of children as there are - <column> elements in that - <table> element. The order of your child - elements is also determined by the order of your - <column> elements for that table. There are - two different elements that can be used as children of the - <row> element. You may use the - <value> element to specify the value of that - column in much the same way you can use attributes in the flat XML data - set. The content of the <value> element will - be considered the content of that column for that row. You may also use - the <null> element to explicitly indicate - that the column is to be given a NULL value. The - <null> element does not contain any attributes - or children. -

- You can use the DTD in - Example 9.4 to validate your - XML data set files. A reference of the valid elements in an XML data - set can be found in Table 9.2 -

Example 9.4: The XML Data Set DTD

<?xml version="1.0" encoding="UTF-8"?>
-<!ELEMENT dataset (table+) | ANY>
-<!ELEMENT table (column*, row*)>
-<!ATTLIST table
-    name CDATA #REQUIRED
->
-<!ELEMENT column (#PCDATA)>
-<!ELEMENT row (value | null | none)*>
-<!ELEMENT value (#PCDATA)>
-<!ELEMENT null EMPTY>
-


Table 9.2. XML Data Set Element Description

ElementPurposeContentsAttributes
<dataset>The root element of the xml data set file.One or more <table> elements.None
<table>Defines a table in the dataset.One or more <column> elements and zero or more <row> elements.name - The name of the table.
<column>Defines a column in the current table.A text node containing the name of the column.None
<row>Defines a row in the table.One or more <value> or <null> elements.None
<value>Sets the value of the column in the same position as this value.A text node containing the value of the corresponding column.None
<null>Sets the value of the column in the same position of this value to NULL.NoneNone


CSV Data Set

- While XML data sets provide a convenient way to structure your data, in many cases they can be time consuming to hand edit as there are not very many XML editors that provide an easy way to edit tabular data via xml. In these cases you may find the CSV data set to be much more useful. The CSV data set is very simple to understand. Each CSV file represents a table. The first row in the CSV file must contain the column names and all subsequent rows will contain the data for those columns. -

- To construct a CSV data set you must instantiate the PHPUnit_Extensions_Database_DataSet_CsvDataSet class. The constructor takes three parameters: $delimiter, $enclosure and $escape. These parameters allow you to specify the exact formatting of rows within your CSV file. So this of course means it doesn't have to really be a CSV file. You can also provide a tab delimited file. The default constructor will specify a comma delimited file with fields enclosed by a double quote. If there is a double quote within a value it will be escaped by an additional double quote. This is as close to an accepted standard for CSV as there is. -

- Once your CSV data set class is instantiated you can use the method addTable() to add CSV files as tables to your data set. The addTable method takes two parameters. The first is $tableName and contains the name of the table you are adding. The second is $csvFile and contains the path to the CSV you will be using to set the data for that table. You can call addTable() for each table you would like to add to your data set. -

- In Example 9.5 you can see an example of how three CSV files can be combined into the database fixture for a database test case. -

Example 9.5: CSV Data Set Example

 
--- fixture/post.csv ---
post_id,title,date_created,contents,rating
1,My First Post,2008-12-01 12:30:29,This is my first post,5
2,My Second Post,2008-12-04 15:35:25,This is my second post,
3,My Third Post,2008-12-09 03:17:05,This is my third post,3
 
--- fixture/post_comment.csv ---
post_comment_id,post_id,author,content,url
1,2,Tom,While the topic seemed interesting the content was lacking.,
2,2,Frank,That is because this is simply an example.,http://phpun.it
 
--- fixture/current_visitors.csv ---
current_visitors_id,ip
 
--- DatabaseTest.php ---
<?php
require_once 'PHPUnit/Extensions/Database/TestCase.php';
require_once 'PHPUnit/Extensions/Database/DataSet/CsvDataSet.php';
 
class DatabaseTest extends PHPUnit_Extensions_Database_TestCase
{
    protected function getConnection()
    {
        $pdo = new PDO('mysql:host=localhost;dbname=testdb', 'root', '');
        return $this->createDefaultDBConnection($pdo, 'testdb');
    }
 
    protected function getDataSet()
    {
    $dataSet = new PHPUnit_Extensions_Database_DataSet_CsvDataSet();
    $dataSet->addTable('post', 'fixture/post.csv');
    $dataSet->addTable('post_comment', 'fixture/post_comment.csv');
    $dataSet->addTable('current_visitors', 'fixture/current_visitors.csv');
        return $dataSet;
    }
}
?>


- Unfortunately, while the CSV dataset is appealing from the aspect of edit-ability, it has the same problems with NULL values as the flat XML dataset. There is no native way to explicitly specify a null value. If you do not specify a value (as I have done with some of the fields above) then the value will actually be set to that data type's equivalent of an empty string. Which in most cases will not be what you want. I will address this shortcoming of both the CSV and the flat XML data sets shortly. -

Replacement Data Set

- ... -

Operations

- ... -

Database Testing Best Practices

- ... -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/docbook.css phpunit-3.6.10/doc/html/docbook.css --- phpunit-3.5.5/doc/html/docbook.css 2010-09-19 10:35:33.000000000 +0000 +++ phpunit-3.6.10/doc/html/docbook.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,421 +0,0 @@ -body { - margin: 0; - padding: 0; - border: 0; - width: 100%; - background: #fff; - min-width: 600px; - font-size: 90%; -} - -a { - color: #369; -} - -a:hover { - color: #fff; - background: #369; - text-decoration: none; -} - -h1, h2, h3 { - margin: .8em 0 .2em 0; - padding: 0; -} - -p { - margin: .4em 0 .8em 0; - padding: 0; -} - -img { - margin: 10px 0 5px; -} - -#header { - clear: both; - float: left; - width: 100%; -} - -#header { - border-bottom: 1px solid #000; -} - -#header p, -#header h1, -#header h2 { - padding: .4em 15px 0 15px; - margin: 0; -} - -#header ul { - clear: left; - float: left; - width: 100%; - list-style: none; - margin: 10px 0 0 0; - padding: 0; -} - -#header ul li { - display: inline; - list-style: none; - margin: 0; - padding: 0; -} - -#header ul li a { - display: block; - float: left; - margin: 0 0 0 1px; - padding: 3px 10px; - text-align: center; - background: #eee; - color: #000; - text-decoration: none; - position: relative; - left: 15px; - line-height: 1.3em; -} - -#header ul li a:hover { - background: #369; - color: #fff; -} - -#header ul li a.active, -#header ul li a.active:hover, -dl dt .chapter a.active, -dl dt .chapter a.active:hover -{ - color: #fff; - background: #000; - font-weight: bold; -} - -#header ul li a span { - display: block; -} - -#layoutdims { - clear: both; - background: #eee; - border-top: 4px solid #000; - margin: 0; - padding: 6px 15px !important; - text-align: right; -} - -.colmask { - position: relative; - clear: both; - float: left; - width: 100%; - overflow: hidden; -} - -.colright, -.colmid, -.colleft { - float: left; - width: 100%; - position: relative; -} - -.col1, -.col2, -.col3 { - float: left; - position: relative; - padding: 0 0 1em 0; - overflow: hidden; -} - -.leftmenu { - background: #fff; -} - -.leftmenu .colleft { - right: 75%; - background: #f4f4f4; -} - -.leftmenu .col1 { - width: 71%; - left: 102%; -} - -.leftmenu .col2 { - width: 21%; - left: 6%; -} - -#footer { - clear: both; - float: left; - width: 100%; - border-top: 1px solid #000; -} - -#footer p { - padding: 10px; - margin: 0; -} - -table { - border-color: black; - border-width: 2; -} - -.epigraph { - font-size: small; - margin-bottom: 40px; - text-align: right; -} - -pre.programlisting, pre.screen, code { - font-family: monospace; -} - -p.note, div.example pre.programlisting, pre.screen { - background-color: #eeeeec; - margin: 1em 0 1em 0; - padding: 0.2em; -} - -.epigraph, .list-of-examples, .list-of-figures, .toc, div.example pre.programlisting, pre.screen { - line-height: 110%; -} - -.filename { - font-style: italic; -} - -.blockquote, .navheader, .navfooter { - -moz-border-radius: 8px; - margin-bottom: 10px; - margin-top: 10px; - padding: 2px; -} - -table .blockquote { - background-color: #eeeeec; - border: 1px solid #eeeeec; -} - -.navheader, .navfooter { - background-color: #d3d7cf; - border: 1px solid #d3d7cf; -} - -.navheader hr, .navfooter hr { - display: none; -} - -.table table { - border: 1px #eeeeec solid; - border-spacing: 0px; -} - -.table td { - border: 1px #eeeeec solid; - text-align: left; - vertical-align: top; -} - -.table th { - background: #eeeeec; - border: 1px #eeeeec solid; - text-align: left; - vertical-align: top; -} - -.sidebar { - display: none; -} - -pre span.bg { - color: #eeeeec; - font-weight: bold; -} - -pre span.comment { - color: #8f5902; - font-weight: bold; -} - -pre span.default { - color: #204a87; - font-weight: bold; -} - -pre span.html { - color: #000000; - font-weight: bold; -} - -pre span.keyword { - color: #4e9a06; - font-weight: bold; -} - -pre span.string { - color: #a40000; - font-weight: bold; -} - -body * { - /* margin: 0 0 0 0; - padding: 0 0 0 0; */ -} - -body { - font-family: Verdana; - font-size: 12px; -} - -body div#header { - margin: 0 0 0 0; - background-color: #333; - border: none; - border-bottom: 10px solid #999; -} - -body div#header h1 { - color: #fff; - margin: 0 0 5px 0; -} - -body div#header ul { - -} - -body div#header ul li { - -} - -body div#header ul li a { - float: left; - display: block; - margin-right: -10px; - margin-bottom: -10px; - padding: 5px 20px 15px 10px; - -moz-border-radius-topleft: 3px; - -webkit-border-top-left-radius: 3px; - -moz-border-radius-topright: 3px; - -webkit-border-top-right-radius: 3px; - background-color: #F4F4F4; -} - -body div#header ul li a:hover { - background-color: #999; -} - -body div#header ul li a.active { - background-color: #999; -} - -body div.colmask { - border-top: 3px solid #999; -} - -body div.colleft div.col2 { - -} - -body div.colleft div.col2 a { - color: #333; - text-decoration: none; - border-bottom: 1px dotted #ccc; -} - -body div.colleft div.col2 span.chapter a { - display: block; - padding: 2px 3px; - margin: 5px 0px 10px -3px; - -} - -body div.colleft div.col2 a:hover { - background: none; - border-bottom: 1px dotted #333; - color: #000; - font-weight: bold; -} - -body div.colleft div.col2 span.chapter a.active { - color: #000; - font-weight: bold; - background: none; - border-bottom: 1px dotted #333; - font-size: 14px; -} - -body div.colleft div.col2 dl dt { - margin: 0 0 5px 0; -} - -body div.colleft div.col2 dl dd dl dt { - margin: 0 0 5px -15px; -} -body div.colleft div.col2 dl dd dl dd { - margin-bottom: 10px; -} -body div.colleft div.col2 dl dd dl dd dl dt { - margin: 0 0 5px -30px; -} - -body div.colleft div.col2 dl dd dl dd dl dt code { - color: #333; -} - -body div.colleft div.col1 table{ - background: #f4f4f4; - padding: 3px 6px; - -moz-border-radius-bottomleft: 5px; - -webkit-border-bottom-left-radius: 5px; - -moz-border-radius-bottomright: 5px; - -webkit-border-bottom-right-radius: 5px; - -} - -body div.colleft div.col1 table a{ - color: #000; - text-decoration: none; - border-bottom: 1px dotted #ccc; - font-size: 15px; -} - -body div.colleft div.col1 table a:hover { - background: none; - border-bottom: 1px dotted #333; - font-weight: bold; - -} - -body div.colleft div.col1 div.chapter div.titlepage h2.title { - margin: 20px 0px 25px 0px !important; - font-size: 26px; - font-weight: normal; -} - -body div.colleft div.col1 div.chapter p { - line-height: 24px; - font-size: 16px; -} - -body div.colleft div.col1 div.chapter div.example { - padding: 5px; -} - -body div.colleft div.col1 div.chapter div.example div.example-contents pre{ - padding: 10px; -} - -body div.colleft div.col1 div.chapter div.table, -body div.colleft div.col1 div.chapter div.example div.example-contents pre.screen, -body div.colleft div.col1 div.chapter div.example div.example-contents pre code { - line-height: 20px; - font-size: 16px; -} diff -Nru phpunit-3.5.5/doc/html/extending-phpunit.html phpunit-3.6.10/doc/html/extending-phpunit.html --- phpunit-3.5.5/doc/html/extending-phpunit.html 2010-09-27 16:52:26.000000000 +0000 +++ phpunit-3.6.10/doc/html/extending-phpunit.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ - - - - Chapter 22. Extending PHPUnit - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 22. Extending PHPUnit

- PHPUnit can be extended in various ways to make the writing of tests - easier and customize the feedback you get from running tests. Here are - common starting points to extend PHPUnit. -

Subclass PHPUnit_Framework_TestCase

- - - Write utility methods in an abstract subclass of - PHPUnit_Framework_TestCase and derive your test case - classes from that class. This is one of the easiest ways to extend - PHPUnit. -

Assert Classes

- - - - Write your own class with assertions special to your purpose. -

Subclass PHPUnit_Extensions_TestDecorator

- - - You can wrap test cases or test suites in a subclass of - PHPUnit_Extensions_TestDecorator and use the - Decorator design pattern to perform some actions before and after the - test runs. -

- - - - PHPUnit ships with two concrete test decorators: - PHPUnit_Extensions_RepeatedTest and - PHPUnit_Extensions_TestSetup. The former is used to - run a test repeatedly and only count it as a success if all iterations - are successful. The latter was discussed in Chapter 6. -

- Example 22.1 - shows a cut-down version of the PHPUnit_Extensions_RepeatedTest - test decorator that illustrates how to write your own test decorators. -

Example 22.1: The RepeatedTest Decorator

<?php
require_once 'PHPUnit/Extensions/TestDecorator.php';
 
class PHPUnit_Extensions_RepeatedTest extends PHPUnit_Extensions_TestDecorator
{
    private $timesRepeat = 1;
 
    public function __construct(PHPUnit_Framework_Test $test, $timesRepeat = 1)
    {
        parent::__construct($test);
 
        if (is_integer($timesRepeat) &&
            $timesRepeat >= 0) {
            $this->timesRepeat = $timesRepeat;
        }
    }
 
    public function count()
    {
        return $this->timesRepeat * $this->test->count();
    }
 
    public function run(PHPUnit_Framework_TestResult $result = NULL)
    {
        if ($result === NULL) {
            $result = $this->createResult();
        }
 
        for ($i = 0; $i < $this->timesRepeat && !$result->shouldStop(); $i++) {
            $this->test->run($result);
        }
 
        return $result;
    }
}
?>


Implement PHPUnit_Framework_Test

- - - - The PHPUnit_Framework_Test interface is narrow and - easy to implement. You can write an implementation of - PHPUnit_Framework_Test that is simpler than - PHPUnit_Framework_TestCase and that runs - data-driven tests, for instance. -

- Example 22.2 - shows a data-driven test case class that compares values from a file - with Comma-Separated Values (CSV). Each line of such a file looks like - foo;bar, where the first value is the one we expect - and the second value is the actual one. -

Example 22.2: A data-driven test

<?php
require_once 'PHPUnit/Util/Timer.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
 
class DataDrivenTest implements PHPUnit_Framework_Test
{
    private $lines;
 
    public function __construct($dataFile)
    {
        $this->lines = file($dataFile);
    }
 
    public function count()
    {
        return 1;
    }
 
    public function run(PHPUnit_Framework_TestResult $result = NULL)
    {
        if ($result === NULL) {
            $result = new PHPUnit_Framework_TestResult;
        }
 
        foreach ($this->lines as $line) {
            $result->startTest($this);
            PHPUnit_Util_Timer::start();
 
            list($expected, $actual) = explode(';', $line);
 
            try {
                PHPUnit_Framework_Assert::assertEquals(trim($expected), trim($actual));
            }
 
            catch (PHPUnit_Framework_AssertionFailedError $e) {
                $result->addFailure($this, $e, PHPUnit_Util_Timer::stop());
            }
 
            catch (Exception $e) {
                $result->addError($this, $e, PHPUnit_Util_Timer::stop());
            }
 
            $result->endTest($this, PHPUnit_Util_Timer::stop());
        }
 
        return $result;
    }
}
 
$test = new DataDrivenTest('data_file.csv');
$result = PHPUnit_TextUI_TestRunner::run($test);
?>
PHPUnit 3.5.0 by Sebastian Bergmann.
-
-.F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) DataDrivenTest
-Failed asserting that two strings are equal.
-expected string <bar>
-difference      <  x>
-got string      <baz>
-/home/sb/DataDrivenTest.php:32
-/home/sb/DataDrivenTest.php:53
-
-FAILURES!
-Tests: 2, Failures: 1.


Subclass PHPUnit_Framework_TestResult

- - - By passing a special-purpose PHPUnit_Framework_TestResult - object to the run() method, you can change the way - tests are run and what result data gets collected. -

Implement PHPUnit_Framework_TestListener

- - - - You do not necessarily need to write a whole subclass of - PHPUnit_Framework_TestResult in order to customize - it. Most of the time, it will suffice to implement a new - PHPUnit_Framework_TestListener - (see Table 21.13) and attach - it to the PHPUnit_Framework_TestResult object, before - running the tests. -

- Example 22.3 - shows a simple implementation of the PHPUnit_Framework_TestListener - interface. -

Example 22.3: A simple test listener

<?php
class SimpleTestListener
implements PHPUnit_Framework_TestListener
{
  public function
  addError(PHPUnit_Framework_Test $test,
           Exception $e,
           $time)
  {
    printf(
      "Error while running test '%s'.\n",
      $test->getName()
    );
  }
 
  public function
  addFailure(PHPUnit_Framework_Test $test,
             PHPUnit_Framework_AssertionFailedError $e,
             $time)
  {
    printf(
      "Test '%s' failed.\n",
      $test->getName()
    );
  }
 
  public function
  addIncompleteTest(PHPUnit_Framework_Test $test,
                    Exception $e,
                    $time)
  {
    printf(
      "Test '%s' is incomplete.\n",
      $test->getName()
    );
  }
 
  public function
  addSkippedTest(PHPUnit_Framework_Test $test,
                 Exception $e,
                 $time)
  {
    printf(
      "Test '%s' has been skipped.\n",
      $test->getName()
    );
  }
 
  public function startTest(PHPUnit_Framework_Test $test)
  {
    printf(
      "Test '%s' started.\n",
      $test->getName()
    );
  }
 
  public function endTest(PHPUnit_Framework_Test $test, $time)
  {
    printf(
      "Test '%s' ended.\n",
      $test->getName()
    );
  }
 
  public function
  startTestSuite(PHPUnit_Framework_TestSuite $suite)
  {
    printf(
      "TestSuite '%s' started.\n",
      $suite->getName()
    );
  }
 
  public function
  endTestSuite(PHPUnit_Framework_TestSuite $suite)
  {
    printf(
      "TestSuite '%s' ended.\n",
      $suite->getName()
    );
  }
}
?>


- - - - Example 22.4 - shows how to run and observe a test suite. -

Example 22.4: Running and observing a test suite

<?php
require_once 'ArrayTest.php';
require_once 'SimpleTestListener.php';
 
// Create a test suite that contains the tests
// from the ArrayTest class.
$suite = new PHPUnit_Framework_TestSuite('ArrayTest');
 
// Create a test result and attach a SimpleTestListener
// object as an observer to it.
$result = new PHPUnit_Framework_TestResult;
$result->addListener(new SimpleTestListener);
 
// Run the tests.
$suite->run($result);
?>
TestSuite 'ArrayTest' started.
-Test 'testNewArrayIsEmpty' started.
-Test 'testNewArrayIsEmpty' ended.
-Test 'testArrayContainsAnElement' started.
-Test 'testArrayContainsAnElement' ended.
-TestSuite 'ArrayTest' ended.


New Test Runner

- If you need different feedback from the test execution, write your own - test runner, interactive or not. The abstract - PHPUnit_Runner_BaseTestRunner class, which the - PHPUnit_TextUI_TestRunner class (the PHPUnit - command-line test runner) inherits from, can be a starting point for - this. -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - Binary files /tmp/Knw5Sy4V92/phpunit-3.5.5/doc/html/figures/Code_Coverage.png and /tmp/U5xiu5QOi5/phpunit-3.6.10/doc/html/figures/Code_Coverage.png differ Binary files /tmp/Knw5Sy4V92/phpunit-3.5.5/doc/html/figures/Code_Coverage2.png and /tmp/U5xiu5QOi5/phpunit-3.6.10/doc/html/figures/Code_Coverage2.png differ Binary files /tmp/Knw5Sy4V92/phpunit-3.5.5/doc/html/figures/Code_Coverage3.png and /tmp/U5xiu5QOi5/phpunit-3.6.10/doc/html/figures/Code_Coverage3.png differ Binary files /tmp/Knw5Sy4V92/phpunit-3.5.5/doc/html/figures/PHPUnit_Framework.png and /tmp/U5xiu5QOi5/phpunit-3.6.10/doc/html/figures/PHPUnit_Framework.png differ diff -Nru phpunit-3.5.5/doc/html/fixtures.html phpunit-3.6.10/doc/html/fixtures.html --- phpunit-3.5.5/doc/html/fixtures.html 2010-09-27 16:52:27.000000000 +0000 +++ phpunit-3.6.10/doc/html/fixtures.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,273 +0,0 @@ - - - - Chapter 6. Fixtures - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 6. Fixtures

- - - One of the most time-consuming parts of writing tests is writing the - code to set the world up in a known state and then return it to its - original state when the test is complete. This known state is called - the fixture of the test. -

- In Example 4.1, the - fixture was simply the array that is stored in the $fixture - variable. Most of the time, though, the fixture will be more complex - than a simple array, and the amount of code needed to set it up will - grow accordingly. The actual content of the test gets lost in the noise - of setting up the fixture. This problem gets even worse when you write - several tests with similar fixtures. Without some help from the testing - framework, we would have to duplicate the code that sets up the fixture - for each test we write. -

- - - - - PHPUnit supports sharing the setup code. Before a test method is run, a - template method called setUp() is invoked. - setUp() is where you create the objects against which - you will test. Once the test method has finished running, whether it - succeeded or failed, another template method called - tearDown() is invoked. tearDown() - is where you clean up the objects against which you tested. -

- In Example 4.2 we - used the producer-consumer relationship between tests to share fixture. This - is not always desired or even possible. Example 6.1 - shows how we can write the tests of the StackTest in such - a way that not the fixture itself is reused but the code that creates it. - First we declare the instance variable, $stack, that we - are going to use instead of a method-local variable. Then we put the - creation of the array fixture into the - setUp() method. Finally, we remove the redundant code - from the test methods and use the newly introduced instance variable, - $this->stack, instead of the method-local variable - $stack with the assertEquals() - assertion method. -

Example 6.1: Using setUp() to create the stack fixture

<?php
class StackTest extends PHPUnit_Framework_TestCase
{
    protected $stack;
 
    protected function setUp()
    {
        $this->stack = array();
    }
 
    public function testEmpty()
    {
        $this->assertTrue(empty($this->stack));
    }
 
    public function testPush()
    {
        array_push($this->stack, 'foo');
        $this->assertEquals('foo', $this->stack[count($this->stack)-1]);
        $this->assertFalse(empty($this->stack));
    }
 
    public function testPop()
    {
        array_push($this->stack, 'foo');
        $this->assertEquals('foo', array_pop($this->stack));
        $this->assertTrue(empty($this->stack));
    }
}
?>


- - - - - - - The setUp() and tearDown() template - methods are run once for each test method (and on fresh instances) of the - test case class. -

- - - - - - - - - - In addition, the setUpBeforeClass() and - tearDownAfterClass() template methods are called before - the first test of the test case class is run and after the last test of the - test case class is run, respectively. -

- - - The example below shows all template methods that are available in a test - case class. -

Example 6.2: Example showing all template methods available

<?php
class TemplateMethodsTest extends PHPUnit_Framework_TestCase
{
    public static function setUpBeforeClass()
    {
        print __METHOD__ . "\n";
    }
 
    protected function setUp()
    {
        print __METHOD__ . "\n";
    }
 
    protected function assertPreConditions()
    {
        print __METHOD__ . "\n";
    }
 
    public function testOne()
    {
        print __METHOD__ . "\n";
        $this->assertTrue(TRUE);
    }
 
    public function testTwo()
    {
        print __METHOD__ . "\n";
        $this->assertTrue(FALSE);
    }
 
    protected function assertPostConditions()
    {
        print __METHOD__ . "\n";
    }
 
    protected function tearDown()
    {
        print __METHOD__ . "\n";
    }
 
    public static function tearDownAfterClass()
    {
        print __METHOD__ . "\n";
    }
 
    protected function onNotSuccessfulTest(Exception $e)
    {
        print __METHOD__ . "\n";
        throw $e;
    }
}
?>
phpunit TemplateMethodsTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-TemplateMethodsTest::setUpBeforeClass
-TemplateMethodsTest::setUp
-TemplateMethodsTest::assertPreConditions
-TemplateMethodsTest::testOne
-TemplateMethodsTest::assertPostConditions
-TemplateMethodsTest::tearDown
-.TemplateMethodsTest::setUp
-TemplateMethodsTest::assertPreConditions
-TemplateMethodsTest::testTwo
-TemplateMethodsTest::tearDown
-TemplateMethodsTest::onNotSuccessfulTest
-FTemplateMethodsTest::tearDownAfterClass
-
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) TemplateMethodsTest::testTwo
-Failed asserting that <boolean:false> is true.
-/home/sb/TemplateMethodsTest.php:30
-
-FAILURES!
-Tests: 2, Assertions: 2, Failures: 1.


More setUp() than tearDown()

- setUp() and tearDown() are nicely - symmetrical in theory but not in practice. In practice, you only need - to implement tearDown() if you have allocated - external resources like files or sockets in setUp(). - If your setUp() just creates plain PHP objects, you - can generally ignore tearDown(). However, if you - create many objects in your setUp(), you might want - to unset() the variables pointing to those objects - in your tearDown() so they can be garbage collected. - The garbage collection of test case objects is not predictable. -

Variations

- What happens when you have two tests with slightly different setups? - There are two possibilities: -

  • - If the setUp() code differs only slightly, move - the code that differs from the setUp() code to - the test method. -

  • - If you really have a different setUp(), you need - a different test case class. Name the class after the difference in - the setup. -

Sharing Fixture

- There are few good reasons to share fixtures between tests, but in most - cases the need to share a fixture between tests stems from an unresolved - design problem. -

- A good example of a fixture that makes sense to share across several - tests is a database connection: you log into the database once and reuse - the database connection instead of creating a new connection for each - test. This makes your tests run faster. -

- - - - Example 6.3 - uses the setUpBeforeClass() and - tearDownAfterClass() template methods to connect to the - database before the test case class' first test and to disconnect from the - database after the last test of the test case, respectively. -

Example 6.3: Sharing fixture between the tests of a test suite

<?php
class DatabaseTest extends PHPUnit_Framework_TestCase
{
    protected static $dbh;
 
    public static function setUpBeforeClass()
    {
        self::$dbh = new PDO('sqlite::memory:');
    }
 
    public static function tearDownAfterClass()
    {
        self::$dbh = NULL;
    }
}
?>


- It cannot be emphasized enough that sharing fixtures between tests - reduces the value of the tests. The underlying design problem is - that objects are not loosely coupled. You will achieve better - results solving the underlying design problem and then writing tests - using stubs (see Chapter 11), than by creating - dependencies between tests at runtime and ignoring the opportunity - to improve your design. -

Global State

- It is hard to test code that uses singletons. - The same is true for code that uses global variables. Typically, the code - you want to test is coupled strongly with a global variable and you cannot - control its creation. An additional problem is the fact that one test's - change to a global variable might break another test. -

- In PHP, global variables work like this: -

  • A global variable $foo = 'bar'; is stored as $GLOBALS['foo'] = 'bar';.

  • The $GLOBALS variable is a so-called super-global variable.

  • Super-global variables are built-in variables that are always available in all scopes.

  • In the scope of a function or method, you may access the global variable $foo by either directly accessing $GLOBALS['foo'] or by using global $foo; to create a local variable with a reference to the global variable.

- Besides global variables, static attributes of classes are also part of - the global state. -

- - - - By default, PHPUnit runs your tests in a way where changes to global - and super-global variables ($GLOBALS, - $_ENV, $_POST, - $_GET, $_COOKIE, - $_SERVER, $_FILES, - $_REQUEST) do not affect other tests. Optionally, this - isolation can be extended to static attributes of classes. -

Note

- The implementation of the backup and restore operations for static - attributes of classes requires PHP 5.3 (or greater). -

- The implementation of the backup and restore operations for global - variables and static attributes of classes uses serialize() - and unserialize(). -

- Objects of some classes that are provided by PHP itself, such as - PDO for example, cannot be serialized and the backup - operation will break when such an object is stored in the - $GLOBALS array, for instance. -

- - - - The @backupGlobals annotation that is discussed in - the section called “@backupGlobals can be used to - control the backup and restore operations for global variables. - Alternatively, you can provide a blacklist of global variables that are to - be excluded from the backup and restore operations like this -

class MyTest extends PHPUnit_Framework_TestCase
-{
-    protected $backupGlobalsBlacklist = array('globalVariable');
-
-    // ...
-}

-

Note

- Please note that setting the $backupGlobalsBlacklist - attribute inside the setUp() method, for instance, - has no effect. -

- - - - The @backupStaticAttributes annotation that is - discussed in the section called “@backupStaticAttributes - can be used to control the backup and restore operations for static - attributes. Alternatively, you can provide a blacklist of static - attributes that are to be excluded from the backup and restore operations - like this

class MyTest extends PHPUnit_Framework_TestCase
-{
-    protected $backupStaticAttributesBlacklist = array(
-      'className' => array('attributeName')
-    );
-
-    // ...
-}

-

Note

- Please note that setting the $backupStaticAttributesBlacklist - attribute inside the setUp() method, for instance, - has no effect. -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/goals.html phpunit-3.6.10/doc/html/goals.html --- phpunit-3.5.5/doc/html/goals.html 2010-09-27 16:52:28.000000000 +0000 +++ phpunit-3.6.10/doc/html/goals.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ - - - - Chapter 2. PHPUnit's Goals - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 2. PHPUnit's Goals

- So far, we only have two tests for the array built-in - and the sizeof() function. When we start to test the - numerous array_*() functions PHP offers, we will need - to write a test for each of them. We could write the infrastructure for - all these tests from scratch. However, it is much better to write a - testing infrastructure once and then write only the unique parts of each - test. PHPUnit is such an infrastructure. -

- A framework such as PHPUnit has to resolve a set of constraints, some of - which seem always to conflict with each other. Simultaneously, tests - should be: -

Easy to learn to write.

- If it's hard to learn how to write tests, developers will not learn - to write them. -

Easy to write.

- If tests are not easy to write, developers will not write them. -

Easy to read.

- Test code should contain no extraneous overhead so that the test - itself does not get lost in noise that surrounds it. -

Easy to execute.

- The tests should run at the touch of a button and present their - results in a clear and unambiguous format. -

Quick to execute.

- Tests should run fast so so they can be run hundreds or thousands - of times a day. -

Isolated.

- The tests should not affect each other. If the order in which the - tests are run changes, the results of the tests should not change. -

Composable.

- We should be able to run any number or combination of tests together. - This is a corollary of isolation. -

- There are two main clashes between these constraints: -

Easy to learn to write versus easy to write.

- Tests do not generally require all the flexibility of a programming - language. Many testing tools provide their own scripting language - that only includes the minimum necessary features for writing tests. - The resulting tests are easy to read and write because they have no - noise to distract you from the content of the tests. However, - learning yet another programming language and set of programming - tools is inconvenient and clutters the mind. -

Isolated versus quick to execute.

- If you want the results of one test to have no effect on the results - of another test, each test should create the full state of the world - before it begins to execute and return the world to its original - state when it finishes. However, setting up the world can take a - long time: for example connecting to a database and initializing it - to a known state using realistic data. -

- PHPUnit attempts to resolve these conflicts by using PHP as the testing - language. Sometimes the full power of PHP is overkill for writing little - straight-line tests, but by using PHP we leverage all the experience and - tools programmers already have in place. Since we are trying to convince - reluctant testers, lowering the barrier to writing those initial tests - is particularly important. -

- PHPUnit errs on the side of isolation over quick execution. Isolated - tests are valuable because they provide high-quality feedback. You do - not get a report with a bunch of test failures, which were really caused - because one test at the beginning of the suite failed and left the world - messed up for the rest of the tests. This orientation towards isolated - tests encourages designs with a large number of simple objects. Each - object can be tested quickly in isolation. The result is better designs - and faster tests. -

- PHPUnit assumes that most tests succeed and it is not worth reporting - the details of successful tests. When a test fails, that fact is worth - noting and reporting. The vast majority of tests should succeed and are - not worth commenting on except to count the number of tests that run. - This is an assumption that is really built into the reporting classes, - and not into the core of PHPUnit. When the results of a test run are - reported, you see how many tests were executed, but you only see details - for those that failed. -

- Tests are expected to be fine-grained, testing one aspect of one object. - Hence, the first time a test fails, execution of the test halts, and - PHPUnit reports the failure. It is an art to test by running in many - small tests. Fine-grained tests improve the overall design of the system. -

- When you test an object with PHPUnit, you do so only through the - object's public interface. Testing based only on publicly visible - behaviour encourages you to confront and solve difficult design problems - earlier, before the results of poor design can infect large parts of the - system. -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/incomplete-and-skipped-tests.html phpunit-3.6.10/doc/html/incomplete-and-skipped-tests.html --- phpunit-3.5.5/doc/html/incomplete-and-skipped-tests.html 2010-09-27 16:52:28.000000000 +0000 +++ phpunit-3.6.10/doc/html/incomplete-and-skipped-tests.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ - - - - Chapter 10. Incomplete and Skipped Tests - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 10. Incomplete and Skipped Tests

Incomplete Tests

- When you are working on a new test case class, you might want to begin - by writing empty test methods such as:

public function testSomething()
-{
-}

to keep track of the tests that you have to write. The - problem with empty test methods is that they are interpreted as a - success by the PHPUnit framework. This misinterpretation leads to the - test reports being useless -- you cannot see whether a test is actually - successful or just not yet implemented. Calling - $this->fail() in the unimplemented test method - does not help either, since then the test will be interpreted as a - failure. This would be just as wrong as interpreting an unimplemented - test as a success. -

- - - - - If we think of a successful test as a green light and a test failure - as a red light, we need an additional yellow light to mark a test - as being incomplete or not yet implemented. - PHPUnit_Framework_IncompleteTest is a marker - interface for marking an exception that is raised by a test method as - the result of the test being incomplete or currently not implemented. - PHPUnit_Framework_IncompleteTestError is the - standard implementation of this interface. -

- Example 10.1 - shows a test case class, SampleTest, that contains one test - method, testSomething(). By calling the convenience - method markTestIncomplete() (which automatically - raises an PHPUnit_Framework_IncompleteTestError - exception) in the test method, we mark the test as being incomplete. -

Example 10.1: Marking a test as incomplete

<?php
class SampleTest extends PHPUnit_Framework_TestCase
{
    public function testSomething()
    {
        // Optional: Test anything here, if you want.
        $this->assertTrue(TRUE, 'This should already work.');
 
        // Stop here and mark this test as incomplete.
        $this->markTestIncomplete(
          'This test has not been implemented yet.'
        );
    }
}
?>


- An incomplete test is denoted by an I in the output - of the PHPUnit command-line test runner, as shown in the following - example: -

phpunit --verbose SampleTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-SampleTest
-I
-
-
-Time: 0 seconds
-
-There was 1 incomplete test:
-
-1) testSomething(SampleTest)
-This test has not been implemented yet.
-/home/sb/SampleTest.php:14
-
-OK, but incomplete or skipped tests!
-Tests: 1, Assertions: 0, Incomplete: 1.

- Table 10.1 - shows the API for marking tests as incomplete. -

Table 10.1. API for Incomplete Tests

MethodMeaning
void markTestIncomplete()Marks the current test as incomplete.
void markTestIncomplete(string $message)Marks the current test as incomplete using $message as an explanatory message.


Skipping Tests

- Not all tests can be run in every environment. Consider, for instance, - a database abstraction layer that has several drivers for the different - database systems it supports. The tests for the MySQL driver can of - course only be run if a MySQL server is available. -

- Example 10.2 - shows a test case class, DatabaseTest, that contains one test - method, testConnection(). In the test case class' - setUp() template method we check whether the MySQLi - extension is available and use the markTestSkipped() - method to skip the test if it is not. -

Example 10.2: Skipping a test

<?php
class DatabaseTest extends PHPUnit_Framework_TestCase
{
    protected function setUp()
    {
        if (!extension_loaded('mysqli')) {
            $this->markTestSkipped(
              'The MySQLi extension is not available.'
            );
        }
    }
 
    public function testConnection()
    {
        // ...
    }
}
?>


- A test that has been skipped is denoted by an S in - the output of the PHPUnit command-line test runner, as shown in the - following example: -

phpunit --verbose DatabaseTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-DatabaseTest
-S
-
-
-Time: 0 seconds
-
-There was 1 skipped test:
-
-1) testConnection(DatabaseTest)
-The MySQLi extension is not available.
-/home/sb/DatabaseTest.php:11
-
-OK, but incomplete or skipped tests!
-Tests: 1, Assertions: 0, Skipped: 1.

- Table 10.2 - shows the API for skipping tests. -

Table 10.2. API for Skipping Tests

MethodMeaning
void markTestSkipped()Marks the current test as skipped.
void markTestSkipped(string $message)Marks the current test as skipped using $message as an explanatory message.


- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/index.html phpunit-3.6.10/doc/html/index.html --- phpunit-3.5.5/doc/html/index.html 2010-09-27 16:52:29.000000000 +0000 +++ phpunit-3.6.10/doc/html/index.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ - - - - - - - - - - -
-
-
- - - - - -
- - - - - - -
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/installation.html phpunit-3.6.10/doc/html/installation.html --- phpunit-3.5.5/doc/html/installation.html 2010-09-27 16:52:30.000000000 +0000 +++ phpunit-3.6.10/doc/html/installation.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +0,0 @@ - - - - Chapter 3. Installing PHPUnit - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 3. Installing PHPUnit

- PHPUnit should be installed using the - PEAR Installer. This installer is - the backbone of PEAR, which provides a distribution system for PHP packages, - and is shipped with every release of PHP since version 4.3.0. -

Note

- PHPUnit 3.5 requires PHP 5.2.7 (or later) but PHP 5.3.3 (or later) is - highly recommended. -

- PHP_CodeCoverage, the library that is used by PHPUnit 3.5 to collect and - process code coverage information, depends on Xdebug 2.0.5 (or later) but - Xdebug 2.1.0 (or later) is highly recommended. -

- The PEAR channel (pear.phpunit.de) that - is used to distribute PHPUnit needs to be registered with the local PEAR - environment. Furthermore, a component that PHPUnit depends upon is hosted on - the Symfony Components PEAR channel (pear.symfony-project.com). -

pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com

- This has to be done only once. Now the PEAR Installer can be used to - install packages from the PHPUnit channel: -

pear install phpunit/PHPUnit

- After the installation you can find the PHPUnit source files inside your - local PEAR directory; the path is usually - /usr/lib/php/PHPUnit. -

- Although using the PEAR Installer is the only supported way to install - PHPUnit, you can install PHPUnit manually. For manual installation, do - the following: -

  1. - Download a release archive from - http://pear.phpunit.de/get/ - and extract it to a directory that is listed in the - include_path of your php.ini - configuration file. -

  2. - Prepare the phpunit script: -

    1. - Rename the phpunit.php script to - phpunit. -

    2. - Replace the @php_bin@ string in it with the - path to your PHP command-line interpreter (usually - /usr/bin/php). -

    3. - Copy it to a directory that is in your path and make it executable - (chmod +x phpunit). -

  3. - Prepare the PHPUnit/Util/PHP.php script: -

    1. - Replace the @php_bin@ string in it with the - path to your PHP command-line interpreter (usually - /usr/bin/php). -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/logging.html phpunit-3.6.10/doc/html/logging.html --- phpunit-3.5.5/doc/html/logging.html 2010-09-27 16:52:31.000000000 +0000 +++ phpunit-3.6.10/doc/html/logging.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,208 +0,0 @@ - - - - Chapter 18. Logging - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 18. Logging

- - - PHPUnit can produce several types of logfiles. -

Test Results (XML)

- The XML logfile for test results produced by PHPUnit is based upon the one - used by the JUnit - task for Apache Ant. The following example shows the XML - logfile generated for the tests in ArrayTest: -

<?xml version="1.0" encoding="UTF-8"?>
-<testsuites>
-  <testsuite name="ArrayTest"
-             file="/home/sb/ArrayTest.php"
-             tests="2"
-             assertions="2"
-             failures="0"
-             errors="0"
-             time="0.016030">
-    <testcase name="testNewArrayIsEmpty"
-              class="ArrayTest"
-              file="/home/sb/ArrayTest.php"
-              line="6"
-              assertions="1"
-              time="0.008044"/>
-    <testcase name="testArrayContainsAnElement"
-              class="ArrayTest"
-              file="/home/sb/ArrayTest.php"
-              line="15"
-              assertions="1"
-              time="0.007986"/>
-  </testsuite>
-</testsuites>

- The following XML logfile was generated for two tests, - testFailure and testError, - of a test case class named FailureErrorTest and - shows how failures and errors are denoted. -

<?xml version="1.0" encoding="UTF-8"?>
-<testsuites>
-  <testsuite name="FailureErrorTest"
-             file="/home/sb/FailureErrorTest.php"
-             tests="2"
-             assertions="1"
-             failures="1"
-             errors="1"
-             time="0.019744">
-    <testcase name="testFailure"
-              class="FailureErrorTest"
-              file="/home/sb/FailureErrorTest.php"
-              line="6"
-              assertions="1"
-              time="0.011456">
-      <failure type="PHPUnit_Framework_ExpectationFailedException">
-testFailure(FailureErrorTest)
-Failed asserting that &lt;integer:2&gt; matches expected value &lt;integer:1&gt;.
-
-/home/sb/FailureErrorTest.php:8
-</failure>
-    </testcase>
-    <testcase name="testError"
-              class="FailureErrorTest"
-              file="/home/sb/FailureErrorTest.php"
-              line="11"
-              assertions="0"
-              time="0.008288">
-      <error type="Exception">testError(FailureErrorTest)
-Exception: 
-
-/home/sb/FailureErrorTest.php:13
-</error>
-    </testcase>
-  </testsuite>
-</testsuites>

Test Results (TAP)

- The Test Anything Protocol (TAP) - is Perl's simple text-based interface between testing modules. The - following example shows the TAP logfile generated for the tests in - ArrayTest: -

TAP version 13
-ok 1 - testNewArrayIsEmpty(ArrayTest)
-ok 2 - testArrayContainsAnElement(ArrayTest)
-1..2

- The following TAP logfile was generated for two tests, - testFailure and testError, - of a test case class named FailureErrorTest and - shows how failures and errors are denoted. -

TAP version 13
-not ok 1 - Failure: testFailure(FailureErrorTest)
-  ---
-  message: 'Failed asserting that <integer:2> matches expected value <integer:1>.'
-  severity: fail
-  data:
-    got: 2
-    expected: 1
-  ...
-not ok 2 - Error: testError(FailureErrorTest)
-1..2

Test Results (JSON)

- The JavaScript Object Notation (JSON) - is a lightweight data-interchange format. The following example shows - the JSON messages generated for the tests in ArrayTest: -

{"event":"suiteStart","suite":"ArrayTest","tests":2}
-{"event":"test","suite":"ArrayTest",
- "test":"testNewArrayIsEmpty(ArrayTest)","status":"pass",
- "time":0.000460147858,"trace":[],"message":""}
-{"event":"test","suite":"ArrayTest",
- "test":"testArrayContainsAnElement(ArrayTest)","status":"pass",
- "time":0.000422954559,"trace":[],"message":""}

- The following JSON messages were generated for two tests, - testFailure and testError, - of a test case class named FailureErrorTest and - show how failures and errors are denoted. -

{"event":"suiteStart","suite":"FailureErrorTest","tests":2}
-{"event":"test","suite":"FailureErrorTest",
- "test":"testFailure(FailureErrorTest)","status":"fail",
- "time":0.0082459449768066,"trace":[],
- "message":"Failed asserting that <integer:2> is equal to <integer:1>."}
-{"event":"test","suite":"FailureErrorTest",
- "test":"testError(FailureErrorTest)","status":"error",
- "time":0.0083680152893066,"trace":[],"message":""}

Code Coverage (XML)

- The XML format for code coverage information logging produced by PHPUnit - is loosely based upon the one used by - Clover. The following example shows the XML - logfile generated for the tests in BankAccountTest: -

<?xml version="1.0" encoding="UTF-8"?>
-<coverage generated="1184835473" phpunit="3.5.0">
-  <project name="BankAccountTest" timestamp="1184835473">
-    <file name="/home/sb/BankAccount.php">
-      <class name="BankAccountException">
-        <metrics methods="0" coveredmethods="0" statements="0"
-                 coveredstatements="0" elements="0" coveredelements="0"/>
-      </class>
-      <class name="BankAccount">
-        <metrics methods="4" coveredmethods="4" statements="13"
-                 coveredstatements="5" elements="17" coveredelements="9"/>
-      </class>
-      <line num="77" type="method" count="3"/>
-      <line num="79" type="stmt" count="3"/>
-      <line num="89" type="method" count="2"/>
-      <line num="91" type="stmt" count="2"/>
-      <line num="92" type="stmt" count="0"/>
-      <line num="93" type="stmt" count="0"/>
-      <line num="94" type="stmt" count="2"/>
-      <line num="96" type="stmt" count="0"/>
-      <line num="105" type="method" count="1"/>
-      <line num="107" type="stmt" count="1"/>
-      <line num="109" type="stmt" count="0"/>
-      <line num="119" type="method" count="1"/>
-      <line num="121" type="stmt" count="1"/>
-      <line num="123" type="stmt" count="0"/>
-      <metrics loc="126" ncloc="37" classes="2" methods="4" coveredmethods="4"
-               statements="13" coveredstatements="5" elements="17"
-               coveredelements="9"/>
-    </file>
-    <metrics files="1" loc="126" ncloc="37" classes="2" methods="4"
-             coveredmethods="4" statements="13" coveredstatements="5"
-             elements="17" coveredelements="9"/>
-  </project>
-</coverage>
- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/organizing-tests.html phpunit-3.6.10/doc/html/organizing-tests.html --- phpunit-3.5.5/doc/html/organizing-tests.html 2010-09-27 16:52:32.000000000 +0000 +++ phpunit-3.6.10/doc/html/organizing-tests.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,216 +0,0 @@ - - - - Chapter 7. Organizing Tests - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 7. Organizing Tests

- - - One of the goals of PHPUnit (see Chapter 2) is that tests - should be composable: we want to be able to run any number or combination - of tests together, for instance all tests for the whole project, or the - tests for all classes of a component that is part of the project, or just - the tests for a single class. -

- PHPUnit supports different ways of organizing tests and composing them into - a test suite. This chapter shows the most commonly used approaches. -

Composing a Test Suite Using the Filesystem

- Probably the easiest way to compose a test suite is to keep all test case - source files in a test directory. PHPUnit can automatically discover and - run the tests by recursively traversing the test directory. -

- Lets take a look at the test suite of the Object_Freezer - library. Looking at this project's directory structure, we see that the - test case classes in the Tests directory mirror the - package and class structure of the System Under Test (SUT) in the - Object directory: -

Object                              Tests
-|-- Freezer                         |-- Freezer
-|   |-- HashGenerator               |   |-- HashGenerator
-|   |   `-- NonRecursiveSHA1.php    |   |   `-- NonRecursiveSHA1Test.php
-|   |-- HashGenerator.php           |   |
-|   |-- IdGenerator                 |   |-- IdGenerator
-|   |   `-- UUID.php                |   |   `-- UUIDTest.php
-|   |-- IdGenerator.php             |   |
-|   |-- LazyProxy.php               |   |
-|   |-- Storage                     |   |-- Storage
-|   |   `-- CouchDB.php             |   |   `-- CouchDB
-|   |                               |   |       |-- WithLazyLoadTest.php
-|   |                               |   |       `-- WithoutLazyLoadTest.php
-|   |-- Storage.php                 |   |-- StorageTest.php
-|   `-- Util.php                    |   `-- UtilTest.php
-`-- Freezer.php                     `-- FreezerTest.php

- To run all tests for the library we just need to point the PHPUnit - command-line test runner to the test directory: -

phpunit Tests
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-............................................................ 60 / 75
-...............
-
-Time: 0 seconds
-
-OK (75 tests, 164 assertions)

- To run only the tests that are declared in the Object_FreezerTest - test case class in Tests/FreezerTest.php we can use - the following command: -

phpunit Tests/FreezerTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-............................
-
-Time: 0 seconds
-
-OK (28 tests, 60 assertions)

- For more fine-grained control of which tests to run we can use the - --filter switch: -

phpunit --filter testFreezingAnObjectWorks Tests
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-.
-
-Time: 0 seconds
-
-OK (1 test, 2 assertions)

Note

- A drawback of this approach is that we have no control over the order in - which the test are run. This can lead to problems with regard to test - dependencies, see the section called “Test Dependencies”. -

Composing a Test Suite Using XML Configuration

- PHPUnit's XML configuration file (Appendix C) - can also be used to compose a test suite. - Example 7.1 - shows a minimal example that will add all *Test classes - that are found in *Test.php files when the - Tests is recursively traversed. -

Example 7.1: Composing a Test Suite Using XML Configuration

<phpunit>
-  <testsuites>
-    <testsuite name="Object_Freezer">
-      <directory>Tests</directory>
-    </testsuite>
-  </testsuites>
-</phpunit>


Note

- A drawback of this approach is that we have no control over the order in - which the test are run. This can lead to problems with regard to test - dependencies, see the section called “Test Dependencies”. -

- Alternatively, we can make the order in which tests are executed explicit: -

Example 7.2: Composing a Test Suite Using XML Configuration

<phpunit>
-  <testsuites>
-    <testsuite name="Object_Freezer">
-      <file>Tests/Freezer/HashGenerator/NonRecursiveSHA1Test.php</file>
-      <file>Tests/Freezer/IdGenerator/UUIDTest.php</file>
-      <file>Tests/Freezer/UtilTest.php</file>
-      <file>Tests/FreezerTest.php</file>
-      <file>Tests/Freezer/StorageTest.php</file>
-      <file>Tests/Freezer/Storage/CouchDB/WithLazyLoadTest.php</file>
-      <file>Tests/Freezer/Storage/CouchDB/WithoutLazyLoadTest.php</file>
-    </testsuite>
-  </testsuites>
-</phpunit>


Using the TestSuite Class

- The PHPUnit_Framework_TestSuite class of the PHPUnit - framework allows us to organize tests into a hierarchy of test suite - objects. -

- Example 7.3 shows - the top-level AllTests class for a project that has a - package named Package. -

Example 7.3: The top-level AllTests class

<?php
require_once 'Package/AllTests.php';
// ...
 
class AllTests
{
    public static function suite()
    {
        $suite = new PHPUnit_Framework_TestSuite('Project');
 
        $suite->addTest(Package_AllTests::suite());
        // ...
 
        return $suite;
    }
}
?>


- The top-level AllTests class aggregates the - package-level Package_AllTests class that in turn - aggregates the test case classes for the classes of said package. -

Example 7.4: The Package_AllTests class

<?php
require_once 'Framework/ClassTest.php';
// ...
 
class Package_AllTests
{
    public static function suite()
    {
        $suite = new PHPUnit_Framework_TestSuite('Package');
 
        $suite->addTestSuite('Package_ClassTest');
        // ...
 
        return $suite;
    }
}
?>


- The Package_ClassTest class is a normal test case - class that extends the PHPUnit_Framework_TestCase base - class. -

  • - Executing phpunit AllTests in the - Tests directory will run all tests. -

  • - Executing phpunit AllTests in the - Tests/Package directory will run only the tests - for the Package_* classes. -

  • - Executing phpunit ClassTest in the - Tests/Package directory will run only the tests - for the Package_Class class (which are declared in - the Package_ClassTest class). -

  • - Executing phpunit --filter testSomething ClassTest - in the Tests/Package directory will run only the - test named testSomething from the - Package_ClassTest class. -

- - - - - The PHPUnit_Framework_TestSuite class offers two - template methods, setUp() and tearDown(), - that are called before the first test of the test suite and after the last - test of the test suite, respectively. -

Example 7.5: The MySuite class

<?php
require_once 'MyTest.php';
 
class MySuite extends PHPUnit_Framework_TestSuite
{
    public static function suite()
    {
        return new MySuite('MyTest');
    }
 
    protected function setUp()
    {
        print __METHOD__ . "\n";
    }
 
    protected function tearDown()
    {
        print __METHOD__ . "\n";
    }
}
?>


- The MyTest test case class that is added to the test - suite MySuite in - Example 7.5 - has two test methods, testOne() and testTwo() - as well as the setUp() and tearDown() - methods. The output shows in which order these eight methods are called: -

MySuite::setUp()
-MyTest::setUp()
-MyTest::testOne()
-MyTest::tearDown()
-MyTest::setUp()
-MyTest::testTwo()
-MyTest::tearDown()
-MySuite::tearDown()

Note

- A TestSuite's setUp() and - tearDown() methods will be called even if no test of - the test suite is run because it is, for instance, filtered. -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/other-uses-for-tests.html phpunit-3.6.10/doc/html/other-uses-for-tests.html --- phpunit-3.5.5/doc/html/other-uses-for-tests.html 2010-09-27 16:52:33.000000000 +0000 +++ phpunit-3.6.10/doc/html/other-uses-for-tests.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,131 +0,0 @@ - - - - Chapter 15. Other Uses for Tests - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 15. Other Uses for Tests

- Once you get used to writing automated tests, you will likely discover - more uses for tests. Here are some examples. -

Agile Documentation

- - - - - - Typically, in a project that is developed using an agile process, - such as Extreme Programming, the documentation cannot keep up with the - frequent changes to the project's design and code. Extreme Programming - demands collective code ownership, so all - developers need to know how the entire system works. If you are - disciplined enough to consequently use "speaking names" for your tests - that describe what a class should do, you can use PHPUnit's TestDox - functionality to generate automated documentation for your project based - on its tests. This documentation gives developers an overview of what - each class of the project is supposed to do. -

- PHPUnit's TestDox functionality looks at a test class and all the test - method names and converts them from camel case PHP names to sentences: - testBalanceIsInitiallyZero() becomes "Balance is - initially zero". If there are several test methods whose names only - differ in a suffix of one or more digits, such as - testBalanceCannotBecomeNegative() and - testBalanceCannotBecomeNegative2(), the sentence - "Balance cannot become negative" will appear only once, assuming that - all of these tests succeed. -

- Let us take a look at the agile documentation generated for the - BankAccount class (from - Example 13.1): -

phpunit --testdox BankAccountTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-BankAccount
- [x] Balance is initially zero
- [x] Balance cannot become negative

- Alternatively, the agile documentation can be generated in HTML or plain - text format and written to a file using the --testdox-html - and --testdox-text arguments. -

- - - Agile Documentation can be used to document the assumptions you make - about the external packages that you use in your project. When you use - an external package, you are exposed to the risks that the package will - not behave as you expect, and that future versions of the package will - change in subtle ways that will break your code, without you knowing it. - You can address these risks by writing a test every time you make an - assumption. If your test succeeds, your assumption is valid. If you - document all your assumptions with tests, future releases of the - external package will be no cause for concern: if the tests succeed, - your system should continue working. -

Cross-Team Tests

- When you document assumptions with tests, you own the tests. The - supplier of the package -- who you make assumptions about -- knows - nothing about your tests. If you want to have a closer relationship - with the supplier of a package, you can use the tests to communicate - and coordinate your activities. -

- When you agree on coordinating your activities with the supplier of a - package, you can write the tests together. Do this in such a way that - the tests reveal as many assumptions as possible. Hidden assumptions are - the death of cooperation. With the tests, you document exactly what you - expect from the supplied package. The supplier will know the package is - complete when all the tests run. -

- - - By using stubs (see the chapter on "Mock Objects", earlier in this book), - you can further decouple yourself from the supplier: The job of the - supplier is to make the tests run with the real implementation of the - package. Your job is to make the tests run for your own code. Until - such time as you have the real implementation of the supplied package, - you use stub objects. Following this approach, the two teams can develop - independently. -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/selenium.html phpunit-3.6.10/doc/html/selenium.html --- phpunit-3.5.5/doc/html/selenium.html 2010-09-27 16:52:34.000000000 +0000 +++ phpunit-3.6.10/doc/html/selenium.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,167 +0,0 @@ - - - - Chapter 17. PHPUnit and Selenium - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 17. PHPUnit and Selenium

Selenium RC

- - - Selenium RC is a - test tool that allows you to write automated user-interface tests for - web applications in any programming language against any HTTP website - using any mainstream browser. It uses - Selenium Core, a - library that performs automated browser tasks using JavaScript. Selenium - tests run directly in a browser, just as real users do. These tests can - be used for both acceptance testing (by performing - higher-level tests on the integrated system instead of just testing each - unit of the system independently) and browser compatibility - testing (by testing the web application on different - operating systems and browsers). -

- Let us take a look at how Selenium RC is installed: -

  1. Download a distribution archive of Selenium RC.
  2. Unzip the distribution archive and copy server/selenium-server.jar to /usr/local/bin, for instance.
  3. Start the Selenium RC server by running java -jar /usr/local/bin/selenium-server.jar.

- Now we can send commands to the Selenium RC server using its client/server - protocol. -

PHPUnit_Extensions_SeleniumTestCase

- - - The PHPUnit_Extensions_SeleniumTestCase test case - extension implements the client/server protocol to talk to Selenium RC as - well as specialized assertion methods for web testing. -

- Example 17.1 shows - how to test the contents of the <title> - element of the http://www.example.com/ - website. -

Example 17.1: Usage example for PHPUnit_Extensions_SeleniumTestCase

<?php
require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
 
class WebTest extends PHPUnit_Extensions_SeleniumTestCase
{
    protected function setUp()
    {
        $this->setBrowser('*firefox');
        $this->setBrowserUrl('http://www.example.com/');
    }
 
    public function testTitle()
    {
        $this->open('http://www.example.com/');
        $this->assertTitle('Example WWW Page');
    }
}
?>
phpunit WebTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 5 seconds
-
-There was 1 failure:
-
-1) testTitle(WebTest)
-Current URL: http://www.example.com/
-
-Failed asserting that two strings are equal.
-expected string <Example WWW Page>
-difference      <         xx>
-got string      <Example Web Page>
-/home/sb/WebTest.php:30
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


- Unlike with the PHPUnit_Framework_TestCase class, - test case classes that extend PHPUnit_Extensions_SeleniumTestCase - have to provide a setUp() method. This method is used - to configure the Selenium RC session. See - Table 17.1 - for the list of methods that are available for this. -

Table 17.1. Selenium RC API: Setup

MethodMeaning
void setBrowser(string $browser)Set the browser to be used by the Selenium RC server.
void setBrowserUrl(string $browserUrl)Set the base URL for the tests.
void setHost(string $host)Set the hostname for the connection to the Selenium RC server.
void setPort(int $port)Set the port for the connection to the Selenium RC server.
void setTimeout(int $timeout)Set the timeout for the connection to the Selenium RC server.
void setSleep(int $seconds)Set the number of seconds the Selenium RC client should sleep between sending action commands to the Selenium RC server.


- PHPUnit can optionally capture a screenshot when a Selenium test fails. To - enable this, set $captureScreenshotOnFailure, - $screenshotPath, and $screenshotUrl - in your test case class as shown in - Example 17.2. -

Example 17.2: Capturing a screenshot when a test fails

<?php
require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
 
class WebTest extends PHPUnit_Extensions_SeleniumTestCase
{
    protected $captureScreenshotOnFailure = TRUE;
    protected $screenshotPath = '/var/www/localhost/htdocs/screenshots';
    protected $screenshotUrl = 'http://localhost/screenshots';
 
    protected function setUp()
    {
        $this->setBrowser('*firefox');
        $this->setBrowserUrl('http://www.example.com/');
    }
 
    public function testTitle()
    {
        $this->open('http://www.example.com/');
        $this->assertTitle('Example WWW Page');
    }
}
?>
phpunit WebTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 5 seconds
-
-There was 1 failure:
-
-1) testTitle(WebTest)
-Current URL: http://www.example.com/
-Screenshot: http://localhost/screenshots/6c8e1e890fff864bd56db436cd0f309e.png
-
-Failed asserting that two strings are equal.
-expected string <Example WWW Page>
-difference      <         xx>
-got string      <Example Web Page>
-/home/sb/WebTest.php:30
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


- You can run each test using a set of browsers: Instead of using - setBrowser() to set up one browser you declare a - public static array named $browsers - in your test case class. Each item in this array describes one browser - configuration. Each of these browsers can be hosted by different - Selenium RC servers. - Example 17.3 shows - an example. -

Example 17.3: Setting up multiple browser configurations

<?php
require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
 
class WebTest extends PHPUnit_Extensions_SeleniumTestCase
{
    public static $browsers = array(
      array(
        'name'    => 'Firefox on Linux',
        'browser' => '*firefox',
        'host'    => 'my.linux.box',
        'port'    => 4444,
        'timeout' => 30000,
      ),
      array(
        'name'    => 'Safari on MacOS X',
        'browser' => '*safari',
        'host'    => 'my.macosx.box',
        'port'    => 4444,
        'timeout' => 30000,
      ),
      array(
        'name'    => 'Safari on Windows XP',
        'browser' => '*custom C:\Program Files\Safari\Safari.exe -url',
        'host'    => 'my.windowsxp.box',
        'port'    => 4444,
        'timeout' => 30000,
      ),
      array(
        'name'    => 'Internet Explorer on Windows XP',
        'browser' => '*iexplore',
        'host'    => 'my.windowsxp.box',
        'port'    => 4444,
        'timeout' => 30000,
      )
    );
 
    protected function setUp()
    {
        $this->setBrowserUrl('http://www.example.com/');
    }
 
    public function testTitle()
    {
        $this->open('http://www.example.com/');
        $this->assertTitle('Example Web Page');
    }
}
?>


- PHPUnit_Extensions_SeleniumTestCase can collect code - coverage information for tests run through Selenium: -

  1. Copy PHPUnit/Extensions/SeleniumTestCase/phpunit_coverage.php into your webserver's document root directory.
  2. In your webserver's php.ini configuration file, configure PHPUnit/Extensions/SeleniumTestCase/prepend.php and PHPUnit/Extensions/SeleniumTestCase/append.php as the auto_prepend_file and auto_append_file, respectively.
  3. In your test case class that extends PHPUnit_Extensions_SeleniumTestCase, use
    protected $coverageScriptUrl = 'http://host/phpunit_coverage.php';
    to configure the URL for the phpunit_coverage.php script.

- Table 17.2 lists the - various assertion methods that PHPUnit_Extensions_SeleniumTestCase - provides. -

Table 17.2. Assertions

AssertionMeaning
void assertElementValueEquals(string $locator, string $text)Reports an error if the value of the element identified by $locator is not equal to the given $text.
void assertElementValueNotEquals(string $locator, string $text)Reports an error if the value of the element identified by $locator is equal to the given $text.
void assertElementValueContains(string $locator, string $text)Reports an error if the value of the element identified by $locator does not contain the given $text.
void assertElementValueNotContains(string $locator, string $text)Reports an error if the value of the element identified by $locator contains the given $text.
void assertElementContainsText(string $locator, string $text)Reports an error if the element identified by $locator does not contain the given $text.
void assertElementNotContainsText(string $locator, string $text)Reports an error if the element identified by $locator contains the given $text.
void assertSelectHasOption(string $selectLocator, string $option)Reports an error if the given option is not available.
void assertSelectNotHasOption(string $selectLocator, string $option)Reports an error if the given option is available.
void assertSelected($selectLocator, $option)Reports an error if the given label is not selected.
void assertNotSelected($selectLocator, $option)Reports an error if the given label is selected.
void assertIsSelected(string $selectLocator, string $value)Reports an error if the given value is not selected.
void assertIsNotSelected(string $selectLocator, string $value)Reports an error if the given value is selected.


- Table 17.3 shows - the template method of PHPUnit_Extensions_SeleniumTestCase: -

Table 17.3. Template Methods

MethodMeaning
void defaultAssertions()Override to perform assertions that are shared by all tests of a test case. This method is called after each command that is sent to the Selenium RC server.


- Please refer to the documentation of Selenium commands - for a reference of the commands available and how they are used. -

- Using the runSelenese($filename) method, you can also - run a Selenium test from its Selenese/HTML specification. Furthermore, - using the static attribute $seleneseDirectory, you can - automatically create test objects from a directory that contains - Selenese/HTML files. The specified directory is recursively searched for - .htm files that are expected to contain Selenese/HTML. - Example 17.4 shows an - example. -

Example 17.4: Use a directory of Selenese/HTML files as tests

<?php
require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
 
class SeleneseTests extends PHPUnit_Extensions_SeleniumTestCase
{
    public static $seleneseDirectory = '/path/to/files';
}
?>


- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/skeleton-generator.html phpunit-3.6.10/doc/html/skeleton-generator.html --- phpunit-3.5.5/doc/html/skeleton-generator.html 2010-09-27 16:52:35.000000000 +0000 +++ phpunit-3.6.10/doc/html/skeleton-generator.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,147 +0,0 @@ - - - - Chapter 16. Skeleton Generator - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 16. Skeleton Generator

Generating a Test Case Class Skeleton

- - - When you are writing tests for existing code, you have to write the - same code fragments such as

public function testMethod()
-{
-}

over and over again. PHPUnit can help you by analyzing the - code of the existing class and generating a skeleton test case class for - it. -

Example 16.1: The Calculator class

<?php
class Calculator
{
    public function add($a, $b)
    {
        return $a + $b;
    }
}
?>


- The following example shows how to generate a skeleton test class - for a class named Calculator - (see Example 16.1). -

phpunit --skeleton Calculator
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-Wrote test class skeleton for Calculator to CalculatorTest.php.

- - - For each method in the original class, there will be an incomplete - test case (see Chapter 10) in - the generated test case class. -

Namespaced Classes and the Skeleton Generator

- When you are using the skeleton generator to generate code based on a - class that is declared in a namespace - you have to provide the qualified name of the class as well as the path to - the source file it is declared in. -

- For instance, for a class Bar that is declared in the - Foo namespace you need to invoke the skeleton - generator like this: -

phpunit --skeleton-test Foo\Bar Bar.php

-

- Below is the output of running the generated test case class. -

phpunit --verbose CalculatorTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-CalculatorTest
-I
-
-
-Time: 0 seconds
-
-There was 1 incomplete test:
-
-1) testAdd(CalculatorTest)
-This test has not been implemented yet.
-/home/sb/CalculatorTest.php:54
-
-OK, but incomplete or skipped tests!
-Tests: 1, Assertions: 0, Incomplete: 1.

- - - - You can use @assert annotation in the - documentation block of a method to automatically generate simple, - yet meaningful tests instead of incomplete test cases. - Example 16.2 - shows an example. -

Example 16.2: The Calculator class with @assert annotations

<?php
class Calculator
{
    /**
     * @assert (0, 0) == 0
     * @assert (0, 1) == 1
     * @assert (1, 0) == 1
     * @assert (1, 1) == 2
     */
    public function add($a, $b)
    {
        return $a + $b;
    }
}
?>


- Each method in the original class is checked for @assert - annotations. These are transformed into test code such as -

    /**
-     * Generated from @assert (0, 0) == 0.
-     */
-    public function testAdd() {
-        $o = new Calculator;
-        $this->assertEquals(0, $o->add(0, 0));
-    }

-

- Below is the output of running the generated test case class. -

phpunit CalculatorTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-....
-
-Time: 0 seconds
-
-
-OK (4 tests, 4 assertions)

- Table 16.1 - shows the supported variations of the @assert - annotation and how they are transformed into test code. -

Table 16.1. Supported variations of the @assert annotation

AnnotationTransformed to
@assert (...) == XassertEquals(X, method(...))
@assert (...) != XassertNotEquals(X, method(...))
@assert (...) === XassertSame(X, method(...))
@assert (...) !== XassertNotSame(X, method(...))
@assert (...) > XassertGreaterThan(X, method(...))
@assert (...) >= XassertGreaterThanOrEqual(X, method(...))
@assert (...) < XassertLessThan(X, method(...))
@assert (...) <= XassertLessThanOrEqual(X, method(...))
@assert (...) throws X@expectedException X


Generating a Class Skeleton from a Test Case Class

- When you are doing Test-Driven Development (see Chapter 13) - and write your tests before the code that the tests exercise, PHPUnit can - help you generate class skeletons from test case classes. -

- Following the convention that the tests for a class Unit - are written in a class named UnitTest, the test case - class' source is searched for variables that reference objects of the - Unit class and analyzing what methods are called on - these objects. For example, take a look at Example 16.4 which has - been generated based on the analysis of Example 16.3. -

Example 16.3: The BowlingGameTest class

<?php
class BowlingGameTest extends PHPUnit_Framework_TestCase
{
    protected $game;
 
    protected function setUp()
    {
        $this->game = new BowlingGame;
    }
 
    protected function rollMany($n, $pins)
    {
        for ($i = 0; $i < $n; $i++) {
            $this->game->roll($pins);
        }
    }
 
    public function testScoreForGutterGameIs0()
    {
        $this->rollMany(20, 0);
        $this->assertEquals(0, $this->game->score());
    }
}
?>


Example 16.4: The generated BowlingGame class skeleton

<?php
/**
 * Generated by PHPUnit on 2008-03-10 at 17:18:33.
 */
class BowlingGame
{
    /**
     * @todo Implement roll().
     */
    public function roll()
    {
        // Remove the following line when you implement this method.
        throw new RuntimeException('Not yet implemented.');
    }
 
    /**
     * @todo Implement score().
     */
    public function score()
    {
        // Remove the following line when you implement this method.
        throw new RuntimeException('Not yet implemented.');
    }
}
?>


- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/test-doubles.html phpunit-3.6.10/doc/html/test-doubles.html --- phpunit-3.5.5/doc/html/test-doubles.html 2010-09-27 16:52:36.000000000 +0000 +++ phpunit-3.6.10/doc/html/test-doubles.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,238 +0,0 @@ - - - - Chapter 11. Test Doubles - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 11. Test Doubles

- Gerard Meszaros introduces the concept of Test Doubles in - [Meszaros2007] like this: -

 

- - - Sometimes it is just plain hard to test the system under test (SUT) - because it depends on other components that cannot be used in the test - environment. This could be because they aren't available, they will not - return the results needed for the test or because executing them would - have undesirable side effects. In other cases, our test strategy requires - us to have more control or visibility of the internal behavior of the SUT. -

- - - - When we are writing a test in which we cannot (or chose not to) use a real - depended-on component (DOC), we can replace it with a Test Double. The - Test Double doesn't have to behave exactly like the real DOC; it merely - has to provide the same API as the real one so that the SUT thinks it is - the real one! -

 
 --Gerard Meszaros

- The getMock($className) method provided by PHPUnit can be - used in a test to automatically generate an object that can act as a test - double for the specified original class. This test double object can be used - in every context where an object of the original class is expected. -

- By default, all methods of the original class are replaced with a dummy - implementation that just returns NULL (without calling - the original method). Using the will($this->returnValue() - method, for instance, you can configure these dummy implementations to - return a value when called. -

Limitations

- Please note that final, private - and static methods cannot be stubbed or mocked. They - are ignored by PHPUnit's test double functionality and retain their - original behavior. -

Stubs

- - - The practice of replacing an object with a test double that (optionally) - returns configured return values is refered to as - stubbing. You can use a stub to - "replace a real component on which the SUT depends so that the test has a - control point for the indirect inputs of the SUT. This allows the test to - force the SUT down paths it might not otherwise execute". -

- - - Example 11.2 shows how - to stub method calls and set up return values. We first use the - getMock() method that is provided by the - PHPUnit_Framework_TestCase class (see Table 21.6) to set up a stub object that looks - like an object of SomeClass - (Example 11.1). We then - use the Fluent Interface - that PHPUnit provides to specify the behavior for the stub. In essence, - this means that you do not need to create several temporary objects and - wire them together afterwards. Instead, you chain method calls as shown in - the example. This leads to more readable and "fluent" code. -

Example 11.1: The class we want to stub

<?php
class SomeClass
{
    public function doSomething()
    {
        // Do something.
    }
}
?>


Example 11.2: Stubbing a method call to return a fixed value

<?php
require_once 'SomeClass.php';
 
class StubTest extends PHPUnit_Framework_TestCase
{
    public function testStub()
    {
        // Create a stub for the SomeClass class.
        $stub = $this->getMock('SomeClass');
 
        // Configure the stub.
        $stub->expects($this->any())
             ->method('doSomething')
             ->will($this->returnValue('foo'));
 
        // Calling $stub->doSomething() will now return
        // 'foo'.
        $this->assertEquals('foo', $stub->doSomething());
    }
}
?>


- "Behind the scenes", PHPUnit automatically generates a new PHP class that - implements the desired behavior when the getMock() - method is used. The generated test double class can be configured through - the optional arguments of the getMock() method. -

  • By default, all methods of the given class are replaced with a test double that just returns NULL unless a return value is configured using will($this->returnValue(), for instance.

  • When the second (optional) parameter is provided, only the methods whose names are in the array are replaced with a configurable test double. The behavior of the other methods is not changed.

  • The third (optional) parameter may hold a parameter array that is passed to the original class' constructor (which is not replaced with a dummy implementation by default).

  • The fourth (optional) parameter can be used to specify a class name for the generated test double class.

  • The fifth (optional) parameter can be used to disable the call to the original class' constructor.

  • The sixth (optional) parameter can be used to disable the call to the original class' clone constructor.

  • The seventh (optional) parameter can be used to disable __autoload() during the generation of the test double class.

- Sometimes you want to return one of the arguments of a method call - (unchanged) as the result of a stubbed method call. - Example 11.3 shows how you - can achieve this using returnArgument() instead of - returnValue(). -

Example 11.3: Stubbing a method call to return one of the arguments

<?php
require_once 'SomeClass.php';
 
class StubTest extends PHPUnit_Framework_TestCase
{
    public function testReturnArgumentStub()
    {
        // Create a stub for the SomeClass class.
        $stub = $this->getMock('SomeClass');
 
        // Configure the stub.
        $stub->expects($this->any())
             ->method('doSomething')
             ->will($this->returnArgument(0));
 
        // $stub->doSomething('foo') returns 'foo'
        $this->assertEquals('foo', $stub->doSomething('foo'));
 
        // $stub->doSomething('bar') returns 'bar'
        $this->assertEquals('bar', $stub->doSomething('bar'));
    }
}
?>


- When the stubbed method call should return a calculated value instead of - a fixed one (see returnValue()) or an (unchanged) - argument (see returnArgument()), you can use - returnCallback() to have the stubbed method return the - result of a callback function or method. See - Example 11.4 for an example. -

Example 11.4: Stubbing a method call to return a value from a callback

<?php
require_once 'SomeClass.php';
 
class StubTest extends PHPUnit_Framework_TestCase
{
    public function testReturnCallbackStub()
    {
        // Create a stub for the SomeClass class.
        $stub = $this->getMock('SomeClass');
 
        // Configure the stub.
        $stub->expects($this->any())
             ->method('doSomething')
             ->will($this->returnCallback('str_rot13'));
 
        // $stub->doSomething($argument) returns str_rot13($argument)
        $this->assertEquals('fbzrguvat', $stub->doSomething('something'));
    }
}
?>


- Instead of returning a value, a stubbed method can also raise an - exception. Example 11.5 - shows how to use throwException() to do this. -

Example 11.5: Stubbing a method call to throw an exception

<?php
require_once 'SomeClass.php';
 
class StubTest extends PHPUnit_Framework_TestCase
{
    public function testThrowExceptionStub()
    {
        // Create a stub for the SomeClass class.
        $stub = $this->getMock('SomeClass');
 
        // Configure the stub.
        $stub->expects($this->any())
             ->method('doSomething')
             ->will($this->throwException(new Exception));
 
        // $stub->doSomething() throws Exception
        $stub->doSomething();
    }
}
?>


- Alternatively, you can write the stub yourself and improve your design - along the way. Widely used resources are accessed through a single façade, - so you can easily replace the resource with the stub. For example, - instead of having direct database calls scattered throughout the code, - you have a single Database object, an implementor of - the IDatabase interface. Then, you can create a stub - implementation of IDatabase and use it for your - tests. You can even create an option for running the tests with the - stub database or the real database, so you can use your tests for both - local testing during development and integration testing with the real - database. -

- Functionality that needs to be stubbed out tends to cluster in the same - object, improving cohesion. By presenting the functionality with a - single, coherent interface you reduce the coupling with the rest of the - system. -

Mock Objects

- The practice of replacing an object with a test double that verifies - expectations, for instance asserting that a method has been called, is - refered to as mocking. -

- - - You can use a mock object "as an observation point - that is used to verify the indirect outputs of the SUT as it is exercised. - Typically, the mock object also includes the functionality of a test stub - in that it must return values to the SUT if it hasn't already failed the - tests but the emphasis is on the verification of the indirect outputs. - Therefore, a mock object is lot more than just a test stub plus - assertions; it is used a fundamentally different way". -

- Here is an example: suppose we want to test that the correct method, - update() in our example, is called on an object that - observes another object. Example 11.6 - shows the code for the Subject and Observer - classes that are part of the System under Test (SUT). -

Example 11.6: The Subject and Observer classes that are part of the System under Test (SUT)

<?php
class Subject
{
    protected $observers = array();
 
    public function attach(Observer $observer)
    {
        $this->observers[] = $observer;
    }
 
    public function doSomething()
    {
        // Do something.
        // ...
 
        // Notify observers that we did something.
        $this->notify('something');
    }
 
    protected function notify($argument)
    {
        foreach ($this->observers as $observer) {
            $observer->update($argument);
        }
    }
 
    // Other methods.
}
 
class Observer
{
    public function update($argument)
    {
        // Do something.
    }
 
    // Other methods.
}
?>


- - - Example 11.7 - shows how to use a mock object to test the interaction between - Subject and Observer objects. -

- We first use the getMock() method that is provided by - the PHPUnit_Framework_TestCase class (see Table 21.6) to set up a mock object for the - Observer. Since we give an array as the second - (optional) parameter for the getMock() method, only - the update() method of the Observer - class is replaced by a mock implementation. -

Example 11.7: Testing that a methods gets called once and with a specified parameter

<?php
class SubjectTest extends PHPUnit_Framework_TestCase
{
    public function testObserversAreUpdated()
    {
        // Create a mock for the Observer class,
        // only mock the update() method.
        $observer = $this->getMock('Observer', array('update'));
 
        // Set up the expectation for the update() method
        // to be called only once and with the string 'something'
        // as its parameter.
        $observer->expects($this->once())
                 ->method('update')
                 ->with($this->equalTo('something'));
 
        // Create a Subject object and attach the mocked
        // Observer object to it.
        $subject = new Subject;
        $subject->attach($observer);
 
        // Call the doSomething() method on the $subject object
        // which we expect to call the mocked Observer object's
        // update() method with the string 'something'.
        $subject->doSomething();
    }
}
?>


- Table 21.1 shows the - constraints and Table 11.1 - shows the matchers that are available. -

Table 11.1. Matchers

MatcherMeaning
PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount any()Returns a matcher that matches when the method it is evaluated for is executed zero or more times.
PHPUnit_Framework_MockObject_Matcher_InvokedCount never()Returns a matcher that matches when the method it is evaluated for is never executed.
PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce atLeastOnce()Returns a matcher that matches when the method it is evaluated for is executed at least once.
PHPUnit_Framework_MockObject_Matcher_InvokedCount once()Returns a matcher that matches when the method it is evaluated for is executed exactly once.
PHPUnit_Framework_MockObject_Matcher_InvokedCount exactly(int $count)Returns a matcher that matches when the method it is evaluated for is executed exactly $count times.
PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex at(int $index)Returns a matcher that matches when the method it is evaluated for is invoked at the given $index.


- - - The getMockForAbstractClass() method returns a mock - object for an abstract class. All abstract methods of the given abstract - class are mocked. This allows for testing the concrete methods of an - abstract class. -

Example 11.8: Testing the concrete methods of an abstract class

<?php
abstract class AbstractClass
{
    public function concreteMethod()
    {
        return $this->abstractMethod();
    }
 
    public abstract function abstractMethod();
}
 
class AbstractClassTest extends PHPUnit_Framework_TestCase
{
    public function testConcreteMethod()
    {
        $stub = $this->getMockForAbstractClass('AbstractClass');
        $stub->expects($this->any())
             ->method('abstractMethod')
             ->will($this->returnValue(TRUE));
 
        $this->assertTrue($stub->concreteMethod());
    }
}
?>


Stubbing and Mocking Web Services

- - - When your application interacts with a web service you want to test it - without actually interacting with the web service. To make the stubbing - and mocking of web services easy, the getMockFromWsdl() - can be used just like getMock() (see above). The only - difference is that getMockFromWsdl() returns a stub or - mock based on a web service description in WSDL and getMock() - returns a stub or mock based on a PHP class or interface. -

- Example 11.9 - shows how getMockFromWsdl() can be used to stub, for - example, the web service described in GoogleSearch.wsdl. -

Example 11.9: Stubbing a web service

<?php
class GoogleTest extends PHPUnit_Framework_TestCase
{
    public function testSearch()
    {
        $googleSearch = $this->getMockFromWsdl(
          'GoogleSearch.wsdl', 'GoogleSearch'
        );
 
        $directoryCategory = new StdClass;
        $directoryCategory->fullViewableName = '';
        $directoryCategory->specialEncoding = '';
 
        $element = new StdClass;
        $element->summary = '';
        $element->URL = 'http://www.phpunit.de/';
        $element->snippet = '...';
        $element->title = '<b>PHPUnit</b>';
        $element->cachedSize = '11k';
        $element->relatedInformationPresent = TRUE;
        $element->hostName = 'www.phpunit.de';
        $element->directoryCategory = $directoryCategory;
        $element->directoryTitle = '';
 
        $result = new StdClass;
        $result->documentFiltering = FALSE;
        $result->searchComments = '';
        $result->estimatedTotalResultsCount = 378000;
        $result->estimateIsExact = FALSE;
        $result->resultElements = array($element);
        $result->searchQuery = 'PHPUnit';
        $result->startIndex = 1;
        $result->endIndex = 1;
        $result->searchTips = '';
        $result->directoryCategories = array();
        $result->searchTime = 0.248822;
 
        $googleSearch->expects($this->any())
                     ->method('doGoogleSearch')
                     ->will($this->returnValue($result));
 
        /**
         * $googleSearch->doGoogleSearch() will now return a stubbed result and
         * the web service's doGoogleSearch() method will not be invoked.
         */
        $this->assertEquals(
          $result,
          $googleSearch->doGoogleSearch(
            '00000000000000000000000000000000',
            'PHPUnit',
            0,
            1,
            FALSE,
            '',
            FALSE,
            '',
            '',
            '' 
          )
        );
    }
}
?>


Mocking the Filesystem

- vfsStream - is a stream wrapper for a - virtual - filesystem that may be helpful in unit tests to mock the real - filesystem. -

- To install vfsStream, the PEAR channel - (pear.php-tools.net) that is used for - its distribution needs to be registered with the local PEAR environment: -

pear channel-discover pear.php-tools.net

- This has to be done only once. Now the PEAR Installer can be used to - install vfsStream: -

pear install pat/vfsStream-alpha

- Example 11.10 - shows a class that interacts with the filesystem. -

Example 11.10: A class that interacts with the filesystem

<?php
class Example
{
    protected $id;
    protected $directory;
 
    public function __construct($id)
    {
        $this->id = $id;
    }
 
    public function setDirectory($directory)
    {
        $this->directory = $directory . DIRECTORY_SEPARATOR . $this->id;
 
        if (!file_exists($this->directory)) {
            mkdir($this->directory, 0700, TRUE);
        }
    }
}?>


- Without a virtual filesystem such as vfsStream we cannot test the - setDirectory() method in isolation from external - influence (see Example 11.11). -

Example 11.11: Testing a class that interacts with the filesystem

<?php
require_once 'Example.php';
 
class ExampleTest extends PHPUnit_Framework_TestCase
{
    protected function setUp()
    {
        if (file_exists(dirname(__FILE__) . '/id')) {
            rmdir(dirname(__FILE__) . '/id');
        }
    }
 
    public function testDirectoryIsCreated()
    {
        $example = new Example('id');
        $this->assertFalse(file_exists(dirname(__FILE__) . '/id'));
 
        $example->setDirectory(dirname(__FILE__));
        $this->assertTrue(file_exists(dirname(__FILE__) . '/id'));
    }
 
    protected function tearDown()
    {
        if (file_exists(dirname(__FILE__) . '/id')) {
            rmdir(dirname(__FILE__) . '/id');
        }
    }
}
?>


- The approach above has several drawbacks: -

  • As with any external resource, there might be intermittent problems with the filesystem. This makes tests interacting with it flaky.

  • In the setUp() and tearDown() methods we have to ensure that the directory does not exist before and after the test.

  • When the test execution terminates before the tearDown() method is invoked the directory will stay in the filesystem.

- Example 11.12 - shows how vfsStream can be used to mock the filesystem in a test for a - class that interacts with the filesystem. -

Example 11.12: Mocking the filesystem in a test for a class that interacts with the filesystem

<?php
require_once 'vfsStream/vfsStream.php';
require_once 'Example.php';
 
class ExampleTest extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        vfsStreamWrapper::register();
        vfsStreamWrapper::setRoot(new vfsStreamDirectory('exampleDir'));
    }
 
    public function testDirectoryIsCreated()
    {
        $example = new Example('id');
        $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('id'));
 
        $example->setDirectory(vfsStream::url('exampleDir'));
        $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('id'));
    }
}
?>


- This has several advantages: -

  • The test itself is more concise.

  • vfsStream gives the test developer full control over what the filesystem environment looks like to the tested code.

  • Since the filesystem operations do not operate on the real filesystem anymore, cleanup operations in a tearDown() method are no longer required.

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/test-driven-development.html phpunit-3.6.10/doc/html/test-driven-development.html --- phpunit-3.5.5/doc/html/test-driven-development.html 2010-09-27 16:52:36.000000000 +0000 +++ phpunit-3.6.10/doc/html/test-driven-development.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,175 +0,0 @@ - - - - Chapter 13. Test-Driven Development - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 13. Test-Driven Development

- - - - - - - Unit Tests are a vital part of several software development practices - and processes such as Test-First Programming, - Extreme Programming, - and Test-Driven Development. - They also allow for Design-by-Contract - in programming languages that do not support this methodology with - language constructs. -

- You can use PHPUnit to write tests once you are done programming. - However, the sooner a test is written after an error has been introduced, - the more valuable the test is. So instead of writing tests months after - the code is "complete", we can write tests days or hours or minutes after - the possible introduction of a defect. Why stop there? Why not write the - tests a little before the possible introduction of a defect? -

- Test-First Programming, which is part of Extreme Programming and - Test-Driven Development, builds upon this idea and takes it to the - extreme. With today's computational power, we have the opportunity to - run thousands of tests thousands of times per day. We can use the - feedback from all of these tests to program in small steps, each of - which carries with it the assurance of a new automated test in addition - to all the tests that have come before. The tests are like pitons, - assuring you that, no matter what happens, once you have made progress - you can only fall so far. -

- When you first write the test it cannot possibly run, because you are - calling on objects and methods that have not been programmed yet. This - might feel strange at first, but after a while you will get used to it. - Think of Test-First Programming as a pragmatic approach to following the - object-oriented programming principle of programming to an interface - instead of programming to an implementation: while you are writing the - test you are thinking about the interface of the object you are - testing -- what does this object look like from the outside. When you - go to make the test really work, you are thinking about pure - implementation. The interface is fixed by the failing test. -

 

- The point of Test-Driven Development - is to drive out the functionality the software actually needs, rather - than what the programmer thinks it probably ought to have. The way it - does this seems at first counterintuitive, if not downright silly, but - it not only makes sense, it also quickly becomes a natural and elegant - way to develop software. -

 
 --Dan North

- What follows is necessarily an abbreviated introduction to Test-Driven - Development. You can explore the topic further in other books, such as - Test-Driven Development [Beck2002] - by Kent Beck or Dave Astels' A Practical Guide to Test-Driven - Development [Astels2003]. -

BankAccount Example

- In this section, we will look at the example of a class that represents - a bank account. The contract for the BankAccount - class not only requires methods to get and set the bank account's - balance, as well as methods to deposit and withdraw money. It also - specifies the following two conditions that must be ensured: -

  • The bank account's initial balance must be zero.

  • The bank account's balance cannot become negative.

- We write the tests for the BankAccount class before we - write the code for the class itself. We use the contract conditions as the - basis for the tests and name the test methods accordingly, as shown in - Example 13.1. -

Example 13.1: Tests for the BankAccount class

<?php
require_once 'BankAccount.php';
 
class BankAccountTest extends PHPUnit_Framework_TestCase
{
    protected $ba;
 
    protected function setUp()
    {
        $this->ba = new BankAccount;
    }
 
    public function testBalanceIsInitiallyZero()
    {
        $this->assertEquals(0, $this->ba->getBalance());
    }
 
    public function testBalanceCannotBecomeNegative()
    {
        try {
            $this->ba->withdrawMoney(1);
        }
 
        catch (BankAccountException $e) {
            $this->assertEquals(0, $this->ba->getBalance());
 
            return;
        }
 
        $this->fail();
    }
 
    public function testBalanceCannotBecomeNegative2()
    {
        try {
            $this->ba->depositMoney(-1);
        }
 
        catch (BankAccountException $e) {
            $this->assertEquals(0, $this->ba->getBalance());
 
            return;
        }
 
        $this->fail();
    }
}
?>


- We now write the minimal amount of code needed for the first test, - testBalanceIsInitiallyZero(), to pass. In our - example this amounts to implementing the getBalance() - method of the BankAccount class, as shown in - Example 13.2. -

Example 13.2: Code needed for the testBalanceIsInitiallyZero() test to pass

<?php
class BankAccount
{
    protected $balance = 0;
 
    public function getBalance()
    {
        return $this->balance;
    }
}
?>


- The test for the first contract condition now passes, but the tests for - the second contract condition fail because we have yet to implement the - methods that these tests call. -

phpunit BankAccountTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-.
-Fatal error: Call to undefined method BankAccount::withdrawMoney()

- For the tests that ensure the second contract condition to pass, we now - need to implement the withdrawMoney(), - depositMoney(), and setBalance() - methods, as shown in - Example 13.3. - These methods are written in a such a way that they raise an - BankAccountException when they are called with - illegal values that would violate the contract conditions. -

Example 13.3: The complete BankAccount class

<?php
class BankAccount
{
    protected $balance = 0;
 
    public function getBalance()
    {
        return $this->balance;
    }
 
    protected function setBalance($balance)
    {
        if ($balance >= 0) {
            $this->balance = $balance;
        } else {
            throw new BankAccountException;
        }
    }
 
    public function depositMoney($balance)
    {
        $this->setBalance($this->getBalance() + $balance);
 
        return $this->getBalance();
    }
 
    public function withdrawMoney($balance)
    {
        $this->setBalance($this->getBalance() - $balance);
 
        return $this->getBalance();
    }
}
?>


- The tests that ensure the second contract condition now pass, too: -

phpunit BankAccountTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-...
-
-Time: 0 seconds
-
-
-OK (3 tests, 3 assertions)

- - - Alternatively, you can use the static assertion methods provided by the - PHPUnit_Framework_Assert class to write the contract - conditions as design-by-contract style assertions into your code, as - shown in Example 13.4. - When one of these assertions fails, an - PHPUnit_Framework_AssertionFailedError exception - will be raised. With this approach, you write less code for the contract - condition checks and the tests become more readable. However, you add a - runtime dependency on PHPUnit to your project. -

Example 13.4: The BankAccount class with Design-by-Contract assertions

<?php
class BankAccount
{
    private $balance = 0;
 
    public function getBalance()
    {
        return $this->balance;
    }
 
    protected function setBalance($balance)
    {
        PHPUnit_Framework_Assert::assertTrue($balance >= 0);
 
        $this->balance = $balance;
    }
 
    public function depositMoney($amount)
    {
        PHPUnit_Framework_Assert::assertTrue($amount >= 0);
 
        $this->setBalance($this->getBalance() + $amount);
 
        return $this->getBalance();
    }
 
    public function withdrawMoney($amount)
    {
        PHPUnit_Framework_Assert::assertTrue($amount >= 0);
        PHPUnit_Framework_Assert::assertTrue($this->balance >= $amount);
 
        $this->setBalance($this->getBalance() - $amount);
 
        return $this->getBalance();
    }
}
?>


- By writing the contract conditions into the tests, we have used - Design-by-Contract to program the BankAccount class. - We then wrote, following the Test-First Programming approach, the - code needed to make the tests pass. However, we forgot to write - tests that call setBalance(), - depositMoney(), and withdrawMoney() - with legal values that do not violate the contract conditions. - We need a means to test our tests or at least to measure their quality. - Such a means is the analysis of code-coverage information that we will - discuss next. -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/testcase-extensions.html phpunit-3.6.10/doc/html/testcase-extensions.html --- phpunit-3.5.5/doc/html/testcase-extensions.html 2010-09-27 16:52:37.000000000 +0000 +++ phpunit-3.6.10/doc/html/testcase-extensions.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ - - - - Chapter 8. TestCase Extensions - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 8. TestCase Extensions

- PHPUnit provides extensions to the standard base-class for test classes, - PHPUnit_Framework_TestCase. -

Testing Output

- - - Sometimes you want to assert that the execution of a method, for - instance, generates an expected output (via echo or - print, for example). The - PHPUnit_Extensions_OutputTestCase class uses PHP's - Output - Buffering feature to provide the functionality that is - necessary for this. -

- Example 8.1 - shows how to subclass PHPUnit_Extensions_OutputTestCase - and use its expectOutputString() method to set the - expected output. If this expected output is not generated, the test - will be counted as a failure. -

Example 8.1: Using PHPUnit_Extensions_OutputTestCase

<?php
require_once 'PHPUnit/Extensions/OutputTestCase.php';
 
class OutputTest extends PHPUnit_Extensions_OutputTestCase
{
    public function testExpectFooActualFoo()
    {
        $this->expectOutputString('foo');
        print 'foo';
    }
 
    public function testExpectBarActualBaz()
    {
        $this->expectOutputString('bar');
        print 'baz';
    }
}
?>
phpunit OutputTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-.F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) OutputTest::testExpectBarActualBaz
-Failed asserting that two strings are equal.
---- Expected
-+++ Actual
-@@ -1 +1 @@
--bar
-+baz
-
-FAILURES!
-Tests: 2, Assertions: 2, Failures: 1.


- Table 8.1 - shows the methods provided by - PHPUnit_Extensions_OutputTestCase. -

Table 8.1. OutputTestCase

MethodMeaning
void expectOutputRegex(string $regularExpression)Set up the expectation that the output matches a $regularExpression.
void expectOutputString(string $expectedString)Set up the expectation that the output is equal to an $expectedString.
bool setOutputCallback(callable $callback)Sets up a callback that is used to, for instance, normalize the actual output.


- There are two other extensions to PHPUnit_Framework_TestCase, - PHPUnit_Extensions_Database_TestCase and - PHPUnit_Extensions_SeleniumTestCase, that are covered - in Chapter 9 and Chapter 17, - respectively. -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/testing-practices.html phpunit-3.6.10/doc/html/testing-practices.html --- phpunit-3.5.5/doc/html/testing-practices.html 2010-09-27 16:52:38.000000000 +0000 +++ phpunit-3.6.10/doc/html/testing-practices.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ - - - - Chapter 12. Testing Practices - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 12. Testing Practices

 

- You can always write more tests. However, you will quickly find that - only a fraction of the tests you can imagine are actually useful. What - you want is to write tests that fail even though you think they should - work, or tests that succeed even though you think they should fail. - Another way to think of it is in cost/benefit terms. You want to write - tests that will pay you back with information. -

 
 --Erich Gamma

During Development

- - - When you need to make a change to the internal structure of the software - you are working on to make it easier to understand and cheaper to modify - without changing its observable behavior, a test suite is invaluable in - applying these so called refactorings - safely. Otherwise, you might not notice the system breaking while you - are carrying out the restructuring. -

- The following conditions will help you to improve the code and design - of your project, while using unit tests to verify that the refactoring's - transformation steps are, indeed, behavior-preserving and do not - introduce errors: -

  1. All unit tests run correctly.

  2. The code communicates its design principles.

  3. The code contains no redundancies.

  4. The code contains the minimal number of classes and methods.

- When you need to add new functionality to the system, write the tests - first. Then, you will be done developing when the test runs. This - practice will be discussed in detail in the next chapter. -

During Debugging

- When you get a defect report, your impulse might be to fix the defect as - quickly as possible. Experience shows that this impulse will not serve - you well; it is likely that the fix for the defect causes another - defect. -

- You can hold your impulse in check by doing the following: -

  1. - Verify that you can reproduce the defect. -

  2. - Find the smallest-scale demonstration of the defect in the code. - For example, if a number appears incorrectly in an output, find the - object that is computing that number. -

  3. - Write an automated test that fails now but will succeed when the - defect is fixed. -

  4. - Fix the defect. -

- Finding the smallest reliable reproduction of the defect gives you the - opportunity to really examine the cause of the defect. The test you - write will improve the chances that when you fix the defect, you really - fix it, because the new test reduces the likelihood of undoing the fix - with future code changes. All the tests you wrote before reduce the - likelihood of inadvertently causing a different problem. -

 

- Unit testing offers many advantages: -

  • Testing gives code authors and reviewers confidence that patches produce the correct results.

  • Authoring testcases is a good impetus for developers to discover edge cases.

  • Testing provides a good way to catch regressions quickly, and to make sure that no regression will be repeated twice.

  • Unit tests provide working examples for how to use an API and can significantly aid documentation efforts.

- Overall, integrated unit testing makes the cost and risk of any - individual change smaller. It will allow the project to make [...] - major architectural improvements [...] quickly and confidently. -

 
 --Benjamin Smedberg
- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/textui.html phpunit-3.6.10/doc/html/textui.html --- phpunit-3.5.5/doc/html/textui.html 2010-09-27 16:52:39.000000000 +0000 +++ phpunit-3.6.10/doc/html/textui.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,308 +0,0 @@ - - - - Chapter 5. The Command-Line Test Runner - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 5. The Command-Line Test Runner

- The PHPUnit command-line test runner can be invoked through the - phpunit command. The following code shows how to run - tests with the PHPUnit command-line test runner: -

phpunit ArrayTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-..
-
-Time: 0 seconds
-
-
-OK (2 tests, 2 assertions)

- For each test run, the PHPUnit command-line tool prints one character to - indicate progress: -

.

- Printed when the test succeeds. -

F

- Printed when an assertion fails while running the test method. -

E

- Printed when an error occurs while running the test method. -

S

- Printed when the test has been skipped (see - Chapter 10). -

I

- Printed when the test is marked as being incomplete or not yet - implemented (see Chapter 10). -

- - - - PHPUnit distinguishes between failures and - errors. A failure is a violated PHPUnit - assertion such as a failing assertEquals() call. - An error is an unexpected exception or a PHP error. Sometimes - this distinction proves useful since errors tend to be easier to fix - than failures. If you have a big list of problems, it is best to - tackle the errors first and see if you have any failures left when - they are all fixed. -

- Let's take a look at the command-line test runner's switches in - the following code: -

phpunit --help
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-Usage: phpunit [switches] UnitTest [UnitTest.php]
-       phpunit [switches] <directory>
-
-  --log-junit <file>       Log test execution in JUnit XML format to file.
-  --log-tap <file>         Log test execution in TAP format to file.
-  --log-dbus               Log test execution to DBUS.
-  --log-json <file>        Log test execution in JSON format.
-
-  --coverage-html <dir>    Generate code coverage report in HTML format.
-  --coverage-clover <file> Write code coverage data in Clover XML format.
-
-  --story-html <file>      Write Story/BDD results in HTML format to file.
-  --story-text <file>      Write Story/BDD results in Text format to file.
-
-  --testdox-html <file>    Write agile documentation in HTML format to file.
-  --testdox-text <file>    Write agile documentation in Text format to file.
-
-  --filter <pattern>       Filter which tests to run.
-  --group ...              Only runs tests from the specified group(s).
-  --exclude-group ...      Exclude tests from the specified group(s).
-  --list-groups            List available test groups.
-
-  --loader <loader>        TestSuiteLoader implementation to use.
-  --repeat <times>         Runs the test(s) repeatedly.
-
-  --story                  Report test execution progress in Story/BDD format.
-  --tap                    Report test execution progress in TAP format.
-  --testdox                Report test execution progress in TestDox format.
-
-  --colors                 Use colors in output.
-  --stderr                 Write to STDERR instead of STDOUT.
-  --stop-on-error          Stop execution upon first error.
-  --stop-on-failure        Stop execution upon first error or failure.
-  --stop-on-skipped        Stop execution upon first skipped test.
-  --stop-on-incomplete     Stop execution upon first incomplete test.
-  --strict                 Mark a test as incomplete if no assertions are made.
-  --verbose                Output more verbose information.
-  --wait                   Waits for a keystroke after each test.
-
-  --skeleton-class         Generate Unit class for UnitTest in UnitTest.php.
-  --skeleton-test          Generate UnitTest class for Unit in Unit.php.
-
-  --process-isolation      Run each test in a separate PHP process.
-  --no-globals-backup      Do not backup and restore $GLOBALS for each test.
-  --static-backup          Backup and restore static attributes for each test.
-  --syntax-check           Try to check source files for syntax errors.
-
-  --bootstrap <file>       A "bootstrap" PHP file that is run before the tests.
-  --configuration <file>   Read configuration from XML file.
-  --no-configuration       Ignore default configuration file (phpunit.xml).
-  --include-path <path(s)> Prepend PHP's include_path with given path(s).
-  -d key[=value]           Sets a php.ini value.
-
-  --help                   Prints this usage information.
-  --version                Prints the version and exits.
phpunit UnitTest

- Runs the tests that are provided by the class - UnitTest. This class is expected to be declared - in the UnitTest.php sourcefile. -

- UnitTest must be either a class that inherits - from PHPUnit_Framework_TestCase or a class that - provides a public static suite() method which - returns an PHPUnit_Framework_Test object, for - example an instance of the - PHPUnit_Framework_TestSuite class. -

phpunit UnitTest UnitTest.php

- Runs the tests that are provided by the class - UnitTest. This class is expected to be declared - in the specified sourcefile. -

--log-junit

- Generates a logfile in JUnit XML format for the tests run. - See Chapter 18 for more details. -

--log-tap

- Generates a logfile using the Test Anything Protocol (TAP) - format for the tests run. See Chapter 18 for more - details. -

--log-dbus

- Log test execution using - DBUS. -

--log-json

- Generates a logfile using the - JSON format. - See Chapter 18 for more details. -

--coverage-html

- Generates a code coverage report in HTML format. See - Chapter 14 for more details. -

- Please note that this functionality is only available when the - tokenizer and Xdebug extensions are installed. -

--coverage-clover

- Generates a logfile in XML format with the code coverage information - for the tests run. See Chapter 18 for more details. -

- Please note that this functionality is only available when the - tokenizer and Xdebug extensions are installed. -

--story-html and --story-text

- Generates reports in HTML or plain text format for the - Behaviour-Driven Development scenarios that are run. See - ??? for more details. -

--testdox-html and --testdox-text

- Generates agile documentation in HTML or plain text format for the - tests that are run. See Chapter 15 for - more details. -

--filter

- Only runs tests whose name matches the given pattern. The pattern - can be either the name of a single test or a - regular expression - that matches multiple test names. -

--group

- Only runs tests from the specified group(s). A test can be tagged as - belonging to a group using the @group annotation. -

- The @author annotation is an alias for - @group allowing to filter tests based on their - authors. -

--exclude-group

- Exclude tests from the specified group(s). A test can be tagged as - belonging to a group using the @group annotation. -

--list-groups

- List available test groups. -

--loader

- Specifies the PHPUnit_Runner_TestSuiteLoader - implementation to use. -

- The standard test suite loader will look for the sourcefile in the - current working directory and in each directory that is specified in - PHP's include_path configuration directive. - Following the PEAR Naming Conventions, a class name such as - Project_Package_Class is mapped to the - sourcefile name Project/Package/Class.php. -

--repeat

- Repeatedly runs the test(s) the specified number of times. -

--story

- Reports the test progress in a format that fits Behaviour-Driven - Development. See ??? for - more details. -

--tap

- Reports the test progress using the Test Anything Protocol (TAP). - See Chapter 18 for more details. -

--testdox

- Reports the test progress as agile documentation. See - Chapter 15 for more details. -

--colors

- Use colors in output. -

--stderr

- Optionally print to STDERR instead of - STDOUT. -

--stop-on-error

- Stop execution upon first error. -

--stop-on-failure

- Stop execution upon first error or failure. -

--stop-on-skipped

- Stop execution upon first skipped test. -

--stop-on-skipped

- Stop execution upon first incomplete test. -

--strict

- Mark a test as incomplete if no assertions are made. -

--verbose

- Output more verbose information, for instance the names of tests - that were incomplete or have been skipped. -

--wait

- Waits for a keystroke after each test. This is useful if you are - running the tests in a window that stays open only as long as the - test runner is active. -

--skeleton-class

- Generates a skeleton class Unit - (in Unit.php) from a test case class - UnitTest (in UnitTest.php). - See Chapter 16 for more details. -

--skeleton-test

- Generates a skeleton test case class UnitTest - (in UnitTest.php) for a class - Unit (in Unit.php). - See Chapter 16 for more details. -

--process-isolation

- Run each test in a separate PHP process. -

--no-globals-backup

- Do not backup and restore $GLOBALS. See the section called “Global State” - for more details. -

--static-backup

- Backup and restore static attributes of user-defined classes. - See the section called “Global State” for more details. -

--syntax-check

- Enables the syntax check of test source files. -

--bootstrap

- A "bootstrap" PHP file that is run before the tests. -

--configuration, -c

- Read configuration from XML file. - See Appendix C for more details. -

- If phpunit.xml or - phpunit.xml.dist (in that order) exist in the - current working directory and --configuration is - not used, the configuration will be automatically - read from that file. -

--no-configuration

- Ignore phpunit.xml and - phpunit.xml.dist from the current working - directory. -

--include-path

- Prepend PHP's include_path with given path(s). -

-d

- Sets the value of the given PHP configuration option. -

Note

- - - When the tested code contains PHP syntax errors, the TextUI test runner - might exit without printing error information. The standard test suite - loader can optionally check the test suite sourcefile for PHP syntax - errors, but not sourcefiles included by the test suite sourcefile. -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/doc/html/writing-tests-for-phpunit.html phpunit-3.6.10/doc/html/writing-tests-for-phpunit.html --- phpunit-3.5.5/doc/html/writing-tests-for-phpunit.html 2010-09-27 16:52:39.000000000 +0000 +++ phpunit-3.6.10/doc/html/writing-tests-for-phpunit.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,251 +0,0 @@ - - - - Chapter 4. Writing Tests for PHPUnit - - - - - - -
-
-
- - - - - -
PrevNext
-

Chapter 4. Writing Tests for PHPUnit

- - - Example 4.1 shows - how we can write tests using PHPUnit that exercice PHP's array operations. - The example introduces the basic conventions and steps for writing tests - with PHPUnit: -

  1. The tests for a class Class go into a class ClassTest.

  2. ClassTest inherits (most of the time) from PHPUnit_Framework_TestCase.

  3. The tests are public methods that are named test*.

    Alternatively, you can use the @test annotation in a method's docblock to mark it as a test method.

  4. Inside the test methods, assertion methods such as assertEquals() (see the section called “PHPUnit_Framework_Assert”) are used to assert that an actual value matches an expected value.

Example 4.1: Testing array operations with PHPUnit

<?php
class StackTest extends PHPUnit_Framework_TestCase
{
    public function testPushAndPop()
    {
        $stack = array();
        $this->assertEquals(0, count($stack));
 
        array_push($stack, 'foo');
        $this->assertEquals('foo', $stack[count($stack)-1]);
        $this->assertEquals(1, count($stack));
 
        $this->assertEquals('foo', array_pop($stack));
        $this->assertEquals(0, count($stack));
    }
}
?>


 

- Whenever you are tempted to type something into a - print statement or a debugger expression, write it - as a test instead. -

 
 --Martin Fowler

Test Dependencies

 

- Unit Tests are primarily written as a good practice to help developers - identify and fix bugs, to refactor code and to serve as documentation - for a unit of software under test. To achieve these benefits, unit tests - ideally should cover all the possible paths in a program. One unit test - usually covers one specific path in one function or method. However a - test method is not necessary an encapsulated, independent entity. Often - there are implicit dependencies between test methods, hidden in the - implementation scenario of a test. -

 
 --Adrian Kuhn et. al.

- - - PHPUnit supports the declaration of explicit dependencies between test - methods. Such dependencies do not define the order in which the test - methods are to be executed but they allow the returning of an instance of - the test fixture by a producer and passing it to the dependent consumers. -

  • A producer is a test method that yields its unit under test as return value.

  • A consumer is a test method that depends on one or more producers and their return values.

- - - - Example 4.2 shows - how to use the @depends annotation to express - dependencies between test methods. -

Example 4.2: Using the @depends annotation to express dependencies

<?php
class StackTest extends PHPUnit_Framework_TestCase
{
    public function testEmpty()
    {
        $stack = array();
        $this->assertEmpty($stack);
 
        return $stack;
    }
 
    /**
     * @depends testEmpty
     */
    public function testPush(array $stack)
    {
        array_push($stack, 'foo');
        $this->assertEquals('foo', $stack[count($stack)-1]);
        $this->assertNotEmpty($stack);
 
        return $stack;
    }
 
    /**
     * @depends testPush
     */
    public function testPop(array $stack)
    {
        $this->assertEquals('foo', array_pop($stack));
        $this->assertEmpty($stack);
    }
}
?>


- In the example above, the first test, testEmpty(), - creates a new array and asserts that it is empty. The test then returns - the fixture as its result. The second test, testPush(), - depends on testEmpty() and is passed the result of that - depended-upon test as its argument. Finally, testPop() - depends upons testPush(). -

- - - To quickly localize defects, we want our attention to be focussed on - relevant failing tests. This is why PHPUnit skips the execution of a test - when a depended-upon test has failed. This improves defect localization by - exploiting the dependencies between tests as shown in - Example 4.3. -

Example 4.3: Exploiting the dependencies between tests

<?php
class DependencyFailureTest extends PHPUnit_Framework_TestCase
{
    public function testOne()
    {
        $this->assertTrue(FALSE);
    }
 
    /**
     * @depends testOne
     */
    public function testTwo()
    {
    }
}
?>
phpunit --verbose DependencyFailureTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-DependencyFailureTest
-FS
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) testOne(DependencyFailureTest)
-Failed asserting that <boolean:false> is true.
-/home/sb/DependencyFailureTest.php:6
-
-There was 1 skipped test:
-
-1) testTwo(DependencyFailureTest)
-This test depends on "DependencyFailureTest::testOne" to pass.
-
-FAILURES!
-Tests: 2, Assertions: 1, Failures: 1, Skipped: 1.


- A test may have more than one @depends annotation. - PHPUnit does not change the order in which tests are executed, you have to - ensure that the dependencies of a test can actually be met before the test - is run. -

Data Providers

- - - A test method can accept arbitrary arguments. These arguments are to be - provided by a data provider method (provider() in - Example 4.4). - The data provider method to be used is specified using the - @dataProvider annotation. -

- A data provider method must be public and either return - an array of arrays or an object that implements the Iterator - interface and yields an array for each iteration step. For each array that - is part of the collection the test method will be called with the contents - of the array as its arguments. -

Example 4.4: Using data providers

<?php
class DataTest extends PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider provider
     */
    public function testAdd($a, $b, $c)
    {
        $this->assertEquals($c, $a + $b);
    }
 
    public function provider()
    {
        return array(
          array(0, 0, 0),
          array(0, 1, 1),
          array(1, 0, 1),
          array(1, 1, 3)
        );
    }
}
?>
phpunit DataTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-...F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) testAdd(DataTest) with data (1, 1, 3)
-Failed asserting that <integer:2> matches expected value <integer:3>.
-/home/sb/DataTest.php:21
-
-FAILURES!
-Tests: 4, Assertions: 4, Failures: 1.
-


Note

- - - - - When a test receives input from both a @dataProvider - method and from one or more tests it @depends on, the - arguments from the data provider will come before the ones from - depended-upon tests. -

Note

- - - - - When a test depends on a test that uses data providers, the depending - test will be executed when the test it depends upon is successful for at - least one data set. The result of a test that uses data providers cannot - be injected into a depending test. -

Testing Exceptions

- - - - Example 4.5 - shows how to use the @expectedException annotation to - test whether an exception is thrown inside the tested code. -

Example 4.5: Using the @expectedException annotation

<?php
class ExceptionTest extends PHPUnit_Framework_TestCase
{
    /**
     * @expectedException InvalidArgumentException
     */
    public function testException()
    {
    }
}
?>
phpunit ExceptionTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) testException(ExceptionTest)
-Expected exception InvalidArgumentException
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


- Alternatively, you can use the setExpectedException() - method to set the expected exception as shown in Example 4.6. -

Example 4.6: Expecting an exception to be raised by the tested code

<?php
class ExceptionTest extends PHPUnit_Framework_TestCase
{
    public function testException()
    {
        $this->setExpectedException('InvalidArgumentException');
    }
}
?>
phpunit ExceptionTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-F
-
-Time: 0 seconds
-
-There was 1 failure:
-
-1) testException(ExceptionTest)
-Expected exception InvalidArgumentException
-
-FAILURES!
-Tests: 1, Assertions: 1, Failures: 1.


- Table 4.1 - shows the methods provided for testing exceptions. -

Table 4.1. Methods for testing exceptions

MethodMeaning
void setExpectedException(string $exceptionName)Set the name of the expected exception to $exceptionName.
String getExpectedException()Return the name of the expected exception.


- You can also use the approach shown in - Example 4.7 - to test exceptions. -

Example 4.7: Alternative approach to testing exceptions

<?php
class ExceptionTest extends PHPUnit_Framework_TestCase {
    public function testException() {
        try {
            // ... Code that is expected to raise an exception ...
        }
 
        catch (InvalidArgumentException $expected) {
            return;
        }
 
        $this->fail('An expected exception has not been raised.');
    }
}
?>


- If the code that is expected to raise an exception in - Example 4.7 - does not raise the expected exception, the subsequent call to - fail() (see - Table 21.2) will halt the - test and signal a problem with the test. If the expected exception is - raised, the catch block will be executed, and the - test will end successfully. -

Testing PHP Errors

- - - - - - - By default, PHPUnit converts PHP errors, warnings, and notices that are - triggered during the execution of a test to an exception. Using these - exceptions, you can, for instance, expect a test to trigger a PHP error as - shown in Example 4.8. -

Example 4.8: Expecting a PHP error using @expectedException

<?php
class ExpectedErrorTest extends PHPUnit_Framework_TestCase
{
    /**
     * @expectedException PHPUnit_Framework_Error
     */
    public function testFailingInclude()
    {
        include 'not_existing_file.php';
    }
}
?>
phpunit ExpectedErrorTest
-PHPUnit 3.5.0 by Sebastian Bergmann.
-
-.
-
-Time: 0 seconds
-
-OK (1 test, 1 assertion)


- - - - PHPUnit_Framework_Error_Notice and - PHPUnit_Framework_Error_Warning represent PHP notices - and warnings, respectively. -

- - - - - -
PrevNext
-
-
-
1. Automating Tests
2. PHPUnit's Goals
3. Installing PHPUnit
4. Writing Tests for PHPUnit
Test Dependencies
Data Providers
Testing Exceptions
Testing PHP Errors
5. The Command-Line Test Runner
6. Fixtures
More setUp() than tearDown()
Variations
Sharing Fixture
Global State
7. Organizing Tests
Composing a Test Suite Using the Filesystem
Composing a Test Suite Using XML Configuration
Using the TestSuite Class
8. TestCase Extensions
Testing Output
9. Database Testing
Data Sets
Flat XML Data Set
XML Data Set
CSV Data Set
Replacement Data Set
Operations
Database Testing Best Practices
10. Incomplete and Skipped Tests
Incomplete Tests
Skipping Tests
11. Test Doubles
Stubs
Mock Objects
Stubbing and Mocking Web Services
Mocking the Filesystem
12. Testing Practices
During Development
During Debugging
13. Test-Driven Development
BankAccount Example
14. Code Coverage Analysis
Specifying Covered Methods
Ignoring Code Blocks
Including and Excluding Files
15. Other Uses for Tests
Agile Documentation
Cross-Team Tests
16. Skeleton Generator
Generating a Test Case Class Skeleton
Generating a Class Skeleton from a Test Case Class
17. PHPUnit and Selenium
Selenium RC
PHPUnit_Extensions_SeleniumTestCase
18. Logging
Test Results (XML)
Test Results (TAP)
Test Results (JSON)
Code Coverage (XML)
19. Build Automation
Apache Ant
Apache Maven
Phing
20. Continuous Integration
Atlassian Bamboo
CruiseControl
phpUnderControl
21. PHPUnit API
Overview
PHPUnit_Framework_Assert
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
PHPUnit_Framework_Test
PHPUnit_Framework_TestCase
PHPUnit_Framework_TestSuite
PHPUnit_Framework_TestResult
Package Structure
22. Extending PHPUnit
Subclass PHPUnit_Framework_TestCase
Assert Classes
Subclass PHPUnit_Extensions_TestDecorator
Implement PHPUnit_Framework_Test
Subclass PHPUnit_Framework_TestResult
Implement PHPUnit_Framework_TestListener
New Test Runner
A. Assertions
B. Annotations
@assert
@author
@backupGlobals
@backupStaticAttributes
@covers
@dataProvider
@depends
@expectedException
@expectedExceptionCode
@expectedExceptionMessage
@group
@outputBuffering
@runTestsInSeparateProcesses
@runInSeparateProcess
@test
@testdox
@ticket
C. The XML Configuration File
PHPUnit
Test Suites
Groups
Including and Excluding Files for Code Coverage
Logging
Test Listeners
Setting PHP INI settings, Constants and Global Variables
Configuring Browsers for Selenium RC
D. Index
E. Bibliography
F. Copyright
-
-
-
- - - - - - diff -Nru phpunit-3.5.5/package.sig phpunit-3.6.10/package.sig --- phpunit-3.5.5/package.sig 2010-11-22 10:42:21.000000000 +0000 +++ phpunit-3.6.10/package.sig 2012-01-27 10:49:40.000000000 +0000 @@ -1,7 +1,7 @@ -----BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.10 (GNU/Linux) +Version: GnuPG v1.4.11 (GNU/Linux) -iEYEABECAAYFAkzqSQ0ACgkQaGfFFLhbXWmz6QCbBHq9Hxx5xH1NHK+e3m8ZnZp+ -LX8An0ss2CZ7Zs03LjEaL/f8LvVIQbkE -=ShsA +iEYEABECAAYFAk8igUQACgkQaGfFFLhbXWntpwCfWEPJt/Fq/FVQeyGQ0Zi7G+PA +BYQAoJR2mWdNmpPVSilqPCFifawC6Zpd +=+BRw -----END PGP SIGNATURE----- diff -Nru phpunit-3.5.5/package.xml phpunit-3.6.10/package.xml --- phpunit-3.5.5/package.xml 2010-11-22 10:42:15.000000000 +0000 +++ phpunit-3.6.10/package.xml 2012-01-27 10:49:19.000000000 +0000 @@ -1,20 +1,20 @@ - + PHPUnit pear.phpunit.de - Regression testing framework for unit tests. - PHPUnit is a regression testing framework used by the developer who implements unit tests in PHP. This is the version to be used with PHP 5. + The PHP Unit Testing framework. + The PHP Unit Testing framework. Sebastian Bergmann sb sebastian@phpunit.de yes - 2010-11-22 - + 2012-01-27 + - 3.5.5 - 3.5.4 + 3.6.10 + 3.6.0 stable @@ -26,429 +26,414 @@ - + - - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - - - - - - - + - + - + - + - + - + - + + - + - + - + - + - + - + - + - + - + + + + + @@ -464,42 +449,32 @@ 5.2.7 - 1.9.1 + 1.9.4 - DbUnit - pear.phpunit.de - 1.0.0 - - File_Iterator pear.phpunit.de - 1.2.3 + 1.3.0 Text_Template pear.phpunit.de - 1.0.0 + 1.1.1 PHP_CodeCoverage pear.phpunit.de - 1.0.2 + 1.1.0 PHP_Timer pear.phpunit.de - 1.0.0 + 1.0.1 PHPUnit_MockObject pear.phpunit.de - 1.0.3 - - - PHPUnit_Selenium - pear.phpunit.de - 1.0.1 + 1.1.0 YAML @@ -520,17 +495,16 @@ - - dbus - + + PHP_Invoker + pear.phpunit.de + 1.1.0 + json - pdo - - - soap + simplexml tokenizer