diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 80e94b17b88..885fe3d3945 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,13 +8,11 @@ on: jobs: test: - name: PHP:${{ matrix.php }} PHP_INVOKER:${{ toJSON(matrix.php_invoker) }} ALLOW_FAILURES:${{ toJSON(matrix.experimental) }} COVERAGE:${{ toJSON(matrix.coverage) }} + name: PHP:${{ matrix.php }} php-invoker:${{ toJSON(matrix.php_invoker) }}${{ matrix.coverage && ' (with coverage)' || '' }}${{ matrix.experimental && ' (allowing failures - php version not supported yet)' || '' }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - experimental: [false] - coverage: [false] php: - "5.3" - "5.4" @@ -24,32 +22,20 @@ jobs: - "7.1" - "7.2" - "7.3" - php_invoker: - - true - - false + - "8.0" + - "8.1" + - "8.2" + php_invoker: [true, false] + coverage: [false] + experimental: [false] include: - - php: "7.4" - php_invoker: true - coverage: true + # run coverage only on PHP 7.4 - php: "7.4" php_invoker: false coverage: true - - php: "8.0" - php_invoker: true - experimental: false - coverage: false - - php: "8.0" - php_invoker: false - coverage: false - experimental: false - - php: "8.1" + - php: "7.4" php_invoker: true - experimental: true - coverage: false - - php: "8.1" - php_invoker: false - experimental: true - coverage: false + coverage: true steps: - name: Checkout Code diff --git a/.gitignore b/.gitignore index 72fc6d5c9b7..53006eff367 100644 --- a/.gitignore +++ b/.gitignore @@ -12,9 +12,9 @@ Tests/TextUI/*.log Tests/TextUI/*.out Tests/TextUI/*.php /bin -/vendor -/composer.lock -/composer.phar +vendor +composer.lock +composer.phar phpunit.xml cache.properties .idea diff --git a/PHPUnit/Extensions/PhptTestCase.php b/PHPUnit/Extensions/PhptTestCase.php index 057eee28b00..d59c37605cb 100644 --- a/PHPUnit/Extensions/PhptTestCase.php +++ b/PHPUnit/Extensions/PhptTestCase.php @@ -106,6 +106,7 @@ public function __construct($filename, array $options = array()) * * @return integer */ + #[\ReturnTypeWillChange] public function count() { return 1; diff --git a/PHPUnit/Extensions/RepeatedTest.php b/PHPUnit/Extensions/RepeatedTest.php index 5cc6baeab1d..671311e8e5b 100644 --- a/PHPUnit/Extensions/RepeatedTest.php +++ b/PHPUnit/Extensions/RepeatedTest.php @@ -115,6 +115,7 @@ public function __construct(PHPUnit_Framework_Test $test, $timesRepeat = 1, $fil * * @return integer */ + #[\ReturnTypeWillChange] public function count() { return $this->timesRepeat * count($this->test); diff --git a/PHPUnit/Extensions/TestDecorator.php b/PHPUnit/Extensions/TestDecorator.php index 0c954d24498..6d97e780886 100644 --- a/PHPUnit/Extensions/TestDecorator.php +++ b/PHPUnit/Extensions/TestDecorator.php @@ -104,6 +104,7 @@ public function basicRun(PHPUnit_Framework_TestResult $result) * * @return integer */ + #[\ReturnTypeWillChange] public function count() { return count($this->test); diff --git a/PHPUnit/Framework/Constraint.php b/PHPUnit/Framework/Constraint.php index 6081c7829cf..512afec9185 100644 --- a/PHPUnit/Framework/Constraint.php +++ b/PHPUnit/Framework/Constraint.php @@ -112,6 +112,7 @@ protected function matches($other) * @return integer * @since Method available since Release 3.4.0 */ + #[\ReturnTypeWillChange] public function count() { return 1; diff --git a/PHPUnit/Framework/Constraint/And.php b/PHPUnit/Framework/Constraint/And.php index 6333d3f7b1c..85f89412e02 100644 --- a/PHPUnit/Framework/Constraint/And.php +++ b/PHPUnit/Framework/Constraint/And.php @@ -151,6 +151,7 @@ public function toString() * @return integer * @since Method available since Release 3.4.0 */ + #[\ReturnTypeWillChange] public function count() { $count = 0; diff --git a/PHPUnit/Framework/Constraint/Composite.php b/PHPUnit/Framework/Constraint/Composite.php index 84395167c6c..8be2fc3b46a 100644 --- a/PHPUnit/Framework/Constraint/Composite.php +++ b/PHPUnit/Framework/Constraint/Composite.php @@ -107,6 +107,7 @@ public function evaluate($other, $description = '', $returnResult = FALSE) * * @return integer */ + #[\ReturnTypeWillChange] public function count() { return count($this->innerConstraint); diff --git a/PHPUnit/Framework/Constraint/IsAnything.php b/PHPUnit/Framework/Constraint/IsAnything.php index 9d8f35e7d0d..c0383262dd5 100644 --- a/PHPUnit/Framework/Constraint/IsAnything.php +++ b/PHPUnit/Framework/Constraint/IsAnything.php @@ -95,6 +95,7 @@ public function toString() * @return integer * @since Method available since Release 3.5.0 */ + #[\ReturnTypeWillChange] public function count() { return 0; diff --git a/PHPUnit/Framework/Constraint/Not.php b/PHPUnit/Framework/Constraint/Not.php index 2d408e7cc26..c8d06481231 100644 --- a/PHPUnit/Framework/Constraint/Not.php +++ b/PHPUnit/Framework/Constraint/Not.php @@ -196,6 +196,7 @@ public function toString() * @return integer * @since Method available since Release 3.4.0 */ + #[\ReturnTypeWillChange] public function count() { return count($this->constraint); diff --git a/PHPUnit/Framework/Constraint/Or.php b/PHPUnit/Framework/Constraint/Or.php index c55088e2bfd..81023f2c4b6 100644 --- a/PHPUnit/Framework/Constraint/Or.php +++ b/PHPUnit/Framework/Constraint/Or.php @@ -144,6 +144,7 @@ public function toString() * @return integer * @since Method available since Release 3.4.0 */ + #[\ReturnTypeWillChange] public function count() { $count = 0; diff --git a/PHPUnit/Framework/Constraint/Xor.php b/PHPUnit/Framework/Constraint/Xor.php index 33a34273249..a98c16cb7f9 100644 --- a/PHPUnit/Framework/Constraint/Xor.php +++ b/PHPUnit/Framework/Constraint/Xor.php @@ -149,6 +149,7 @@ public function toString() * @return integer * @since Method available since Release 3.4.0 */ + #[\ReturnTypeWillChange] public function count() { $count = 0; diff --git a/PHPUnit/Framework/TestCase.php b/PHPUnit/Framework/TestCase.php index 398ed947e22..e676df9ae17 100644 --- a/PHPUnit/Framework/TestCase.php +++ b/PHPUnit/Framework/TestCase.php @@ -328,6 +328,7 @@ public function toString() * * @return integer */ + #[\ReturnTypeWillChange] public function count() { return 1; diff --git a/PHPUnit/Framework/TestResult.php b/PHPUnit/Framework/TestResult.php index d9691a4b07a..89c7388461e 100644 --- a/PHPUnit/Framework/TestResult.php +++ b/PHPUnit/Framework/TestResult.php @@ -729,6 +729,7 @@ public function run(PHPUnit_Framework_Test $test) * * @return integer */ + #[\ReturnTypeWillChange] public function count() { return $this->runTests; diff --git a/PHPUnit/Framework/TestSuite.php b/PHPUnit/Framework/TestSuite.php index b1a3da578c6..324fcf7fc29 100644 --- a/PHPUnit/Framework/TestSuite.php +++ b/PHPUnit/Framework/TestSuite.php @@ -422,6 +422,7 @@ public function addTestFiles($filenames) * * @return integer */ + #[\ReturnTypeWillChange] public function count() { if ($this->numTests > -1) { @@ -925,6 +926,7 @@ public function setBackupStaticAttributes($backupStaticAttributes) * @return RecursiveIteratorIterator * @since Method available since Release 3.1.0 */ + #[\ReturnTypeWillChange] public function getIterator() { return new RecursiveIteratorIterator( diff --git a/PHPUnit/Util/Configuration.php b/PHPUnit/Util/Configuration.php index 2907a8e76b6..3ece8ab7d64 100644 --- a/PHPUnit/Util/Configuration.php +++ b/PHPUnit/Util/Configuration.php @@ -538,8 +538,10 @@ public function handlePHPConfiguration() // See https://github.com/sebastianbergmann/phpunit/issues/277 switch ($array) { case 'var': - $target = &$GLOBALS; - break; + foreach ($configuration[$array] as $name => $value) { + $GLOBALS[$name] = $value; + } + continue 2; case 'env': $target = &$_ENV; @@ -550,8 +552,10 @@ public function handlePHPConfiguration() break; default: - $target = &$GLOBALS['_' . strtoupper($array)]; - break; + foreach ($configuration[$array] as $name => $value) { + $GLOBALS['_' . strtoupper($array)][$name] = $value; + } + continue 2; } foreach ($configuration[$array] as $name => $value) { diff --git a/PHPUnit/Util/Getopt.php b/PHPUnit/Util/Getopt.php index 45fb7d80410..8f89b56af38 100644 --- a/PHPUnit/Util/Getopt.php +++ b/PHPUnit/Util/Getopt.php @@ -181,7 +181,7 @@ protected static function parseLongOption($arg, $long_options, &$opts, &$args) if (substr($long_opt, -1) == '=') { if (substr($long_opt, -2) != '==') { - if (!strlen($opt_arg)) { + if ($opt_arg === null || !strlen($opt_arg)) { if (false === $opt_arg = current($args)) { throw new PHPUnit_Framework_Exception( "option --$opt requires an argument" diff --git a/PHPUnit/Util/TestSuiteIterator.php b/PHPUnit/Util/TestSuiteIterator.php index 4e7cf899574..160e2bcf86b 100644 --- a/PHPUnit/Util/TestSuiteIterator.php +++ b/PHPUnit/Util/TestSuiteIterator.php @@ -80,6 +80,7 @@ public function __construct(PHPUnit_Framework_TestSuite $testSuite) * Rewinds the Iterator to the first element. * */ + #[\ReturnTypeWillChange] public function rewind() { $this->position = 0; @@ -90,6 +91,7 @@ public function rewind() * * @return boolean */ + #[\ReturnTypeWillChange] public function valid() { return $this->position < count($this->tests); @@ -100,6 +102,7 @@ public function valid() * * @return integer */ + #[\ReturnTypeWillChange] public function key() { return $this->position; @@ -110,6 +113,7 @@ public function key() * * @return PHPUnit_Framework_Test */ + #[\ReturnTypeWillChange] public function current() { return $this->valid() ? $this->tests[$this->position] : NULL; @@ -119,6 +123,7 @@ public function current() * Moves forward to next element. * */ + #[\ReturnTypeWillChange] public function next() { $this->position++; diff --git a/README.md b/README.md index d1b44f05fa8..c7f1c2f8493 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# PHPUnit 3.7.x php 5.3-8.0 compatible +# PHPUnit 3.7.x php 5.3-8.2 compatible -This version of PHPUnit bases on release 3.7.38 and is adjusted for compatibility with PHP 5.3-8.0. +This version of PHPUnit bases on release 3.7.38 and is adjusted for compatibility with PHP 5.3-8.2. The package was created especially for testing https://github.com/zf1s packages. All credits go to original PHPUnit author and contributors. diff --git a/Tests/_files/DoubleTestCase.php b/Tests/_files/DoubleTestCase.php index ba601a4a28f..226c962a0c7 100644 --- a/Tests/_files/DoubleTestCase.php +++ b/Tests/_files/DoubleTestCase.php @@ -8,6 +8,7 @@ public function __construct(PHPUnit_Framework_TestCase $testCase) $this->testCase = $testCase; } + #[\ReturnTypeWillChange] public function count() { return 2; diff --git a/Tests/_files/SampleArrayAccess.php b/Tests/_files/SampleArrayAccess.php index 0d97d7803dc..4514cc5f9e1 100644 --- a/Tests/_files/SampleArrayAccess.php +++ b/Tests/_files/SampleArrayAccess.php @@ -13,6 +13,7 @@ class SampleArrayAccess implements ArrayAccess public function __construct() { $this->container = array(); } + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { $this->container[] = $value; @@ -20,12 +21,15 @@ public function offsetSet($offset, $value) { $this->container[$offset] = $value; } } + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); } + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); } + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; } diff --git a/Tests/_files/TestIterator.php b/Tests/_files/TestIterator.php index 01135e3b39a..a5cdd2c8ade 100644 --- a/Tests/_files/TestIterator.php +++ b/Tests/_files/TestIterator.php @@ -9,26 +9,31 @@ public function __construct($array = array()) $this->array = $array; } + #[\ReturnTypeWillChange] public function rewind() { $this->position = 0; } + #[\ReturnTypeWillChange] public function valid() { return $this->position < count($this->array); } + #[\ReturnTypeWillChange] public function key() { return $this->position; } + #[\ReturnTypeWillChange] public function current() { return $this->array[$this->position]; } + #[\ReturnTypeWillChange] public function next() { $this->position++; diff --git a/Tests/_files/TestIterator2.php b/Tests/_files/TestIterator2.php index bae3655fea6..e6b0e131b06 100644 --- a/Tests/_files/TestIterator2.php +++ b/Tests/_files/TestIterator2.php @@ -8,26 +8,31 @@ public function __construct(array $array) $this->data = $array; } + #[\ReturnTypeWillChange] public function current() { return current($this->data); } + #[\ReturnTypeWillChange] public function next() { next($this->data); } + #[\ReturnTypeWillChange] public function key() { return key($this->data); } + #[\ReturnTypeWillChange] public function valid() { return key($this->data) !== null; } + #[\ReturnTypeWillChange] public function rewind() { reset($this->data); diff --git a/composer.json b/composer.json index 94b400ccd95..a34ff87398e 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,10 @@ { "name": "zf1s/phpunit", "replace": { - "phpunit/phpunit": "^3.7.38" + "phpunit/phpunit": "^3.7.38", + "phpunit/php-text-template": "^1.2.1", + "phpunit/phpunit-mock-objects": "^1.2.3", + "phpunit/php-file-iterator": "^1.4.5" }, "description": "The PHP Unit Testing framework.", "type": "library", @@ -22,13 +25,19 @@ "support": { "issues": "https://github.com/zf1s/phpunit/issues" }, + "repositories": [ + { + "type": "pear", + "url": "https://pear.php.net" + } + ], "require": { "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.1", - "phpunit/php-code-coverage": "~1.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/phpunit-mock-objects": "^1.2.3", + "phpunit/php-file-iterator": "^1.4.5", + "phpunit/php-code-coverage": "^1.2.6", "phpunit/php-timer": "1.0.7", - "phpunit/phpunit-mock-objects": "~1.2", "symfony/yaml": "~2.0", "ext-ctype": "*", "ext-dom": "*", @@ -40,12 +49,6 @@ "require-dev": { "pear-pear.php.net/pear": "~1.9|~1.10" }, - "repositories": [ - { - "type": "pear", - "url": "https://pear.php.net" - } - ], "suggest": { "phpunit/php-invoker": "~1.1" }, @@ -54,7 +57,10 @@ ], "autoload": { "classmap": [ - "PHPUnit/" + "PHPUnit/", + "deps/php-file-iterator/src", + "deps/php-text-template/src", + "deps/phpunit-mock-objects/PHPUnit" ] }, "extra": { diff --git a/deps/php-file-iterator/.gitattributes b/deps/php-file-iterator/.gitattributes new file mode 100644 index 00000000000..461090b7ecc --- /dev/null +++ b/deps/php-file-iterator/.gitattributes @@ -0,0 +1 @@ +*.php diff=php diff --git a/deps/php-file-iterator/.gitignore b/deps/php-file-iterator/.gitignore new file mode 100644 index 00000000000..a7419836bf1 --- /dev/null +++ b/deps/php-file-iterator/.gitignore @@ -0,0 +1,7 @@ +build/api +build/code-browser +build/coverage +build/logs +build/pdepend +cache.properties +phpunit.xml diff --git a/deps/php-file-iterator/ChangeLog.md b/deps/php-file-iterator/ChangeLog.md new file mode 100644 index 00000000000..5c842c6fc10 --- /dev/null +++ b/deps/php-file-iterator/ChangeLog.md @@ -0,0 +1,41 @@ +# Change Log + +All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). + +## [1.4.5] - 2017-11-27 + +### Fixed + +* Fixed [#37](https://github.com/sebastianbergmann/php-file-iterator/issues/37): Regression caused by fix for [#30](https://github.com/sebastianbergmann/php-file-iterator/issues/30) + +## [1.4.4] - 2017-11-27 + +### Fixed + +* Fixed [#30](https://github.com/sebastianbergmann/php-file-iterator/issues/30): Exclude is not considered if it is a parent of the base path + +## [1.4.3] - 2017-11-25 + +### Fixed + +* Fixed [#34](https://github.com/sebastianbergmann/php-file-iterator/issues/34): Factory should use canonical directory names + +## [1.4.2] - 2016-11-26 + +No changes + +## [1.4.1] - 2015-07-26 + +No changes + +## 1.4.0 - 2015-04-02 + +### Added + +* [Added support for wildcards (glob) in exclude](https://github.com/sebastianbergmann/php-file-iterator/pull/23) + +[1.4.5]: https://github.com/sebastianbergmann/php-file-iterator/compare/1.4.4...1.4.5 +[1.4.4]: https://github.com/sebastianbergmann/php-file-iterator/compare/1.4.3...1.4.4 +[1.4.3]: https://github.com/sebastianbergmann/php-file-iterator/compare/1.4.2...1.4.3 +[1.4.2]: https://github.com/sebastianbergmann/php-file-iterator/compare/1.4.1...1.4.2 +[1.4.1]: https://github.com/sebastianbergmann/php-file-iterator/compare/1.4.0...1.4.1 diff --git a/deps/php-file-iterator/LICENSE b/deps/php-file-iterator/LICENSE new file mode 100644 index 00000000000..6cccbbbfc34 --- /dev/null +++ b/deps/php-file-iterator/LICENSE @@ -0,0 +1,33 @@ +File_Iterator + +Copyright (c) 2009-2015, Sebastian Bergmann . +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + * Neither the name of Sebastian Bergmann nor the names of his + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/deps/php-file-iterator/README.md b/deps/php-file-iterator/README.md new file mode 100644 index 00000000000..8f2caf2a4d4 --- /dev/null +++ b/deps/php-file-iterator/README.md @@ -0,0 +1,12 @@ +# File_Iterator + +## Installation + +You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/): + + composer require phpunit/php-file-iterator + +If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency: + + composer require --dev phpunit/php-file-iterator + diff --git a/deps/php-file-iterator/composer.json b/deps/php-file-iterator/composer.json new file mode 100644 index 00000000000..c6527943f10 --- /dev/null +++ b/deps/php-file-iterator/composer.json @@ -0,0 +1,36 @@ +{ + "name": "phpunit/php-file-iterator", + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "type": "library", + "keywords": [ + "iterator", + "filesystem" + ], + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "irc": "irc://irc.freenode.net/phpunit" + }, + "require": { + "php": ">=5.3.3" + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + } +} + diff --git a/deps/php-file-iterator/src/Facade.php b/deps/php-file-iterator/src/Facade.php new file mode 100644 index 00000000000..902a0af936d --- /dev/null +++ b/deps/php-file-iterator/src/Facade.php @@ -0,0 +1,123 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Façade implementation that uses File_Iterator_Factory to create a + * File_Iterator that operates on an AppendIterator that contains an + * RecursiveDirectoryIterator for each given path. The list of unique + * files is returned as an array. + * + * @since Class available since Release 1.3.0 + */ +class File_Iterator_Facade +{ + /** + * @param array|string $paths + * @param array|string $suffixes + * @param array|string $prefixes + * @param array $exclude + * @param bool $commonPath + * @return array + */ + public function getFilesAsArray($paths, $suffixes = '', $prefixes = '', array $exclude = array(), $commonPath = FALSE) + { + if (is_string($paths)) { + $paths = array($paths); + } + + $factory = new File_Iterator_Factory; + $iterator = $factory->getFileIterator( + $paths, $suffixes, $prefixes, $exclude + ); + + $files = array(); + + foreach ($iterator as $file) { + $file = $file->getRealPath(); + + if ($file) { + $files[] = $file; + } + } + + foreach ($paths as $path) { + if (is_file($path)) { + $files[] = realpath($path); + } + } + + $files = array_unique($files); + sort($files); + + if ($commonPath) { + return array( + 'commonPath' => $this->getCommonPath($files), + 'files' => $files + ); + } else { + return $files; + } + } + + /** + * Returns the common path of a set of files. + * + * @param array $files + * @return string + */ + protected function getCommonPath(array $files) + { + $count = count($files); + + if ($count == 0) { + return ''; + } + + if ($count == 1) { + return dirname($files[0]) . DIRECTORY_SEPARATOR; + } + + $_files = array(); + + foreach ($files as $file) { + $_files[] = $_fileParts = explode(DIRECTORY_SEPARATOR, $file); + + if (empty($_fileParts[0])) { + $_fileParts[0] = DIRECTORY_SEPARATOR; + } + } + + $common = ''; + $done = FALSE; + $j = 0; + $count--; + + while (!$done) { + for ($i = 0; $i < $count; $i++) { + if ($_files[$i][$j] != $_files[$i+1][$j]) { + $done = TRUE; + break; + } + } + + if (!$done) { + $common .= $_files[0][$j]; + + if ($j > 0) { + $common .= DIRECTORY_SEPARATOR; + } + } + + $j++; + } + + return DIRECTORY_SEPARATOR . $common; + } +} diff --git a/deps/php-file-iterator/src/Factory.php b/deps/php-file-iterator/src/Factory.php new file mode 100644 index 00000000000..9cc3fb7b16d --- /dev/null +++ b/deps/php-file-iterator/src/Factory.php @@ -0,0 +1,91 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Factory Method implementation that creates a File_Iterator that operates on + * an AppendIterator that contains an RecursiveDirectoryIterator for each given + * path. + * + * @since Class available since Release 1.1.0 + */ +class File_Iterator_Factory +{ + /** + * @param array|string $paths + * @param array|string $suffixes + * @param array|string $prefixes + * @param array $exclude + * @return AppendIterator + */ + public function getFileIterator($paths, $suffixes = '', $prefixes = '', array $exclude = array()) + { + if (is_string($paths)) { + $paths = array($paths); + } + + $paths = $this->getPathsAfterResolvingWildcards($paths); + $exclude = $this->getPathsAfterResolvingWildcards($exclude); + + if (is_string($prefixes)) { + if ($prefixes != '') { + $prefixes = array($prefixes); + } else { + $prefixes = array(); + } + } + + if (is_string($suffixes)) { + if ($suffixes != '') { + $suffixes = array($suffixes); + } else { + $suffixes = array(); + } + } + + $iterator = new AppendIterator; + + foreach ($paths as $path) { + if (is_dir($path)) { + $iterator->append( + new File_Iterator( + new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::FOLLOW_SYMLINKS) + ), + $suffixes, + $prefixes, + $exclude, + $path + ) + ); + } + } + + return $iterator; + } + + /** + * @param array $paths + * @return array + */ + protected function getPathsAfterResolvingWildcards(array $paths) + { + $_paths = array(); + + foreach ($paths as $path) { + if ($locals = glob($path, GLOB_ONLYDIR)) { + $_paths = array_merge($_paths, array_map('realpath', $locals)); + } else { + $_paths[] = realpath($path); + } + } + + return $_paths; + } +} diff --git a/deps/php-file-iterator/src/Iterator.php b/deps/php-file-iterator/src/Iterator.php new file mode 100644 index 00000000000..a09a3e91a29 --- /dev/null +++ b/deps/php-file-iterator/src/Iterator.php @@ -0,0 +1,159 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * FilterIterator implementation that filters files based on prefix(es) and/or + * suffix(es). Hidden files and files from hidden directories are also filtered. + * + * @since Class available since Release 1.0.0 + */ +class File_Iterator extends FilterIterator +{ + const PREFIX = 0; + const SUFFIX = 1; + + /** + * @var array + */ + protected $suffixes = array(); + + /** + * @var array + */ + protected $prefixes = array(); + + /** + * @var array + */ + protected $exclude = array(); + + /** + * @var string + */ + protected $basepath; + + /** + * @param Iterator $iterator + * @param array $suffixes + * @param array $prefixes + * @param array $exclude + * @param string $basepath + */ + public function __construct(Iterator $iterator, array $suffixes = array(), array $prefixes = array(), array $exclude = array(), $basepath = NULL) + { + $exclude = array_filter(array_map('realpath', $exclude)); + + if ($basepath !== NULL) { + $basepath = realpath($basepath); + } + + if ($basepath === FALSE) { + $basepath = NULL; + } else { + foreach ($exclude as &$_exclude) { + $_exclude = str_replace($basepath, '', $_exclude); + } + } + + $this->prefixes = $prefixes; + $this->suffixes = $suffixes; + $this->exclude = $exclude; + $this->basepath = $basepath; + + parent::__construct($iterator); + } + + /** + * @return bool + */ + #[\ReturnTypeWillChange] + public function accept() + { + $current = $this->getInnerIterator()->current(); + $filename = $current->getFilename(); + $realpath = $current->getRealPath(); + + if ($this->basepath !== NULL) { + $realpath = str_replace($this->basepath, '', $realpath); + } + + // Filter files in hidden directories. + if (preg_match('=/\.[^/]*/=', $realpath)) { + return FALSE; + } + + return $this->acceptPath($realpath) && + $this->acceptPrefix($filename) && + $this->acceptSuffix($filename); + } + + /** + * @param string $path + * @return bool + * @since Method available since Release 1.1.0 + */ + protected function acceptPath($path) + { + foreach ($this->exclude as $exclude) { + if (strpos($path, $exclude) === 0) { + return FALSE; + } + } + + return TRUE; + } + + /** + * @param string $filename + * @return bool + * @since Method available since Release 1.1.0 + */ + protected function acceptPrefix($filename) + { + return $this->acceptSubString($filename, $this->prefixes, self::PREFIX); + } + + /** + * @param string $filename + * @return bool + * @since Method available since Release 1.1.0 + */ + protected function acceptSuffix($filename) + { + return $this->acceptSubString($filename, $this->suffixes, self::SUFFIX); + } + + /** + * @param string $filename + * @param array $subStrings + * @param int $type + * @return bool + * @since Method available since Release 1.1.0 + */ + protected function acceptSubString($filename, array $subStrings, $type) + { + if (empty($subStrings)) { + return TRUE; + } + + $matched = FALSE; + + foreach ($subStrings as $string) { + if (($type == self::PREFIX && strpos($filename, $string) === 0) || + ($type == self::SUFFIX && + substr($filename, -1 * strlen($string)) == $string)) { + $matched = TRUE; + break; + } + } + + return $matched; + } +} diff --git a/deps/php-text-template/.gitattributes b/deps/php-text-template/.gitattributes new file mode 100644 index 00000000000..461090b7ecc --- /dev/null +++ b/deps/php-text-template/.gitattributes @@ -0,0 +1 @@ +*.php diff=php diff --git a/deps/php-text-template/.gitignore b/deps/php-text-template/.gitignore new file mode 100644 index 00000000000..c5992124843 --- /dev/null +++ b/deps/php-text-template/.gitignore @@ -0,0 +1,5 @@ +/composer.lock +/composer.phar +/.idea +/vendor + diff --git a/deps/php-text-template/LICENSE b/deps/php-text-template/LICENSE new file mode 100644 index 00000000000..9f9a32d9b46 --- /dev/null +++ b/deps/php-text-template/LICENSE @@ -0,0 +1,33 @@ +Text_Template + +Copyright (c) 2009-2015, Sebastian Bergmann . +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + * Neither the name of Sebastian Bergmann nor the names of his + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/deps/php-text-template/README.md b/deps/php-text-template/README.md new file mode 100644 index 00000000000..ec8f59360f8 --- /dev/null +++ b/deps/php-text-template/README.md @@ -0,0 +1,14 @@ +# Text_Template + +## Installation + +## Installation + +To add this package as a local, per-project dependency to your project, simply add a dependency on `phpunit/php-text-template` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on Text_Template: + + { + "require": { + "phpunit/php-text-template": "~1.2" + } + } + diff --git a/deps/php-text-template/composer.json b/deps/php-text-template/composer.json new file mode 100644 index 00000000000..a5779c8357e --- /dev/null +++ b/deps/php-text-template/composer.json @@ -0,0 +1,29 @@ +{ + "name": "phpunit/php-text-template", + "description": "Simple template engine.", + "type": "library", + "keywords": [ + "template" + ], + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues" + }, + "require": { + "php": ">=5.3.3" + }, + "autoload": { + "classmap": [ + "src/" + ] + } +} + diff --git a/deps/php-text-template/src/Template.php b/deps/php-text-template/src/Template.php new file mode 100644 index 00000000000..9eb39ad5d6a --- /dev/null +++ b/deps/php-text-template/src/Template.php @@ -0,0 +1,135 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * A simple template engine. + * + * @since Class available since Release 1.0.0 + */ +class Text_Template +{ + /** + * @var string + */ + protected $template = ''; + + /** + * @var string + */ + protected $openDelimiter = '{'; + + /** + * @var string + */ + protected $closeDelimiter = '}'; + + /** + * @var array + */ + protected $values = array(); + + /** + * Constructor. + * + * @param string $file + * @throws InvalidArgumentException + */ + public function __construct($file = '', $openDelimiter = '{', $closeDelimiter = '}') + { + $this->setFile($file); + $this->openDelimiter = $openDelimiter; + $this->closeDelimiter = $closeDelimiter; + } + + /** + * Sets the template file. + * + * @param string $file + * @throws InvalidArgumentException + */ + public function setFile($file) + { + $distFile = $file . '.dist'; + + if (file_exists($file)) { + $this->template = file_get_contents($file); + } + + else if (file_exists($distFile)) { + $this->template = file_get_contents($distFile); + } + + else { + throw new InvalidArgumentException( + 'Template file could not be loaded.' + ); + } + } + + /** + * Sets one or more template variables. + * + * @param array $values + * @param bool $merge + */ + public function setVar(array $values, $merge = TRUE) + { + if (!$merge || empty($this->values)) { + $this->values = $values; + } else { + $this->values = array_merge($this->values, $values); + } + } + + /** + * Renders the template and returns the result. + * + * @return string + */ + public function render() + { + $keys = array(); + + foreach ($this->values as $key => $value) { + $keys[] = $this->openDelimiter . $key . $this->closeDelimiter; + } + + return str_replace($keys, $this->values, $this->template); + } + + /** + * Renders the template and writes the result to a file. + * + * @param string $target + */ + public function renderTo($target) + { + $fp = @fopen($target, 'wt'); + + if ($fp) { + fwrite($fp, $this->render()); + fclose($fp); + } else { + $error = error_get_last(); + + throw new RuntimeException( + sprintf( + 'Could not write to %s: %s', + $target, + substr( + $error['message'], + strpos($error['message'], ':') + 2 + ) + ) + ); + } + } +} + diff --git a/deps/phpunit-mock-objects/.gitattributes b/deps/phpunit-mock-objects/.gitattributes new file mode 100644 index 00000000000..461090b7ecc --- /dev/null +++ b/deps/phpunit-mock-objects/.gitattributes @@ -0,0 +1 @@ +*.php diff=php diff --git a/deps/phpunit-mock-objects/.gitignore b/deps/phpunit-mock-objects/.gitignore new file mode 100644 index 00000000000..a7419836bf1 --- /dev/null +++ b/deps/phpunit-mock-objects/.gitignore @@ -0,0 +1,7 @@ +build/api +build/code-browser +build/coverage +build/logs +build/pdepend +cache.properties +phpunit.xml diff --git a/deps/phpunit-mock-objects/.travis.yml b/deps/phpunit-mock-objects/.travis.yml new file mode 100644 index 00000000000..a419159bfd4 --- /dev/null +++ b/deps/phpunit-mock-objects/.travis.yml @@ -0,0 +1,22 @@ +language: php + +php: + - 5.3 + - 5.4 + +before_script: + - mkdir -p vendor + - git clone --branch=3.7 --depth=100 --quiet git://github.com/sebastianbergmann/phpunit.git vendor/phpunit + - git clone --branch=1.2 --depth=100 --quiet git://github.com/sebastianbergmann/php-code-coverage.git vendor/php-code-coverage + - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/php-text-template.git vendor/php-text-template + - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/php-token-stream.git vendor/php-token-stream + - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/php-file-iterator.git vendor/php-file-iterator + - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/php-timer.git vendor/php-timer + - git clone --branch=master --depth=100 --quiet git://github.com/pear/pear-core.git vendor/pear-core + - git clone --branch=trunk --depth=100 --quiet git://github.com/pear/Console_Getopt.git vendor/console-getopt + +script: php -d include_path=vendor/php-text-template:vendor/php-token-stream:vendor/php-file-iterator:vendor/phpunit:vendor/php-code-coverage:vendor/php-timer:vendor/php-invoker:vendor/pear-core:vendor/console-getopt:vendor:. ./vendor/phpunit/phpunit.php --configuration ./build/travis-ci.xml + +notifications: + email: false + irc: "irc.freenode.org#phpunit" diff --git a/deps/phpunit-mock-objects/CONTRIBUTING.md b/deps/phpunit-mock-objects/CONTRIBUTING.md new file mode 100644 index 00000000000..b2905398264 --- /dev/null +++ b/deps/phpunit-mock-objects/CONTRIBUTING.md @@ -0,0 +1,5 @@ +Pull Requests for bug fixes should be made against the current release branch (1.2). + +Pull Requests for new features should be made against master. + +For further notes please refer to [https://github.com/sebastianbergmann/phpunit/blob/master/CONTRIBUTING.md](https://github.com/sebastianbergmann/phpunit/blob/master/CONTRIBUTING.md) diff --git a/deps/phpunit-mock-objects/ChangeLog.markdown b/deps/phpunit-mock-objects/ChangeLog.markdown new file mode 100644 index 00000000000..fc576e599e6 --- /dev/null +++ b/deps/phpunit-mock-objects/ChangeLog.markdown @@ -0,0 +1,27 @@ +PHPUnit_MockObject 1.2 +====================== + +This is the list of changes for the PHPUnit_MockObject 1.2 release series. + +PHPUnit_MockObject 1.2.3 +------------------------ + +* Fixed a bug where getting two mocks with different argument cloning options returned the same mock. + +PHPUnit_MockObject 1.2.2 +------------------------ + +* Fixed #100: Removed the unique mock object ID introduced in version 1.2. + +PHPUnit_MockObject 1.2.1 +------------------------ + +* No changes. + +PHPUnit_MockObject 1.2.0 +------------------------ + +* Implemented #47: Make cloning of arguments passed to mocked methods optional. +* Implemented #84: `getMockFromWsdl()` now works with namespaces. +* Fixed #90: Mocks with a fixed class name could only be created once. + diff --git a/deps/phpunit-mock-objects/LICENSE b/deps/phpunit-mock-objects/LICENSE new file mode 100644 index 00000000000..830850c38e7 --- /dev/null +++ b/deps/phpunit-mock-objects/LICENSE @@ -0,0 +1,33 @@ +PHPUnit_MockObject + +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. diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Autoload.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Autoload.php new file mode 100644 index 00000000000..296a1aca7a5 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Autoload.php @@ -0,0 +1,100 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2002-2011 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.1.0 + */ + +spl_autoload_register( + function ($class) + { + static $classes = NULL; + static $path = NULL; + + if ($classes === NULL) { + $classes = array( + 'phpunit_framework_mockobject_builder_identity' => '/Framework/MockObject/Builder/Identity.php', + 'phpunit_framework_mockobject_builder_invocationmocker' => '/Framework/MockObject/Builder/InvocationMocker.php', + 'phpunit_framework_mockobject_builder_match' => '/Framework/MockObject/Builder/Match.php', + 'phpunit_framework_mockobject_builder_methodnamematch' => '/Framework/MockObject/Builder/MethodNameMatch.php', + 'phpunit_framework_mockobject_builder_namespace' => '/Framework/MockObject/Builder/Namespace.php', + 'phpunit_framework_mockobject_builder_parametersmatch' => '/Framework/MockObject/Builder/ParametersMatch.php', + 'phpunit_framework_mockobject_builder_stub' => '/Framework/MockObject/Builder/Stub.php', + 'phpunit_framework_mockobject_generator' => '/Framework/MockObject/Generator.php', + 'phpunit_framework_mockobject_invocation' => '/Framework/MockObject/Invocation.php', + 'phpunit_framework_mockobject_invocation_object' => '/Framework/MockObject/Invocation/Object.php', + 'phpunit_framework_mockobject_invocation_static' => '/Framework/MockObject/Invocation/Static.php', + 'phpunit_framework_mockobject_invocationmocker' => '/Framework/MockObject/InvocationMocker.php', + 'phpunit_framework_mockobject_invokable' => '/Framework/MockObject/Invokable.php', + 'phpunit_framework_mockobject_matcher' => '/Framework/MockObject/Matcher.php', + 'phpunit_framework_mockobject_matcher_anyinvokedcount' => '/Framework/MockObject/Matcher/AnyInvokedCount.php', + 'phpunit_framework_mockobject_matcher_anyparameters' => '/Framework/MockObject/Matcher/AnyParameters.php', + 'phpunit_framework_mockobject_matcher_invocation' => '/Framework/MockObject/Matcher/Invocation.php', + 'phpunit_framework_mockobject_matcher_invokedatindex' => '/Framework/MockObject/Matcher/InvokedAtIndex.php', + 'phpunit_framework_mockobject_matcher_invokedatleastonce' => '/Framework/MockObject/Matcher/InvokedAtLeastOnce.php', + 'phpunit_framework_mockobject_matcher_invokedcount' => '/Framework/MockObject/Matcher/InvokedCount.php', + 'phpunit_framework_mockobject_matcher_invokedrecorder' => '/Framework/MockObject/Matcher/InvokedRecorder.php', + 'phpunit_framework_mockobject_matcher_methodname' => '/Framework/MockObject/Matcher/MethodName.php', + 'phpunit_framework_mockobject_matcher_parameters' => '/Framework/MockObject/Matcher/Parameters.php', + 'phpunit_framework_mockobject_matcher_statelessinvocation' => '/Framework/MockObject/Matcher/StatelessInvocation.php', + 'phpunit_framework_mockobject_mockbuilder' => '/Framework/MockObject/MockBuilder.php', + 'phpunit_framework_mockobject_mockobject' => '/Framework/MockObject/MockObject.php', + 'phpunit_framework_mockobject_stub' => '/Framework/MockObject/Stub.php', + 'phpunit_framework_mockobject_stub_consecutivecalls' => '/Framework/MockObject/Stub/ConsecutiveCalls.php', + 'phpunit_framework_mockobject_stub_exception' => '/Framework/MockObject/Stub/Exception.php', + 'phpunit_framework_mockobject_stub_matchercollection' => '/Framework/MockObject/Stub/MatcherCollection.php', + 'phpunit_framework_mockobject_stub_return' => '/Framework/MockObject/Stub/Return.php', + 'phpunit_framework_mockobject_stub_returnargument' => '/Framework/MockObject/Stub/ReturnArgument.php', + 'phpunit_framework_mockobject_stub_returncallback' => '/Framework/MockObject/Stub/ReturnCallback.php', + 'phpunit_framework_mockobject_stub_returnself' => '/Framework/MockObject/Stub/ReturnSelf.php', + 'phpunit_framework_mockobject_stub_returnvaluemap' => '/Framework/MockObject/Stub/ReturnValueMap.php', + 'phpunit_framework_mockobject_verifiable' => '/Framework/MockObject/Verifiable.php' + ); + + $path = dirname(dirname(dirname(__FILE__))); + } + + $cn = strtolower($class); + + if (isset($classes[$cn])) { + require $path . $classes[$cn]; + } + } +); diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Autoload.php.in b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Autoload.php.in new file mode 100644 index 00000000000..fe019c061df --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Autoload.php.in @@ -0,0 +1,65 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2002-2011 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.1.0 + */ + +spl_autoload_register( + function ($class) + { + static $classes = NULL; + static $path = NULL; + + if ($classes === NULL) { + $classes = array( + ___CLASSLIST___ + ); + + $path = dirname(dirname(dirname(__FILE__))); + } + + $cn = strtolower($class); + + if (isset($classes[$cn])) { + require $path . $classes[$cn]; + } + } +); diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/Identity.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/Identity.php new file mode 100644 index 00000000000..0c66818fd80 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/Identity.php @@ -0,0 +1,70 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Builder interface for unique identifiers. + * + * Defines the interface for recording unique identifiers. The identifiers + * can be used to define the invocation order of expectations. The expectation + * is recorded using id() and then defined in order using + * PHPUnit_Framework_MockObject_Builder_Match::after(). + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Interface available since Release 1.0.0 + */ +interface PHPUnit_Framework_MockObject_Builder_Identity +{ + /** + * Sets the identification of the expectation to $id. + * + * @note The identifier is unique per mock object. + * @param string $id Unique identifiation of expectation. + */ + public function id($id); +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/InvocationMocker.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/InvocationMocker.php new file mode 100644 index 00000000000..ba4e5b318fb --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/InvocationMocker.php @@ -0,0 +1,193 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Builder for mocked or stubbed invocations. + * + * Provides methods for building expectations without having to resort to + * instantiating the various matchers manually. These methods also form a + * more natural way of reading the expectation. This class should be together + * with the test case PHPUnit_Framework_MockObject_TestCase. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Builder_InvocationMocker implements PHPUnit_Framework_MockObject_Builder_MethodNameMatch +{ + /** + * @var PHPUnit_Framework_MockObject_Stub_MatcherCollection + */ + protected $collection; + + /** + * @var PHPUnit_Framework_MockObject_Matcher + */ + protected $matcher; + + /** + * @param PHPUnit_Framework_MockObject_Stub_MatcherCollection $collection + * @param PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher + */ + public function __construct(PHPUnit_Framework_MockObject_Stub_MatcherCollection $collection, PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher) + { + $this->collection = $collection; + $this->matcher = new PHPUnit_Framework_MockObject_Matcher( + $invocationMatcher + ); + + $this->collection->addMatcher($this->matcher); + } + + /** + * @return PHPUnit_Framework_MockObject_Matcher + */ + public function getMatcher() + { + return $this->matcher; + } + + /** + * @param mixed $id + * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker + */ + public function id($id) + { + $this->collection->registerId($id, $this); + + return $this; + } + + /** + * @param PHPUnit_Framework_MockObject_Stub $stub + * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker + */ + public function will(PHPUnit_Framework_MockObject_Stub $stub) + { + $this->matcher->stub = $stub; + + return $this; + } + + /** + * @param mixed $id + * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker + */ + public function after($id) + { + $this->matcher->afterMatchBuilderId = $id; + + return $this; + } + + /** + * @param mixed $argument, ... + * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker + */ + public function with() + { + $args = func_get_args(); + + if ($this->matcher->methodNameMatcher === NULL) { + throw new PHPUnit_Framework_Exception( + 'Method name matcher is not defined, cannot define parameter ' . + ' matcher without one' + ); + } + + if ($this->matcher->parametersMatcher !== NULL) { + throw new PHPUnit_Framework_Exception( + 'Parameter matcher is already defined, cannot redefine' + ); + } + + $this->matcher->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_Parameters($args); + + return $this; + } + + /** + * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker + */ + public function withAnyParameters() + { + if ($this->matcher->methodNameMatcher === NULL) { + throw new PHPUnit_Framework_Exception( + 'Method name matcher is not defined, cannot define parameter ' . + 'matcher without one' + ); + } + + if ($this->matcher->parametersMatcher !== NULL) { + throw new PHPUnit_Framework_Exception( + 'Parameter matcher is already defined, cannot redefine' + ); + } + + $this->matcher->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_AnyParameters; + + return $this; + } + + /** + * @param PHPUnit_Framework_Constraint|string $constraint + * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker + */ + public function method($constraint) + { + if ($this->matcher->methodNameMatcher !== NULL) { + throw new PHPUnit_Framework_Exception( + 'Method name matcher is already defined, cannot redefine' + ); + } + + $this->matcher->methodNameMatcher = new PHPUnit_Framework_MockObject_Matcher_MethodName($constraint); + + return $this; + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/Match.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/Match.php new file mode 100644 index 00000000000..ce2ee18f50c --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/Match.php @@ -0,0 +1,66 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Builder interface for invocation order matches. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Interface available since Release 1.0.0 + */ +interface PHPUnit_Framework_MockObject_Builder_Match extends PHPUnit_Framework_MockObject_Builder_Stub +{ + /** + * Defines the expectation which must occur before the current is valid. + * + * @param string $id The identification of the expectation that should + * occur before this one. + * @return PHPUnit_Framework_MockObject_Builder_Stub + */ + public function after($id); +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/MethodNameMatch.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/MethodNameMatch.php new file mode 100644 index 00000000000..9569d38ec1c --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/MethodNameMatch.php @@ -0,0 +1,68 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Builder interface for matcher of method names. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Interface available since Release 1.0.0 + */ +interface PHPUnit_Framework_MockObject_Builder_MethodNameMatch extends PHPUnit_Framework_MockObject_Builder_ParametersMatch +{ + /** + * Adds a new method name match and returns the parameter match object for + * further matching possibilities. + * + * @param PHPUnit_Framework_Constraint $name + * Constraint for matching method, if a string is passed it will use + * the PHPUnit_Framework_Constraint_IsEqual. + * @return PHPUnit_Framework_MockObject_Builder_ParametersMatch + */ + public function method($name); +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/Namespace.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/Namespace.php new file mode 100644 index 00000000000..dfa0bd77629 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/Namespace.php @@ -0,0 +1,79 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Interface for builders which can register builders with a given identification. + * + * This interface relates to PHPUnit_Framework_MockObject_Builder_Identity. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Interface available since Release 1.0.0 + */ +interface PHPUnit_Framework_MockObject_Builder_Namespace +{ + /** + * Looks up the match builder with identification $id and returns it. + * + * @param string $id The identifiction of the match builder. + * @return PHPUnit_Framework_MockObject_Builder_Match + */ + public function lookupId($id); + + /** + * Registers the match builder $builder with the identification $id. The + * builder can later be looked up using lookupId() to figure out if it + * has been invoked. + * + * @param string $id + * The identification of the match builder. + * @param PHPUnit_Framework_MockObject_Builder_Match $builder + * The builder which is being registered. + */ + public function registerId($id, PHPUnit_Framework_MockObject_Builder_Match $builder); +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/ParametersMatch.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/ParametersMatch.php new file mode 100644 index 00000000000..61c53bf5cdf --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/ParametersMatch.php @@ -0,0 +1,89 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Builder interface for parameter matchers. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Interface available since Release 1.0.0 + */ +interface PHPUnit_Framework_MockObject_Builder_ParametersMatch extends PHPUnit_Framework_MockObject_Builder_Match +{ + /** + * Sets the parameters to match for, each parameter to this funtion will + * be part of match. To perform specific matches or constraints create a + * new PHPUnit_Framework_Constraint and use it for the parameter. + * If the parameter value is not a constraint it will use the + * PHPUnit_Framework_Constraint_IsEqual for the value. + * + * Some examples: + * + * // match first parameter with value 2 + * $b->with(2); + * // match first parameter with value 'smock' and second identical to 42 + * $b->with('smock', new PHPUnit_Framework_Constraint_IsEqual(42)); + * + * + * @return PHPUnit_Framework_MockObject_Builder_ParametersMatch + */ + public function with(); + + /** + * Sets a matcher which allows any kind of parameters. + * + * Some examples: + * + * // match any number of parameters + * $b->withAnyParamers(); + * + * + * @return PHPUnit_Framework_MockObject_Matcher_AnyParameters + */ + public function withAnyParameters(); +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/Stub.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/Stub.php new file mode 100644 index 00000000000..86a091e3d69 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Builder/Stub.php @@ -0,0 +1,66 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Builder interface for stubs which are actions replacing an invocation. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Interface available since Release 1.0.0 + */ +interface PHPUnit_Framework_MockObject_Builder_Stub extends PHPUnit_Framework_MockObject_Builder_Identity +{ + /** + * Stubs the matching method with the stub object $stub. Any invocations of + * the matched method will now be handled by the stub instead. + * + * @param PHPUnit_Framework_MockObject_Stub $stub The stub object. + * @return PHPUnit_Framework_MockObject_Builder_Identity + */ + public function will(PHPUnit_Framework_MockObject_Stub $stub); +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator.php new file mode 100644 index 00000000000..b5af44db160 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator.php @@ -0,0 +1,808 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Mock Object Code Generator + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Generator +{ + /** + * @var array + */ + protected static $cache = array(); + + /** + * @var array + */ + protected static $blacklistedMethodNames = array( + '__clone' => TRUE, + 'abstract' => TRUE, + 'and' => TRUE, + 'array' => TRUE, + 'as' => TRUE, + 'break' => TRUE, + 'case' => TRUE, + 'catch' => TRUE, + 'class' => TRUE, + 'clone' => TRUE, + 'const' => TRUE, + 'continue' => TRUE, + 'declare' => TRUE, + 'default' => TRUE, + 'die' => TRUE, + 'do' => TRUE, + 'echo' => TRUE, + 'else' => TRUE, + 'elseif' => TRUE, + 'empty' => TRUE, + 'enddeclare' => TRUE, + 'endfor' => TRUE, + 'endforeach' => TRUE, + 'endif' => TRUE, + 'endswitch' => TRUE, + 'endwhile' => TRUE, + 'eval' => TRUE, + 'exit' => TRUE, + 'expects' => TRUE, + 'extends' => TRUE, + 'final' => TRUE, + 'for' => TRUE, + 'foreach' => TRUE, + 'function' => TRUE, + 'global' => TRUE, + 'goto' => TRUE, + 'if' => TRUE, + 'implements' => TRUE, + 'include' => TRUE, + 'include_once' => TRUE, + 'instanceof' => TRUE, + 'interface' => TRUE, + 'isset' => TRUE, + 'list' => TRUE, + 'namespace' => TRUE, + 'new' => TRUE, + 'or' => TRUE, + 'print' => TRUE, + 'private' => TRUE, + 'protected' => TRUE, + 'public' => TRUE, + 'require' => TRUE, + 'require_once' => TRUE, + 'return' => TRUE, + 'static' => TRUE, + 'staticExpects' => TRUE, + 'switch' => TRUE, + 'throw' => TRUE, + 'try' => TRUE, + 'unset' => TRUE, + 'use' => TRUE, + 'var' => TRUE, + 'while' => TRUE, + 'xor' => TRUE + ); + + /** + * @var boolean + */ + protected static $soapLoaded = NULL; + + /** + * 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 object + * @throws InvalidArgumentException + * @since Method available since Release 1.0.0 + */ + public static function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $cloneArguments = TRUE) + { + if (!is_string($originalClassName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($mockClassName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(4, 'string'); + } + + if (!is_array($methods) && !is_null($methods)) { + throw new InvalidArgumentException; + } + + if (NULL !== $methods) { + foreach ($methods as $method) { + if (!preg_match('~[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*~', $method)) { + throw new PHPUnit_Framework_Exception( + sprintf( + 'Cannot stub or mock method with invalid name "%s"', + $method + ) + ); + } + } + if ($methods != array_unique($methods)) { + throw new PHPUnit_Framework_Exception( + sprintf( + 'Cannot stub or mock using a method list that contains duplicates: "%s"', + implode(', ', $methods) + ) + ); + } + } + + if ($mockClassName != '' && class_exists($mockClassName, FALSE)) { + $reflect = new ReflectionClass($mockClassName); + if (!$reflect->implementsInterface("PHPUnit_Framework_MockObject_MockObject")) { + throw new PHPUnit_Framework_Exception( + sprintf( + 'Class "%s" already exists.', + $mockClassName + ) + ); + } + } + + $mock = self::generate( + $originalClassName, + $methods, + $mockClassName, + $callOriginalClone, + $callAutoload, + $cloneArguments + ); + + return self::getObject( + $mock['code'], + $mock['mockClassName'], + $originalClassName, + $callOriginalConstructor, + $callAutoload, + $arguments + ); + } + + /** + * @param string $code + * @param string $className + * @param string $originalClassName + * @param string $callOriginalConstructor + * @param string $callAutoload + * @param array $arguments + * @return object + */ + protected static function getObject($code, $className, $originalClassName = '', $callOriginalConstructor = FALSE, $callAutoload = FALSE, array $arguments = array()) + { + if (!class_exists($className, FALSE)) { + eval($code); + } + + if ($callOriginalConstructor && + !interface_exists($originalClassName, $callAutoload)) { + if (count($arguments) == 0) { + $object = new $className; + } else { + $class = new ReflectionClass($className); + $object = $class->newInstanceArgs($arguments); + } + } else { + // Use a trick to create a new object of a class + // without invoking its constructor. + $object = unserialize( + sprintf('O:%d:"%s":0:{}', strlen($className), $className) + ); + } + + return $object; + } + + /** + * 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 object + * @since Method available since Release 1.0.0 + * @throws InvalidArgumentException + */ + public static function getMockForAbstractClass($originalClassName, array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $mockedMethods = array(), $cloneArguments = TRUE) + { + if (!is_string($originalClassName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($mockClassName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(3, 'string'); + } + + if (class_exists($originalClassName, $callAutoload) || + interface_exists($originalClassName, $callAutoload)) { + $methods = array(); + $reflector = new ReflectionClass($originalClassName); + + foreach ($reflector->getMethods() as $method) { + if ($method->isAbstract() || in_array($method->getName(), $mockedMethods)) { + $methods[] = $method->getName(); + } + } + + if (empty($methods)) { + $methods = NULL; + } + + return self::getMock( + $originalClassName, + $methods, + $arguments, + $mockClassName, + $callOriginalConstructor, + $callOriginalClone, + $callAutoload, + $cloneArguments + ); + } else { + throw new PHPUnit_Framework_Exception( + sprintf( + 'Class "%s" does not exist.', + $originalClassName + ) + ); + } + } + + /** + * Returns an object for the specified trait. + * + * @param string $traitName + * @param array $arguments + * @param string $traitClassName + * @param boolean $callOriginalConstructor + * @param boolean $callOriginalClone + * @param boolean $callAutoload + * @return object + * @since Method available since Release 1.1.0 + * @throws InvalidArgumentException + */ + public static function getObjectForTrait($traitName, array $arguments = array(), $traitClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE) + { + if (!is_string($traitName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + if (!is_string($traitClassName)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(3, 'string'); + } + + if (!trait_exists($traitName, $callAutoload)) { + throw new PHPUnit_Framework_Exception( + sprintf( + 'Trait "%s" does not exist.', + $traitName + ) + ); + } + + $className = self::generateClassName( + $traitName, $traitClassName, 'Trait_' + ); + + $templateDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Generator' . + DIRECTORY_SEPARATOR; + $classTemplate = new Text_Template( + $templateDir . 'trait_class.tpl' + ); + + $classTemplate->setVar( + array( + 'class_name' => $className['className'], + 'trait_name' => $traitName + ) + ); + + return self::getObject( + $classTemplate->render(), + $className['className'] + ); + } + + /** + * @param string $originalClassName + * @param array $methods + * @param string $mockClassName + * @param boolean $callOriginalClone + * @param boolean $callAutoload + * @param boolean $cloneArguments + * @return array + */ + public static function generate($originalClassName, array $methods = NULL, $mockClassName = '', $callOriginalClone = TRUE, $callAutoload = TRUE, $cloneArguments = TRUE) + { + if ($mockClassName == '') { + $key = md5( + $originalClassName . + serialize($methods) . + serialize($callOriginalClone) . + serialize($cloneArguments) + ); + + if (isset(self::$cache[$key])) { + return self::$cache[$key]; + } + } + + $mock = self::generateMock( + $originalClassName, + $methods, + $mockClassName, + $callOriginalClone, + $callAutoload, + $cloneArguments + ); + + if (isset($key)) { + self::$cache[$key] = $mock; + } + + return $mock; + } + + /** + * @param string $wsdlFile + * @param string $originalClassName + * @param array $methods + * @param array $options + * @return array + */ + public static function generateClassFromWsdl($wsdlFile, $originalClassName, array $methods = array(), array $options = array()) + { + if (self::$soapLoaded === NULL) { + self::$soapLoaded = extension_loaded('soap'); + } + + if (self::$soapLoaded) { + $client = new SOAPClient($wsdlFile, $options); + $_methods = array_unique($client->__getFunctions()); + unset($client); + + $templateDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . + 'Generator' . DIRECTORY_SEPARATOR; + $methodTemplate = new Text_Template( + $templateDir . 'wsdl_method.tpl' + ); + $methodsBuffer = ''; + + foreach ($_methods as $method) { + $nameStart = strpos($method, ' ') + 1; + $nameEnd = strpos($method, '('); + $name = substr($method, $nameStart, $nameEnd - $nameStart); + + if (empty($methods) || in_array($name, $methods)) { + $args = explode( + ',', + substr( + $method, + $nameEnd + 1, + strpos($method, ')') - $nameEnd - 1 + ) + ); + $numArgs = count($args); + + for ($i = 0; $i < $numArgs; $i++) { + $args[$i] = substr($args[$i], strpos($args[$i], '$')); + } + + $methodTemplate->setVar( + array( + 'method_name' => $name, + 'arguments' => join(', ', $args) + ) + ); + + $methodsBuffer .= $methodTemplate->render(); + } + } + + $optionsBuffer = 'array('; + foreach ($options as $key => $value) { + $optionsBuffer .= $key . ' => ' . $value; + } + + $optionsBuffer .= ')'; + + $classTemplate = new Text_Template( + $templateDir . 'wsdl_class.tpl' + ); + + $namespace = ''; + if(strpos($originalClassName, '\\') !== FALSE) { + $parts = explode('\\', $originalClassName); + $originalClassName = array_pop($parts); + $namespace = 'namespace ' . join('\\', $parts) . ';'; + } + + $classTemplate->setVar( + array( + 'namespace' => $namespace, + 'class_name' => $originalClassName, + 'wsdl' => $wsdlFile, + 'options' => $optionsBuffer, + 'methods' => $methodsBuffer + ) + ); + + return $classTemplate->render(); + } else { + throw new PHPUnit_Framework_Exception( + 'The SOAP extension is required to generate a mock object ' . + 'from WSDL.' + ); + } + } + + /** + * @param string $originalClassName + * @param array|null $methods + * @param string $mockClassName + * @param boolean $callOriginalClone + * @param boolean $callAutoload + * @param boolean $cloneArguments + * @return array + */ + protected static function generateMock($originalClassName, $methods, $mockClassName, $callOriginalClone, $callAutoload, $cloneArguments = TRUE) + { + $templateDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Generator' . + DIRECTORY_SEPARATOR; + $classTemplate = new Text_Template( + $templateDir . 'mocked_class.tpl' + ); + $cloneTemplate = ''; + $isClass = FALSE; + $isInterface = FALSE; + + $mockClassName = self::generateClassName( + $originalClassName, $mockClassName, 'Mock_' + ); + + if (class_exists($mockClassName['fullClassName'], $callAutoload)) { + $isClass = TRUE; + } else { + if (interface_exists($mockClassName['fullClassName'], $callAutoload)) { + $isInterface = TRUE; + } + } + + if (!class_exists($mockClassName['fullClassName'], $callAutoload) && + !interface_exists($mockClassName['fullClassName'], $callAutoload)) { + $prologue = 'class ' . $mockClassName['originalClassName'] . "\n{\n}\n\n"; + + if (!empty($mockClassName['namespaceName'])) { + $prologue = 'namespace ' . $mockClassName['namespaceName'] . + " {\n\n" . $prologue . "}\n\n" . + "namespace {\n\n"; + + $epilogue = "\n\n}"; + } + + $cloneTemplate = new Text_Template( + $templateDir . 'mocked_clone.tpl' + ); + } else { + $class = new ReflectionClass($mockClassName['fullClassName']); + + if ($class->isFinal()) { + throw new PHPUnit_Framework_Exception( + sprintf( + 'Class "%s" is declared "final" and cannot be mocked.', + $mockClassName['fullClassName'] + ) + ); + } + + if ($class->hasMethod('__clone')) { + $cloneMethod = $class->getMethod('__clone'); + + if (!$cloneMethod->isFinal()) { + if ($callOriginalClone && !$isInterface) { + $cloneTemplate = new Text_Template( + $templateDir . 'unmocked_clone.tpl' + ); + } else { + $cloneTemplate = new Text_Template( + $templateDir . 'mocked_clone.tpl' + ); + } + } + } else { + $cloneTemplate = new Text_Template( + $templateDir . 'mocked_clone.tpl' + ); + } + } + + if (is_object($cloneTemplate)) { + $cloneTemplate = $cloneTemplate->render(); + } + + if (is_array($methods) && empty($methods) && + ($isClass || $isInterface)) { + $methods = get_class_methods($mockClassName['fullClassName']); + } + + if (!is_array($methods)) { + $methods = array(); + } + + $mockedMethods = ''; + + if (isset($class)) { + foreach ($methods as $methodName) { + try { + $method = $class->getMethod($methodName); + + if (self::canMockMethod($method)) { + $mockedMethods .= self::generateMockedMethodDefinitionFromExisting( + $templateDir, $method, $cloneArguments + ); + } + } + + catch (ReflectionException $e) { + $mockedMethods .= self::generateMockedMethodDefinition( + $templateDir, $mockClassName['fullClassName'], $methodName, $cloneArguments + ); + } + } + } else { + foreach ($methods as $methodName) { + $mockedMethods .= self::generateMockedMethodDefinition( + $templateDir, $mockClassName['fullClassName'], $methodName, $cloneArguments + ); + } + } + + $classTemplate->setVar( + array( + 'prologue' => isset($prologue) ? $prologue : '', + 'epilogue' => isset($epilogue) ? $epilogue : '', + 'class_declaration' => self::generateMockClassDeclaration( + $mockClassName, $isInterface + ), + 'clone' => $cloneTemplate, + 'mock_class_name' => $mockClassName['className'], + 'mocked_methods' => $mockedMethods + ) + ); + + return array( + 'code' => $classTemplate->render(), + 'mockClassName' => $mockClassName['className'] + ); + } + + /** + * @param string $originalClassName + * @param string $className + * @param string $prefix + * @return array + */ + protected static function generateClassName($originalClassName, $className, $prefix) + { + if ($originalClassName[0] == '\\') { + $originalClassName = substr($originalClassName, 1); + } + + $classNameParts = explode('\\', $originalClassName); + + if (count($classNameParts) > 1) { + $originalClassName = array_pop($classNameParts); + $namespaceName = join('\\', $classNameParts); + $fullClassName = $namespaceName . '\\' . $originalClassName; + } else { + $namespaceName = ''; + $fullClassName = $originalClassName; + } + + if ($className == '') { + do { + $className = $prefix . $originalClassName . '_' . + substr(md5(microtime()), 0, 8); + } + while (class_exists($className, FALSE)); + } + + return array( + 'className' => $className, + 'originalClassName' => $originalClassName, + 'fullClassName' => $fullClassName, + 'namespaceName' => $namespaceName + ); + } + + /** + * @param array $mockClassName + * @param boolean $isInterface + * @return array + */ + protected static function generateMockClassDeclaration(array $mockClassName, $isInterface) + { + $buffer = 'class '; + + if ($isInterface) { + $buffer .= sprintf( + "%s implements PHPUnit_Framework_MockObject_MockObject, %s%s", + $mockClassName['className'], + !empty($mockClassName['namespaceName']) ? $mockClassName['namespaceName'] . '\\' : '', + $mockClassName['originalClassName'] + ); + } else { + $buffer .= sprintf( + "%s extends %s%s implements PHPUnit_Framework_MockObject_MockObject", + $mockClassName['className'], + !empty($mockClassName['namespaceName']) ? $mockClassName['namespaceName'] . '\\' : '', + $mockClassName['originalClassName'] + ); + } + + return $buffer; + } + + /** + * @param string $templateDir + * @param ReflectionMethod $method + * @param boolean $cloneArguments + * @return string + */ + protected static function generateMockedMethodDefinitionFromExisting($templateDir, ReflectionMethod $method, $cloneArguments = TRUE) + { + if ($method->isPrivate()) { + $modifier = 'private'; + } + + else if ($method->isProtected()) { + $modifier = 'protected'; + } + + else { + $modifier = 'public'; + } + + if ($method->isStatic()) { + $static = TRUE; + } else { + $static = FALSE; + } + + if ($method->returnsReference()) { + $reference = '&'; + } else { + $reference = ''; + } + + return self::generateMockedMethodDefinition( + $templateDir, + $method->getDeclaringClass()->getName(), + $method->getName(), + $cloneArguments, + $modifier, + PHPUnit_Util_Class::getMethodParameters($method), + PHPUnit_Util_Class::getMethodParameters($method, TRUE), + $reference, + $static + ); + } + + /** + * @param string $templateDir + * @param string $className + * @param string $methodName + * @param boolean $cloneArguments + * @param string $modifier + * @param string $arguments_decl + * @param string $arguments_call + * @param string $reference + * @param boolean $static + * @return string + */ + protected static function generateMockedMethodDefinition($templateDir, $className, $methodName, $cloneArguments = TRUE, $modifier = 'public', $arguments_decl = '', $arguments_call = '', $reference = '', $static = FALSE) + { + if ($static) { + $template = new Text_Template( + $templateDir . 'mocked_static_method.tpl' + ); + } else { + $template = new Text_Template( + $templateDir . 'mocked_object_method.tpl' + ); + } + + $template->setVar( + array( + 'arguments_decl' => $arguments_decl, + 'arguments_call' => $arguments_call, + 'arguments_count' => !empty($arguments_call) ? count(explode(',', $arguments_call)) : 0, + 'class_name' => $className, + 'method_name' => $methodName, + 'modifier' => $modifier, + 'reference' => $reference, + 'clone_arguments' => $cloneArguments ? 'TRUE' : 'FALSE' + ) + ); + + return $template->render(); + } + + /** + * @param ReflectionMethod $method + * @return boolean + */ + protected static function canMockMethod(ReflectionMethod $method) + { + if ($method->isConstructor() || $method->isFinal() || + isset(self::$blacklistedMethodNames[$method->getName()])) { + return FALSE; + } + + return TRUE; + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/mocked_class.tpl.dist b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/mocked_class.tpl.dist new file mode 100644 index 00000000000..0b41d1ac530 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/mocked_class.tpl.dist @@ -0,0 +1,52 @@ +{prologue}{class_declaration} +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + +{clone}{mocked_methods} + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +}{epilogue} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/mocked_clone.tpl.dist b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/mocked_clone.tpl.dist new file mode 100644 index 00000000000..bd846dee76e --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/mocked_clone.tpl.dist @@ -0,0 +1,4 @@ + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/mocked_object_method.tpl.dist b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/mocked_object_method.tpl.dist new file mode 100644 index 00000000000..6a6fe99384f --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/mocked_object_method.tpl.dist @@ -0,0 +1,23 @@ + + #[\ReturnTypeWillChange] + {modifier} function {reference}{method_name}({arguments_decl}) + { + $arguments = array({arguments_call}); + $count = func_num_args(); + + if ($count > {arguments_count}) { + $_arguments = func_get_args(); + + for ($i = {arguments_count}; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = $this->__phpunit_getInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Object( + '{class_name}', '{method_name}', $arguments, $this, {clone_arguments} + ) + ); + + return $result; + } diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/mocked_static_method.tpl.dist b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/mocked_static_method.tpl.dist new file mode 100644 index 00000000000..3a8bc183d35 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/mocked_static_method.tpl.dist @@ -0,0 +1,23 @@ + + #[\ReturnTypeWillChange] + {modifier} static function {reference}{method_name}({arguments_decl}) + { + $arguments = array({arguments_call}); + $count = func_num_args(); + + if ($count > {arguments_count}) { + $_arguments = func_get_args(); + + for ($i = {arguments_count}; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = self::__phpunit_getStaticInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Static( + '{class_name}', '{method_name}', $arguments, {clone_arguments} + ) + ); + + return $result; + } diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/trait_class.tpl.dist b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/trait_class.tpl.dist new file mode 100644 index 00000000000..48b4bbf2686 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/trait_class.tpl.dist @@ -0,0 +1,4 @@ +class {class_name} +{ + use {trait_name}; +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/unmocked_clone.tpl.dist b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/unmocked_clone.tpl.dist new file mode 100644 index 00000000000..fa0e70abc2f --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/unmocked_clone.tpl.dist @@ -0,0 +1,5 @@ + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + parent::__clone(); + } diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/wsdl_class.tpl.dist b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/wsdl_class.tpl.dist new file mode 100644 index 00000000000..05ad1d78695 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/wsdl_class.tpl.dist @@ -0,0 +1,9 @@ +{namespace} + +class {class_name} extends \SOAPClient +{ + public function __construct($wsdl, array $options) + { + parent::__construct('{wsdl}', $options); + } +{methods}} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/wsdl_method.tpl.dist b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/wsdl_method.tpl.dist new file mode 100644 index 00000000000..6007b01d4f3 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator/wsdl_method.tpl.dist @@ -0,0 +1,5 @@ + + #[\ReturnTypeWillChange] + public function {method_name}({arguments}) + { + } diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Invocation.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Invocation.php new file mode 100644 index 00000000000..d044b24a0d7 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Invocation.php @@ -0,0 +1,58 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Interface for invocations. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Interface available since Release 1.0.0 + */ +interface PHPUnit_Framework_MockObject_Invocation +{ +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Invocation/Object.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Invocation/Object.php new file mode 100644 index 00000000000..1a608087c2a --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Invocation/Object.php @@ -0,0 +1,75 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Represents a non-static invocation. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Invocation_Object extends PHPUnit_Framework_MockObject_Invocation_Static +{ + /** + * @var object + */ + public $object; + + /** + * @param string $className + * @param string $methodname + * @param array $parameters + * @param object $object + * @param object $cloneObjects + */ + public function __construct($className, $methodName, array $parameters, $object, $cloneObjects = FALSE) + { + parent::__construct($className, $methodName, $parameters, $cloneObjects); + $this->object = $object; + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Invocation/Static.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Invocation/Static.php new file mode 100644 index 00000000000..58bc643e332 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Invocation/Static.php @@ -0,0 +1,191 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Represents a static invocation. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Invocation_Static implements PHPUnit_Framework_MockObject_Invocation, PHPUnit_Framework_SelfDescribing +{ + /** + * @var array + */ + protected static $uncloneableExtensions = array( + 'mysqli' => TRUE, + 'SQLite' => TRUE, + 'sqlite3' => TRUE, + 'tidy' => TRUE, + 'xmlwriter' => TRUE, + 'xsl' => TRUE + ); + + /** + * @var array + */ + protected static $uncloneableClasses = array( + 'Closure', + 'COMPersistHelper', + 'IteratorIterator', + 'RecursiveIteratorIterator', + 'SplFileObject', + 'PDORow', + 'ZipArchive' + ); + + /** + * @var string + */ + public $className; + + /** + * @var string + */ + public $methodName; + + /** + * @var array + */ + public $parameters; + + /** + * @param string $className + * @param string $methodname + * @param array $parameters + * @param boolean $cloneObjects + */ + public function __construct($className, $methodName, array $parameters, $cloneObjects = FALSE) + { + $this->className = $className; + $this->methodName = $methodName; + $this->parameters = $parameters; + + if (!$cloneObjects) { + return; + } + + foreach ($this->parameters as $key => $value) { + if (is_object($value)) { + $this->parameters[$key] = $this->cloneObject($value); + } + } + } + + /** + * @return string + */ + public function toString() + { + return sprintf( + "%s::%s(%s)", + + $this->className, + $this->methodName, + join( + ', ', + array_map( + array('PHPUnit_Util_Type', 'shortenedExport'), + $this->parameters + ) + ) + ); + } + + /** + * @param object $original + * @return object + */ + protected function cloneObject($original) + { + $cloneable = NULL; + $object = new ReflectionObject($original); + + // Check the blacklist before asking PHP reflection to work around + // https://bugs.php.net/bug.php?id=53967 + if ($object->isInternal() && + isset(self::$uncloneableExtensions[$object->getExtensionName()])) { + $cloneable = FALSE; + } + + if ($cloneable === NULL) { + foreach (self::$uncloneableClasses as $class) { + if ($original instanceof $class) { + $cloneable = FALSE; + break; + } + } + } + + if ($cloneable === NULL && method_exists($object, 'isCloneable')) { + $cloneable = $object->isCloneable(); + } + + if ($cloneable === NULL && $object->hasMethod('__clone')) { + $method = $object->getMethod('__clone'); + $cloneable = $method->isPublic(); + } + + if ($cloneable === NULL) { + $cloneable = TRUE; + } + + if ($cloneable) { + try { + return clone $original; + } + + catch (Exception $e) { + return $original; + } + } else { + return $original; + } + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/InvocationMocker.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/InvocationMocker.php new file mode 100644 index 00000000000..d2803ab2305 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/InvocationMocker.php @@ -0,0 +1,201 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Mocker for invocations which are sent from + * PHPUnit_Framework_MockObject_MockObject objects. + * + * Keeps track of all expectations and stubs as well as registering + * identifications for builders. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_InvocationMocker implements PHPUnit_Framework_MockObject_Stub_MatcherCollection, PHPUnit_Framework_MockObject_Invokable, PHPUnit_Framework_MockObject_Builder_Namespace +{ + /** + * @var PHPUnit_Framework_MockObject_Matcher_Invocation[] + */ + protected $matchers = array(); + + /** + * @var PHPUnit_Framework_MockObject_Builder_Match[] + */ + protected $builderMap = array(); + + /** + * @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher + */ + public function addMatcher(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + $this->matchers[] = $matcher; + } + + /** + * @since Method available since Release 1.1.0 + */ + public function hasMatchers() + { + if (empty($this->matchers)) { + return FALSE; + } + + foreach ($this->matchers as $matcher) { + if (!$matcher instanceof PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount) { + return TRUE; + } + } + + return FALSE; + } + + /** + * @param mixed $id + * @return boolean|null + */ + public function lookupId($id) + { + if (isset($this->builderMap[$id])) { + return $this->builderMap[$id]; + } + + return NULL; + } + + /** + * @param mixed $id + * @param PHPUnit_Framework_MockObject_Builder_Match $builder + * @throws PHPUnit_Framework_Exception + */ + public function registerId($id, PHPUnit_Framework_MockObject_Builder_Match $builder) + { + if (isset($this->builderMap[$id])) { + throw new PHPUnit_Framework_Exception( + 'Match builder with id <' . $id . '> is already registered.' + ); + } + + $this->builderMap[$id] = $builder; + } + + /** + * @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher + * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker + */ + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return new PHPUnit_Framework_MockObject_Builder_InvocationMocker( + $this, $matcher + ); + } + + /** + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * @return mixed + */ + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) + { + $exception = NULL; + $hasReturnValue = FALSE; + + if (strtolower($invocation->methodName) == '__tostring') { + $returnValue = ''; + } else { + $returnValue = NULL; + } + + foreach ($this->matchers as $match) { + try { + if ($match->matches($invocation)) { + $value = $match->invoked($invocation); + + if (!$hasReturnValue) { + $returnValue = $value; + $hasReturnValue = TRUE; + } + } + } + + catch (Exception $e) { + $exception = $e; + } + } + + if ($exception !== NULL) { + throw $exception; + } + + return $returnValue; + } + + /** + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * @return boolean + */ + public function matches(PHPUnit_Framework_MockObject_Invocation $invocation) + { + foreach ($this->matchers as $matcher) { + if (!$matcher->matches($invocation)) { + return FALSE; + } + } + + return TRUE; + } + + /** + * @return boolean + */ + public function verify() + { + foreach ($this->matchers as $matcher) { + $matcher->verify(); + } + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Invokable.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Invokable.php new file mode 100644 index 00000000000..5286a2e96ba --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Invokable.php @@ -0,0 +1,79 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Interface for classes which can be invoked. + * + * The invocation will be taken from a mock object and passed to an object + * of this class. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Interface available since Release 1.0.0 + */ +interface PHPUnit_Framework_MockObject_Invokable extends PHPUnit_Framework_MockObject_Verifiable +{ + /** + * Invokes the invocation object $invocation so that it can be checked for + * expectations or matched against stubs. + * + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * The invocation object passed from mock object. + * @return object + */ + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation); + + /** + * Checks if the invocation matches. + * + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * The invocation object passed from mock object. + * @return boolean + */ + public function matches(PHPUnit_Framework_MockObject_Invocation $invocation); +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher.php new file mode 100644 index 00000000000..01c569af4a4 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher.php @@ -0,0 +1,308 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Main matcher which defines a full expectation using method, parameter and + * invocation matchers. + * This matcher encapsulates all the other matchers and allows the builder to + * set the specific matchers when the appropriate methods are called (once(), + * where() etc.). + * + * All properties are public so that they can easily be accessed by the builder. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Matcher implements PHPUnit_Framework_MockObject_Matcher_Invocation +{ + /** + * @var PHPUnit_Framework_MockObject_Matcher_Invocation + */ + public $invocationMatcher; + + /** + * @var mixed + */ + public $afterMatchBuilderId = NULL; + + /** + * @var boolean + */ + public $afterMatchBuilderIsInvoked = FALSE; + + /** + * @var PHPUnit_Framework_MockObject_Matcher_MethodName + */ + public $methodNameMatcher = NULL; + + /** + * @var PHPUnit_Framework_MockObject_Matcher_Parameters + */ + public $parametersMatcher = NULL; + + /** + * @var PHPUnit_Framework_MockObject_Stub + */ + public $stub = NULL; + + /** + * @param PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher + */ + public function __construct(PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher) + { + $this->invocationMatcher = $invocationMatcher; + } + + /** + * @return string + */ + public function toString() + { + $list = array(); + + if ($this->invocationMatcher !== NULL) { + $list[] = $this->invocationMatcher->toString(); + } + + if ($this->methodNameMatcher !== NULL) { + $list[] = 'where ' . $this->methodNameMatcher->toString(); + } + + if ($this->parametersMatcher !== NULL) { + $list[] = 'and ' . $this->parametersMatcher->toString(); + } + + if ($this->afterMatchBuilderId !== NULL) { + $list[] = 'after ' . $this->afterMatchBuilderId; + } + + if ($this->stub !== NULL) { + $list[] = 'will ' . $this->stub->toString(); + } + + return join(' ', $list); + } + + /** + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * @return mixed + */ + public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation) + { + if ($this->invocationMatcher === NULL) { + throw new PHPUnit_Framework_Exception( + 'No invocation matcher is set' + ); + } + + if ($this->methodNameMatcher === NULL) { + throw new PHPUnit_Framework_Exception('No method matcher is set'); + } + + if ($this->afterMatchBuilderId !== NULL) { + $builder = $invocation->object + ->__phpunit_getInvocationMocker() + ->lookupId($this->afterMatchBuilderId); + + if (!$builder) { + throw new PHPUnit_Framework_Exception( + sprintf( + 'No builder found for match builder identification <%s>', + + $this->afterMatchBuilderId + ) + ); + } + + $matcher = $builder->getMatcher(); + + if ($matcher && $matcher->invocationMatcher->hasBeenInvoked()) { + $this->afterMatchBuilderIsInvoked = TRUE; + } + } + + $this->invocationMatcher->invoked($invocation); + + try { + if ( $this->parametersMatcher !== NULL && + !$this->parametersMatcher->matches($invocation)) { + $this->parametersMatcher->verify(); + } + } + + catch (PHPUnit_Framework_ExpectationFailedException $e) { + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf( + "Expectation failed for %s when %s\n%s", + + $this->methodNameMatcher->toString(), + $this->invocationMatcher->toString(), + $e->getMessage() + ), + $e->getComparisonFailure() + ); + } + + if ($this->stub) { + return $this->stub->invoke($invocation); + } + + return NULL; + } + + /** + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * @return boolean + */ + public function matches(PHPUnit_Framework_MockObject_Invocation $invocation) + { + if ($this->afterMatchBuilderId !== NULL) { + $builder = $invocation->object + ->__phpunit_getInvocationMocker() + ->lookupId($this->afterMatchBuilderId); + + if (!$builder) { + throw new PHPUnit_Framework_Exception( + sprintf( + 'No builder found for match builder identification <%s>', + + $this->afterMatchBuilderId + ) + ); + } + + $matcher = $builder->getMatcher(); + + if (!$matcher) { + return FALSE; + } + + if (!$matcher->invocationMatcher->hasBeenInvoked()) { + return FALSE; + } + } + + if ($this->invocationMatcher === NULL) { + throw new PHPUnit_Framework_Exception( + 'No invocation matcher is set' + ); + } + + if ($this->methodNameMatcher === NULL) { + throw new PHPUnit_Framework_Exception('No method matcher is set'); + } + + if (!$this->invocationMatcher->matches($invocation)) { + return FALSE; + } + + try { + if (!$this->methodNameMatcher->matches($invocation)) { + return FALSE; + } + } + + catch (PHPUnit_Framework_ExpectationFailedException $e) { + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf( + "Expectation failed for %s when %s\n%s", + + $this->methodNameMatcher->toString(), + $this->invocationMatcher->toString(), + $e->getMessage() + ), + $e->getComparisonFailure() + ); + } + + return TRUE; + } + + /** + * @throws PHPUnit_Framework_Exception + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function verify() + { + if ($this->invocationMatcher === NULL) { + throw new PHPUnit_Framework_Exception( + 'No invocation matcher is set' + ); + } + + if ($this->methodNameMatcher === NULL) { + throw new PHPUnit_Framework_Exception('No method matcher is set'); + } + + try { + $this->invocationMatcher->verify(); + + if ($this->parametersMatcher === NULL) { + $this->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_AnyParameters; + } + + $invocationIsAny = get_class($this->invocationMatcher) === 'PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount'; + if (!$invocationIsAny) { + $this->parametersMatcher->verify(); + } + } + + catch (PHPUnit_Framework_ExpectationFailedException $e) { + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf( + "Expectation failed for %s when %s.\n%s", + + $this->methodNameMatcher->toString(), + $this->invocationMatcher->toString(), + $e->getMessage() + ) + ); + } + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/AnyInvokedCount.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/AnyInvokedCount.php new file mode 100644 index 00000000000..8c1ce608f74 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/AnyInvokedCount.php @@ -0,0 +1,72 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Invocation matcher which checks if a method has been invoked zero or more + * times. This matcher will always match. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount extends PHPUnit_Framework_MockObject_Matcher_InvokedRecorder +{ + /** + * @return string + */ + public function toString() + { + return 'invoked zero or more times'; + } + + /** + */ + public function verify() + { + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/AnyParameters.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/AnyParameters.php new file mode 100644 index 00000000000..a06d420c321 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/AnyParameters.php @@ -0,0 +1,74 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Invocation matcher which allos any parameters to a method. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Matcher_AnyParameters extends PHPUnit_Framework_MockObject_Matcher_StatelessInvocation +{ + /** + * @return string + */ + public function toString() + { + return 'with any parameters'; + } + + /** + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * @return boolean + */ + public function matches(PHPUnit_Framework_MockObject_Invocation $invocation) + { + return TRUE; + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/Invocation.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/Invocation.php new file mode 100644 index 00000000000..59b30be862e --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/Invocation.php @@ -0,0 +1,88 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Interface for classes which matches an invocation based on its + * method name, argument, order or call count. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Interface available since Release 1.0.0 + */ +interface PHPUnit_Framework_MockObject_Matcher_Invocation extends PHPUnit_Framework_SelfDescribing, PHPUnit_Framework_MockObject_Verifiable +{ + /** + * Registers the invocation $invocation in the object as being invoked. + * This will only occur after matches() returns true which means the + * current invocation is the correct one. + * + * The matcher can store information from the invocation which can later + * be checked in verify(), or it can check the values directly and throw + * and exception if an expectation is not met. + * + * If the matcher is a stub it will also have a return value. + * + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * Object containing information on a mocked or stubbed method which + * was invoked. + * @return mixed + */ + public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation); + + /** + * Checks if the invocation $invocation matches the current rules. If it does + * the matcher will get the invoked() method called which should check if an + * expectation is met. + * + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * Object containing information on a mocked or stubbed method which + * was invoked. + * @return bool + */ + public function matches(PHPUnit_Framework_MockObject_Invocation $invocation); +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/InvokedAtIndex.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/InvokedAtIndex.php new file mode 100644 index 00000000000..cf969b772c7 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/InvokedAtIndex.php @@ -0,0 +1,127 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Invocation matcher which checks if a method was invoked at a certain index. + * + * If the expected index number does not match the current invocation index it + * will not match which means it skips all method and parameter matching. Only + * once the index is reached will the method and parameter start matching and + * verifying. + * + * If the index is never reached it will throw an exception in index. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex implements PHPUnit_Framework_MockObject_Matcher_Invocation +{ + /** + * @var integer + */ + protected $sequenceIndex; + + /** + * @var integer + */ + protected $currentIndex = -1; + + /** + * @param integer $sequenceIndex + */ + public function __construct($sequenceIndex) + { + $this->sequenceIndex = $sequenceIndex; + } + + /** + * @return string + */ + public function toString() + { + return 'invoked at sequence index ' . $this->sequenceIndex; + } + + /** + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * @return boolean + */ + public function matches(PHPUnit_Framework_MockObject_Invocation $invocation) + { + $this->currentIndex++; + + return $this->currentIndex == $this->sequenceIndex; + } + + /** + * @param PHPUnit_Framework_MockObject_Invocation $invocation + */ + public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation) + { + } + + /** + * Verifies that the current expectation is valid. If everything is OK the + * code should just return, if not it must throw an exception. + * + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function verify() + { + if ($this->currentIndex < $this->sequenceIndex) { + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf( + 'The expected invocation at index %s was never reached.', + + $this->sequenceIndex + ) + ); + } + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/InvokedAtLeastOnce.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/InvokedAtLeastOnce.php new file mode 100644 index 00000000000..1fb89ad2230 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/InvokedAtLeastOnce.php @@ -0,0 +1,85 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Invocation matcher which checks if a method has been invoked at least one + * time. + * + * If the number of invocations is 0 it will throw an exception in verify. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce extends PHPUnit_Framework_MockObject_Matcher_InvokedRecorder +{ + /** + * @return string + */ + public function toString() + { + return 'invoked at least once'; + } + + /** + * Verifies that the current expectation is valid. If everything is OK the + * code should just return, if not it must throw an exception. + * + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function verify() + { + $count = $this->getInvocationCount(); + + if ($count < 1) { + throw new PHPUnit_Framework_ExpectationFailedException( + 'Expected invocation at least once but it never occured.' + ); + } + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/InvokedCount.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/InvokedCount.php new file mode 100644 index 00000000000..9131c41985e --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/InvokedCount.php @@ -0,0 +1,143 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Invocation matcher which checks if a method has been invoked a certain amount + * of times. + * If the number of invocations exceeds the value it will immediately throw an + * exception, + * If the number is less it will later be checked in verify() and also throw an + * exception. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Matcher_InvokedCount extends PHPUnit_Framework_MockObject_Matcher_InvokedRecorder +{ + /** + * @var integer + */ + protected $expectedCount; + + /** + * @param interger $expectedCount + */ + public function __construct($expectedCount) + { + $this->expectedCount = $expectedCount; + } + + /** + * @return string + */ + public function toString() + { + return 'invoked ' . $this->expectedCount . ' time(s)'; + } + + /** + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation) + { + parent::invoked($invocation); + + $count = $this->getInvocationCount(); + + if ($count > $this->expectedCount) { + $message = $invocation->toString() . ' InvokedCount.php'; + + switch ($this->expectedCount) { + case 0: { + $message .= 'was not expected to be called.'; + } + break; + + case 1: { + $message .= 'was not expected to be called more than once.'; + } + break; + + default: { + $message .= sprintf( + 'was not expected to be called more than %d times.', + + $this->expectedCount + ); + } + } + + throw new PHPUnit_Framework_ExpectationFailedException($message); + } + } + + /** + * Verifies that the current expectation is valid. If everything is OK the + * code should just return, if not it must throw an exception. + * + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function verify() + { + $count = $this->getInvocationCount(); + + if ($count !== $this->expectedCount) { + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf( + 'Method was expected to be called %d times, ' . + 'actually called %d times.', + + $this->expectedCount, + $count + ) + ); + } + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/InvokedRecorder.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/InvokedRecorder.php new file mode 100644 index 00000000000..146a277c67b --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/InvokedRecorder.php @@ -0,0 +1,107 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Records invocations and provides convenience methods for checking them later + * on. + * This abstract class can be implemented by matchers which needs to check the + * number of times an invocation has occured. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + * @abstract + */ +abstract class PHPUnit_Framework_MockObject_Matcher_InvokedRecorder implements PHPUnit_Framework_MockObject_Matcher_Invocation +{ + /** + * @var PHPUnit_Framework_MockObject_Invocation[] + */ + protected $invocations = array(); + + /** + * @return integer + */ + public function getInvocationCount() + { + return count($this->invocations); + } + + /** + * @return PHPUnit_Framework_MockObject_Invocation[] + */ + public function getInvocations() + { + return $this->invocations; + } + + /** + * @return boolean + */ + public function hasBeenInvoked() + { + return count($this->invocations) > 0; + } + + /** + * @param PHPUnit_Framework_MockObject_Invocation $invocation + */ + public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation) + { + $this->invocations[] = $invocation; + } + + /** + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * @return boolean + */ + public function matches(PHPUnit_Framework_MockObject_Invocation $invocation) + { + return TRUE; + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/MethodName.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/MethodName.php new file mode 100644 index 00000000000..b889e3ee0e1 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/MethodName.php @@ -0,0 +1,102 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Invocation matcher which looks for a specific method name in the invocations. + * + * Checks the method name all incoming invocations, the name is checked against + * the defined constraint $constraint. If the constraint is met it will return + * true in matches(). + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Matcher_MethodName extends PHPUnit_Framework_MockObject_Matcher_StatelessInvocation +{ + /** + * @var PHPUnit_Framework_Constraint + */ + protected $constraint; + + /** + * @param PHPUnit_Framework_Constraint|string + * @throws PHPUnit_Framework_Constraint + */ + public function __construct($constraint) + { + if (!$constraint instanceof PHPUnit_Framework_Constraint) { + if (!is_string($constraint)) { + throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); + } + + $constraint = new PHPUnit_Framework_Constraint_IsEqual( + $constraint, 0, 10, FALSE, TRUE + ); + } + + $this->constraint = $constraint; + } + + /** + * @return string + */ + public function toString() + { + return 'method name ' . $this->constraint->toString(); + } + + /** + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * @return boolean + */ + public function matches(PHPUnit_Framework_MockObject_Invocation $invocation) + { + return $this->constraint->evaluate($invocation->methodName, '', TRUE); + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/Parameters.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/Parameters.php new file mode 100644 index 00000000000..e3284a41a61 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/Parameters.php @@ -0,0 +1,160 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Invocation matcher which looks for specific parameters in the invocations. + * + * Checks the parameters of all incoming invocations, the parameter list is + * checked against the defined constraints in $parameters. If the constraint + * is met it will return true in matches(). + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Matcher_Parameters extends PHPUnit_Framework_MockObject_Matcher_StatelessInvocation +{ + /** + * @var array + */ + protected $parameters = array(); + + /** + * @var PHPUnit_Framework_MockObject_Invocation + */ + protected $invocation; + + /** + * @param array $parameters + */ + public function __construct(array $parameters) + { + foreach ($parameters as $parameter) { + if (!($parameter instanceof PHPUnit_Framework_Constraint)) { + $parameter = new PHPUnit_Framework_Constraint_IsEqual( + $parameter + ); + } + + $this->parameters[] = $parameter; + } + } + + /** + * @return string + */ + public function toString() + { + $text = 'with parameter'; + + foreach ($this->parameters as $index => $parameter) { + if ($index > 0) { + $text .= ' and'; + } + + $text .= ' ' . $index . ' ' . $parameter->toString(); + } + + return $text; + } + + /** + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * @return boolean + */ + public function matches(PHPUnit_Framework_MockObject_Invocation $invocation) + { + $this->invocation = $invocation; + $this->verify(); + + return count($invocation->parameters) < count($this->parameters); + } + + /** + * Checks if the invocation $invocation matches the current rules. If it + * does the matcher will get the invoked() method called which should check + * if an expectation is met. + * + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * Object containing information on a mocked or stubbed method which + * was invoked. + * @return bool + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function verify() + { + if ($this->invocation === NULL) { + throw new PHPUnit_Framework_ExpectationFailedException( + 'Mocked method does not exist.' + ); + } + + if (count($this->invocation->parameters) < count($this->parameters)) { + throw new PHPUnit_Framework_ExpectationFailedException( + sprintf( + 'Parameter count for invocation %s is too low.', + + $this->invocation->toString() + ) + ); + } + + foreach ($this->parameters as $i => $parameter) { + $parameter->evaluate( + $this->invocation->parameters[$i], + sprintf( + 'Parameter %s for invocation %s does not match expected ' . + 'value.', + + $i, + $this->invocation->toString() + ) + ); + } + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/StatelessInvocation.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/StatelessInvocation.php new file mode 100644 index 00000000000..2f914470418 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher/StatelessInvocation.php @@ -0,0 +1,96 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Invocation matcher which does not care about previous state from earlier + * invocations. + * + * This abstract class can be implemented by matchers which does not care about + * state but only the current run-time value of the invocation itself. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + * @abstract + */ +abstract class PHPUnit_Framework_MockObject_Matcher_StatelessInvocation implements PHPUnit_Framework_MockObject_Matcher_Invocation +{ + /** + * Registers the invocation $invocation in the object as being invoked. + * This will only occur after matches() returns true which means the + * current invocation is the correct one. + * + * The matcher can store information from the invocation which can later + * be checked in verify(), or it can check the values directly and throw + * and exception if an expectation is not met. + * + * If the matcher is a stub it will also have a return value. + * + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * Object containing information on a mocked or stubbed method which + * was invoked. + * @return mixed + */ + public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation) + { + } + + /** + * Checks if the invocation $invocation matches the current rules. If it does + * the matcher will get the invoked() method called which should check if an + * expectation is met. + * + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * Object containing information on a mocked or stubbed method which + * was invoked. + * @return bool + */ + public function verify() + { + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/MockBuilder.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/MockBuilder.php new file mode 100644 index 00000000000..0aa569dc30c --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/MockBuilder.php @@ -0,0 +1,291 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Giorgio Sironi + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Implementation of the Builder pattern for Mock objects. + * + * @package PHPUnit_MockObject + * @author Giorgio Sironi + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_MockBuilder +{ + /** + * @var PHPUnit_Framework_TestCase + */ + protected $testCase; + + /** + * @var string + */ + protected $className; + + /** + * @var array + */ + protected $methods = array(); + + /** + * @var string + */ + protected $mockClassName = ''; + + /** + * @var array + */ + protected $constructorArgs = array(); + + /** + * @var boolean + */ + protected $originalConstructor = TRUE; + + /** + * @var boolean + */ + protected $originalClone = TRUE; + + /** + * @var boolean + */ + protected $autoload = TRUE; + + /** + * @var boolean + */ + protected $cloneArguments = FALSE; + + /** + * @param PHPUnit_Framework_TestCase + * @param string + */ + public function __construct(PHPUnit_Framework_TestCase $testCase, $className) + { + $this->testCase = $testCase; + $this->className = $className; + } + + /** + * Creates a mock object using a fluent interface. + * + * @return PHPUnit_Framework_MockObject_MockObject + */ + public function getMock() + { + return $this->testCase->getMock( + $this->className, + $this->methods, + $this->constructorArgs, + $this->mockClassName, + $this->originalConstructor, + $this->originalClone, + $this->autoload, + $this->cloneArguments + ); + } + + /** + * Creates a mock object for an abstract class using a fluent interface. + * + * @return PHPUnit_Framework_MockObject_MockObject + */ + public function getMockForAbstractClass() + { + return $this->testCase->getMockForAbstractClass( + $this->className, + $this->constructorArgs, + $this->mockClassName, + $this->originalConstructor, + $this->originalClone, + $this->autoload, + $this->methods, + $this->cloneArguments + ); + } + + /** + * Specifies the subset of methods to mock. Default is to mock all of them. + * + * @param array|null $methods + * @return PHPUnit_Framework_MockObject_MockBuilder + */ + public function setMethods($methods) + { + $this->methods = $methods; + + return $this; + } + + /** + * Specifies the arguments for the constructor. + * + * @param array $args + * @return PHPUnit_Framework_MockObject_MockBuilder + */ + public function setConstructorArgs(array $args) + { + $this->constructorArgs = $args; + + return $this; + } + + /** + * Specifies the name for the mock class. + * + * @param string $name + * @return PHPUnit_Framework_MockObject_MockBuilder + */ + public function setMockClassName($name) + { + $this->mockClassName = $name; + + return $this; + } + + /** + * Disables the invocation of the original constructor. + * + * @return PHPUnit_Framework_MockObject_MockBuilder + */ + public function disableOriginalConstructor() + { + $this->originalConstructor = FALSE; + + return $this; + } + + /** + * Enables the invocation of the original constructor. + * + * @return PHPUnit_Framework_MockObject_MockBuilder + * @since Method available since Release 1.2.0 + */ + public function enableOriginalConstructor() + { + $this->originalConstructor = TRUE; + + return $this; + } + + /** + * Disables the invocation of the original clone constructor. + * + * @return PHPUnit_Framework_MockObject_MockBuilder + */ + public function disableOriginalClone() + { + $this->originalClone = FALSE; + + return $this; + } + + /** + * Enables the invocation of the original clone constructor. + * + * @return PHPUnit_Framework_MockObject_MockBuilder + * @since Method available since Release 1.2.0 + */ + public function enableOriginalClone() + { + $this->originalClone = TRUE; + + return $this; + } + + /** + * Disables the use of class autoloading while creating the mock object. + * + * @return PHPUnit_Framework_MockObject_MockBuilder + */ + public function disableAutoload() + { + $this->autoload = FALSE; + + return $this; + } + + /** + * Enables the use of class autoloading while creating the mock object. + * + * @return PHPUnit_Framework_MockObject_MockBuilder + * @since Method available since Release 1.2.0 + */ + public function enableAutoload() + { + $this->autoload = TRUE; + + return $this; + } + + /** + * Disables the cloning of arguments passed to mocked methods. + * + * @return PHPUnit_Framework_MockObject_MockBuilder + * @since Method available since Release 1.2.0 + */ + public function disableArgumentCloning() + { + $this->cloneArguments = FALSE; + + return $this; + } + + /** + * Enables the cloning of arguments passed to mocked methods. + * + * @return PHPUnit_Framework_MockObject_MockBuilder + * @since Method available since Release 1.2.0 + */ + public function enableArgumentCloning() + { + $this->cloneArguments = TRUE; + + return $this; + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/MockObject.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/MockObject.php new file mode 100644 index 00000000000..f60fa70a3c6 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/MockObject.php @@ -0,0 +1,94 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Interface for all mock objects which are generated by + * PHPUnit_Framework_MockObject_Mock. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Interface available since Release 1.0.0 + */ +interface PHPUnit_Framework_MockObject_MockObject /*extends PHPUnit_Framework_MockObject_Verifiable*/ +{ + /** + * Registers a new expectation in the mock object and returns the match + * object which can be infused with further details. + * + * @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher + * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker + */ + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher); + + /** + * Registers a new static expectation in the mock object and returns the + * match object which can be infused with further details. + * + * @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher + * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker + */ + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher); + + /** + * @return PHPUnit_Framework_MockObject_InvocationMocker + */ + public function __phpunit_getInvocationMocker(); + + /** + * @return PHPUnit_Framework_MockObject_InvocationMocker + */ + public static function __phpunit_getStaticInvocationMocker(); + + /** + * Verifies that the current expectation is valid. If everything is OK the + * code should just return, if not it must throw an exception. + * + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function __phpunit_verify(); +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub.php new file mode 100644 index 00000000000..56555bfce80 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub.php @@ -0,0 +1,71 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * An object that stubs the process of a normal method for a mock object. + * + * The stub object will replace the code for the stubbed method and return a + * specific value instead of the original value. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Interface available since Release 1.0.0 + */ +interface PHPUnit_Framework_MockObject_Stub extends PHPUnit_Framework_SelfDescribing +{ + /** + * Fakes the processing of the invocation $invocation by returning a + * specific value. + * + * @param PHPUnit_Framework_MockObject_Invocation $invocation + * The invocation which was mocked and matched by the current method + * and argument matchers. + * @return mixed + */ + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation); +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ConsecutiveCalls.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ConsecutiveCalls.php new file mode 100644 index 00000000000..9f54bdd9165 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ConsecutiveCalls.php @@ -0,0 +1,87 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Patrick Müller + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Stubs a method by returning a user-defined stack of values. + * + * @package PHPUnit_MockObject + * @author Patrick Müller + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls implements PHPUnit_Framework_MockObject_Stub +{ + protected $stack; + protected $value; + + public function __construct($stack) + { + $this->stack = $stack; + } + + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) + { + $this->value = array_shift($this->stack); + + if ($this->value instanceof PHPUnit_Framework_MockObject_Stub) { + $this->value = $this->value->invoke($invocation); + } + + return $this->value; + } + + public function toString() + { + return sprintf( + 'return user-specified value %s', + + PHPUnit_Util_Type::toString($this->value) + ); + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/Exception.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/Exception.php new file mode 100644 index 00000000000..dc8152cdbc1 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/Exception.php @@ -0,0 +1,80 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Oliver Schlicht + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Stubs a method by raising a user-defined exception. + * + * @package PHPUnit_MockObject + * @author Oliver Schlicht + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Stub_Exception implements PHPUnit_Framework_MockObject_Stub +{ + protected $exception; + + public function __construct(Exception $exception) + { + $this->exception = $exception; + } + + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) + { + throw $this->exception; + } + + public function toString() + { + return sprintf( + 'raise user-specified exception %s', + + PHPUnit_Util_Type::toString($this->exception) + ); + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/MatcherCollection.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/MatcherCollection.php new file mode 100644 index 00000000000..2040fd5a5d4 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/MatcherCollection.php @@ -0,0 +1,66 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Stubs a method by returning a user-defined value. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Interface available since Release 1.0.0 + */ +interface PHPUnit_Framework_MockObject_Stub_MatcherCollection +{ + /** + * Adds a new matcher to the collection which can be used as an expectation + * or a stub. + * + * @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher + * Matcher for invocations to mock objects. + */ + public function addMatcher(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher); +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/Return.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/Return.php new file mode 100644 index 00000000000..c67353696f0 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/Return.php @@ -0,0 +1,78 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Stubs a method by returning a user-defined value. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Stub_Return implements PHPUnit_Framework_MockObject_Stub +{ + protected $value; + + public function __construct($value) + { + $this->value = $value; + } + + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) + { + return $this->value; + } + + public function toString() + { + return sprintf( + 'return user-specified value %s', + + PHPUnit_Util_Type::toString($this->value) + ); + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ReturnArgument.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ReturnArgument.php new file mode 100644 index 00000000000..d5b668c4329 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ReturnArgument.php @@ -0,0 +1,78 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Stubs a method by returning an argument that was passed to the mocked method. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Stub_ReturnArgument extends PHPUnit_Framework_MockObject_Stub_Return +{ + protected $argumentIndex; + + public function __construct($argumentIndex) + { + $this->argumentIndex = $argumentIndex; + } + + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) + { + if (isset($invocation->parameters[$this->argumentIndex])) { + return $invocation->parameters[$this->argumentIndex]; + } else { + return NULL; + } + } + + public function toString() + { + return sprintf('return argument #%d', $this->argumentIndex); + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ReturnCallback.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ReturnCallback.php new file mode 100644 index 00000000000..282fd35d124 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ReturnCallback.php @@ -0,0 +1,94 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.0.0 + */ +class PHPUnit_Framework_MockObject_Stub_ReturnCallback implements PHPUnit_Framework_MockObject_Stub +{ + protected $callback; + + public function __construct($callback) + { + $this->callback = $callback; + } + + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) + { + return call_user_func_array($this->callback, $invocation->parameters); + } + + public function toString() + { + if (is_array($this->callback)) { + if (is_object($this->callback[0])) { + $class = get_class($this->callback[0]); + $type = '->'; + } else { + $class = $this->callback[0]; + $type = '::'; + } + + return sprintf( + 'return result of user defined callback %s%s%s() with the ' . + 'passed arguments', + + $class, + $type, + $this->callback[1] + ); + } else { + return 'return result of user defined callback ' . $this->callback . + ' with the passed arguments'; + } + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ReturnSelf.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ReturnSelf.php new file mode 100644 index 00000000000..66959447f84 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ReturnSelf.php @@ -0,0 +1,76 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @author Kris Wallsmith + * @copyright 2010 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.1.0 + */ + +/** + * Stubs a method by returning the current object. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @author Kris Wallsmith + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.1.0 + */ +class PHPUnit_Framework_MockObject_Stub_ReturnSelf implements PHPUnit_Framework_MockObject_Stub +{ + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) + { + if (!$invocation instanceof PHPUnit_Framework_MockObject_Invocation_Object) { + throw new PHPUnit_Framework_Exception( + 'The current object can only be returned when mocking an ' . + 'object, not a static class.' + ); + } + + return $invocation->object; + } + + public function toString() + { + return 'return the current object'; + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ReturnValueMap.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ReturnValueMap.php new file mode 100644 index 00000000000..f743fdee524 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Stub/ReturnValueMap.php @@ -0,0 +1,87 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.1.0 + */ + +/** + * Stubs a method by returning a value from a map. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Class available since Release 1.1.0 + */ +class PHPUnit_Framework_MockObject_Stub_ReturnValueMap implements PHPUnit_Framework_MockObject_Stub +{ + protected $valueMap; + + public function __construct(array $valueMap) + { + $this->valueMap = $valueMap; + } + + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) + { + $parameterCount = count($invocation->parameters); + + foreach ($this->valueMap as $map) { + if (!is_array($map) || $parameterCount != count($map) - 1) { + continue; + } + + $return = array_pop($map); + if ($invocation->parameters === $map) { + return $return; + } + } + + return NULL; + } + + public function toString() + { + return 'return value from a map'; + } +} diff --git a/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Verifiable.php b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Verifiable.php new file mode 100644 index 00000000000..9c70ba79192 --- /dev/null +++ b/deps/phpunit-mock-objects/PHPUnit/Framework/MockObject/Verifiable.php @@ -0,0 +1,65 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +/** + * Interface for classes which must verify a given expectation. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since Interface available since Release 1.0.0 + */ +interface PHPUnit_Framework_MockObject_Verifiable +{ + /** + * Verifies that the current expectation is valid. If everything is OK the + * code should just return, if not it must throw an exception. + * + * @throws PHPUnit_Framework_ExpectationFailedException + */ + public function verify(); +} diff --git a/deps/phpunit-mock-objects/Tests/GeneratorTest.php b/deps/phpunit-mock-objects/Tests/GeneratorTest.php new file mode 100644 index 00000000000..2ffbbc31252 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/GeneratorTest.php @@ -0,0 +1,79 @@ +assertTrue(method_exists($mock, 'testFunction')); + } + + /** + * @covers PHPUnit_Framework_MockObject_Generator::getMock + * @expectedException PHPUnit_Framework_Exception + * @expectedExceptionMessage duplicates: "foo, foo" + */ + public function testGetMockGeneratorFails() + { + $mock = PHPUnit_Framework_MockObject_Generator::getMock('StdClass', array('foo', 'foo')); + } + + /** + * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass + */ + public function testGetMockForAbstractClassDoesNotFailWhenFakingInterfaces() + { + $mock = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass('Countable'); + $this->assertTrue(method_exists($mock, 'count')); + } + + /** + * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass + */ + public function testGetMockForAbstractClassStubbingAbstractClass() + { + $mock = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass('AbstractMockTestClass'); + $this->assertTrue(method_exists($mock, 'doSomething')); + } + + /** + * @dataProvider getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider + * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass + * @expectedException PHPUnit_Framework_Exception + */ + public function testGetMockForAbstractClassExpectingInvalidArgumentException($className, $mockClassName) + { + $mock = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass($className, array(), $mockClassName); + } + + /** + * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass + * @expectedException PHPUnit_Framework_Exception + */ + public function testGetMockForAbstractClassAnstractClassDoesNotExist() + { + $mock = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass('Tux'); + } + + /** + * Dataprovider for test "testGetMockForAbstractClassExpectingInvalidArgumentException" + */ + public static function getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider() + { + return array( + 'className not a string' => array(array(), ''), + 'mockClassName not a string' => array('Countable', new StdClass), + ); + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockBuilderTest.php b/deps/phpunit-mock-objects/Tests/MockBuilderTest.php new file mode 100644 index 00000000000..4acc2f47fe7 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockBuilderTest.php @@ -0,0 +1,152 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Giorgio Sironi + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ + +require_once 'PHPUnit/Framework/TestCase.php'; + +require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Mockable.php'; + +/** + * @package PHPUnit_MockObject + * @author Giorgio Sironi + * @author Sebastian Bergmann + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/phpunit-mock-objects + * @since File available since Release 1.0.0 + */ +class Framework_MockBuilderTest extends PHPUnit_Framework_TestCase +{ + public function testMockBuilderRequiresClassName() + { + $spec = $this->getMockBuilder('Mockable'); + $mock = $spec->getMock(); + $this->assertTrue($mock instanceof Mockable); + } + + public function testByDefaultMocksAllMethods() + { + $spec = $this->getMockBuilder('Mockable'); + $mock = $spec->getMock(); + $this->assertNull($mock->mockableMethod()); + $this->assertNull($mock->anotherMockableMethod()); + } + + public function testMethodsToMockCanBeSpecified() + { + $spec = $this->getMockBuilder('Mockable'); + $spec->setMethods(array('mockableMethod')); + $mock = $spec->getMock(); + $this->assertNull($mock->mockableMethod()); + $this->assertTrue($mock->anotherMockableMethod()); + } + + public function testByDefaultDoesNotPassArgumentsToTheConstructor() + { + $spec = $this->getMockBuilder('Mockable'); + $mock = $spec->getMock(); + $this->assertEquals(array(NULL, NULL), $mock->constructorArgs); + } + + public function testMockClassNameCanBeSpecified() + { + $spec = $this->getMockBuilder('Mockable'); + $spec->setMockClassName('ACustomClassName'); + $mock = $spec->getMock(); + $this->assertTrue($mock instanceof ACustomClassName); + } + + public function testConstructorArgumentsCanBeSpecified() + { + $spec = $this->getMockBuilder('Mockable'); + $spec->setConstructorArgs($expected = array(23, 42)); + $mock = $spec->getMock(); + $this->assertEquals($expected, $mock->constructorArgs); + } + + public function testOriginalConstructorCanBeDisabled() + { + $spec = $this->getMockBuilder('Mockable'); + $spec->disableOriginalConstructor(); + $mock = $spec->getMock(); + $this->assertNull($mock->constructorArgs); + } + + public function testByDefaultOriginalCloneIsPreserved() + { + $spec = $this->getMockBuilder('Mockable'); + $mock = $spec->getMock(); + $cloned = clone $mock; + $this->assertTrue($cloned->cloned); + } + + public function testOriginalCloneCanBeDisabled() + { + $spec = $this->getMockBuilder('Mockable'); + $spec->disableOriginalClone(); + $mock = $spec->getMock(); + $mock->cloned = FALSE; + $cloned = clone $mock; + $this->assertFalse($cloned->cloned); + } + + public function testCallingAutoloadCanBeDisabled() + { + // it is not clear to me how to test this nor the difference + // between calling it or not + $this->markTestIncomplete(); + } + + public function testProvidesAFluentInterface() + { + $spec = $this->getMockBuilder('Mockable') + ->setMethods(array('mockableMethod')) + ->setConstructorArgs(array()) + ->setMockClassName('DummyClassName') + ->disableOriginalConstructor() + ->disableOriginalClone() + ->disableAutoload(); + $this->assertTrue($spec instanceof PHPUnit_Framework_MockObject_MockBuilder); + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/Invocation/ObjectTest.php b/deps/phpunit-mock-objects/Tests/MockObject/Invocation/ObjectTest.php new file mode 100644 index 00000000000..b28b1246f24 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/Invocation/ObjectTest.php @@ -0,0 +1,82 @@ +assertSame('FooClass', $invocation->className); + } + + public function testAllowToGetMethodNameSetInConstructor() + { + $invocation = new PHPUnit_Framework_MockObject_Invocation_Object( + 'FooClass', + 'FooMethod', + array('an_argument'), + new StdClass); + + $this->assertSame('FooMethod', $invocation->methodName); + } + + public function testAllowToGetObjectSetInConstructor() + { + $expectedObject = new StdClass; + + $invocation = new PHPUnit_Framework_MockObject_Invocation_Object( + 'FooClass', + 'FooMethod', + array('an_argument'), + $expectedObject); + + $this->assertSame($expectedObject, $invocation->object); + } + + public function testAllowToGetMethodParametersSetInConstructor() + { + $expectedParameters = array( + 'foo', 5, array('a', 'b'), new StdClass, NULL, FALSE + ); + + $invocation = new PHPUnit_Framework_MockObject_Invocation_Object( + 'FooClass', + 'FooMethod', + $expectedParameters, + new StdClass + ); + + $this->assertSame($expectedParameters, $invocation->parameters); + } + + public function testConstructorAllowToSetFlagCloneObjectsInParameters() + { + $parameters = array(new StdClass); + $cloneObjects = TRUE; + + $invocation = new PHPUnit_Framework_MockObject_Invocation_Object( + 'FooClass', + 'FooMethod', + $parameters, + new StdClass, + $cloneObjects + ); + + $this->assertEquals($parameters, $invocation->parameters); + $this->assertNotSame($parameters, $invocation->parameters); + } +} + diff --git a/deps/phpunit-mock-objects/Tests/MockObject/Invocation/StaticTest.php b/deps/phpunit-mock-objects/Tests/MockObject/Invocation/StaticTest.php new file mode 100644 index 00000000000..09e6e3c6106 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/Invocation/StaticTest.php @@ -0,0 +1,52 @@ +assertSame('FooClass', $invocation->className); + } + + public function testAllowToGetMethodNameSetInConstructor() + { + $invocation = new PHPUnit_Framework_MockObject_Invocation_Static('FooClass', 'FooMethod', array('an_argument')); + + $this->assertSame('FooMethod', $invocation->methodName); + } + + public function testAllowToGetMethodParametersSetInConstructor() + { + $expectedParameters = array( + 'foo', 5, array('a', 'b'), new StdClass, NULL, FALSE + ); + + $invocation = new PHPUnit_Framework_MockObject_Invocation_Static( + 'FooClass', 'FooMethod', $expectedParameters + ); + + $this->assertSame($expectedParameters, $invocation->parameters); + } + + public function testConstructorAllowToSetFlagCloneObjectsInParameters() + { + $parameters = array(new StdClass); + $cloneObjects = TRUE; + + $invocation = new PHPUnit_Framework_MockObject_Invocation_Static( + 'FooClass', + 'FooMethod', + $parameters, + $cloneObjects + ); + + $this->assertEquals($parameters, $invocation->parameters); + $this->assertNotSame($parameters, $invocation->parameters); + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/class.phpt b/deps/phpunit-mock-objects/Tests/MockObject/class.phpt new file mode 100644 index 00000000000..bdeecb845ad --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/class.phpt @@ -0,0 +1,128 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function bar(Foo $foo) + { + $arguments = array($foo); + $count = func_num_args(); + + if ($count > 1) { + $_arguments = func_get_args(); + + for ($i = 1; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = $this->__phpunit_getInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Object( + 'Foo', 'bar', $arguments, $this, TRUE + ) + ); + + return $result; + } + + public function baz(Foo $foo) + { + $arguments = array($foo); + $count = func_num_args(); + + if ($count > 1) { + $_arguments = func_get_args(); + + for ($i = 1; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = $this->__phpunit_getInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Object( + 'Foo', 'baz', $arguments, $this, TRUE + ) + ); + + return $result; + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/class_call_parent_clone.phpt b/deps/phpunit-mock-objects/Tests/MockObject/class_call_parent_clone.phpt new file mode 100644 index 00000000000..784031f825e --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/class_call_parent_clone.phpt @@ -0,0 +1,82 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + parent::__clone(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + diff --git a/deps/phpunit-mock-objects/Tests/MockObject/class_call_parent_constructor.phpt b/deps/phpunit-mock-objects/Tests/MockObject/class_call_parent_constructor.phpt new file mode 100644 index 00000000000..f9c1040154e --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/class_call_parent_constructor.phpt @@ -0,0 +1,81 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + diff --git a/deps/phpunit-mock-objects/Tests/MockObject/class_dont_call_parent_clone.phpt b/deps/phpunit-mock-objects/Tests/MockObject/class_dont_call_parent_clone.phpt new file mode 100644 index 00000000000..5d337bc421b --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/class_dont_call_parent_clone.phpt @@ -0,0 +1,81 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', FALSE) +--FILE-- + +--EXPECTF-- +class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + diff --git a/deps/phpunit-mock-objects/Tests/MockObject/class_dont_call_parent_constructor.phpt b/deps/phpunit-mock-objects/Tests/MockObject/class_dont_call_parent_constructor.phpt new file mode 100644 index 00000000000..f9c1040154e --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/class_dont_call_parent_constructor.phpt @@ -0,0 +1,81 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + diff --git a/deps/phpunit-mock-objects/Tests/MockObject/class_implementing_interface_call_parent_constructor.phpt b/deps/phpunit-mock-objects/Tests/MockObject/class_implementing_interface_call_parent_constructor.phpt new file mode 100644 index 00000000000..66a2af86e5c --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/class_implementing_interface_call_parent_constructor.phpt @@ -0,0 +1,86 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + diff --git a/deps/phpunit-mock-objects/Tests/MockObject/class_implementing_interface_dont_call_parent_constructor.phpt b/deps/phpunit-mock-objects/Tests/MockObject/class_implementing_interface_dont_call_parent_constructor.phpt new file mode 100644 index 00000000000..66a2af86e5c --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/class_implementing_interface_dont_call_parent_constructor.phpt @@ -0,0 +1,86 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + diff --git a/deps/phpunit-mock-objects/Tests/MockObject/class_partial.phpt b/deps/phpunit-mock-objects/Tests/MockObject/class_partial.phpt new file mode 100644 index 00000000000..0720b13fbb3 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/class_partial.phpt @@ -0,0 +1,107 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array('bar'), 'MockFoo', TRUE, TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function bar(Foo $foo) + { + $arguments = array($foo); + $count = func_num_args(); + + if ($count > 1) { + $_arguments = func_get_args(); + + for ($i = 1; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = $this->__phpunit_getInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Object( + 'Foo', 'bar', $arguments, $this, TRUE + ) + ); + + return $result; + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/interface.phpt b/deps/phpunit-mock-objects/Tests/MockObject/interface.phpt new file mode 100644 index 00000000000..6a4c8436707 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/interface.phpt @@ -0,0 +1,101 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function bar(Foo $foo) + { + $arguments = array($foo); + $count = func_num_args(); + + if ($count > 1) { + $_arguments = func_get_args(); + + for ($i = 1; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = $this->__phpunit_getInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Object( + 'Foo', 'bar', $arguments, $this, TRUE + ) + ); + + return $result; + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/invocation_object_clone_object.phpt b/deps/phpunit-mock-objects/Tests/MockObject/invocation_object_clone_object.phpt new file mode 100644 index 00000000000..685bf2e8146 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/invocation_object_clone_object.phpt @@ -0,0 +1,130 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE, TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function bar(Foo $foo) + { + $arguments = array($foo); + $count = func_num_args(); + + if ($count > 1) { + $_arguments = func_get_args(); + + for ($i = 1; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = $this->__phpunit_getInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Object( + 'Foo', 'bar', $arguments, $this, TRUE + ) + ); + + return $result; + } + + public function baz(Foo $foo) + { + $arguments = array($foo); + $count = func_num_args(); + + if ($count > 1) { + $_arguments = func_get_args(); + + for ($i = 1; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = $this->__phpunit_getInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Object( + 'Foo', 'baz', $arguments, $this, TRUE + ) + ); + + return $result; + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/invocation_static_clone_object.phpt b/deps/phpunit-mock-objects/Tests/MockObject/invocation_static_clone_object.phpt new file mode 100644 index 00000000000..469b0b3c793 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/invocation_static_clone_object.phpt @@ -0,0 +1,130 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE, TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public static function bar(Foo $foo) + { + $arguments = array($foo); + $count = func_num_args(); + + if ($count > 1) { + $_arguments = func_get_args(); + + for ($i = 1; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = self::__phpunit_getStaticInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Static( + 'Foo', 'bar', $arguments, TRUE + ) + ); + + return $result; + } + + public static function baz(Foo $foo) + { + $arguments = array($foo); + $count = func_num_args(); + + if ($count > 1) { + $_arguments = func_get_args(); + + for ($i = 1; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = self::__phpunit_getStaticInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Static( + 'Foo', 'baz', $arguments, TRUE + ) + ); + + return $result; + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class.phpt b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class.phpt new file mode 100644 index 00000000000..d63c4ceb372 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class.phpt @@ -0,0 +1,131 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE, TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function bar(NS\Foo $foo) + { + $arguments = array($foo); + $count = func_num_args(); + + if ($count > 1) { + $_arguments = func_get_args(); + + for ($i = 1; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = $this->__phpunit_getInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Object( + 'NS\Foo', 'bar', $arguments, $this, TRUE + ) + ); + + return $result; + } + + public function baz(NS\Foo $foo) + { + $arguments = array($foo); + $count = func_num_args(); + + if ($count > 1) { + $_arguments = func_get_args(); + + for ($i = 1; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = $this->__phpunit_getInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Object( + 'NS\Foo', 'baz', $arguments, $this, TRUE + ) + ); + + return $result; + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_call_parent_clone.phpt b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_call_parent_clone.phpt new file mode 100644 index 00000000000..1531f1dea19 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_call_parent_clone.phpt @@ -0,0 +1,84 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + parent::__clone(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + diff --git a/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_call_parent_constructor.phpt b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_call_parent_constructor.phpt new file mode 100644 index 00000000000..20b3bb9b8e6 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_call_parent_constructor.phpt @@ -0,0 +1,83 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + diff --git a/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_dont_call_parent_clone.phpt b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_dont_call_parent_clone.phpt new file mode 100644 index 00000000000..1c800797662 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_dont_call_parent_clone.phpt @@ -0,0 +1,83 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', FALSE) +--FILE-- + +--EXPECTF-- +class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + diff --git a/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_dont_call_parent_constructor.phpt b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_dont_call_parent_constructor.phpt new file mode 100644 index 00000000000..20b3bb9b8e6 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_dont_call_parent_constructor.phpt @@ -0,0 +1,83 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + diff --git a/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_implementing_interface_call_parent_constructor.phpt b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_implementing_interface_call_parent_constructor.phpt new file mode 100644 index 00000000000..ffee89775c8 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_implementing_interface_call_parent_constructor.phpt @@ -0,0 +1,88 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + diff --git a/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_implementing_interface_dont_call_parent_constructor.phpt b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_implementing_interface_dont_call_parent_constructor.phpt new file mode 100644 index 00000000000..ffee89775c8 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_implementing_interface_dont_call_parent_constructor.phpt @@ -0,0 +1,88 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + diff --git a/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_partial.phpt b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_partial.phpt new file mode 100644 index 00000000000..3bea847bb6d --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_class_partial.phpt @@ -0,0 +1,109 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array('bar'), 'MockFoo', TRUE, TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function bar(NS\Foo $foo) + { + $arguments = array($foo); + $count = func_num_args(); + + if ($count > 1) { + $_arguments = func_get_args(); + + for ($i = 1; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = $this->__phpunit_getInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Object( + 'NS\Foo', 'bar', $arguments, $this, TRUE + ) + ); + + return $result; + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/namespaced_interface.phpt b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_interface.phpt new file mode 100644 index 00000000000..077ac08aa7c --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/namespaced_interface.phpt @@ -0,0 +1,103 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE, TRUE) +--FILE-- + +--EXPECTF-- +class MockFoo implements PHPUnit_Framework_MockObject_MockObject, NS\Foo +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function bar(NS\Foo $foo) + { + $arguments = array($foo); + $count = func_num_args(); + + if ($count > 1) { + $_arguments = func_get_args(); + + for ($i = 1; $i < $count; $i++) { + $arguments[] = $_arguments[$i]; + } + } + + $result = $this->__phpunit_getInvocationMocker()->invoke( + new PHPUnit_Framework_MockObject_Invocation_Object( + 'NS\Foo', 'bar', $arguments, $this, TRUE + ) + ); + + return $result; + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/nonexistent_class.phpt b/deps/phpunit-mock-objects/Tests/MockObject/nonexistent_class.phpt new file mode 100644 index 00000000000..f5be8d25ce1 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/nonexistent_class.phpt @@ -0,0 +1,78 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE) +--FILE-- + +--EXPECTF-- +class Foo +{ +} + +class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/nonexistent_class_with_namespace.phpt b/deps/phpunit-mock-objects/Tests/MockObject/nonexistent_class_with_namespace.phpt new file mode 100644 index 00000000000..b6c8f546663 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/nonexistent_class_with_namespace.phpt @@ -0,0 +1,86 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE) +--FILE-- + +--EXPECTF-- +namespace NS { + +class Foo +{ +} + +} + +namespace { + +class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/nonexistent_class_with_namespace_starting_with_separator.phpt b/deps/phpunit-mock-objects/Tests/MockObject/nonexistent_class_with_namespace_starting_with_separator.phpt new file mode 100644 index 00000000000..2e0bfb2ba2a --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/nonexistent_class_with_namespace_starting_with_separator.phpt @@ -0,0 +1,86 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE) +--FILE-- + +--EXPECTF-- +namespace NS { + +class Foo +{ +} + +} + +namespace { + +class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject +{ + private static $__phpunit_staticInvocationMocker; + private $__phpunit_invocationMocker; + + public function __clone() + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); + } + + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return $this->__phpunit_getInvocationMocker()->expects($matcher); + } + + public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + { + return self::__phpunit_getStaticInvocationMocker()->expects($matcher); + } + + public function __phpunit_getInvocationMocker() + { + if ($this->__phpunit_invocationMocker === NULL) { + $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return $this->__phpunit_invocationMocker; + } + + public static function __phpunit_getStaticInvocationMocker() + { + if (self::$__phpunit_staticInvocationMocker === NULL) { + self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; + } + + return self::$__phpunit_staticInvocationMocker; + } + + public function __phpunit_hasMatchers() + { + return self::__phpunit_getStaticInvocationMocker()->hasMatchers() || + $this->__phpunit_getInvocationMocker()->hasMatchers(); + } + + public function __phpunit_verify() + { + self::__phpunit_getStaticInvocationMocker()->verify(); + $this->__phpunit_getInvocationMocker()->verify(); + } + + public function __phpunit_cleanup() + { + self::$__phpunit_staticInvocationMocker = NULL; + $this->__phpunit_invocationMocker = NULL; + } +} + +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/wsdl_class.phpt b/deps/phpunit-mock-objects/Tests/MockObject/wsdl_class.phpt new file mode 100644 index 00000000000..52c9839efce --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/wsdl_class.phpt @@ -0,0 +1,36 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch') +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +class GoogleSearch extends \SOAPClient +{ + public function __construct($wsdl, array $options) + { + parent::__construct('%s/GoogleSearch.wsdl', $options); + } + + public function doGetCachedPage($key, $url) + { + } + + public function doSpellingSuggestion($key, $phrase) + { + } + + public function doGoogleSearch($key, $q, $start, $maxResults, $filter, $restrict, $safeSearch, $lr, $ie, $oe) + { + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/wsdl_class_namespace.phpt b/deps/phpunit-mock-objects/Tests/MockObject/wsdl_class_namespace.phpt new file mode 100644 index 00000000000..b3075c543a0 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/wsdl_class_namespace.phpt @@ -0,0 +1,38 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch') +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +namespace My\Space; + +class GoogleSearch extends \SOAPClient +{ + public function __construct($wsdl, array $options) + { + parent::__construct('%s/GoogleSearch.wsdl', $options); + } + + public function doGetCachedPage($key, $url) + { + } + + public function doSpellingSuggestion($key, $phrase) + { + } + + public function doGoogleSearch($key, $q, $start, $maxResults, $filter, $restrict, $safeSearch, $lr, $ie, $oe) + { + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObject/wsdl_class_partial.phpt b/deps/phpunit-mock-objects/Tests/MockObject/wsdl_class_partial.phpt new file mode 100644 index 00000000000..4a69f266c05 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObject/wsdl_class_partial.phpt @@ -0,0 +1,29 @@ +--TEST-- +PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch', array('doGoogleSearch')) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +class GoogleSearch extends \SOAPClient +{ + public function __construct($wsdl, array $options) + { + parent::__construct('%s/GoogleSearch.wsdl', $options); + } + + public function doGoogleSearch($key, $q, $start, $maxResults, $filter, $restrict, $safeSearch, $lr, $ie, $oe) + { + } +} diff --git a/deps/phpunit-mock-objects/Tests/MockObjectTest.php b/deps/phpunit-mock-objects/Tests/MockObjectTest.php new file mode 100644 index 00000000000..7e8c5cf2180 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/MockObjectTest.php @@ -0,0 +1,648 @@ +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @copyright 2010-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 + */ + +require_once 'PHPUnit/Framework/TestCase.php'; + +require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'AbstractMockTestClass.php'; +require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'AnInterface.php'; +require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'FunctionCallback.php'; +require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'MethodCallback.php'; +require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'MethodCallbackByReference.php'; +require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'PartialMockTestClass.php'; +require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'SomeClass.php'; +require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'StaticMockTestClass.php'; + +/** + * + * + * @package PHPUnit_MockObject + * @author Sebastian Bergmann + * @author Patrick Mueller + * @author Frank Kleine + * @copyright 2010-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @version Release: @package_version@ + * @link http://www.phpunit.de/ + * @since Class available since Release 3.0.0 + */ +class Framework_MockObjectTest extends PHPUnit_Framework_TestCase +{ + public function testMockedMethodIsNeverCalled() + { + $mock = $this->getMock('AnInterface'); + $mock->expects($this->never()) + ->method('doSomething'); + } + + public function testMockedMethodIsNotCalledWhenExpectsAnyWithParameter() + { + $mock = $this->getMock('SomeClass'); + $mock->expects($this->any()) + ->method('doSomethingElse') + ->with('someArg'); + } + + public function testMockedMethodIsCalledAtLeastOnce() + { + $mock = $this->getMock('AnInterface'); + $mock->expects($this->atLeastOnce()) + ->method('doSomething'); + + $mock->doSomething(); + } + + public function testMockedMethodIsCalledAtLeastOnce2() + { + $mock = $this->getMock('AnInterface'); + $mock->expects($this->atLeastOnce()) + ->method('doSomething'); + + $mock->doSomething(); + $mock->doSomething(); + } + + public function testMockedMethodIsCalledOnce() + { + $mock = $this->getMock('AnInterface'); + $mock->expects($this->once()) + ->method('doSomething'); + + $mock->doSomething(); + } + + public function testMockedMethodIsCalledOnceWithParameter() + { + $mock = $this->getMock('SomeClass'); + $mock->expects($this->once()) + ->method('doSomethingElse') + ->with($this->equalTo('something')); + + $mock->doSomethingElse('something'); + } + + public function testMockedMethodIsCalledExactly() + { + $mock = $this->getMock('AnInterface'); + $mock->expects($this->exactly(2)) + ->method('doSomething'); + + $mock->doSomething(); + $mock->doSomething(); + } + + public function testStubbedException() + { + $mock = $this->getMock('AnInterface'); + $mock->expects($this->any()) + ->method('doSomething') + ->will($this->throwException(new Exception)); + + try { + $mock->doSomething(); + } + + catch (Exception $e) { + return; + } + + $this->fail(); + } + + public function testStubbedReturnValue() + { + $mock = $this->getMock('AnInterface'); + $mock->expects($this->any()) + ->method('doSomething') + ->will($this->returnValue('something')); + + $this->assertEquals('something', $mock->doSomething()); + } + + public function testStubbedReturnValueMap() + { + $map = array( + array('a', 'b', 'c', 'd'), + array('e', 'f', 'g', 'h') + ); + + $mock = $this->getMock('AnInterface'); + $mock->expects($this->any()) + ->method('doSomething') + ->will($this->returnValueMap($map)); + + $this->assertEquals('d', $mock->doSomething('a', 'b', 'c')); + $this->assertEquals('h', $mock->doSomething('e', 'f', 'g')); + $this->assertEquals(NULL, $mock->doSomething('foo', 'bar')); + } + + public function testFunctionCallback() + { + $mock = $this->getMock('SomeClass', array('doSomething'), array(), '', FALSE); + $mock->expects($this->once()) + ->method('doSomething') + ->will($this->returnCallback('functionCallback')); + + $this->assertEquals('pass', $mock->doSomething('foo', 'bar')); + } + + public function testStaticMethodCallback() + { + $mock = $this->getMock('SomeClass', array('doSomething'), array(), '', FALSE); + $mock->expects($this->once()) + ->method('doSomething') + ->will($this->returnCallback(array('MethodCallback', 'staticCallback'))); + + $this->assertEquals('pass', $mock->doSomething('foo', 'bar')); + } + + public function testPublicMethodCallback() + { + $mock = $this->getMock('SomeClass', array('doSomething'), array(), '', FALSE); + $mock->expects($this->once()) + ->method('doSomething') + ->will($this->returnCallback(array(new MethodCallback, 'nonStaticCallback'))); + + $this->assertEquals('pass', $mock->doSomething('foo', 'bar')); + } + + public function testMockClassOnlyGeneratedOnce() + { + $mock1 = $this->getMock('AnInterface'); + $mock2 = $this->getMock('AnInterface'); + + $this->assertEquals(get_class($mock1), get_class($mock2)); + } + + public function testMockClassDifferentForPartialMocks() + { + $mock1 = $this->getMock('PartialMockTestClass'); + $mock2 = $this->getMock('PartialMockTestClass', array('doSomething')); + $mock3 = $this->getMock('PartialMockTestClass', array('doSomething')); + $mock4 = $this->getMock('PartialMockTestClass', array('doAnotherThing')); + $mock5 = $this->getMock('PartialMockTestClass', array('doAnotherThing')); + + $this->assertNotEquals(get_class($mock1), get_class($mock2)); + $this->assertNotEquals(get_class($mock1), get_class($mock3)); + $this->assertNotEquals(get_class($mock1), get_class($mock4)); + $this->assertNotEquals(get_class($mock1), get_class($mock5)); + $this->assertEquals(get_class($mock2), get_class($mock3)); + $this->assertNotEquals(get_class($mock2), get_class($mock4)); + $this->assertNotEquals(get_class($mock2), get_class($mock5)); + $this->assertEquals(get_class($mock4), get_class($mock5)); + } + + public function testMockClassStoreOverrulable() + { + $mock1 = $this->getMock('PartialMockTestClass'); + $mock2 = $this->getMock('PartialMockTestClass', array(), array(), 'MyMockClassNameForPartialMockTestClass1'); + $mock3 = $this->getMock('PartialMockTestClass'); + $mock4 = $this->getMock('PartialMockTestClass', array('doSomething'), array(), 'AnotherMockClassNameForPartialMockTestClass'); + $mock5 = $this->getMock('PartialMockTestClass', array(), array(), 'MyMockClassNameForPartialMockTestClass2'); + + $this->assertNotEquals(get_class($mock1), get_class($mock2)); + $this->assertEquals(get_class($mock1), get_class($mock3)); + $this->assertNotEquals(get_class($mock1), get_class($mock4)); + $this->assertNotEquals(get_class($mock2), get_class($mock3)); + $this->assertNotEquals(get_class($mock2), get_class($mock4)); + $this->assertNotEquals(get_class($mock2), get_class($mock5)); + $this->assertNotEquals(get_class($mock3), get_class($mock4)); + $this->assertNotEquals(get_class($mock3), get_class($mock5)); + $this->assertNotEquals(get_class($mock4), get_class($mock5)); + } + + /** + * @covers PHPUnit_Framework_MockObject_Generator::getMock + */ + public function testGetMockWithFixedClassNameCanProduceTheSameMockTwice() + { + $mock = $this->getMockBuilder('StdClass')->setMockClassName('FixedName')->getMock(); + $mock = $this->getMockBuilder('StdClass')->setMockClassName('FixedName')->getMock(); + $this->assertInstanceOf('StdClass', $mock); + } + + public function testOriginalConstructorSettingConsidered() + { + $mock1 = $this->getMock('PartialMockTestClass'); + $mock2 = $this->getMock('PartialMockTestClass', array(), array(), '', FALSE); + + $this->assertTrue($mock1->constructorCalled); + $this->assertFalse($mock2->constructorCalled); + } + + public function testOriginalCloneSettingConsidered() + { + $mock1 = $this->getMock('PartialMockTestClass'); + $mock2 = $this->getMock('PartialMockTestClass', array(), array(), '', TRUE, FALSE); + + $this->assertNotEquals(get_class($mock1), get_class($mock2)); + } + + public function testStubbedReturnValueForStaticMethod() + { + $this->getMockClass( + 'StaticMockTestClass', + array('doSomething'), + array(), + 'StaticMockTestClassMock' + ); + + StaticMockTestClassMock::staticExpects($this->any()) + ->method('doSomething') + ->will($this->returnValue('something')); + + $this->assertEquals( + 'something', StaticMockTestClassMock::doSomething() + ); + } + + public function testStubbedReturnValueForStaticMethod2() + { + $this->getMockClass( + 'StaticMockTestClass', + array('doSomething'), + array(), + 'StaticMockTestClassMock2' + ); + + StaticMockTestClassMock2::staticExpects($this->any()) + ->method('doSomething') + ->will($this->returnValue('something')); + + $this->assertEquals( + 'something', StaticMockTestClassMock2::doSomethingElse() + ); + } + + public function testGetMockForAbstractClass() + { + $mock = $this->getMock('AbstractMockTestClass'); + $mock->expects($this->never()) + ->method('doSomething'); + } + + public function testClonedMockObjectShouldStillEqualTheOriginal() + { + $a = $this->getMock('stdClass'); + $b = clone $a; + $this->assertEquals($a, $b); + } + + public function testMockObjectsConstructedIndepentantlyShouldBeEqual() + { + $a = $this->getMock('stdClass'); + $b = $this->getMock('stdClass'); + $this->assertEquals($a, $b); + } + + public function testMockObjectsConstructedIndepentantlyShouldNotBeTheSame() + { + $a = $this->getMock('stdClass'); + $b = $this->getMock('stdClass'); + $this->assertNotSame($a, $b); + } + + public function testClonedMockObjectCanBeUsedInPlaceOfOriginalOne() + { + $x = $this->getMock('stdClass'); + $y = clone $x; + + $mock = $this->getMock('stdClass', array('foo')); + $mock->expects($this->once())->method('foo')->with($this->equalTo($x)); + $mock->foo($y); + } + + public function testClonedMockObjectIsNotIdenticalToOriginalOne() + { + $x = $this->getMock('stdClass'); + $y = clone $x; + + $mock = $this->getMock('stdClass', array('foo')); + $mock->expects($this->once())->method('foo')->with($this->logicalNot($this->identicalTo($x))); + $mock->foo($y); + } + + public function testStaticMethodCallWithArgumentCloningEnabled() + { + $expectedObject = new StdClass; + + $this->getMockClass( + 'StaticMockTestClass', + array('doSomething'), + array(), + 'StaticMockTestClassMock3', + FALSE, + TRUE, + TRUE, + TRUE + ); + + $actualArguments = array(); + + StaticMockTestClassMock3::staticExpects($this->any()) + ->method('doSomething') + ->will($this->returnCallback(function() use (&$actualArguments) { + $actualArguments = func_get_args(); + })); + + StaticMockTestClassMock3::doSomething($expectedObject); + + $this->assertEquals(1, count($actualArguments)); + $this->assertNotSame($expectedObject, $actualArguments[0]); + } + + public function testStaticMethodCallWithArgumentCloningDisabled() + { + $expectedObject = new StdClass; + + $this->getMockClass( + 'StaticMockTestClass', + array('doSomething'), + array(), + 'StaticMockTestClassMock4', + FALSE, + TRUE, + TRUE, + FALSE + ); + + $actualArguments = array(); + + StaticMockTestClassMock4::staticExpects($this->any()) + ->method('doSomething') + ->will($this->returnCallback(function() use (&$actualArguments) { + $actualArguments = func_get_args(); + })); + + StaticMockTestClassMock4::doSomething($expectedObject); + + $this->assertEquals(1, count($actualArguments)); + $this->assertEquals($expectedObject, $actualArguments[0]); + $this->assertSame($expectedObject, $actualArguments[0]); + } + + public function testObjectMethodCallWithArgumentCloningEnabled() + { + $expectedObject = new StdClass; + + $mock = $this->getMockBuilder('SomeClass') + ->setMethods(array('doSomethingElse')) + ->enableArgumentCloning() + ->getMock(); + + $actualArguments = array(); + + $mock->expects($this->any()) + ->method('doSomethingElse') + ->will($this->returnCallback(function() use (&$actualArguments) { + $actualArguments = func_get_args(); + })); + + $mock->doSomethingElse($expectedObject); + + $this->assertEquals(1, count($actualArguments)); + $this->assertEquals($expectedObject, $actualArguments[0]); + $this->assertNotSame($expectedObject, $actualArguments[0]); + } + + public function testObjectMethodCallWithArgumentCloningDisabled() + { + $expectedObject = new StdClass; + + $mock = $this->getMockBuilder('SomeClass') + ->setMethods(array('doSomethingElse')) + ->disableArgumentCloning() + ->getMock(); + + $actualArguments = array(); + + $mock->expects($this->any()) + ->method('doSomethingElse') + ->will($this->returnCallback(function() use (&$actualArguments) { + $actualArguments = func_get_args(); + })); + + $mock->doSomethingElse($expectedObject); + + $this->assertEquals(1, count($actualArguments)); + $this->assertSame($expectedObject, $actualArguments[0]); + } + + public function testArgumentCloningOptionGeneratesUniqueMock() + { + $mockWithCloning = $this->getMockBuilder('SomeClass') + ->setMethods(array('doSomethingElse')) + ->enableArgumentCloning() + ->getMock(); + + $mockWithoutCloning = $this->getMockBuilder('SomeClass') + ->setMethods(array('doSomethingElse')) + ->disableArgumentCloning() + ->getMock(); + + $this->assertNotEquals($mockWithCloning, $mockWithoutCloning); + } + + public function testVerificationOfMethodNameFailsWithoutParameters() + { + $mock = $this->getMock('SomeClass', array('right', 'wrong'), array(), '', TRUE, TRUE, TRUE); + $mock->expects($this->once()) + ->method('right'); + + $mock->wrong(); + try { + $mock->__phpunit_verify(); + $this->fail('Expected exception'); + } catch (PHPUnit_Framework_ExpectationFailedException $e) { + $this->assertSame( + "Expectation failed for method name is equal to when invoked 1 time(s).\n" + . 'Method was expected to be called 1 times, actually called 0 times.', + $e->getMessage() + ); + } + + $this->resetMockObjects(); + } + + public function testVerificationOfMethodNameFailsWithParameters() + { + $mock = $this->getMock('SomeClass', array('right', 'wrong'), array(), '', TRUE, TRUE, TRUE); + $mock->expects($this->once()) + ->method('right'); + + $mock->wrong(); + try { + $mock->__phpunit_verify(); + $this->fail('Expected exception'); + } catch (PHPUnit_Framework_ExpectationFailedException $e) { + $this->assertSame( + "Expectation failed for method name is equal to when invoked 1 time(s).\n" + . 'Method was expected to be called 1 times, actually called 0 times.', + $e->getMessage() + ); + } + + $this->resetMockObjects(); + } + + public function testVerificationOfNeverFailsWithEmptyParameters() + { + $mock = $this->getMock('SomeClass', array('right', 'wrong'), array(), '', TRUE, TRUE, TRUE); + $mock->expects($this->never()) + ->method('right') + ->with(); + + try { + $mock->right(); + $this->fail('Expected exception'); + } catch (PHPUnit_Framework_ExpectationFailedException $e) { + $this->assertSame( + 'SomeClass::right() was not expected to be called.', + $e->getMessage() + ); + } + + $this->resetMockObjects(); + } + + public function testVerificationOfNeverFailsWithAnyParameters() + { + $mock = $this->getMock('SomeClass', array('right', 'wrong'), array(), '', TRUE, TRUE, TRUE); + $mock->expects($this->never()) + ->method('right') + ->withAnyParameters(); + + try { + $mock->right(); + $this->fail('Expected exception'); + } catch (PHPUnit_Framework_ExpectationFailedException $e) { + $this->assertSame( + 'SomeClass::right() was not expected to be called.', + $e->getMessage() + ); + } + + $this->resetMockObjects(); + } + + public function testMockArgumentsPassedByReference() { + $foo = $this->getMockBuilder('MethodCallbackByReference') + ->setMethods(array('bar')) + ->disableOriginalConstructor() + ->disableArgumentCloning() + ->getMock(); + + $foo->expects($this->any()) + ->method('bar') + ->will($this->returnCallback(array($foo, 'callback'))); + + $a = $b = $c = 0; + + $foo->bar($a, $b, $c); + + $this->assertEquals(1, $b); + } + + public function testMockArgumentsPassedByReference2() { + $foo = $this->getMockBuilder('MethodCallbackByReference') + ->disableOriginalConstructor() + ->disableArgumentCloning() + ->getMock(); + + $foo->expects($this->any()) + ->method('bar') + ->will($this->returnCallback( + function ($a, &$b, $c) { + $b = 1; + } + )); + + $a = $b = $c = 0; + + $foo->bar($a, $b, $c); + + $this->assertEquals(1, $b); + } + + /** + * @requires extension soap + */ + public function testCreateMockFromWsdl() + { + $mock = $this->getMockFromWsdl(__DIR__ . '/_files/GoogleSearch.wsdl', 'WsdlMock'); + $this->assertStringStartsWith( + 'Mock_WsdlMock_', + get_class($mock) + ); + } + + /** + * @requires extension soap + */ + public function testCreateNamespacedMockFromWsdl() + { + $mock = $this->getMockFromWsdl(__DIR__ . '/_files/GoogleSearch.wsdl', 'My\\Space\\WsdlMock'); + $this->assertStringStartsWith( + 'Mock_WsdlMock_', + get_class($mock) + ); + } + + /** + * @requires extension soap + */ + public function testCreateTwoMocksOfOneWsdlFile() + { + $mock = $this->getMockFromWsdl(__DIR__ . '/_files/GoogleSearch.wsdl'); + $mock = $this->getMockFromWsdl(__DIR__ . '/_files/GoogleSearch.wsdl'); + } + + private function resetMockObjects() + { + $refl = new ReflectionObject($this); + $refl = $refl->getParentClass(); + $prop = $refl->getProperty('mockObjects'); + $prop->setAccessible(true); + $prop->setValue($this, array()); + } +} diff --git a/deps/phpunit-mock-objects/Tests/_files/AbstractMockTestClass.php b/deps/phpunit-mock-objects/Tests/_files/AbstractMockTestClass.php new file mode 100644 index 00000000000..1f2641f1e2b --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/_files/AbstractMockTestClass.php @@ -0,0 +1,5 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deps/phpunit-mock-objects/Tests/_files/MethodCallback.php b/deps/phpunit-mock-objects/Tests/_files/MethodCallback.php new file mode 100644 index 00000000000..f8db62edd39 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/_files/MethodCallback.php @@ -0,0 +1,21 @@ +constructorArgs = array($arg1, $arg2); + } + + public function mockableMethod() + { + // something different from NULL + return TRUE; + } + + public function anotherMockableMethod() + { + // something different from NULL + return TRUE; + } + + public function __clone() + { + $this->cloned = TRUE; + } +} diff --git a/deps/phpunit-mock-objects/Tests/_files/PartialMockTestClass.php b/deps/phpunit-mock-objects/Tests/_files/PartialMockTestClass.php new file mode 100644 index 00000000000..1b119f12789 --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/_files/PartialMockTestClass.php @@ -0,0 +1,18 @@ +constructorCalled = TRUE; + } + + public function doSomething() + { + } + + public function doAnotherThing() + { + } +} diff --git a/deps/phpunit-mock-objects/Tests/_files/SomeClass.php b/deps/phpunit-mock-objects/Tests/_files/SomeClass.php new file mode 100644 index 00000000000..2cd53b21fff --- /dev/null +++ b/deps/phpunit-mock-objects/Tests/_files/SomeClass.php @@ -0,0 +1,13 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deps/phpunit-mock-objects/build/PHPCS/Sniffs/ControlStructures/ControlSignatureSniff.php b/deps/phpunit-mock-objects/build/PHPCS/Sniffs/ControlStructures/ControlSignatureSniff.php new file mode 100644 index 00000000000..bf9d520d384 --- /dev/null +++ b/deps/phpunit-mock-objects/build/PHPCS/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -0,0 +1,22 @@ +getTokens(); + + if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE || + $tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { + + $phpcsFile->addError( + 'Concatenation operator must be surrounded by whitespace', + $stackPtr + ); + } + } +} diff --git a/deps/phpunit-mock-objects/build/PHPCS/ruleset.xml b/deps/phpunit-mock-objects/build/PHPCS/ruleset.xml new file mode 100644 index 00000000000..402f2140b59 --- /dev/null +++ b/deps/phpunit-mock-objects/build/PHPCS/ruleset.xml @@ -0,0 +1,35 @@ + + + Sebastian Bergmann's coding standard + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deps/phpunit-mock-objects/build/phpmd.xml b/deps/phpunit-mock-objects/build/phpmd.xml new file mode 100644 index 00000000000..23ecb8b0b63 --- /dev/null +++ b/deps/phpunit-mock-objects/build/phpmd.xml @@ -0,0 +1,27 @@ + + + + Sebastian Bergmann's ruleset + + + + + + + + + + + + + + + + + + + diff --git a/deps/phpunit-mock-objects/build/travis-ci.xml b/deps/phpunit-mock-objects/build/travis-ci.xml new file mode 100644 index 00000000000..66dad14f2fc --- /dev/null +++ b/deps/phpunit-mock-objects/build/travis-ci.xml @@ -0,0 +1,28 @@ + + + + + + + + + + ../Tests + ../Tests + + + + + + + + + + ../PHPUnit + + ../PHPUnit/Framework/MockObject/Autoload.php + + + + diff --git a/deps/phpunit-mock-objects/composer.json b/deps/phpunit-mock-objects/composer.json new file mode 100644 index 00000000000..583f140361d --- /dev/null +++ b/deps/phpunit-mock-objects/composer.json @@ -0,0 +1,37 @@ +{ + "name": "phpunit/phpunit-mock-objects", + "description": "Mock Object library for PHPUnit", + "type": "library", + "keywords": [ + "xunit", + "mock" + ], + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit-mock-objects/issues", + "irc": "irc://irc.freenode.net/phpunit" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-text-template": "*" + }, + "suggest": { + "ext-soap": "*" + }, + "autoload": { + "classmap": [ + "PHPUnit/" + ] + }, + "include-path": [ + "" + ] +} diff --git a/deps/phpunit-mock-objects/package.xml b/deps/phpunit-mock-objects/package.xml new file mode 100644 index 00000000000..dfa8129612a --- /dev/null +++ b/deps/phpunit-mock-objects/package.xml @@ -0,0 +1,193 @@ + + + PHPUnit_MockObject + pear.phpunit.de + Mock Object library for PHPUnit + Mock Object library for PHPUnit + + Sebastian Bergmann + sb + sb@sebastian-bergmann.de + yes + + 2013-01-13 + + 1.2.3 + 1.2.0 + + + stable + stable + + The BSD 3-Clause License + http://github.com/sebastianbergmann/phpunit-mock-objects/blob/master/README.markdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5.3.3 + + + 1.9.4 + + + Text_Template + pear.phpunit.de + 1.1.1 + + + + + soap + + + + + diff --git a/deps/phpunit-mock-objects/phpunit.xml.dist b/deps/phpunit-mock-objects/phpunit.xml.dist new file mode 100644 index 00000000000..0ce22dffc23 --- /dev/null +++ b/deps/phpunit-mock-objects/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + + + + + Tests + Tests + + + + + + + + + + + + PHPUnit + + PHPUnit/Framework/MockObject/Autoload.php + + + +