pax_global_header00006660000000000000000000000064122622204160014507gustar00rootroot0000000000000052 comment=d38cef1df6e0c66d43911e15bc31275c606228b6 phpunit-3.7.28/000077500000000000000000000000001226222041600132775ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/000077500000000000000000000000001226222041600153235ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/CONTRIBUTING.md000066400000000000000000000063601226222041600175610ustar00rootroot00000000000000Contributing to PHPUnit ======================= Contributions to PHPUnit, its related modules, and its documentation are always welcome. You make our lifes easier by sending us your contributions through GitHub pull requests. Please note that the `3.6.` branch is closed for features and that pull requests should to be based on `master` or the `3.7.` once it exists. We are trying to keep backwards compatibility breaks in PHPUnit 3.7 to an absolute minimum so please take this into account when proposing changes. Due to time constraints, we are not always able to respond as quickly as we would like. Please do not take delays personal and feel free to remind us here or on IRC if you feel that we forgot to respond. 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`. In addition to the checkouts listed above, the YAML component that is provided by the Symfony project is required: pear install pear.symfony.com/Yaml The `phpunit/phpunit.php` script can be used to invoke the PHPUnit test runner. Running the test suite(s) ------------------------- It is not possible to use a system-wide installed version of PHPUnit to run the test suite of a Git checkout. Because of that is is necessary to change the `include_paths` as described below. This can be achieved with a small wrapper script designed to work with every module in the PHPUnit stack. Note that you might have to change the path to your PEAR installation here pointing to `/usr/local/lib/php`. You can find it using `pear config-show | grep php_dir`. ### Linux / MacOS X #!/bin/bash php -d include_path='.:../phpunit/:../dbunit/:../php-code-coverage/:../php-file-iterator/:../php-invoker/:../php-text-template/:../php-timer:../php-token-stream:../phpunit-mock-objects/:../phpunit-selenium/:../phpunit-story/:/usr/local/lib/php' ../phpunit/phpunit.php $* ### Windows @echo off php -d include_path='.;../phpunit/;../dbunit/;../php-code-coverage/;../php-file-iterator/;../php-invoker/;../php-text-template/;../php-timer;../php-token-stream;../phpunit-mock-objects/;../phpunit-selenium/;../phpunit-story/;C:/Program Files/PHP/pear' ../phpunit/phpunit.php %* phpunit-3.7.28/PHPUnit-3.7.28/LICENSE000066400000000000000000000030061226222041600163270ustar00rootroot00000000000000PHPUnit Copyright (c) 2002-2013, 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. phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/000077500000000000000000000000001226222041600166125ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Autoload.php000066400000000000000000000335651226222041600211070ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since File available since Release 3.5.0 */ if (defined('PHPUNIT_COMPOSER_INSTALL')) { return; } $paths = array( __DIR__ . '/../vendor', __DIR__ . '/../../..' ); foreach ($paths as $path) { if (@is_dir($path . '/composer') && @is_file($path . '/autoload.php')) { require_once $path . '/autoload.php'; define('PHPUNIT_COMPOSER_INSTALL', $path . '/autoload.php'); return; } } 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'; spl_autoload_register( function ($class) { static $classes = NULL; static $path = NULL; if ($classes === NULL) { $classes = array( 'phpunit_extensions_grouptestsuite' => '/Extensions/GroupTestSuite.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_callback' => '/Framework/Constraint/Callback.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_isjson' => '/Framework/Constraint/IsJson.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_jsonmatches' => '/Framework/Constraint/JsonMatches.php', 'phpunit_framework_constraint_jsonmatches_errormessageprovider' => '/Framework/Constraint/JsonMatches/ErrorMessageProvider.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_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_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__); } $cn = strtolower($class); if (isset($classes[$cn])) { require $path . $classes[$cn]; } } ); // Symfony Yaml autoloader spl_autoload_register( function ($class) { if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Yaml')) { $file = sprintf( 'Symfony/Component/Yaml%s.php', substr( str_replace('\\', '/', $class), strlen('Symfony\Component\Yaml') ) ); if (stream_resolve_include_path($file)) { require_once $file; } } } ); if (stream_resolve_include_path('PHP/Invoker/Autoload.php')) { require_once 'PHP/Invoker/Autoload.php'; } if (stream_resolve_include_path('PHPUnit/Extensions/Database/Autoload.php')) { require_once 'PHPUnit/Extensions/Database/Autoload.php'; } if (stream_resolve_include_path('PHPUnit/Extensions/SeleniumCommon/Autoload.php')) { require_once 'PHPUnit/Extensions/SeleniumCommon/Autoload.php'; } else if (stream_resolve_include_path('PHPUnit/Extensions/SeleniumTestCase/Autoload.php')) { require_once 'PHPUnit/Extensions/SeleniumTestCase/Autoload.php'; } if (stream_resolve_include_path('PHPUnit/Extensions/Story/Autoload.php')) { require_once 'PHPUnit/Extensions/Story/Autoload.php'; } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Extensions/000077500000000000000000000000001226222041600207515ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Extensions/GroupTestSuite.php000066400000000000000000000076221226222041600244370ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } } } } } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Extensions/PhptTestCase.php000066400000000000000000000211521226222041600240320ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since File available since Release 3.1.4 */ if (stream_resolve_include_path('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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception($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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Extensions/PhptTestCase/000077500000000000000000000000001226222041600233205ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Extensions/PhptTestCase/Logger.php000066400000000000000000000047721226222041600252620ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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) { } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Extensions/PhptTestSuite.php000066400000000000000000000064271226222041600242600ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception */ 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'); } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Extensions/RepeatedTest.php000066400000000000000000000117141226222041600240570ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception */ 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 PHPUnit_Framework_Exception */ 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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Extensions/TestDecorator.php000066400000000000000000000105531226222041600242500ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 */ public function run(PHPUnit_Framework_TestResult $result = NULL) { if ($result === NULL) { $result = $this->createResult(); } $this->basicRun($result); return $result; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Extensions/TicketListener.php000066400000000000000000000167731226222041600244310ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/000077500000000000000000000000001226222041600205475ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Assert.php000066400000000000000000002625121226222041600225310ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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|ArrayAccess $array * @param string $message * @since Method available since Release 3.0.0 */ public static function assertArrayHasKey($key, $array, $message = '') { if (!(is_integer($key) || is_string($key))) { throw PHPUnit_Util_InvalidArgumentHelper::factory( 1, 'integer or string' ); } if (!(is_array($array) || $array instanceof ArrayAccess)) { throw PHPUnit_Util_InvalidArgumentHelper::factory( 2, 'array or ArrayAccess' ); } $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|ArrayAccess $array * @param string $message * @since Method available since Release 3.0.0 */ public static function assertArrayNotHasKey($key, $array, $message = '') { if (!(is_integer($key) || is_string($key))) { throw PHPUnit_Util_InvalidArgumentHelper::factory( 1, 'integer or string' ); } if (!(is_array($array) || $array instanceof ArrayAccess)) { throw PHPUnit_Util_InvalidArgumentHelper::factory( 2, 'array or ArrayAccess' ); } $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 contains only instances of a given classname * * @param string $classname * @param array|Traversable $haystack * @param string $message */ public static function assertContainsOnlyInstancesOf($classname, $haystack, $message = '') { if (!(is_array($haystack) || is_object($haystack) && $haystack instanceof Traversable)) { throw PHPUnit_Util_InvalidArgumentHelper::factory( 2, 'array or iterator' ); } self::assertThat( $haystack, new PHPUnit_Framework_Constraint_TraversableContainsOnly( $classname, FALSE ), $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 array|Countable|Iterator $expected * @param array|Countable|Iterator $actual * @param string $message */ public static 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 array|Countable|Iterator $expected * @param array|Countable|Iterator $actual * @param string $message */ public static 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 suffix. * * @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 suffix. * * @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 PHPUnit_Framework_Exception; } } /** * 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); } /** * Asserts that a string is a valid JSON string. * * @param string $filename * @param string $message * @since Method available since Release 3.7.20 */ public static function assertJson($expectedJson, $message = '') { if (!is_string($expectedJson)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); } self::assertThat($expectedJson, self::isJson(), $message); } /** * Asserts that two given JSON encoded objects or arrays are equal. * * @param string $expectedJson * @param string $actualJson * @param string $message */ public static function assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message = '') { self::assertJson($expectedJson, $message); self::assertJson($actualJson, $message); $expected = json_decode($expectedJson); $actual = json_decode($actualJson); self::assertEquals($expected, $actual, $message); } /** * Asserts that two given JSON encoded objects or arrays are not equal. * * @param string $expectedJson * @param string $actualJson * @param string $message */ public static function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message = '') { self::assertJson($expectedJson, $message); self::assertJson($actualJson, $message); $expected = json_decode($expectedJson); $actual = json_decode($actualJson); self::assertNotEquals($expected, $actual, $message); } /** * Asserts that the generated JSON encoded object and the content of the given file are equal. * * @param string $expectedFile * @param string $actualJson * @param string $message */ public static function assertJsonStringEqualsJsonFile($expectedFile, $actualJson, $message = '') { self::assertFileExists($expectedFile, $message); $expectedJson = file_get_contents($expectedFile); self::assertJson($expectedJson, $message); self::assertJson($actualJson, $message); // call constraint $constraint = new PHPUnit_Framework_Constraint_JsonMatches( $expectedJson ); self::assertThat($actualJson, $constraint, $message); } /** * Asserts that the generated JSON encoded object and the content of the given file are not equal. * * @param string $expectedFile * @param string $actualJson * @param string $message */ public static function assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message = '') { self::assertFileExists($expectedFile, $message); $expectedJson = file_get_contents($expectedFile); self::assertJson($expectedJson, $message); self::assertJson($actualJson, $message); // call constraint $constraint = new PHPUnit_Framework_Constraint_JsonMatches( $expectedJson ); self::assertThat($actualJson, new PHPUnit_Framework_Constraint_Not($constraint), $message); } /** * Asserts that two JSON files are not equal. * * @param string $expectedFile * @param string $actualFile * @param string $message */ public static function assertJsonFileNotEqualsJsonFile($expectedFile, $actualFile, $message = '') { self::assertFileExists($expectedFile, $message); self::assertFileExists($actualFile, $message); $actualJson = file_get_contents($actualFile); $expectedJson = file_get_contents($expectedFile); self::assertJson($expectedJson, $message); self::assertJson($actualJson, $message); // call constraint $constraintExpected = new PHPUnit_Framework_Constraint_JsonMatches( $expectedJson ); $constraintActual = new PHPUnit_Framework_Constraint_JsonMatches($actualJson); self::assertThat($expectedJson, new PHPUnit_Framework_Constraint_Not($constraintActual), $message); self::assertThat($actualJson, new PHPUnit_Framework_Constraint_Not($constraintExpected), $message); } /** * Asserts that two JSON files are equal. * * @param string $expectedFile * @param string $actualFile * @param string $message */ public static function assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message = '') { self::assertFileExists($expectedFile, $message); self::assertFileExists($actualFile, $message); $actualJson = file_get_contents($actualFile); $expectedJson = file_get_contents($expectedFile); self::assertJson($expectedJson, $message); self::assertJson($actualJson, $message); // call constraint $constraintExpected = new PHPUnit_Framework_Constraint_JsonMatches( $expectedJson ); $constraintActual = new PHPUnit_Framework_Constraint_JsonMatches($actualJson); self::assertThat($expectedJson, $constraintActual, $message); self::assertThat($actualJson, $constraintExpected, $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_Callback matcher object. * * @param callable $callback * @return PHPUnit_Framework_Constraint_Callback */ public static function callback($callback) { return new PHPUnit_Framework_Constraint_Callback($callback); } /** * 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_IsJson matcher object. * * @return PHPUnit_Framework_Constraint_IsJson * @since Method available since Release 3.7.20 */ public static function isJson() { return new PHPUnit_Framework_Constraint_IsJson; } /** * 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_TraversableContainsOnly matcher * object. * * @param string $classname * @return PHPUnit_Framework_Constraint_TraversableContainsOnly */ public static function containsOnlyInstancesOf($classname) { return new PHPUnit_Framework_Constraint_TraversableContainsOnly($classname, FALSE); } /** * 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 PHPUnit_Framework_Exception */ 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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Assert/000077500000000000000000000000001226222041600220105ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Assert/Functions.php000066400000000000000000001750401226222041600245000ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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 call_user_func_array( 'PHPUnit_Framework_TestCase::any', func_get_args() ); } /** * Returns a PHPUnit_Framework_Constraint_IsAnything matcher object. * * @return PHPUnit_Framework_Constraint_IsAnything * @since Method available since Release 3.0.0 */ function anything() { return call_user_func_array( 'PHPUnit_Framework_Assert::anything', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::arrayHasKey', func_get_args() ); } /** * Asserts that an array has a specified key. * * @param mixed $key * @param array|ArrayAccess $array * @param string $message * @since Method available since Release 3.0.0 */ function assertArrayHasKey($key, $array, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertArrayHasKey', func_get_args() ); } /** * Asserts that an array does not have a specified key. * * @param mixed $key * @param array|ArrayAccess $array * @param string $message * @since Method available since Release 3.0.0 */ function assertArrayNotHasKey($key, $array, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertArrayNotHasKey', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeContains', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeContainsOnly', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeCount', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeEmpty', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeEquals', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeGreaterThan', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeGreaterThanOrEqual', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeInstanceOf', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeInternalType', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeLessThan', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeLessThanOrEqual', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeNotContains', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeNotContainsOnly', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeNotCount', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeNotEmpty', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeNotEquals', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeNotInstanceOf', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeNotInternalType', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeNotSame', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertAttributeSame', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertClassHasAttribute', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertClassHasStaticAttribute', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertClassNotHasAttribute', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertClassNotHasStaticAttribute', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertContains', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertContainsOnly', func_get_args() ); } /** * Asserts that a haystack contains only instances of a given classname * * @param string $classname * @param array|Traversable $haystack * @param string $message */ function assertContainsOnlyInstancesOf($classname, $haystack, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertContainsOnlyInstancesOf', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertCount', func_get_args() ); } /** * Asserts that a variable is empty. * * @param mixed $actual * @param string $message * @throws PHPUnit_Framework_AssertionFailedError */ function assertEmpty($actual, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertEmpty', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertEqualXMLStructure', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertEquals', func_get_args() ); } /** * Asserts that a condition is false. * * @param boolean $condition * @param string $message * @throws PHPUnit_Framework_AssertionFailedError */ function assertFalse($condition, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertFalse', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertFileEquals', func_get_args() ); } /** * Asserts that a file exists. * * @param string $filename * @param string $message * @since Method available since Release 3.0.0 */ function assertFileExists($filename, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertFileExists', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertFileNotEquals', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertFileNotExists', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertGreaterThan', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertGreaterThanOrEqual', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertInstanceOf', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertInternalType', func_get_args() ); } /** * Asserts that a string is a valid JSON string. * * @param string $filename * @param string $message * @since Method available since Release 3.7.20 */ function assertJson($expectedJson, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertJson', func_get_args() ); } /** * Asserts that two JSON files are equal. * * @param string $expectedFile * @param string $actualFile * @param string $message */ function assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertJsonFileEqualsJsonFile', func_get_args() ); } /** * Asserts that two JSON files are not equal. * * @param string $expectedFile * @param string $actualFile * @param string $message */ function assertJsonFileNotEqualsJsonFile($expectedFile, $actualFile, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertJsonFileNotEqualsJsonFile', func_get_args() ); } /** * Asserts that the generated JSON encoded object and the content of the given file are equal. * * @param string $expectedFile * @param string $actualJson * @param string $message */ function assertJsonStringEqualsJsonFile($expectedFile, $actualJson, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertJsonStringEqualsJsonFile', func_get_args() ); } /** * Asserts that two given JSON encoded objects or arrays are equal. * * @param string $expectedJson * @param string $actualJson * @param string $message */ function assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertJsonStringEqualsJsonString', func_get_args() ); } /** * Asserts that the generated JSON encoded object and the content of the given file are not equal. * * @param string $expectedFile * @param string $actualJson * @param string $message */ function assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonFile', func_get_args() ); } /** * Asserts that two given JSON encoded objects or arrays are not equal. * * @param string $expectedJson * @param string $actualJson * @param string $message */ function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonString', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertLessThan', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertLessThanOrEqual', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertNotContains', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertNotContainsOnly', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertNotCount', func_get_args() ); } /** * Asserts that a variable is not empty. * * @param mixed $actual * @param string $message * @throws PHPUnit_Framework_AssertionFailedError */ function assertNotEmpty($actual, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertNotEmpty', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertNotEquals', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertNotInstanceOf', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertNotInternalType', func_get_args() ); } /** * Asserts that a variable is not NULL. * * @param mixed $actual * @param string $message */ function assertNotNull($actual, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertNotNull', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertNotRegExp', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertNotSame', func_get_args() ); } /** * Assert that the size of two arrays (or `Countable` or `Iterator` objects) * is not the same. * * @param array|Countable|Iterator $expected * @param array|Countable|Iterator $actual * @param string $message */ function assertNotSameSize($expected, $actual, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertNotSameSize', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertNotTag', func_get_args() ); } /** * Asserts that a variable is NULL. * * @param mixed $actual * @param string $message */ function assertNull($actual, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertNull', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertObjectHasAttribute', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertObjectNotHasAttribute', func_get_args() ); } /** * Asserts that a string matches a given regular expression. * * @param string $pattern * @param string $string * @param string $message */ function assertRegExp($pattern, $string, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertRegExp', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertSame', func_get_args() ); } /** * Assert that the size of two arrays (or `Countable` or `Iterator` objects) * is the same. * * @param array|Countable|Iterator $expected * @param array|Countable|Iterator $actual * @param string $message */ function assertSameSize($expected, $actual, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertSameSize', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertSelectCount', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertSelectEquals', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertSelectRegExp', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertStringEndsNotWith', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertStringEndsWith', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertStringEqualsFile', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertStringMatchesFormat', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertStringMatchesFormatFile', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertStringNotEqualsFile', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertStringNotMatchesFormat', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertStringNotMatchesFormatFile', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertStringStartsNotWith', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertStringStartsWith', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertTag', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertThat', func_get_args() ); } /** * Asserts that a condition is true. * * @param boolean $condition * @param string $message * @throws PHPUnit_Framework_AssertionFailedError */ function assertTrue($condition, $message = '') { return call_user_func_array( 'PHPUnit_Framework_Assert::assertTrue', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertXmlFileEqualsXmlFile', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertXmlFileNotEqualsXmlFile', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertXmlStringEqualsXmlFile', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlFile', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlString', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_TestCase::at', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_TestCase::atLeastOnce', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::attribute', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::attributeEqualTo', func_get_args() ); } /** * Returns a PHPUnit_Framework_Constraint_Callback matcher object. * * @param callable $callback * @return PHPUnit_Framework_Constraint_Callback */ function callback($callback) { return call_user_func_array( 'PHPUnit_Framework_Assert::callback', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::classHasAttribute', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::classHasStaticAttribute', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::contains', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::containsOnly', func_get_args() ); } /** * Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher * object. * * @param string $classname * @return PHPUnit_Framework_Constraint_TraversableContainsOnly */ function containsOnlyInstancesOf($classname) { return call_user_func_array( 'PHPUnit_Framework_Assert::containsOnlyInstancesOf', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::equalTo', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_TestCase::exactly', func_get_args() ); } /** * Returns a PHPUnit_Framework_Constraint_FileExists matcher object. * * @return PHPUnit_Framework_Constraint_FileExists * @since Method available since Release 3.0.0 */ function fileExists() { return call_user_func_array( 'PHPUnit_Framework_Assert::fileExists', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::greaterThan', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::greaterThanOrEqual', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::identicalTo', func_get_args() ); } /** * Returns a PHPUnit_Framework_Constraint_IsEmpty matcher object. * * @return PHPUnit_Framework_Constraint_IsEmpty * @since Method available since Release 3.5.0 */ function isEmpty() { return call_user_func_array( 'PHPUnit_Framework_Assert::isEmpty', func_get_args() ); } /** * Returns a PHPUnit_Framework_Constraint_IsFalse matcher object. * * @return PHPUnit_Framework_Constraint_IsFalse * @since Method available since Release 3.3.0 */ function isFalse() { return call_user_func_array( 'PHPUnit_Framework_Assert::isFalse', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::isInstanceOf', func_get_args() ); } /** * Returns a PHPUnit_Framework_Constraint_IsJson matcher object. * * @return PHPUnit_Framework_Constraint_IsJson * @since Method available since Release 3.7.20 */ function isJson() { return call_user_func_array( 'PHPUnit_Framework_Assert::isJson', func_get_args() ); } /** * Returns a PHPUnit_Framework_Constraint_IsNull matcher object. * * @return PHPUnit_Framework_Constraint_IsNull * @since Method available since Release 3.3.0 */ function isNull() { return call_user_func_array( 'PHPUnit_Framework_Assert::isNull', func_get_args() ); } /** * Returns a PHPUnit_Framework_Constraint_IsTrue matcher object. * * @return PHPUnit_Framework_Constraint_IsTrue * @since Method available since Release 3.3.0 */ function isTrue() { return call_user_func_array( 'PHPUnit_Framework_Assert::isTrue', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::isType', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::lessThan', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::lessThanOrEqual', func_get_args() ); } /** * Returns a PHPUnit_Framework_Constraint_And matcher object. * * @return PHPUnit_Framework_Constraint_And * @since Method available since Release 3.0.0 */ function logicalAnd() { return call_user_func_array( 'PHPUnit_Framework_Assert::logicalAnd', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::logicalNot', func_get_args() ); } /** * Returns a PHPUnit_Framework_Constraint_Or matcher object. * * @return PHPUnit_Framework_Constraint_Or * @since Method available since Release 3.0.0 */ function logicalOr() { return call_user_func_array( 'PHPUnit_Framework_Assert::logicalOr', func_get_args() ); } /** * Returns a PHPUnit_Framework_Constraint_Xor matcher object. * * @return PHPUnit_Framework_Constraint_Xor * @since Method available since Release 3.0.0 */ function logicalXor() { return call_user_func_array( 'PHPUnit_Framework_Assert::logicalXor', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::matches', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::matchesRegularExpression', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_TestCase::never', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::objectHasAttribute', func_get_args() ); } /** * * * @param mixed $value, ... * @return PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls * @since Method available since Release 3.0.0 */ function onConsecutiveCalls() { return call_user_func_array( 'PHPUnit_Framework_TestCase::onConsecutiveCalls', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_TestCase::once', func_get_args() ); } /** * * * @param integer $argumentIndex * @return PHPUnit_Framework_MockObject_Stub_ReturnArgument * @since Method available since Release 3.3.0 */ function returnArgument($argumentIndex) { return call_user_func_array( 'PHPUnit_Framework_TestCase::returnArgument', func_get_args() ); } /** * * * @param mixed $callback * @return PHPUnit_Framework_MockObject_Stub_ReturnCallback * @since Method available since Release 3.3.0 */ function returnCallback($callback) { return call_user_func_array( 'PHPUnit_Framework_TestCase::returnCallback', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_TestCase::returnSelf', func_get_args() ); } /** * * * @param mixed $value * @return PHPUnit_Framework_MockObject_Stub_Return * @since Method available since Release 3.0.0 */ function returnValue($value) { return call_user_func_array( 'PHPUnit_Framework_TestCase::returnValue', func_get_args() ); } /** * * * @param array $valueMap * @return PHPUnit_Framework_MockObject_Stub_ReturnValueMap * @since Method available since Release 3.6.0 */ function returnValueMap(array $valueMap) { return call_user_func_array( 'PHPUnit_Framework_TestCase::returnValueMap', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::stringContains', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::stringEndsWith', func_get_args() ); } /** * 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 call_user_func_array( 'PHPUnit_Framework_Assert::stringStartsWith', func_get_args() ); } /** * * * @param Exception $exception * @return PHPUnit_Framework_MockObject_Stub_Exception * @since Method available since Release 3.1.0 */ function throwException(Exception $exception) { return call_user_func_array( 'PHPUnit_Framework_TestCase::throwException', func_get_args() ); } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/AssertionFailedError.php000066400000000000000000000052411226222041600253500ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since Class available since Release 2.0.0 */ class PHPUnit_Framework_AssertionFailedError extends PHPUnit_Framework_Exception implements PHPUnit_Framework_SelfDescribing { /** * Wrapper for getMessage() which is declared as final. * * @return string */ public function toString() { return $this->getMessage(); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Comparator.php000066400000000000000000000076301226222041600233750ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Comparator/000077500000000000000000000000001226222041600226565ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Comparator/Array.php000066400000000000000000000145701226222041600244540ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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)); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Comparator/DOMDocument.php000066400000000000000000000107171226222041600255130ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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(); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Comparator/Double.php000066400000000000000000000100121226222041600245730ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Comparator/Exception.php000066400000000000000000000065771226222041600253440ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Comparator/MockObject.php000066400000000000000000000064141226222041600254140ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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['__phpunit_invocationMocker']); return $array; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Comparator/Numeric.php000066400000000000000000000110071226222041600247700ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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_infinite($actual) XOR is_infinite($expected)) || (is_nan($actual) OR 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) ) ); } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Comparator/Object.php000066400000000000000000000133421226222041600246000ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Comparator/Resource.php000066400000000000000000000077211226222041600251650ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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) ); } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Comparator/Scalar.php000066400000000000000000000130001226222041600245660ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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) ) ); } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Comparator/SplObjectStorage.php000066400000000000000000000112001226222041600265730ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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.' ); } } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Comparator/Type.php000066400000000000000000000101621226222041600243100ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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) ) ); } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/ComparatorFactory.php000066400000000000000000000131111226222041600247140ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 * @throws PHPUnit_Framework_Exception */ public function getComparatorFor($expected, $actual) { foreach ($this->comparators as $comparator) { if ($comparator->accepts($expected, $actual)) { return $comparator; } } throw new PHPUnit_Framework_Exception( 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]); } } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/ComparisonFailure.php000066400000000000000000000116551226222041600247120ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 string $expectedAsString * @param string $actualAsString * @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(); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint.php000066400000000000000000000142131226222041600234050ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 overridden 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(); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/000077500000000000000000000000001226222041600226735ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/And.php000066400000000000000000000123161226222041600241110ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 * @throws PHPUnit_Framework_Exception */ public function setConstraints(array $constraints) { $this->constraints = array(); foreach ($constraints as $key => $constraint) { if (!($constraint instanceof PHPUnit_Framework_Constraint)) { throw new PHPUnit_Framework_Exception( '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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/ArrayHasKey.php000066400000000000000000000076311226222041600255760ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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(); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/Attribute.php000066400000000000000000000110371226222041600253510ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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(); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/Callback.php000066400000000000000000000075731226222041600251140ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ */ /** * Constraint that evaluates against a specified closure. * * @package PHPUnit * @subpackage Framework_Constraint * @author Sebastian Bergmann * @author Timon Rapp * @copyright 2002-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ */ class PHPUnit_Framework_Constraint_Callback extends PHPUnit_Framework_Constraint { private $callback; /** * @param callable $callback * @throws InvalidArgumentException */ public function __construct($callback) { if (!is_callable($callback)) { throw new InvalidArgumentException( sprintf( 'Specified callback <%s> is not callable.', $this->callbackToString($callback) ) ); } $this->callback = $callback; } /** * Evaluates the constraint for parameter $value. Returns TRUE if the * constraint is met, FALSE otherwise. * * @param mixed $value Value or object to evaluate. * @return bool */ protected function matches($other) { return call_user_func($this->callback, $other); } /** * Returns a string representation of the constraint. * * @return string */ public function toString() { return 'is accepted by specified callback'; } private function callbackToString($callback) { if (!is_array($callback)) { return $callback; } if (empty($callback)) { return "empty array"; } if (!isset($callback[0]) || !isset($callback[1])) { return "array without indexes 0 and 1 set"; } if (is_object($callback[0])) { $callback[0] = get_class($callback[0]); } return $callback[0] . '::' . $callback[1]; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/ClassHasAttribute.php000066400000000000000000000101031226222041600267640ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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() ); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/ClassHasStaticAttribute.php000066400000000000000000000070511226222041600301440ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 ); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/Composite.php000066400000000000000000000100331226222041600253430ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since File available since Release 3.6.0 */ /** * * * @package PHPUnit * @subpackage Framework_Constraint * @author Bernhard Schussek * @copyright 2001-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/Count.php000066400000000000000000000077761226222041600245150ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 '; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/Exception.php000066400000000000000000000101041226222041600253360ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since File available since Release 3.6.6 */ /** * * * @package PHPUnit * @subpackage Framework_Constraint * @author Sebastian Bergmann * @copyright 2001-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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) { $message = ''; if ($other instanceof Exception && $other->getMessage()) { $message = '. Message was: "' . $other->getMessage() . '"'; } return sprintf( 'exception of type "%s" matches expected exception "%s"%s', get_class($other), $this->className, $message ); } 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 ); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/ExceptionCode.php000066400000000000000000000071711226222041600261430ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since File available since Release 3.6.6 */ /** * * * @package PHPUnit * @subpackage Framework_Constraint * @author Sebastian Bergmann * @copyright 2001-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 '; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/ExceptionMessage.php000066400000000000000000000071331226222041600266530ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since File available since Release 3.6.6 */ /** * * * @package PHPUnit * @subpackage Framework_Constraint * @author Sebastian Bergmann * @copyright 2001-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 '; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/FileExists.php000066400000000000000000000071311226222041600254650ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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'; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/GreaterThan.php000066400000000000000000000065311226222041600256150ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/IsAnything.php000066400000000000000000000074151226222041600254700ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/IsEmpty.php000066400000000000000000000071521226222041600250030ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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() ); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/IsEqual.php000066400000000000000000000152261226222041600247550ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 ); } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/IsFalse.php000066400000000000000000000060441226222041600247360ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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'; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/IsIdentical.php000066400000000000000000000135111226222041600255750ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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) && !is_nan($this->value) && !is_nan($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); } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/IsInstanceOf.php000066400000000000000000000077431226222041600257440ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 ); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/IsJson.php000066400000000000000000000073021226222041600246130ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since File available since Release 3.7.20 */ /** * Constraint that asserts that a string is valid JSON. * * @package PHPUnit * @subpackage Framework_Constraint * @author Sebastian Bergmann * @copyright 2001-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since Class available since Release 3.7.20 */ class PHPUnit_Framework_Constraint_IsJson 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) { json_decode($other); if (json_last_error()) { return FALSE; } return TRUE; } /** * 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) { json_decode($other); $error = PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::determineJsonError( json_last_error() ); return sprintf( '%s is valid JSON (%s)', PHPUnit_Util_Type::shortenedExport($other), $error ); } /** * Returns a string representation of the constraint. * * @return string */ public function toString() { return 'is valid JSON'; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/IsNull.php000066400000000000000000000060401226222041600246120ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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'; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/IsTrue.php000066400000000000000000000060401226222041600246170ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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'; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/IsType.php000066400000000000000000000127171226222041600246310ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception */ public function __construct($type) { if (!isset($this->types[$type])) { throw new PHPUnit_Framework_Exception( 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 ); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/JsonMatches.php000066400000000000000000000070221226222041600256230ustar00rootroot00000000000000. * 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 Bastian Feder * @copyright 2002-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause * @link http://www.phpunit.de/ * @since File available since Release 3.7.0 */ /** * Asserts whether or not two JSON objects are equal. * * @package PHPUnit * @subpackage Framework_Constraint * @author Bastian Feder * @copyright 2011 Bastian Feder * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause * @link http://www.phpunit.de/ * @since Class available since Release 3.7.0 */ class PHPUnit_Framework_Constraint_JsonMatches extends PHPUnit_Framework_Constraint { /** * @var string */ protected $value; /** * Creates a new constraint. * * @param string $value */ public function __construct($value) { $this->value = $value; } /** * 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) { $decodedOther = json_decode($other); if (json_last_error()) { return FALSE; } $decodedValue = json_decode($this->value); if (json_last_error()) { return FALSE; } return $decodedOther == $decodedValue; } /** * Returns a string representation of the object. * * @return string */ public function toString() { return sprintf( 'matches JSON string "%s"', $this->value ); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/JsonMatches/000077500000000000000000000000001226222041600251115ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/JsonMatches/ErrorMessageProvider.php000066400000000000000000000076331226222041600317440ustar00rootroot00000000000000. * 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 Bastian Feder * @copyright 2002-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause * @link http://www.phpunit.de/ * @since File available since Release 3.7.0 */ /** * Provides human readable messages for each JSON error. * * @package PHPUnit * @subpackage Framework_Constraint * @author Bastian Feder * @copyright 2011 Bastian Feder * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause * @link http://www.phpunit.de/ * @since Class available since Release 3.7.0 */ class PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider { /** * Translates JSON error to a human readable string. * * @param string $error * @return string */ public static function determineJsonError($error, $prefix = '') { switch ($error) { case JSON_ERROR_NONE: return; case JSON_ERROR_DEPTH: return $prefix . 'Maximum stack depth exceeded'; case JSON_ERROR_STATE_MISMATCH: return $prefix . 'Underflow or the modes mismatch'; case JSON_ERROR_CTRL_CHAR: return $prefix . 'Unexpected control character found'; case JSON_ERROR_SYNTAX: return $prefix . 'Syntax error, malformed JSON'; case JSON_ERROR_UTF8: return $prefix . 'Malformed UTF-8 characters, possibly incorrectly encoded'; default: return $prefix . 'Unknown error'; } } /** * Translates a given type to a human readable message prefix. * * @param string $type * @return string */ public static function translateTypeToPrefix($type) { switch (strtolower($type)) { case 'expected': $prefix = 'Expected value JSON decode error - '; break; case 'actual': $prefix = 'Actual value JSON decode error - '; break; default: $prefix = ''; break; } return $prefix; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/LessThan.php000066400000000000000000000065201226222041600251300ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/Not.php000066400000000000000000000145431226222041600241530ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/ObjectHasAttribute.php000066400000000000000000000061141226222041600271340ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/Or.php000066400000000000000000000120061226222041600237630ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/PCREMatch.php000066400000000000000000000071121226222041600251130ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 ); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/SameSize.php000066400000000000000000000054271226222041600251340ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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) { parent::__construct($this->getCountOf($expected)); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/StringContains.php000066400000000000000000000077021226222041600263570ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 ); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/StringEndsWith.php000066400000000000000000000065471226222041600263340ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 . '"'; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/StringMatches.php000066400000000000000000000104731226222041600261640ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 = $this->createPatternFromFormat( preg_replace('/\r\n/', "\n", $string) ); $this->string = $string; } protected function failureDescription($other) { return "format description matches text"; } protected function additionalFailureDescription($other) { $from = preg_split('(\r\n|\r|\n)', $this->string); $to = preg_split('(\r\n|\r|\n)', $other); foreach ($from as $index => $line) { if (isset($to[$index]) && $line !== $to[$index]) { $line = $this->createPatternFromFormat($line); if (preg_match($line, $to[$index]) > 0) { $from[$index] = $to[$index]; } } } $this->string = join("\n", $from); $other = join("\n", $to); return PHPUnit_Util_Diff::diff($this->string, $other); } protected function createPatternFromFormat($string) { $string = 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+)?', '.' ), preg_quote($string, '/') ); return '/^' . $string . '$/s'; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/StringStartsWith.php000066400000000000000000000065261226222041600267200ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 . '"'; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/TraversableContains.php000066400000000000000000000120201226222041600273500ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception */ 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() ); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/TraversableContainsOnly.php000066400000000000000000000111111226222041600302120ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 . '"'; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Constraint/Xor.php000066400000000000000000000121711226222041600241560ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Error.php000066400000000000000000000055021226222041600223530ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 Exception $previous */ public function __construct($message, $code, $file, $line, Exception $previous = NULL) { parent::__construct($message, $code, $previous); $this->file = $file; $this->line = $line; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Error/000077500000000000000000000000001226222041600216405ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Error/Deprecated.php000066400000000000000000000051701226222041600244140ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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; } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Error/Notice.php000066400000000000000000000051421226222041600235740ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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; } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Error/Warning.php000066400000000000000000000051451226222041600237630ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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; } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Exception.php000066400000000000000000000046541226222041600232270ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since Class available since Release 3.4.0 */ class PHPUnit_Framework_Exception extends RuntimeException { } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/ExpectationFailedException.php000066400000000000000000000062231226222041600265320ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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, Exception $previous = NULL) { $this->comparisonFailure = $comparisonFailure; parent::__construct($message, 0, $previous); } /** * @return PHPUnit_Framework_ComparisonFailure */ public function getComparisonFailure() { return $this->comparisonFailure; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/IncompleteTest.php000066400000000000000000000050051226222041600242170ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since Interface available since Release 2.0.0 */ interface PHPUnit_Framework_IncompleteTest { } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/IncompleteTestError.php000066400000000000000000000050711226222041600252340ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 { } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/OutputError.php000066400000000000000000000050151226222041600235730ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since Class available since Release 3.6.0 */ class PHPUnit_Framework_OutputError extends PHPUnit_Framework_AssertionFailedError { } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Process/000077500000000000000000000000001226222041600221655ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Process/TestCaseMethod.tpl.dist000066400000000000000000000026241226222041600265300ustar00rootroot00000000000000setCodeCoverage(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(); phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/SelfDescribing.php000066400000000000000000000050741226222041600241510ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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(); } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/SkippedTest.php000066400000000000000000000046641226222041600235310ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since Interface available since Release 3.0.0 */ interface PHPUnit_Framework_SkippedTest { } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/SkippedTestError.php000066400000000000000000000050571226222041600245400ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 { } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/SkippedTestSuiteError.php000066400000000000000000000050721226222041600255470ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 { } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/SyntheticError.php000066400000000000000000000071011226222041600242430ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Test.php000066400000000000000000000052571226222041600222100ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/TestCase.php000066400000000000000000001512671226222041600230070ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 required preconditions for a test. * * @var array */ private $required = array( 'PHP' => NULL, 'PHPUnit' => NULL, 'functions' => array(), 'extensions' => array() ); /** * 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 (strlen($this->output) === 0) { 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 * @since Method available since Release 3.2.0 */ public function setExpectedException($exceptionName, $exceptionMessage = '', $exceptionCode = NULL) { $this->expectedException = $exceptionName; $this->expectedExceptionMessage = $exceptionMessage; $this->expectedExceptionCode = $exceptionCode; } /** * @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->required['PHP'] = $requirements['PHP']; } if (isset($requirements['PHPUnit'])) { $this->required['PHPUnit'] = $requirements['PHPUnit']; } if (isset($requirements['extensions'])) { $this->required['extensions'] = $requirements['extensions']; } if (isset($requirements['functions'])) { $this->required['functions'] = $requirements['functions']; } } catch (ReflectionException $e) { } } /** * @since Method available since Release 3.6.0 */ protected function checkRequirements() { $this->setRequirementsFromAnnotation(); $missingRequirements = array(); if ($this->required['PHP'] && version_compare(PHP_VERSION, $this->required['PHP'], '<')) { $missingRequirements[] = sprintf( 'PHP %s (or later) is required.', $this->required['PHP'] ); } $phpunitVersion = PHPUnit_Runner_Version::id(); if ($this->required['PHPUnit'] && version_compare($phpunitVersion, $this->required['PHPUnit'], '<')) { $missingRequirements[] = sprintf( 'PHPUnit %s (or later) is required.', $this->required['PHPUnit'] ); } foreach ($this->required['functions'] as $requiredFunction) { if (!function_exists($requiredFunction)) { $missingRequirements[] = sprintf( 'Function %s is required.', $requiredFunction ); } } foreach ($this->required['extensions'] as $requiredExtension) { if (!extension_loaded($requiredExtension)) { $missingRequirements[] = sprintf( 'Extension %s is required.', $requiredExtension ); } } if ($missingRequirements) { $this->markTestSkipped( implode( PHP_EOL, $missingRequirements ) ); } } /** * 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 PHPUnit_Framework_Exception */ 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 instanceof PHPUnit_Framework_Warning && !$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', __DIR__, 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'; } if (defined('PHPUNIT_COMPOSER_INSTALL')) { $composerAutoload = var_export(PHPUNIT_COMPOSER_INSTALL, TRUE); } else { $composerAutoload = '\'\''; } if (defined('__PHPUNIT_PHAR__')) { $phar = var_export(__PHPUNIT_PHAR__, TRUE); } else { $phar = '\'\''; } $data = var_export(serialize($this->data), TRUE); $dependencyInput = var_export(serialize($this->dependencyInput), TRUE); $includePath = var_export(get_include_path(), TRUE); // must do these fixes because TestCaseMethod.tpl has unserialize('{data}') in it, and we can't break BC // the lines above used to use addcslashes() rather than var_export(), which breaks null byte escape sequences $data = "'." . $data . ".'"; $dependencyInput = "'." . $dependencyInput . ".'"; $includePath = "'." . $includePath . ".'"; $template->setVar( array( 'composerAutoload' => $composerAutoload, 'phar' => $phar, '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 ($this->backupStaticAttributes === TRUE) { PHPUnit_Util_GlobalState::backupStaticAttributes( $this->backupStaticAttributesBlacklist ); } } // Start output buffering. ob_start(); $this->outputBufferingActive = TRUE; // Clean up stat cache. clearstatcache(); // Backup the cwd $currentWorkingDirectory = getcwd(); 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(); } // Clean up the mock objects. $this->mockObjects = array(); // 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 cwd if it was changed by the test if ($currentWorkingDirectory != getcwd()) { chdir($currentWorkingDirectory); } // 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 ($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 PHPUnit_Framework_Exception */ 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) { $checkException = FALSE; if (is_string($this->expectedException)) { $checkException = TRUE; if ($e instanceof PHPUnit_Framework_Exception) { $checkException = FALSE; } $reflector = new ReflectionClass($this->expectedException); if ($this->expectedException == 'PHPUnit_Framework_Exception' || $reflector->isSubclassOf('PHPUnit_Framework_Exception')) { $checkException = TRUE; } } if ($checkException) { $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(); } } /** * 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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @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 * @throws PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @since Method available since Release 3.1.0 */ protected function setLocale() { $args = func_get_args(); if (count($args) < 2) { throw new PHPUnit_Framework_Exception; } $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 PHPUnit_Framework_Exception; } if (!is_array($locale) && !is_string($locale)) { throw new PHPUnit_Framework_Exception; } $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 * @param boolean $cloneArguments * @return PHPUnit_Framework_MockObject_MockObject * @throws PHPUnit_Framework_Exception * @since Method available since Release 3.0.0 */ public function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $cloneArguments = FALSE) { $mockObject = PHPUnit_Framework_MockObject_Generator::getMock( $originalClassName, $methods, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $cloneArguments ); $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 * @param boolean $cloneArguments * @return string * @throws PHPUnit_Framework_Exception * @since Method available since Release 3.5.0 */ protected function getMockClass($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = FALSE, $callOriginalClone = TRUE, $callAutoload = TRUE, $cloneArguments = FALSE) { $mock = $this->getMock( $originalClassName, $methods, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $cloneArguments ); 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 * @param boolean $cloneArguments * @return PHPUnit_Framework_MockObject_MockObject * @since Method available since Release 3.4.0 * @throws PHPUnit_Framework_Exception */ public function getMockForAbstractClass($originalClassName, array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $mockedMethods = array(), $cloneArguments = FALSE) { $mockObject = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass( $originalClassName, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $mockedMethods, $cloneArguments ); $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) ); } if (!class_exists($originalClassName)) { 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 * @param boolean $cloneArguments * @return object * @since Method available since Release 3.6.0 * @throws PHPUnit_Framework_Exception */ protected function getObjectForTrait($traitName, array $arguments = array(), $traitClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $cloneArguments = FALSE) { return PHPUnit_Framework_MockObject_Generator::getObjectForTrait( $traitName, $arguments, $traitClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $cloneArguments ); } /** * 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) { } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/TestFailure.php000066400000000000000000000122371226222041600235140ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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->toString(), $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); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/TestListener.php000066400000000000000000000105221226222041600237050ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/TestResult.php000066400000000000000000000574541226222041600234150ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 allCompletelyImplemented() { 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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @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'); } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/TestSuite.php000066400000000000000000000675361226222041600232320ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception */ 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 PHPUnit_Framework_Exception; } if (!$theClass->isSubclassOf('PHPUnit_Framework_TestCase')) { throw new PHPUnit_Framework_Exception( '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) { $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 PHPUnit_Framework_Exception */ 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 PHPUnit_Framework_Exception; } } /** * 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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception */ 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() ) ); } $groups = PHPUnit_Util_Test::getGroups($className, $name); if ($data instanceof PHPUnit_Framework_Warning) { $test->addTest($data, $groups); } else { 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 PHPUnit_Framework_Exception('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 PHPUnit_Framework_Exception */ 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 && // Some extensions use test names that are not classes; // The method_exists() triggers an autoload call that causes issues with die()ing autoloaders. class_exists($this->name, false) && 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 && // Some extensions use test names that are not classes; // The method_exists() triggers an autoload call that causes issues with die()ing autoloaders. class_exists($this->name, false) && 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 $result */ 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() { } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/TestSuite/000077500000000000000000000000001226222041600225005ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/TestSuite/DataProvider.php000066400000000000000000000053031226222041600255760ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since File available since Release 3.4.0 */ /** * * * @package PHPUnit * @subpackage Framework_TestSuite * @author Sebastian Bergmann * @copyright 2001-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Framework/Warning.php000066400000000000000000000070651226222041600226750ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception */ 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'; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Runner/000077500000000000000000000000001226222041600200635ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Runner/BaseTestRunner.php000066400000000000000000000134011226222041600234770ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 mixed $suffixes * @return PHPUnit_Framework_Test */ public function getTest($suiteClassName, $suiteClassFile = '', $suffixes = '') { if (is_dir($suiteClassName) && !is_file($suiteClassName . '.php') && empty($suiteClassFile)) { $facade = new File_Iterator_Facade; $files = $facade->getFilesAsArray( $suiteClassName, $suffixes ); $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 (PHPUnit_Framework_Exception $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); } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Runner/StandardTestSuiteLoader.php000066400000000000000000000126071226222041600253430ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception */ 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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Runner/TestSuiteLoader.php000066400000000000000000000053661226222041600236660ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Runner/Version.php000066400000000000000000000071131226222041600222230ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since Class available since Release 2.0.0 */ class PHPUnit_Runner_Version { const VERSION = '3.7.28'; protected static $version; /** * Returns the current version of PHPUnit. * * @return string */ public static function id() { if (self::$version === NULL) { self::$version = self::VERSION; if (is_dir(dirname(dirname(__DIR__)) . '/.git')) { $dir = getcwd(); chdir(__DIR__); $version = exec('git describe --tags 2>&1', $output, $returnCode); chdir($dir); if ($version && $returnCode === 0) { if (count(explode('.', self::VERSION)) == 3) { self::$version = $version; } else { $version = explode('-', $version); self::$version = self::VERSION . '-' . $version[2]; } } else { self::$version = self::VERSION . '-dev'; } } } return self::$version; } /** * @return string */ public static function getVersionString() { return 'PHPUnit ' . self::id() . ' by Sebastian Bergmann.'; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/TextUI/000077500000000000000000000000001226222041600177745ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/TextUI/Command.php000066400000000000000000000704061226222041600220720ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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, 'testsuite=' => 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, '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, 'test-suffix=' => 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'], $this->arguments['testSuffixes'] ); } 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 (PHPUnit_Framework_Exception $e) { PHPUnit_TextUI_TestRunner::showError($e->getMessage()); } 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 '--testsuite': { $this->arguments['testsuite'] = $option[1]; } break; case '--group': { $this->arguments['groups'] = explode(',', $option[1]); } break; case '--exclude-group': { $this->arguments['excludeGroups'] = explode( ',', $option[1] ); } break; case '--test-suffix': { $this->arguments['testSuffixes'] = 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 '--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($this->arguments['testSuffixes'])) { $this->arguments['testSuffixes'] = array('Test.php', '.phpt'); } 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(isset($this->arguments['testsuite']) ? $this->arguments['testsuite'] : null); 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); } } /** * 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 = stream_resolve_include_path($loaderFile); if ($loaderFile) { 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 = stream_resolve_include_path($printerFile); if ($printerFile) { 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 (PHPUnit_Framework_Exception $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. --testsuite Filter which testsuite 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. --test-suffix ... Only search for test in files with specified suffix(es). Default: Test.php,.phpt --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 debugging 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. EOT; } /** * Custom callback for test suite discovery. */ protected function handleCustomTestSuite() { } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/TextUI/ResultPrinter.php000066400000000000000000000427371226222041600233440ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception * @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() ) ); $e = $defect->thrownException()->getPrevious(); while ($e) { $this->write( "\nCaused by\n" . PHPUnit_Framework_TestFailure::exceptionToString($e). "\n" . PHPUnit_Util_Filter::getFilteredStacktrace($e) ); $e = $e->getPrevious(); } } /** * @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 (count($result) === 0) { if ($this->colors) { $this->write("\x1b[30;43m\x1b[2K"); } $this->write( "No tests executed!\n" ); if ($this->colors) { $this->write("\x1b[0m\x1b[2K"); } } else if ($result->wasSuccessful() && $result->allCompletelyImplemented() && $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->allCompletelyImplemented() || !$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"); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/TextUI/TestRunner.php000066400000000000000000001010511226222041600226140ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception */ 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 PHPUnit_Framework_Exception( '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'])) { $test = new PHPUnit_Extensions_RepeatedTest( $suite, $arguments['repeat'], $arguments['filter'], $arguments['groups'], $arguments['excludeGroups'], $arguments['processIsolation'] ); $suite = new PHPUnit_Framework_TestSuite(); $suite->addTest($test); } $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'] ) ); } $codeCoverageReports = 0; if (extension_loaded('xdebug')) { if (isset($arguments['coverageClover'])) { $codeCoverageReports++; } if (isset($arguments['reportDirectory'])) { $codeCoverageReports++; } if (isset($arguments['coveragePHP'])) { $codeCoverageReports++; } if (isset($arguments['coverageText'])) { $codeCoverageReports++; } } if ($codeCoverageReports > 0) { $codeCoverage = new PHP_CodeCoverage( NULL, $this->codeCoverageFilter ); $codeCoverage->setAddUncoveredFilesFromWhitelist( $arguments['addUncoveredFilesFromWhitelist'] ); $codeCoverage->setProcessUncoveredFilesFromWhitelist( $arguments['processUncoveredFilesFromWhitelist'] ); if (isset($arguments['forceCoversAnnotation'])) { $codeCoverage->setForceCoversAnnotation( $arguments['forceCoversAnnotation'] ); } if (isset($arguments['mapTestClassNameToCoveredClassName'])) { $codeCoverage->setMapTestClassNameToCoveredClassName( $arguments['mapTestClassNameToCoveredClassName'] ); } $result->setCodeCoverage($codeCoverage); } if ($codeCoverageReports > 1) { if (isset($arguments['cacheTokens'])) { $codeCoverage->setCacheTokens($arguments['cacheTokens']); } } 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)) { if (isset($arguments['coverageClover'])) { $this->printer->write( "\nGenerating code coverage report in Clover XML format ..." ); $writer = new PHP_CodeCoverage_Report_Clover; $writer->process($codeCoverage, $arguments['coverageClover']); $this->printer->write(" done\n"); unset($writer); } if (isset($arguments['reportDirectory'])) { $this->printer->write( "\nGenerating code coverage report in HTML format ..." ); $writer = new PHP_CodeCoverage_Report_HTML( $arguments['reportCharset'], $arguments['reportHighlight'], $arguments['reportLowUpperBound'], $arguments['reportHighLowerBound'], sprintf( ' and PHPUnit %s', PHPUnit_Runner_Version::id() ) ); $writer->process($codeCoverage, $arguments['reportDirectory']); $this->printer->write(" done\n"); unset($writer); } if (isset($arguments['coveragePHP'])) { $this->printer->write( "\nGenerating code coverage report in PHP format ..." ); $writer = new PHP_CodeCoverage_Report_PHP; $writer->process($codeCoverage, $arguments['coveragePHP']); $this->printer->write(" done\n"); unset($writer); } if (isset($arguments['coverageText'])) { 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, $arguments['reportLowUpperBound'], $arguments['reportHighLowerBound'], $arguments['coverageTextShowUncoveredFiles'] ); $writer->process($codeCoverage, $colors); } } 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 . PHP_EOL); 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']; } $groupCliArgs = array(); if (!empty($arguments['groups'])) { $groupCliArgs = $arguments['groups']; } $groupConfiguration = $arguments['configuration']->getGroupConfiguration(); if (!empty($groupConfiguration['include']) && !isset($arguments['groups'])) { $arguments['groups'] = $groupConfiguration['include']; } if (!empty($groupConfiguration['exclude']) && !isset($arguments['excludeGroups'])) { $arguments['excludeGroups'] = array_diff($groupConfiguration['exclude'], $groupCliArgs); } foreach ($arguments['configuration']->getListenerConfiguration() as $listener) { if (!class_exists($listener['class'], FALSE) && $listener['file'] !== '') { require_once $listener['file']; } if (class_exists($listener['class'])) { 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['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']; $arguments['processUncoveredFilesFromWhitelist'] = $filterConfiguration['whitelist']['processUncoveredFilesFromWhitelist']; 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['processUncoveredFilesFromWhitelist'] = isset($arguments['processUncoveredFilesFromWhitelist']) ? $arguments['processUncoveredFilesFromWhitelist'] : FALSE; $arguments['backupGlobals'] = isset($arguments['backupGlobals']) ? $arguments['backupGlobals'] : NULL; $arguments['backupStaticAttributes'] = isset($arguments['backupStaticAttributes']) ? $arguments['backupStaticAttributes'] : NULL; $arguments['cacheTokens'] = isset($arguments['cacheTokens']) ? $arguments['cacheTokens'] : FALSE; $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['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'] ) . '/'; } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/000077500000000000000000000000001226222041600175275ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Class.php000066400000000000000000000253441226222041600213150ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since File available since Release 3.1.0 */ /** * Class helpers. * * @package PHPUnit * @subpackage Util * @author Sebastian Bergmann * @copyright 2001-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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(); /* Note: PHP extensions may use empty names for reference arguments * or "..." for methods taking a variable number of arguments. */ if ($name === '$' || $name === '$...') { $name = '$arg' . $i; } $default = ''; $reference = ''; $typeHint = ''; if (!$forCall) { if ($parameter->isArray()) { $typeHint = 'array '; } else if (version_compare(PHP_VERSION, '5.4', '>') && $parameter->isCallable()) { $typeHint = 'callable '; } 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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception * @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 || $attribute->isPublic()) { return $object->$attributeName; } $attribute->setAccessible(TRUE); $value = $attribute->getValue($object); $attribute->setAccessible(FALSE); return $value; } throw new PHPUnit_Framework_Exception( sprintf( 'Attribute "%s" not found in object.', $attributeName ) ); } /** * 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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Configuration.php000066400000000000000000000776071226222041600230700ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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, FALSE, TRUE); $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; $processUncoveredFilesFromWhitelist = FALSE; $tmp = $this->xpath->query('filter/whitelist'); if ($tmp->length == 1) { if ($tmp->item(0)->hasAttribute('addUncoveredFilesFromWhitelist')) { $addUncoveredFilesFromWhitelist = $this->getBoolean( (string)$tmp->item(0)->getAttribute( 'addUncoveredFilesFromWhitelist' ), TRUE ); } if ($tmp->item(0)->hasAttribute('processUncoveredFilesFromWhitelist')) { $processUncoveredFilesFromWhitelist = $this->getBoolean( (string)$tmp->item(0)->getAttribute( 'processUncoveredFilesFromWhitelist' ), FALSE ); } } 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, 'processUncoveredFilesFromWhitelist' => $processUncoveredFilesFromWhitelist, '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 ); } foreach ($listener->childNodes as $node) { if ($node instanceof DOMElement && $node->tagName == 'arguments') { foreach ($node->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('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) { // See https://github.com/sebastianbergmann/phpunit/issues/277 switch ($array) { case 'var': $target = &$GLOBALS; break; case 'env': $target = &$_ENV; break; case 'server': $target = &$_SERVER; break; default: $target = &$GLOBALS['_' . strtoupper($array)]; break; } 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'), FALSE ); } 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($testSuiteFilter=null) { $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), $testSuiteFilter); } if ($testSuiteNodes->length > 1) { $suite = new PHPUnit_Framework_TestSuite; foreach ($testSuiteNodes as $testSuiteNode) { $suite->addTestSuite( $this->getTestSuite($testSuiteNode, $testSuiteFilter) ); } return $suite; } } /** * @param DOMElement $testSuiteNode * @return PHPUnit_Framework_TestSuite * @since Method available since Release 3.4.0 */ protected function getTestSuite(DOMElement $testSuiteNode, $testSuiteFilter=null) { 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) { if ($testSuiteFilter && $directoryNode->parentNode->getAttribute('name') != $testSuiteFilter) { continue; } $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) { if ($testSuiteFilter && $fileNode->parentNode->getAttribute('name') != $testSuiteFilter) { continue; } $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 = stream_resolve_include_path($path); if ($includePathFile) { $file = $includePathFile; } } return $file; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/DeprecatedFeature.php000066400000000000000000000066241226222041600236240ustar00rootroot00000000000000. * 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-3-Clause The BSD 3-Clause 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-3-Clause The BSD 3-Clause License * @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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/DeprecatedFeature/000077500000000000000000000000001226222041600231035ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/DeprecatedFeature/Logger.php000066400000000000000000000151241226222041600250360ustar00rootroot00000000000000. * 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-3-Clause The BSD 3-Clause 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-3-Clause The BSD 3-Clause License * @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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Diff.php000066400000000000000000000204651226222041600211170ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 as string. * * @param array|string $from * @param array|string $to * @return string */ public static function diff($from, $to) { $buffer= "--- Expected\n+++ Actual\n"; $diff = self::diffToArray($from,$to); $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; } /** * Returns the diff between two arrays or strings as array. * * every array-entry containts two elements: * - [0] => string $token * - [1] => 2|1|0 * * - 2: REMOVED: $token was removed from $from * - 1: ADDED: $token was added to $from * - 0: OLD: $token is not changed in $to * * @param array|string $from * @param array|string $to * @return array */ public static function diffToArray($from, $to) { preg_match_all('(\r\n|\r|\n)', $from, $fromMatches); preg_match_all('(\r\n|\r|\n)', $to, $toMatches); if (is_string($from)) { $from = preg_split('(\r\n|\r|\n)', $from); } if (is_string($to)) { $to = preg_split('(\r\n|\r|\n)', $to); } $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; if (isset($fromMatches[0]) && $toMatches[0] && count($fromMatches[0]) === count($toMatches[0]) && $fromMatches[0] !== $toMatches[0]) { $diff[] = array( '#Warning: Strings contain different line endings!', 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 */); } return $diff; } /** * 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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/ErrorHandler.php000066400000000000000000000110111226222041600226210ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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 __DIR__ . '/../Framework/Error.php'; require_once __DIR__ . '/../Framework/Error/Notice.php'; require_once __DIR__ . '/../Framework/Error/Warning.php'; require_once __DIR__ . '/../Framework/Error/Deprecated.php'; /** * Error handler that converts PHP errors and warnings to exceptions. * * @package PHPUnit * @subpackage Util * @author Sebastian Bergmann * @copyright 2001-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 ($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); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Fileloader.php000066400000000000000000000073461226222041600223200ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception */ public static function checkAndLoad($filename) { $includePathFilename = stream_resolve_include_path($filename); if (!$includePathFilename || !is_readable($includePathFilename)) { throw new PHPUnit_Framework_Exception( 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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Filesystem.php000066400000000000000000000056371226222041600223770ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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'; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Filter.php000066400000000000000000000116461226222041600214750ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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) { $prefix = FALSE; $script = realpath($GLOBALS['_SERVER']['SCRIPT_NAME']); if (defined('__PHPUNIT_PHAR__')) { $prefix = 'phar://' . __PHPUNIT_PHAR__ . '/'; } 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 { if ($e->getPrevious()) { $eTrace = $e->getPrevious()->getTrace(); } 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']]) && strpos($frame['file'], $prefix) !== 0 && $frame['file'] !== $script) { 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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Getopt.php000066400000000000000000000152411226222041600215050ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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"); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/GlobalState.php000066400000000000000000000337311226222041600224500ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since File available since Release 3.4.0 */ /** * * * @package PHPUnit * @subpackage Util * @author Sebastian Bergmann * @copyright 2001-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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(); $prefix = FALSE; $result = ''; if (defined('__PHPUNIT_PHAR__')) { $prefix = 'phar://' . __PHPUNIT_PHAR__ . '/'; } for ($i = count($files) - 1; $i > 0; $i--) { $file = $files[$i]; if ($prefix !== FALSE && strpos($file, $prefix) === 0) { continue; } if (!isset($blacklist[$file]) && is_file($file)) { $result = 'require_once \'' . $file . "';\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_Token_Stream') !== 0 && strpos($declaredClasses[$i], 'Symfony') !== 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(); self::addDirectoryContainingClassToPHPUnitFilesList('File_Iterator'); self::addDirectoryContainingClassToPHPUnitFilesList('PHP_CodeCoverage'); self::addDirectoryContainingClassToPHPUnitFilesList('PHP_Invoker'); self::addDirectoryContainingClassToPHPUnitFilesList('PHP_Timer'); self::addDirectoryContainingClassToPHPUnitFilesList('PHP_Token'); self::addDirectoryContainingClassToPHPUnitFilesList('PHPUnit_Framework_TestCase', 2); self::addDirectoryContainingClassToPHPUnitFilesList('PHPUnit_Extensions_Database_TestCase', 2); self::addDirectoryContainingClassToPHPUnitFilesList('PHPUnit_Framework_MockObject_Generator', 2); self::addDirectoryContainingClassToPHPUnitFilesList('PHPUnit_Extensions_SeleniumTestCase', 2); self::addDirectoryContainingClassToPHPUnitFilesList('PHPUnit_Extensions_Story_TestCase', 2); self::addDirectoryContainingClassToPHPUnitFilesList('Text_Template'); } return self::$phpunitFiles; } /** * @param string $className * @param integer $parent * @since Method available since Release 3.7.2 */ protected static function addDirectoryContainingClassToPHPUnitFilesList($className, $parent = 1) { if (!class_exists($className)) { return; } $reflector = new ReflectionClass($className); $directory = $reflector->getFileName(); for ($i = 0; $i < $parent; $i++) { $directory = dirname($directory); } $facade = new File_Iterator_Facade; foreach ($facade->getFilesAsArray($directory, '.php') as $file) { self::$phpunitFiles[$file] = TRUE; } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/InvalidArgumentHelper.php000066400000000000000000000060011226222041600244660ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since File available since Release 3.4.0 */ /** * Factory for PHPUnit_Framework_Exception objects that are used to describe * invalid arguments passed to a function or method. * * @package PHPUnit * @subpackage Util * @author Sebastian Bergmann * @copyright 2001-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception( sprintf( 'Argument #%d%sof %s::%s() must be a %s', $argument, $value !== NULL ? ' (' . $value . ')' : ' ', $stack[1]['class'], $stack[1]['function'], $type ) ); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Log/000077500000000000000000000000001226222041600202505ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Log/JSON.php000066400000000000000000000167611226222041600215450ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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, PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE), 'Incomplete Test: ' . $e->getMessage(), $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, PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE), 'Skipped Test: ' . $e->getMessage(), $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) { array_walk_recursive($buffer, function(&$input) { if (is_string($input)) { $input = PHPUnit_Util_String::convertToUtf8($input); } }); if (defined('JSON_PRETTY_PRINT')) { parent::write(json_encode($buffer, JSON_PRETTY_PRINT)); } else { parent::write(json_encode($buffer)); } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Log/JUnit.php000066400000000000000000000360431226222041600220200ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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; } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Log/TAP.php000066400000000000000000000162001226222041600214040ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since File available since Release 3.0.0 */ /** * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception * @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 Symfony\Component\Yaml\Dumper; $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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/PHP.php000066400000000000000000000265641226222041600207040ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 = escapeshellarg($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) { $time = 0; if (!empty($stderr)) { $result->addError( $test, new PHPUnit_Framework_Exception(trim($stderr)), $time ); } else { set_error_handler(function($errno, $errstr, $errfile, $errline) { throw new ErrorException($errstr, $errno, $errno, $errfile, $errline); }); try { if (strpos($stdout, "#!/usr/bin/env php\n") === 0) { $stdout = substr($stdout, 19); } $childResult = unserialize(str_replace("#!/usr/bin/env php\n", '', $stdout)); restore_error_handler(); } catch (ErrorException $e) { restore_error_handler(); $childResult = FALSE; $result->addError( $test, new PHPUnit_Framework_Exception(trim($stdout), 0, $e), $time ); } 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 ); } } } $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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/PHP/000077500000000000000000000000001226222041600201565ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/PHP/Default.php000066400000000000000000000051301226222041600222520ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/PHP/Windows.php000066400000000000000000000062461226222041600223310ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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, TRUE) . "; ?>" ); } /** * @since Method available since Release 3.5.12 */ protected function cleanup() { unlink($this->tempFile); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Printer.php000066400000000000000000000141101226222041600216600ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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 PHPUnit_Framework_Exception */ 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 PHPUnit_Framework_Exception; } $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'); } } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/String.php000066400000000000000000000073111226222041600215100ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Test.php000066400000000000000000000467121226222041600211710ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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_VERSION = '/@requires\s+(?PPHP(?:Unit)?)\s+(?P[\d\.-]+(dev|(RC|alpha|beta)[\d\.])?)[ \t]*\r?$/m'; const REGEX_REQUIRES = '/@requires\s+(?Pfunction|extension)\s(?P([^ ]+))\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 ReflectionClass($className); $docComment = $reflector->getDocComment(); $reflector = new ReflectionMethod($className, $methodName); $docComment .= "\n" . $reflector->getDocComment(); $requires = array(); if ($count = preg_match_all(self::REGEX_REQUIRES_VERSION, $docComment, $matches)) { for ($i = 0; $i < $count; $i++) { $requires[$matches['name'][$i]] = $matches['value'][$i]; } } // https://bugs.php.net/bug.php?id=63055 $matches = array(); if ($count = preg_match_all(self::REGEX_REQUIRES, $docComment, $matches)) { for ($i = 0; $i < $count; $i++) { $name = $matches['name'][$i] . 's'; if (!isset($requires[$name])) { $requires[$name] = array(); } $requires[$name][] = $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(); $docComment = substr($docComment, 3, -2); 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 = self::_parseAnnotationContent( $annotations['method']['expectedExceptionMessage'][0] ); } if (isset($matches[3])) { $code = $matches[3]; } else if (isset($annotations['method']['expectedExceptionCode'])) { $code = self::_parseAnnotationContent( $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; } /** * Parse annotation content to use constant/class constant values * * Constants are specified using a starting '@'. For example: @ClassName::CONST_NAME * * If the constant is not found the string is used as is to ensure maximum BC. * * @param string $message * @return string */ protected static function _parseAnnotationContent($message) { if (strpos($message, '::') !== FALSE && count(explode('::', $message) == 2)) { if (defined($message)) { $message = constant($message); } } return $message; } /** * 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) { if (is_object($data)) { $data = iterator_to_array($data); } foreach ($data as $key => $value) { if (!is_array($value)) { throw new PHPUnit_Framework_Exception( 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])) { try { $method = new ReflectionMethod($className, $methodName); $annotations = self::parseAnnotations($method->getDocComment()); } catch (ReflectionException $e) { $annotations = array(); } self::$annotationCache[$className . '::' . $methodName] = $annotations; } 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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/TestDox/000077500000000000000000000000001226222041600211215ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/TestDox/NamePrettifier.php000066400000000000000000000120421226222041600245470ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/TestDox/ResultPrinter.php000066400000000000000000000231631226222041600244610ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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() { } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/TestDox/ResultPrinter/000077500000000000000000000000001226222041600237435ustar00rootroot00000000000000phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/TestDox/ResultPrinter/HTML.php000066400000000000000000000073121226222041600252230ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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(''); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/TestDox/ResultPrinter/Text.php000066400000000000000000000062511226222041600254040ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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"); } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/TestSuiteIterator.php000066400000000000000000000101511226222041600237010ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/Type.php000066400000000000000000000233051226222041600211640ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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("\r\n", "\n\r", "\r"), array("\n", "\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); } if (is_object($value)) { return sprintf( '%s Object (%s)', get_class($value), count(self::toArray($value)) > 0 ? '...' : '' ); } if (is_array($value)) { return sprintf( 'Array (%s)', 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; } } phpunit-3.7.28/PHPUnit-3.7.28/PHPUnit/Util/XML.php000066400000000000000000000726461226222041600207170ustar00rootroot00000000000000. * 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause 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-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @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_callback( '/[\\x00-\\x04\\x0b\\x0c\\x0e-\\x1f\\x7f]/', function ($matches) { return sprintf('&#x%02x;', ord($matches[0])); }, 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 * @param boolean $xinclude * @return DOMDocument * @since Method available since Release 3.3.0 */ public static function loadFile($filename, $isHtml = FALSE, $xinclude = 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, $xinclude); } /** * 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. If $isHtml is * false and $xinclude is true, xinclude is performed on the loaded * DOMDocument. * * 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 * @param boolean $xinclude * @return DOMDocument * @since Method available since Release 3.3.0 * @author Mike Naberezny * @author Derek DeVries * @author Tobias Schlitt */ public static function load($actual, $isHtml = FALSE, $filename = '', $xinclude = FALSE) { 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); } if ('' !== $filename) { // Necessary for xinclude $document->documentURI = $filename; } if (!$isHtml && $xinclude) { $document->xinclude(); } 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 PHPUnit_Framework_Exception * @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 PHPUnit_Framework_Exception( '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 empty string else if ($options['content'] === '') { if (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) { continue; } $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 && $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 || $childNode->nodeType === XML_CDATA_SECTION_NODE) { $result .= trim($childNode->data) . ' '; } else { $result .= self::getNodeText($childNode); } } return str_replace(' ', ' ', $result); } } phpunit-3.7.28/PHPUnit-3.7.28/README.md000066400000000000000000000117201226222041600166030ustar00rootroot00000000000000# 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. [![Build Status](https://travis-ci.org/sebastianbergmann/phpunit.png?branch=3.7)](https://travis-ci.org/sebastianbergmann/phpunit) ## Requirements * PHPUnit 3.7 requires PHP 5.3.3 (or later) but PHP 5.4.6 (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.2.1 (or later) is highly recommended. ## Installation ### PHP Archive (PHAR) The easiest way to obtain PHPUnit is to download a [PHP Archive (PHAR)](http://php.net/phar) that has all required (as well as some optional) dependencies of PHPUnit bundled in a single file: wget https://phar.phpunit.de/phpunit.phar chmod +x phpunit.phar mv phpunit.phar /usr/local/bin/phpunit You can also immediately use the PHAR after you have downloaded it, of course: wget https://phar.phpunit.de/phpunit.phar php phpunit.phar ### Composer Simply add a dependency on `phpunit/phpunit` to your project's `composer.json` file if you use [Composer](http://getcomposer.org/) to manage the dependencies of your project. Here is a minimal example of a `composer.json` file that just defines a development-time dependency on PHPUnit 3.7: { "require-dev": { "phpunit/phpunit": "3.7.*" } } For a system-wide installation via Composer, you can run: composer global require 'phpunit/phpunit=3.7.*' Make sure you have `~/.composer/vendor/bin/` in your path. ### PEAR Installer 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 ## Documentation The documentation for PHPUnit is available in different formats: * [English, multiple HTML files](http://www.phpunit.de/manual/3.7/en/index.html) * [English, single HTML file](http://www.phpunit.de/manual/3.7/en/phpunit-book.html) * [English, PDF](http://www.phpunit.de/manual/3.7/en/phpunit-book.pdf) * [English, ePub](http://www.phpunit.de/manual/3.7/en/phpunit-book.epub) * [Brazilian Portuguese, multiple HTML files](http://www.phpunit.de/manual/3.7/pt_br/index.html) * [Brazilian Portuguese, single HTML file](http://www.phpunit.de/manual/3.7/pt_br/phpunit-book.html) * [Brazilian Portuguese, PDF](http://www.phpunit.de/manual/3.7/pt_br/phpunit-book.pdf) * [Brazilian Portuguese, ePub](http://www.phpunit.de/manual/3.7/pt_br/phpunit-book.epub) * [French, multiple HTML files](http://www.phpunit.de/manual/3.7/fr/index.html) * [French, single HTML file](http://www.phpunit.de/manual/3.7/fr/phpunit-book.html) * [French, PDF](http://www.phpunit.de/manual/3.7/fr/phpunit-book.pdf) * [French, ePub](http://www.phpunit.de/manual/3.7/fr/phpunit-book.epub) * [Japanese, multiple HTML files](http://www.phpunit.de/manual/3.7/ja/index.html) * [Japanese, single HTML file](http://www.phpunit.de/manual/3.7/ja/phpunit-book.html) * [Japanese, PDF](http://www.phpunit.de/manual/3.7/ja/phpunit-book.pdf) * [Japanese, ePub](http://www.phpunit.de/manual/3.7/ja/phpunit-book.epub) * [Simplified Chinese, multiple HTML files](http://www.phpunit.de/manual/3.7/zh_cn/index.html) * [Simplified Chinese, single HTML file](http://www.phpunit.de/manual/3.7/zh_cn/phpunit-book.html) * [Simplified Chinese, PDF](http://www.phpunit.de/manual/3.7/zh_cn/phpunit-book.pdf) * [Simplified Chinese, ePub](http://www.phpunit.de/manual/3.7/zh_cn/phpunit-book.epub) ## Mailing Lists * [dev@phpunit.de](mailto:dev-subscribe@phpunit.de) is a list for those who want to help out with the development of PHPUnit * [user@phpunit.de](mailto:user-subscribe@phpunit.de) is a list for general PHPUnit support; ask PHPUnit questions here ## IRC The [#phpunit channel on the Freenode IRC network](irc://irc.freenode.net/phpunit) is a place to chat about PHPUnit. ## List of Contributors Thanks to everyone who has contributed to PHPUnit! You can find a detailed list of contributors on every PHPUnit related package on GitHub. This list shows only the major components: * [PHPUnit](https://github.com/sebastianbergmann/phpunit/graphs/contributors) * [PHP_CodeCoverage](https://github.com/sebastianbergmann/php-code-coverage/graphs/contributors) * [PHPUnit_MockObject](https://github.com/sebastianbergmann/phpunit-mock-objects/graphs/contributors) A very special thanks to everyone who has contributed to the documentation and helps maintaining the translations: * [PHPUnit Documentation](https://github.com/sebastianbergmann/phpunit-documentation/graphs/contributors) Please refer to [CONTRIBUTING.md](https://github.com/sebastianbergmann/phpunit/blob/master/CONTRIBUTING.md) for information on how to contribute to PHPUnit and its related projects. phpunit-3.7.28/PHPUnit-3.7.28/phpunit.bat000066400000000000000000000036261226222041600175110ustar00rootroot00000000000000@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" %* phpunit-3.7.28/PHPUnit-3.7.28/phpunit.php000077500000000000000000000037551226222041600175400ustar00rootroot00000000000000#!/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(); phpunit-3.7.28/package.sig000066400000000000000000000003061226222041600153750ustar00rootroot00000000000000-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) iEYEABECAAYFAlJfkX4ACgkQaGfFFLhbXWlXEgCggl4xQI8RhegpIprghuvWIUbQ e6wAoI0rQIk55voJMkxe4qcpAMXIwXgR =OYY/ -----END PGP SIGNATURE----- phpunit-3.7.28/package.xml000066400000000000000000000462061226222041600154240ustar00rootroot00000000000000 PHPUnit pear.phpunit.de The PHP Unit Testing framework. The PHP Unit Testing framework. Sebastian Bergmann sb sebastian@phpunit.de yes 2013-10-17 3.7.28 3.7.0 stable stable The BSD 3-Clause License http://github.com/sebastianbergmann/phpunit/blob/master/README.md 5.3.3 1.9.4 File_Iterator pear.phpunit.de 1.3.1 Text_Template pear.phpunit.de 1.1.1 PHP_CodeCoverage pear.phpunit.de 1.2.1 1.2.99 PHP_Timer pear.phpunit.de 1.0.4 PHPUnit_MockObject pear.phpunit.de 1.2.0 1.2.99 Yaml pear.symfony.com 2.0.0 2.99.99 dom pcre PHP_Invoker pear.phpunit.de 1.1.0 1.1.99 json simplexml tokenizer windows