first commit
This commit is contained in:
1
vendor/phpunit/phpunit-mock-objects/.gitattributes
vendored
Normal file
1
vendor/phpunit/phpunit-mock-objects/.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.php diff=php
|
7
vendor/phpunit/phpunit-mock-objects/.gitignore
vendored
Normal file
7
vendor/phpunit/phpunit-mock-objects/.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
build/coverage
|
||||
build/logs
|
||||
cache.properties
|
||||
/vendor
|
||||
/composer.lock
|
||||
/composer.phar
|
||||
/.idea
|
67
vendor/phpunit/phpunit-mock-objects/.php_cs
vendored
Normal file
67
vendor/phpunit/phpunit-mock-objects/.php_cs
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
$finder = Symfony\CS\Finder\DefaultFinder::create()
|
||||
->files()
|
||||
->in('src')
|
||||
->in('tests')
|
||||
->name('*.php');
|
||||
|
||||
return Symfony\CS\Config\Config::create()
|
||||
->level(\Symfony\CS\FixerInterface::NONE_LEVEL)
|
||||
->fixers(
|
||||
array(
|
||||
'align_double_arrow',
|
||||
'align_equals',
|
||||
'braces',
|
||||
'concat_with_spaces',
|
||||
'duplicate_semicolon',
|
||||
'elseif',
|
||||
'empty_return',
|
||||
'encoding',
|
||||
'eof_ending',
|
||||
'extra_empty_lines',
|
||||
'function_call_space',
|
||||
'function_declaration',
|
||||
'indentation',
|
||||
'join_function',
|
||||
'line_after_namespace',
|
||||
'linefeed',
|
||||
'list_commas',
|
||||
'lowercase_constants',
|
||||
'lowercase_keywords',
|
||||
'method_argument_space',
|
||||
'multiple_use',
|
||||
'namespace_no_leading_whitespace',
|
||||
'no_blank_lines_after_class_opening',
|
||||
'no_empty_lines_after_phpdocs',
|
||||
'parenthesis',
|
||||
'php_closing_tag',
|
||||
'phpdoc_indent',
|
||||
'phpdoc_no_access',
|
||||
'phpdoc_no_empty_return',
|
||||
'phpdoc_no_package',
|
||||
'phpdoc_params',
|
||||
'phpdoc_scalar',
|
||||
'phpdoc_separation',
|
||||
'phpdoc_to_comment',
|
||||
'phpdoc_trim',
|
||||
'phpdoc_types',
|
||||
'phpdoc_var_without_name',
|
||||
'remove_lines_between_uses',
|
||||
'return',
|
||||
'self_accessor',
|
||||
'short_array_syntax',
|
||||
'short_tag',
|
||||
'single_line_after_imports',
|
||||
'single_quote',
|
||||
'spaces_before_semicolon',
|
||||
'spaces_cast',
|
||||
'ternary_spaces',
|
||||
'trailing_spaces',
|
||||
'trim_array_spaces',
|
||||
'unused_use',
|
||||
'visibility',
|
||||
'whitespacy_lines'
|
||||
)
|
||||
)
|
||||
->finder($finder);
|
||||
|
28
vendor/phpunit/phpunit-mock-objects/.travis.yml
vendored
Normal file
28
vendor/phpunit/phpunit-mock-objects/.travis.yml
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.0snapshot
|
||||
- 7.1
|
||||
- 7.1snapshot
|
||||
- master
|
||||
|
||||
sudo: false
|
||||
|
||||
before_install:
|
||||
- composer self-update
|
||||
- composer clear-cache
|
||||
|
||||
install:
|
||||
- travis_retry composer update --no-interaction --no-ansi --no-progress --no-suggest --optimize-autoloader --prefer-stable
|
||||
|
||||
script:
|
||||
- ./vendor/bin/phpunit --coverage-clover=coverage.xml
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
1
vendor/phpunit/phpunit-mock-objects/CONTRIBUTING.md
vendored
Normal file
1
vendor/phpunit/phpunit-mock-objects/CONTRIBUTING.md
vendored
Normal file
@ -0,0 +1 @@
|
||||
Please refer to [https://github.com/sebastianbergmann/phpunit/blob/master/CONTRIBUTING.md](https://github.com/sebastianbergmann/phpunit/blob/master/CONTRIBUTING.md) for details on how to contribute to this project.
|
33
vendor/phpunit/phpunit-mock-objects/LICENSE
vendored
Normal file
33
vendor/phpunit/phpunit-mock-objects/LICENSE
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
PHPUnit_MockObject
|
||||
|
||||
Copyright (c) 2002-2015, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of Sebastian Bergmann nor the names of his
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
22
vendor/phpunit/phpunit-mock-objects/README.md
vendored
Normal file
22
vendor/phpunit/phpunit-mock-objects/README.md
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
[](https://packagist.org/packages/phpunit/phpunit-mock-objects)
|
||||
[](https://php.net/)
|
||||
[](https://travis-ci.org/sebastianbergmann/phpunit-mock-objects)
|
||||
|
||||
# PHPUnit_MockObject
|
||||
|
||||
**PHPUnit_MockObject** is the default mock object library for PHPUnit.
|
||||
|
||||
## Requirements
|
||||
|
||||
* PHP 5.6 is required but using the latest version of PHP is highly recommended
|
||||
|
||||
## Installation
|
||||
|
||||
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
|
||||
|
||||
composer require phpunit/phpunit-mock-objects
|
||||
|
||||
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/phpunit-mock-objects
|
||||
|
42
vendor/phpunit/phpunit-mock-objects/build.xml
vendored
Normal file
42
vendor/phpunit/phpunit-mock-objects/build.xml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="PHPUnit_MockObjects">
|
||||
<target name="clean" description="Cleanup build artifacts">
|
||||
<delete dir="${basedir}/vendor"/>
|
||||
<delete file="${basedir}/composer.lock"/>
|
||||
|
||||
<delete>
|
||||
<fileset dir="${basedir}/build">
|
||||
<include name="**/*.phar" />
|
||||
</fileset>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="composer" depends="clean" description="Install dependencies with Composer">
|
||||
<tstamp>
|
||||
<format property="thirty.days.ago" pattern="MM/dd/yyyy hh:mm aa" offset="-30" unit="day"/>
|
||||
</tstamp>
|
||||
<delete>
|
||||
<fileset dir="${basedir}">
|
||||
<include name="composer.phar" />
|
||||
<date datetime="${thirty.days.ago}" when="before"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
|
||||
<get src="https://getcomposer.org/composer.phar" dest="${basedir}/composer.phar" skipexisting="true"/>
|
||||
|
||||
<exec executable="php">
|
||||
<arg value="composer.phar"/>
|
||||
<arg value="install"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer">
|
||||
<exec executable="phpcs">
|
||||
<arg value="--standard=PSR2" />
|
||||
<arg value="--extensions=php" />
|
||||
<arg path="${basedir}/src" />
|
||||
<arg path="${basedir}/tests" />
|
||||
</exec>
|
||||
</target>
|
||||
</project>
|
||||
|
53
vendor/phpunit/phpunit-mock-objects/composer.json
vendored
Normal file
53
vendor/phpunit/phpunit-mock-objects/composer.json
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
"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.6 || ^7.0",
|
||||
"phpunit/php-text-template": "^1.2",
|
||||
"doctrine/instantiator": "^1.0.2",
|
||||
"sebastian/exporter": "^1.2 || ^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.4"
|
||||
},
|
||||
"conflict": {
|
||||
"phpunit/phpunit": "<5.4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-soap": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [
|
||||
"tests/_fixture/"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.2.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
vendor/phpunit/phpunit-mock-objects/phpunit.xml
vendored
Normal file
21
vendor/phpunit/phpunit-mock-objects/phpunit.xml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.6/phpunit.xsd"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
backupGlobals="false"
|
||||
beStrictAboutCoversAnnotation="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
beStrictAboutTestsThatDoNotTestAnything="true"
|
||||
beStrictAboutTodoAnnotatedTests="true"
|
||||
verbose="true">
|
||||
<testsuite>
|
||||
<directory suffix="Test.php">tests</directory>
|
||||
<directory suffix=".phpt">tests</directory>
|
||||
</testsuite>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
31
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/Identity.php
vendored
Normal file
31
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/Identity.php
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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().
|
||||
*
|
||||
* @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 identification of expectation.
|
||||
*/
|
||||
public function id($id);
|
||||
}
|
291
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/InvocationMocker.php
vendored
Normal file
291
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/InvocationMocker.php
vendored
Normal file
@ -0,0 +1,291 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $configurableMethods = [];
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Stub_MatcherCollection $collection
|
||||
* @param PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher
|
||||
* @param array $configurableMethods
|
||||
*/
|
||||
public function __construct(PHPUnit_Framework_MockObject_Stub_MatcherCollection $collection, PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher, array $configurableMethods)
|
||||
{
|
||||
$this->collection = $collection;
|
||||
$this->matcher = new PHPUnit_Framework_MockObject_Matcher(
|
||||
$invocationMatcher
|
||||
);
|
||||
|
||||
$this->collection->addMatcher($this->matcher);
|
||||
|
||||
$this->configurableMethods = $configurableMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 $value
|
||||
* @param mixed $nextValues, ...
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function willReturn($value, ...$nextValues)
|
||||
{
|
||||
$stub = count($nextValues) === 0 ?
|
||||
new PHPUnit_Framework_MockObject_Stub_Return($value) :
|
||||
new PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls(
|
||||
array_merge([$value], $nextValues)
|
||||
);
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $reference
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function willReturnReference(&$reference)
|
||||
{
|
||||
$stub = new PHPUnit_Framework_MockObject_Stub_ReturnReference($reference);
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $valueMap
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function willReturnMap(array $valueMap)
|
||||
{
|
||||
$stub = new PHPUnit_Framework_MockObject_Stub_ReturnValueMap(
|
||||
$valueMap
|
||||
);
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $argumentIndex
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function willReturnArgument($argumentIndex)
|
||||
{
|
||||
$stub = new PHPUnit_Framework_MockObject_Stub_ReturnArgument(
|
||||
$argumentIndex
|
||||
);
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable $callback
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function willReturnCallback($callback)
|
||||
{
|
||||
$stub = new PHPUnit_Framework_MockObject_Stub_ReturnCallback(
|
||||
$callback
|
||||
);
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function willReturnSelf()
|
||||
{
|
||||
$stub = new PHPUnit_Framework_MockObject_Stub_ReturnSelf;
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $values, ...
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function willReturnOnConsecutiveCalls(...$values)
|
||||
{
|
||||
$stub = new PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls($values);
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Exception $exception
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function willThrowException(Exception $exception)
|
||||
{
|
||||
$stub = new PHPUnit_Framework_MockObject_Stub_Exception($exception);
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function after($id)
|
||||
{
|
||||
$this->matcher->afterMatchBuilderId = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a parameters matcher can be defined, throw exceptions otherwise.
|
||||
*
|
||||
* @throws PHPUnit_Framework_MockObject_RuntimeException
|
||||
*/
|
||||
private function canDefineParameters()
|
||||
{
|
||||
if ($this->matcher->methodNameMatcher === null) {
|
||||
throw new PHPUnit_Framework_MockObject_RuntimeException(
|
||||
'Method name matcher is not defined, cannot define parameter ' .
|
||||
'matcher without one'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->matcher->parametersMatcher !== null) {
|
||||
throw new PHPUnit_Framework_MockObject_RuntimeException(
|
||||
'Parameter matcher is already defined, cannot redefine'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array ...$arguments
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function with(...$arguments)
|
||||
{
|
||||
$this->canDefineParameters();
|
||||
|
||||
$this->matcher->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_Parameters($arguments);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array ...$arguments
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function withConsecutive(...$arguments)
|
||||
{
|
||||
$this->canDefineParameters();
|
||||
|
||||
$this->matcher->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_ConsecutiveParameters($arguments);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function withAnyParameters()
|
||||
{
|
||||
$this->canDefineParameters();
|
||||
|
||||
$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_MockObject_RuntimeException(
|
||||
'Method name matcher is already defined, cannot redefine'
|
||||
);
|
||||
}
|
||||
|
||||
if (is_string($constraint) && !in_array(strtolower($constraint), $this->configurableMethods)) {
|
||||
throw new PHPUnit_Framework_MockObject_RuntimeException(
|
||||
sprintf(
|
||||
'Trying to configure method "%s" which cannot be configured because it does not exist, has not been specified, is final, or is static',
|
||||
$constraint
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->matcher->methodNameMatcher = new PHPUnit_Framework_MockObject_Matcher_MethodName($constraint);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
27
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/Match.php
vendored
Normal file
27
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/Match.php
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Builder interface for invocation order matches.
|
||||
*
|
||||
* @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);
|
||||
}
|
27
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/MethodNameMatch.php
vendored
Normal file
27
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/MethodNameMatch.php
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Builder interface for matcher of method names.
|
||||
*
|
||||
* @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);
|
||||
}
|
38
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/Namespace.php
vendored
Normal file
38
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/Namespace.php
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for builders which can register builders with a given identification.
|
||||
*
|
||||
* This interface relates to PHPUnit_Framework_MockObject_Builder_Identity.
|
||||
*
|
||||
* @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 identification 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);
|
||||
}
|
49
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/ParametersMatch.php
vendored
Normal file
49
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/ParametersMatch.php
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Builder interface for parameter matchers.
|
||||
*
|
||||
* @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:
|
||||
* <code>
|
||||
* // 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));
|
||||
* </code>
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Builder_ParametersMatch
|
||||
*/
|
||||
public function with(...$arguments);
|
||||
|
||||
/**
|
||||
* Sets a matcher which allows any kind of parameters.
|
||||
*
|
||||
* Some examples:
|
||||
* <code>
|
||||
* // match any number of parameters
|
||||
* $b->withAnyParameters();
|
||||
* </code>
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Matcher_AnyParameters
|
||||
*/
|
||||
public function withAnyParameters();
|
||||
}
|
27
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/Stub.php
vendored
Normal file
27
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Builder/Stub.php
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Builder interface for stubs which are actions replacing an invocation.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Builder_Identity
|
||||
*/
|
||||
public function will(PHPUnit_Framework_MockObject_Stub $stub);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since Class available since Release 2.0.6
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_BadMethodCallException extends BadMethodCallException implements PHPUnit_Framework_MockObject_Exception
|
||||
{
|
||||
}
|
18
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Exception/Exception.php
vendored
Normal file
18
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Exception/Exception.php
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for exceptions used by PHPUnit_MockObject.
|
||||
*
|
||||
* @since Interface available since Release 2.0.6
|
||||
*/
|
||||
interface PHPUnit_Framework_MockObject_Exception
|
||||
{
|
||||
}
|
16
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Exception/RuntimeException.php
vendored
Normal file
16
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Exception/RuntimeException.php
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since Class available since Release 2.0.6
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_RuntimeException extends RuntimeException implements PHPUnit_Framework_MockObject_Exception
|
||||
{
|
||||
}
|
1324
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator.php
vendored
Normal file
1324
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/deprecation.tpl.dist
vendored
Normal file
2
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/deprecation.tpl.dist
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
@trigger_error({deprecation}, E_USER_DEPRECATED);
|
40
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/mocked_class.tpl.dist
vendored
Normal file
40
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/mocked_class.tpl.dist
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
{prologue}{class_declaration}
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = {configurable};
|
||||
|
||||
{clone}{mocked_methods}
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->expects($matcher);
|
||||
}
|
||||
{method}
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}{epilogue}
|
@ -0,0 +1,7 @@
|
||||
|
||||
public function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
4
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/mocked_clone.tpl.dist
vendored
Normal file
4
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/mocked_clone.tpl.dist
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
22
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/mocked_method.tpl.dist
vendored
Normal file
22
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/mocked_method.tpl.dist
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
{modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
|
||||
{{deprecation}
|
||||
$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, '{return_type}', $this, {clone_arguments}
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
|
||||
{modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
|
||||
{{deprecation}
|
||||
$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];
|
||||
}
|
||||
}
|
||||
|
||||
$this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'{class_name}', '{method_name}', $arguments, '{return_type}', $this, {clone_arguments}
|
||||
)
|
||||
);
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
|
||||
{modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
|
||||
{
|
||||
throw new PHPUnit_Framework_MockObject_BadMethodCallException('Static method "{method_name}" cannot be invoked on mock object');
|
||||
}
|
22
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/proxied_method.tpl.dist
vendored
Normal file
22
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/proxied_method.tpl.dist
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
{modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
|
||||
{
|
||||
$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];
|
||||
}
|
||||
}
|
||||
|
||||
$this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'{class_name}', '{method_name}', $arguments, '{return_type}', $this, {clone_arguments}
|
||||
)
|
||||
);
|
||||
|
||||
return call_user_func_array(array($this->__phpunit_originalObject, "{method_name}"), $arguments);
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
|
||||
{modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
|
||||
{
|
||||
$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];
|
||||
}
|
||||
}
|
||||
|
||||
$this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'{class_name}', '{method_name}', $arguments, '{return_type}', $this, {clone_arguments}
|
||||
)
|
||||
);
|
||||
|
||||
call_user_func_array(array($this->__phpunit_originalObject, "{method_name}"), $arguments);
|
||||
}
|
4
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/trait_class.tpl.dist
vendored
Normal file
4
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/trait_class.tpl.dist
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{prologue}class {class_name}
|
||||
{
|
||||
use {trait_name};
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
parent::__clone();
|
||||
}
|
7
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/wsdl_class.tpl.dist
vendored
Normal file
7
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/wsdl_class.tpl.dist
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{namespace}class {class_name} extends \SoapClient
|
||||
{
|
||||
public function __construct($wsdl, array $options)
|
||||
{
|
||||
parent::__construct('{wsdl}', $options);
|
||||
}
|
||||
{methods}}
|
4
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/wsdl_method.tpl.dist
vendored
Normal file
4
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator/wsdl_method.tpl.dist
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
public function {method_name}({arguments})
|
||||
{
|
||||
}
|
22
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Invocation.php
vendored
Normal file
22
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Invocation.php
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for invocations.
|
||||
*
|
||||
* @since Interface available since Release 1.0.0
|
||||
*/
|
||||
interface PHPUnit_Framework_MockObject_Invocation
|
||||
{
|
||||
/**
|
||||
* @return mixed Mocked return value.
|
||||
*/
|
||||
public function generateReturnValue();
|
||||
}
|
37
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Invocation/Object.php
vendored
Normal file
37
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Invocation/Object.php
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a non-static invocation.
|
||||
*
|
||||
* @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 string $returnType
|
||||
* @param object $object
|
||||
* @param bool $cloneObjects
|
||||
*/
|
||||
public function __construct($className, $methodName, array $parameters, $returnType, $object, $cloneObjects = false)
|
||||
{
|
||||
parent::__construct($className, $methodName, $parameters, $returnType, $cloneObjects);
|
||||
|
||||
$this->object = $object;
|
||||
}
|
||||
}
|
207
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Invocation/Static.php
vendored
Normal file
207
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Invocation/Static.php
vendored
Normal file
@ -0,0 +1,207 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
|
||||
/**
|
||||
* Represents a static invocation.
|
||||
*
|
||||
* @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 = [
|
||||
'mysqli' => true,
|
||||
'SQLite' => true,
|
||||
'sqlite3' => true,
|
||||
'tidy' => true,
|
||||
'xmlwriter' => true,
|
||||
'xsl' => true
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $uncloneableClasses = [
|
||||
'Closure',
|
||||
'COMPersistHelper',
|
||||
'IteratorIterator',
|
||||
'RecursiveIteratorIterator',
|
||||
'SplFileObject',
|
||||
'PDORow',
|
||||
'ZipArchive'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $className;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $methodName;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $parameters;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $returnType;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $returnTypeNullable = false;
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $methodName
|
||||
* @param array $parameters
|
||||
* @param string $returnType
|
||||
* @param bool $cloneObjects
|
||||
*/
|
||||
public function __construct($className, $methodName, array $parameters, $returnType, $cloneObjects = false)
|
||||
{
|
||||
$this->className = $className;
|
||||
$this->methodName = $methodName;
|
||||
$this->parameters = $parameters;
|
||||
|
||||
if (strpos($returnType, '?') === 0) {
|
||||
$returnType = substr($returnType, 1);
|
||||
$this->returnTypeNullable = true;
|
||||
}
|
||||
|
||||
$this->returnType = $returnType;
|
||||
|
||||
if (!$cloneObjects) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->parameters as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->parameters[$key] = $this->cloneObject($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
$exporter = new Exporter;
|
||||
|
||||
return sprintf(
|
||||
'%s::%s(%s)%s',
|
||||
$this->className,
|
||||
$this->methodName,
|
||||
implode(
|
||||
', ',
|
||||
array_map(
|
||||
[$exporter, 'shortenedExport'],
|
||||
$this->parameters
|
||||
)
|
||||
),
|
||||
$this->returnType ? sprintf(': %s', $this->returnType) : ''
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed Mocked return value.
|
||||
*/
|
||||
public function generateReturnValue()
|
||||
{
|
||||
switch ($this->returnType) {
|
||||
case '': return;
|
||||
case 'string': return $this->returnTypeNullable ? null : '';
|
||||
case 'float': return $this->returnTypeNullable ? null : 0.0;
|
||||
case 'int': return $this->returnTypeNullable ? null : 0;
|
||||
case 'bool': return $this->returnTypeNullable ? null : false;
|
||||
case 'array': return $this->returnTypeNullable ? null : [];
|
||||
case 'void': return;
|
||||
|
||||
case 'callable':
|
||||
case 'Closure':
|
||||
return function () {};
|
||||
|
||||
case 'Traversable':
|
||||
case 'Generator':
|
||||
$generator = function () { yield; };
|
||||
|
||||
return $generator();
|
||||
|
||||
default:
|
||||
if ($this->returnTypeNullable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
return $generator->getMock($this->returnType, [], [], '', false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
}
|
178
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/InvocationMocker.php
vendored
Normal file
178
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/InvocationMocker.php
vendored
Normal file
@ -0,0 +1,178 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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 = [];
|
||||
|
||||
/**
|
||||
* @var PHPUnit_Framework_MockObject_Builder_Match[]
|
||||
*/
|
||||
protected $builderMap = [];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $configurableMethods = [];
|
||||
|
||||
/**
|
||||
* @param array $configurableMethods
|
||||
*/
|
||||
public function __construct(array $configurableMethods)
|
||||
{
|
||||
$this->configurableMethods = $configurableMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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()
|
||||
{
|
||||
foreach ($this->matchers as $matcher) {
|
||||
if ($matcher->hasMatchers()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return bool|null
|
||||
*/
|
||||
public function lookupId($id)
|
||||
{
|
||||
if (isset($this->builderMap[$id])) {
|
||||
return $this->builderMap[$id];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id
|
||||
* @param PHPUnit_Framework_MockObject_Builder_Match $builder
|
||||
*
|
||||
* @throws PHPUnit_Framework_MockObject_RuntimeException
|
||||
*/
|
||||
public function registerId($id, PHPUnit_Framework_MockObject_Builder_Match $builder)
|
||||
{
|
||||
if (isset($this->builderMap[$id])) {
|
||||
throw new PHPUnit_Framework_MockObject_RuntimeException(
|
||||
'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,
|
||||
$this->configurableMethods
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
$exception = null;
|
||||
$hasReturnValue = false;
|
||||
$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;
|
||||
}
|
||||
|
||||
if ($hasReturnValue) {
|
||||
return $returnValue;
|
||||
} elseif (strtolower($invocation->methodName) == '__tostring') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $invocation->generateReturnValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
foreach ($this->matchers as $matcher) {
|
||||
if (!$matcher->matches($invocation)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
foreach ($this->matchers as $matcher) {
|
||||
$matcher->verify();
|
||||
}
|
||||
}
|
||||
}
|
39
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Invokable.php
vendored
Normal file
39
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Invokable.php
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for classes which can be invoked.
|
||||
*
|
||||
* The invocation will be taken from a mock object and passed to an object
|
||||
* of this class.
|
||||
*
|
||||
* @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 bool
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation);
|
||||
}
|
274
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher.php
vendored
Normal file
274
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher.php
vendored
Normal file
@ -0,0 +1,274 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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 bool
|
||||
*/
|
||||
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 = [];
|
||||
|
||||
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 implode(' ', $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_MockObject_RuntimeException(
|
||||
'No invocation matcher is set'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->methodNameMatcher === null) {
|
||||
throw new PHPUnit_Framework_MockObject_RuntimeException('No method matcher is set');
|
||||
}
|
||||
|
||||
if ($this->afterMatchBuilderId !== null) {
|
||||
$builder = $invocation->object
|
||||
->__phpunit_getInvocationMocker()
|
||||
->lookupId($this->afterMatchBuilderId);
|
||||
|
||||
if (!$builder) {
|
||||
throw new PHPUnit_Framework_MockObject_RuntimeException(
|
||||
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 $invocation->generateReturnValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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_MockObject_RuntimeException(
|
||||
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_MockObject_RuntimeException(
|
||||
'No invocation matcher is set'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->methodNameMatcher === null) {
|
||||
throw new PHPUnit_Framework_MockObject_RuntimeException('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_MockObject_RuntimeException
|
||||
* @throws PHPUnit_Framework_ExpectationFailedException
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
if ($this->invocationMatcher === null) {
|
||||
throw new PHPUnit_Framework_MockObject_RuntimeException(
|
||||
'No invocation matcher is set'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->methodNameMatcher === null) {
|
||||
throw new PHPUnit_Framework_MockObject_RuntimeException('No method matcher is set');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->invocationMatcher->verify();
|
||||
|
||||
if ($this->parametersMatcher === null) {
|
||||
$this->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_AnyParameters;
|
||||
}
|
||||
|
||||
$invocationIsAny = $this->invocationMatcher instanceof PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$invocationIsNever = $this->invocationMatcher instanceof PHPUnit_Framework_MockObject_Matcher_InvokedCount && $this->invocationMatcher->isNever();
|
||||
|
||||
if (!$invocationIsAny && !$invocationIsNever) {
|
||||
$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(),
|
||||
PHPUnit_Framework_TestFailure::exceptionToString($e)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @since Method available since Release 1.2.4
|
||||
*/
|
||||
public function hasMatchers()
|
||||
{
|
||||
if ($this->invocationMatcher !== null &&
|
||||
!$this->invocationMatcher instanceof PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
32
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/AnyInvokedCount.php
vendored
Normal file
32
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/AnyInvokedCount.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Invocation matcher which checks if a method has been invoked zero or more
|
||||
* times. This matcher will always match.
|
||||
*
|
||||
* @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()
|
||||
{
|
||||
}
|
||||
}
|
35
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/AnyParameters.php
vendored
Normal file
35
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/AnyParameters.php
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Invocation matcher which allows any parameters to a method.
|
||||
*
|
||||
* @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 bool
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
126
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/ConsecutiveParameters.php
vendored
Normal file
126
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/ConsecutiveParameters.php
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Invocation matcher which looks for sets of specific parameters in the invocations.
|
||||
*
|
||||
* Checks the parameters of the incoming invocations, the parameter list is
|
||||
* checked against the defined constraints in $parameters. If the constraint
|
||||
* is met it will return true in matches().
|
||||
*
|
||||
* It takes a list of match groups and and increases a call index after each invocation.
|
||||
* So the first invocation uses the first group of constraints, the second the next and so on.
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Matcher_ConsecutiveParameters extends PHPUnit_Framework_MockObject_Matcher_StatelessInvocation
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $parameterGroups = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $invocations = [];
|
||||
|
||||
/**
|
||||
* @param array $parameterGroups
|
||||
*/
|
||||
public function __construct(array $parameterGroups)
|
||||
{
|
||||
foreach ($parameterGroups as $index => $parameters) {
|
||||
foreach ($parameters as $parameter) {
|
||||
if (!$parameter instanceof PHPUnit_Framework_Constraint) {
|
||||
$parameter = new PHPUnit_Framework_Constraint_IsEqual($parameter);
|
||||
}
|
||||
|
||||
$this->parameterGroups[$index][] = $parameter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
$text = 'with consecutive parameters';
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
$this->invocations[] = $invocation;
|
||||
$callIndex = count($this->invocations) - 1;
|
||||
|
||||
$this->verifyInvocation($invocation, $callIndex);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function verify()
|
||||
{
|
||||
foreach ($this->invocations as $callIndex => $invocation) {
|
||||
$this->verifyInvocation($invocation, $callIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify a single invocation
|
||||
*
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
* @param int $callIndex
|
||||
*
|
||||
* @throws PHPUnit_Framework_ExpectationFailedException
|
||||
*/
|
||||
private function verifyInvocation(PHPUnit_Framework_MockObject_Invocation $invocation, $callIndex)
|
||||
{
|
||||
if (isset($this->parameterGroups[$callIndex])) {
|
||||
$parameters = $this->parameterGroups[$callIndex];
|
||||
} else {
|
||||
// no parameter assertion for this call index
|
||||
return;
|
||||
}
|
||||
|
||||
if ($invocation === null) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
'Mocked method does not exist.'
|
||||
);
|
||||
}
|
||||
|
||||
if (count($invocation->parameters) < count($parameters)) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
sprintf(
|
||||
'Parameter count for invocation %s is too low.',
|
||||
$invocation->toString()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($parameters as $i => $parameter) {
|
||||
$parameter->evaluate(
|
||||
$invocation->parameters[$i],
|
||||
sprintf(
|
||||
'Parameter %s for invocation #%d %s does not match expected ' .
|
||||
'value.',
|
||||
$i,
|
||||
$callIndex,
|
||||
$invocation->toString()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
46
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/Invocation.php
vendored
Normal file
46
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/Invocation.php
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for classes which matches an invocation based on its
|
||||
* method name, argument, order or call count.
|
||||
*
|
||||
* @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);
|
||||
}
|
87
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtIndex.php
vendored
Normal file
87
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtIndex.php
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex implements PHPUnit_Framework_MockObject_Matcher_Invocation
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $sequenceIndex;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $currentIndex = -1;
|
||||
|
||||
/**
|
||||
* @param int $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 bool
|
||||
*/
|
||||
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
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
57
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtLeastCount.php
vendored
Normal file
57
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtLeastCount.php
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Invocation matcher which checks if a method has been invoked at least
|
||||
* N times.
|
||||
*
|
||||
* @since Class available since Release 2.2.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastCount extends PHPUnit_Framework_MockObject_Matcher_InvokedRecorder
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $requiredInvocations;
|
||||
|
||||
/**
|
||||
* @param int $requiredInvocations
|
||||
*/
|
||||
public function __construct($requiredInvocations)
|
||||
{
|
||||
$this->requiredInvocations = $requiredInvocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return 'invoked at least ' . $this->requiredInvocations . ' times';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->requiredInvocations) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
'Expected invocation at least ' . $this->requiredInvocations .
|
||||
' times but it occurred ' . $count . ' time(s).'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
45
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtLeastOnce.php
vendored
Normal file
45
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtLeastOnce.php
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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 occurred.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
57
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtMostCount.php
vendored
Normal file
57
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtMostCount.php
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Invocation matcher which checks if a method has been invoked at least
|
||||
* N times.
|
||||
*
|
||||
* @since Class available since Release 2.2.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Matcher_InvokedAtMostCount extends PHPUnit_Framework_MockObject_Matcher_InvokedRecorder
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $allowedInvocations;
|
||||
|
||||
/**
|
||||
* @param int $allowedInvocations
|
||||
*/
|
||||
public function __construct($allowedInvocations)
|
||||
{
|
||||
$this->allowedInvocations = $allowedInvocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return 'invoked at most ' . $this->allowedInvocations . ' times';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->allowedInvocations) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
'Expected invocation at most ' . $this->allowedInvocations .
|
||||
' times but it occurred ' . $count . ' time(s).'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
110
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedCount.php
vendored
Normal file
110
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedCount.php
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Matcher_InvokedCount extends PHPUnit_Framework_MockObject_Matcher_InvokedRecorder
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $expectedCount;
|
||||
|
||||
/**
|
||||
* @param int $expectedCount
|
||||
*/
|
||||
public function __construct($expectedCount)
|
||||
{
|
||||
$this->expectedCount = $expectedCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNever()
|
||||
{
|
||||
return $this->expectedCount == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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() . ' ';
|
||||
|
||||
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
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
68
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedRecorder.php
vendored
Normal file
68
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedRecorder.php
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 occurred.
|
||||
*
|
||||
* @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 = [];
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getInvocationCount()
|
||||
{
|
||||
return count($this->invocations);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Framework_MockObject_Invocation[]
|
||||
*/
|
||||
public function getInvocations()
|
||||
{
|
||||
return $this->invocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
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 bool
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
68
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/MethodName.php
vendored
Normal file
68
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/MethodName.php
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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().
|
||||
*
|
||||
* @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 bool
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
return $this->constraint->evaluate($invocation->methodName, '', true);
|
||||
}
|
||||
}
|
158
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/Parameters.php
vendored
Normal file
158
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/Parameters.php
vendored
Normal file
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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().
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Matcher_Parameters extends PHPUnit_Framework_MockObject_Matcher_StatelessInvocation
|
||||
{
|
||||
/**
|
||||
* @var PHPUnit_Framework_Constraint[]
|
||||
*/
|
||||
protected $parameters = [];
|
||||
|
||||
/**
|
||||
* @var PHPUnit_Framework_MockObject_Invocation
|
||||
*/
|
||||
protected $invocation;
|
||||
|
||||
/**
|
||||
* @var PHPUnit_Framework_ExpectationFailedException
|
||||
*/
|
||||
private $parameterVerificationResult;
|
||||
|
||||
/**
|
||||
* @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 bool
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
$this->invocation = $invocation;
|
||||
$this->parameterVerificationResult = null;
|
||||
|
||||
try {
|
||||
$this->parameterVerificationResult = $this->verify();
|
||||
|
||||
return $this->parameterVerificationResult;
|
||||
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
|
||||
$this->parameterVerificationResult = $e;
|
||||
|
||||
throw $this->parameterVerificationResult;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws PHPUnit_Framework_ExpectationFailedException
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
if (isset($this->parameterVerificationResult)) {
|
||||
return $this->guardAgainstDuplicateEvaluationOfParameterConstraints();
|
||||
}
|
||||
|
||||
if ($this->invocation === null) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
'Mocked method does not exist.'
|
||||
);
|
||||
}
|
||||
|
||||
if (count($this->invocation->parameters) < count($this->parameters)) {
|
||||
$message = 'Parameter count for invocation %s is too low.';
|
||||
|
||||
// The user called `->with($this->anything())`, but may have meant
|
||||
// `->withAnyParameters()`.
|
||||
//
|
||||
// @see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/199
|
||||
if (count($this->parameters) === 1 &&
|
||||
get_class($this->parameters[0]) === 'PHPUnit_Framework_Constraint_IsAnything') {
|
||||
$message .= "\nTo allow 0 or more parameters with any value, omit ->with() or use ->withAnyParameters() instead.";
|
||||
}
|
||||
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
sprintf($message, $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()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws PHPUnit_Framework_ExpectationFailedException
|
||||
*/
|
||||
private function guardAgainstDuplicateEvaluationOfParameterConstraints()
|
||||
{
|
||||
if ($this->parameterVerificationResult instanceof Exception) {
|
||||
throw $this->parameterVerificationResult;
|
||||
}
|
||||
|
||||
return (bool) $this->parameterVerificationResult;
|
||||
}
|
||||
}
|
54
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/StatelessInvocation.php
vendored
Normal file
54
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/StatelessInvocation.php
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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()
|
||||
{
|
||||
}
|
||||
}
|
408
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/MockBuilder.php
vendored
Normal file
408
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/MockBuilder.php
vendored
Normal file
@ -0,0 +1,408 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the Builder pattern for Mock objects.
|
||||
*
|
||||
* @since File available since Release 1.0.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_MockBuilder
|
||||
{
|
||||
/**
|
||||
* @var PHPUnit_Framework_TestCase
|
||||
*/
|
||||
private $testCase;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $methods = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $methodsExcept = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $mockClassName = '';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $constructorArgs = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $originalConstructor = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $originalClone = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $autoload = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $cloneArguments = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $callOriginalMethods = false;
|
||||
|
||||
/**
|
||||
* @var object
|
||||
*/
|
||||
private $proxyTarget = null;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $allowMockingUnknownTypes = true;
|
||||
|
||||
/**
|
||||
* @var PHPUnit_Framework_MockObject_Generator
|
||||
*/
|
||||
private $generator;
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_TestCase $testCase
|
||||
* @param array|string $type
|
||||
*/
|
||||
public function __construct(PHPUnit_Framework_TestCase $testCase, $type)
|
||||
{
|
||||
$this->testCase = $testCase;
|
||||
$this->type = $type;
|
||||
$this->generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a mock object using a fluent interface.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
public function getMock()
|
||||
{
|
||||
$object = $this->generator->getMock(
|
||||
$this->type,
|
||||
$this->methods,
|
||||
$this->constructorArgs,
|
||||
$this->mockClassName,
|
||||
$this->originalConstructor,
|
||||
$this->originalClone,
|
||||
$this->autoload,
|
||||
$this->cloneArguments,
|
||||
$this->callOriginalMethods,
|
||||
$this->proxyTarget,
|
||||
$this->allowMockingUnknownTypes
|
||||
);
|
||||
|
||||
$this->testCase->registerMockObject($object);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a mock object for an abstract class using a fluent interface.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
public function getMockForAbstractClass()
|
||||
{
|
||||
$object = $this->generator->getMockForAbstractClass(
|
||||
$this->type,
|
||||
$this->constructorArgs,
|
||||
$this->mockClassName,
|
||||
$this->originalConstructor,
|
||||
$this->originalClone,
|
||||
$this->autoload,
|
||||
$this->methods,
|
||||
$this->cloneArguments
|
||||
);
|
||||
|
||||
$this->testCase->registerMockObject($object);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a mock object for a trait using a fluent interface.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
public function getMockForTrait()
|
||||
{
|
||||
$object = $this->generator->getMockForTrait(
|
||||
$this->type,
|
||||
$this->constructorArgs,
|
||||
$this->mockClassName,
|
||||
$this->originalConstructor,
|
||||
$this->originalClone,
|
||||
$this->autoload,
|
||||
$this->methods,
|
||||
$this->cloneArguments
|
||||
);
|
||||
|
||||
$this->testCase->registerMockObject($object);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(array $methods = null)
|
||||
{
|
||||
$this->methods = $methods;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the subset of methods to not mock. Default is to mock all of them.
|
||||
*
|
||||
* @param array $methods
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
*/
|
||||
public function setMethodsExcept(array $methods = [])
|
||||
{
|
||||
$this->methodsExcept = $methods;
|
||||
|
||||
$this->setMethods(
|
||||
array_diff(
|
||||
$this->generator->getClassMethods($this->type),
|
||||
$this->methodsExcept
|
||||
)
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the invocation of the original methods.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
*
|
||||
* @since Method available since Release 2.0.0
|
||||
*/
|
||||
public function enableProxyingToOriginalMethods()
|
||||
{
|
||||
$this->callOriginalMethods = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the invocation of the original methods.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
*
|
||||
* @since Method available since Release 2.0.0
|
||||
*/
|
||||
public function disableProxyingToOriginalMethods()
|
||||
{
|
||||
$this->callOriginalMethods = false;
|
||||
$this->proxyTarget = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the proxy target.
|
||||
*
|
||||
* @param object $object
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
*
|
||||
* @since Method available since Release 2.0.0
|
||||
*/
|
||||
public function setProxyTarget($object)
|
||||
{
|
||||
$this->proxyTarget = $object;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
*
|
||||
* @since Method available since Release 3.2.0
|
||||
*/
|
||||
public function allowMockingUnknownTypes()
|
||||
{
|
||||
$this->allowMockingUnknownTypes = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
*
|
||||
* @since Method available since Release 3.2.0
|
||||
*/
|
||||
public function disallowMockingUnknownTypes()
|
||||
{
|
||||
$this->allowMockingUnknownTypes = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
55
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/MockObject.php
vendored
Normal file
55
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/MockObject.php
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for all mock objects which are generated by
|
||||
* PHPUnit_Framework_MockObject_MockBuilder.
|
||||
*
|
||||
* @method PHPUnit_Framework_MockObject_Builder_InvocationMocker method($constraint)
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Framework_MockObject_InvocationMocker
|
||||
*
|
||||
* @since Method available since Release 2.0.0
|
||||
*/
|
||||
public function __phpunit_setOriginalObject($originalObject);
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Framework_MockObject_InvocationMocker
|
||||
*/
|
||||
public function __phpunit_getInvocationMocker();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function __phpunit_hasMatchers();
|
||||
}
|
30
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub.php
vendored
Normal file
30
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub.php
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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);
|
||||
}
|
48
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ConsecutiveCalls.php
vendored
Normal file
48
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ConsecutiveCalls.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
|
||||
/**
|
||||
* Stubs a method by returning a user-defined stack of values.
|
||||
*
|
||||
* @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()
|
||||
{
|
||||
$exporter = new Exporter;
|
||||
|
||||
return sprintf(
|
||||
'return user-specified value %s',
|
||||
$exporter->export($this->value)
|
||||
);
|
||||
}
|
||||
}
|
48
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/Exception.php
vendored
Normal file
48
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/Exception.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
|
||||
/**
|
||||
* Stubs a method by raising a user-defined exception.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
// TODO Replace check with type declaration when support for PHP 5 is dropped
|
||||
if (!$exception instanceof Throwable && !$exception instanceof Exception) {
|
||||
throw new PHPUnit_Framework_MockObject_RuntimeException(
|
||||
'Exception must be an instance of Throwable (PHP 7) or Exception (PHP 5)'
|
||||
);
|
||||
}
|
||||
|
||||
$this->exception = $exception;
|
||||
}
|
||||
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
throw $this->exception;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
$exporter = new Exporter;
|
||||
|
||||
return sprintf(
|
||||
'raise user-specified exception %s',
|
||||
$exporter->export($this->exception)
|
||||
);
|
||||
}
|
||||
}
|
25
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/MatcherCollection.php
vendored
Normal file
25
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/MatcherCollection.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stubs a method by returning a user-defined value.
|
||||
*
|
||||
* @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);
|
||||
}
|
41
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/Return.php
vendored
Normal file
41
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/Return.php
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
|
||||
/**
|
||||
* Stubs a method by returning a user-defined value.
|
||||
*
|
||||
* @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()
|
||||
{
|
||||
$exporter = new Exporter;
|
||||
|
||||
return sprintf(
|
||||
'return user-specified value %s',
|
||||
$exporter->export($this->value)
|
||||
);
|
||||
}
|
||||
}
|
38
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnArgument.php
vendored
Normal file
38
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnArgument.php
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stubs a method by returning an argument that was passed to the mocked method.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return sprintf('return argument #%d', $this->argumentIndex);
|
||||
}
|
||||
}
|
51
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnCallback.php
vendored
Normal file
51
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnCallback.php
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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';
|
||||
}
|
||||
}
|
||||
}
|
22
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnReference.php
vendored
Normal file
22
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnReference.php
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stubs a method by returning a user-defined reference to a value.
|
||||
*
|
||||
* @since Class available since Release 3.0.7
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Stub_ReturnReference extends PHPUnit_Framework_MockObject_Stub_Return
|
||||
{
|
||||
public function __construct(&$value)
|
||||
{
|
||||
$this->value = &$value;
|
||||
}
|
||||
}
|
34
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnSelf.php
vendored
Normal file
34
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnSelf.php
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stubs a method by returning the current object.
|
||||
*
|
||||
* @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_MockObject_RuntimeException(
|
||||
'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';
|
||||
}
|
||||
}
|
47
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnValueMap.php
vendored
Normal file
47
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnValueMap.php
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stubs a method by returning a value from a map.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'return value from a map';
|
||||
}
|
||||
}
|
25
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Verifiable.php
vendored
Normal file
25
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Verifiable.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for classes which must verify a given expectation.
|
||||
*
|
||||
* @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();
|
||||
}
|
200
vendor/phpunit/phpunit-mock-objects/tests/GeneratorTest.php
vendored
Normal file
200
vendor/phpunit/phpunit-mock-objects/tests/GeneratorTest.php
vendored
Normal file
@ -0,0 +1,200 @@
|
||||
<?php
|
||||
/**
|
||||
* @covers PHPUnit_Framework_MockObject_Generator
|
||||
*
|
||||
* @uses PHPUnit_Framework_MockObject_InvocationMocker
|
||||
* @uses PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
* @uses PHPUnit_Framework_MockObject_Invocation_Object
|
||||
* @uses PHPUnit_Framework_MockObject_Invocation_Static
|
||||
* @uses PHPUnit_Framework_MockObject_Matcher
|
||||
* @uses PHPUnit_Framework_MockObject_Matcher_InvokedRecorder
|
||||
* @uses PHPUnit_Framework_MockObject_Matcher_MethodName
|
||||
* @uses PHPUnit_Framework_MockObject_Stub_Return
|
||||
* @uses PHPUnit_Framework_MockObject_Matcher_InvokedCount
|
||||
*/
|
||||
class Framework_MockObject_GeneratorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var PHPUnit_Framework_MockObject_Generator
|
||||
*/
|
||||
private $generator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_MockObject_RuntimeException
|
||||
*/
|
||||
public function testGetMockFailsWhenInvalidFunctionNameIsPassedInAsAFunctionToMock()
|
||||
{
|
||||
$this->generator->getMock(stdClass::class, [0]);
|
||||
}
|
||||
|
||||
public function testGetMockCanCreateNonExistingFunctions()
|
||||
{
|
||||
$mock = $this->generator->getMock(stdClass::class, ['testFunction']);
|
||||
|
||||
$this->assertTrue(method_exists($mock, 'testFunction'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_MockObject_RuntimeException
|
||||
* @expectedExceptionMessage duplicates: "foo, bar, foo" (duplicate: "foo")
|
||||
*/
|
||||
public function testGetMockGeneratorFails()
|
||||
{
|
||||
$this->generator->getMock(stdClass::class, ['foo', 'bar', 'foo']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testGetMockBlacklistedMethodNamesPhp7()
|
||||
{
|
||||
$mock = $this->generator->getMock(InterfaceWithSemiReservedMethodName::class);
|
||||
|
||||
$this->assertTrue(method_exists($mock, 'unset'));
|
||||
$this->assertInstanceOf(InterfaceWithSemiReservedMethodName::class, $mock);
|
||||
}
|
||||
|
||||
public function testGetMockForAbstractClassDoesNotFailWhenFakingInterfaces()
|
||||
{
|
||||
$mock = $this->generator->getMockForAbstractClass(Countable::class);
|
||||
|
||||
$this->assertTrue(method_exists($mock, 'count'));
|
||||
}
|
||||
|
||||
public function testGetMockForAbstractClassStubbingAbstractClass()
|
||||
{
|
||||
$mock = $this->generator->getMockForAbstractClass(AbstractMockTestClass::class);
|
||||
|
||||
$this->assertTrue(method_exists($mock, 'doSomething'));
|
||||
}
|
||||
|
||||
public function testGetMockForAbstractClassWithNonExistentMethods()
|
||||
{
|
||||
$mock = $this->generator->getMockForAbstractClass(
|
||||
AbstractMockTestClass::class,
|
||||
[],
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
['nonexistentMethod']
|
||||
);
|
||||
|
||||
$this->assertTrue(method_exists($mock, 'nonexistentMethod'));
|
||||
$this->assertTrue(method_exists($mock, 'doSomething'));
|
||||
}
|
||||
|
||||
public function testGetMockForAbstractClassShouldCreateStubsOnlyForAbstractMethodWhenNoMethodsWereInformed()
|
||||
{
|
||||
$mock = $this->generator->getMockForAbstractClass(AbstractMockTestClass::class);
|
||||
|
||||
$mock->expects($this->any())
|
||||
->method('doSomething')
|
||||
->willReturn('testing');
|
||||
|
||||
$this->assertEquals('testing', $mock->doSomething());
|
||||
$this->assertEquals(1, $mock->returnAnything());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider
|
||||
* @expectedException PHPUnit_Framework_Exception
|
||||
*/
|
||||
public function testGetMockForAbstractClassExpectingInvalidArgumentException($className, $mockClassName)
|
||||
{
|
||||
$this->generator->getMockForAbstractClass($className, [], $mockClassName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_MockObject_RuntimeException
|
||||
*/
|
||||
public function testGetMockForAbstractClassAbstractClassDoesNotExist()
|
||||
{
|
||||
$this->generator->getMockForAbstractClass('Tux');
|
||||
}
|
||||
|
||||
public function getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider()
|
||||
{
|
||||
return [
|
||||
'className not a string' => [[], ''],
|
||||
'mockClassName not a string' => [Countable::class, new stdClass],
|
||||
];
|
||||
}
|
||||
|
||||
public function testGetMockForTraitWithNonExistentMethodsAndNonAbstractMethods()
|
||||
{
|
||||
$mock = $this->generator->getMockForTrait(
|
||||
AbstractTrait::class,
|
||||
[],
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
['nonexistentMethod']
|
||||
);
|
||||
|
||||
$this->assertTrue(method_exists($mock, 'nonexistentMethod'));
|
||||
$this->assertTrue(method_exists($mock, 'doSomething'));
|
||||
$this->assertTrue($mock->mockableMethod());
|
||||
$this->assertTrue($mock->anotherMockableMethod());
|
||||
}
|
||||
|
||||
public function testGetMockForTraitStubbingAbstractMethod()
|
||||
{
|
||||
$mock = $this->generator->getMockForTrait(AbstractTrait::class);
|
||||
|
||||
$this->assertTrue(method_exists($mock, 'doSomething'));
|
||||
}
|
||||
|
||||
public function testGetMockForSingletonWithReflectionSuccess()
|
||||
{
|
||||
$mock = $this->generator->getMock(SingletonClass::class, ['doSomething'], [], '', false);
|
||||
|
||||
$this->assertInstanceOf('SingletonClass', $mock);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_MockObject_RuntimeException
|
||||
*/
|
||||
public function testExceptionIsRaisedForMutuallyExclusiveOptions()
|
||||
{
|
||||
$this->generator->getMock(stdClass::class, [], [], '', false, true, true, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testCanImplementInterfacesThatHaveMethodsWithReturnTypes()
|
||||
{
|
||||
$stub = $this->generator->getMock([AnInterfaceWithReturnType::class, AnInterface::class]);
|
||||
|
||||
$this->assertInstanceOf(AnInterfaceWithReturnType::class, $stub);
|
||||
$this->assertInstanceOf(AnInterface::class, $stub);
|
||||
$this->assertInstanceOf(PHPUnit_Framework_MockObject_MockObject::class, $stub);
|
||||
}
|
||||
|
||||
public function testCanConfigureMethodsForDoubleOfNonExistentClass()
|
||||
{
|
||||
$className = 'X' . md5(microtime());
|
||||
|
||||
$mock = $this->generator->getMock($className, ['someMethod']);
|
||||
|
||||
$this->assertInstanceOf($className, $mock);
|
||||
}
|
||||
|
||||
public function testCanInvokeMethodsOfNonExistentClass()
|
||||
{
|
||||
$className = 'X' . md5(microtime());
|
||||
|
||||
$mock = $this->generator->getMock($className, ['someMethod']);
|
||||
|
||||
$mock->expects($this->once())->method('someMethod');
|
||||
|
||||
$this->assertNull($mock->someMethod());
|
||||
}
|
||||
}
|
126
vendor/phpunit/phpunit-mock-objects/tests/MockBuilderTest.php
vendored
Normal file
126
vendor/phpunit/phpunit-mock-objects/tests/MockBuilderTest.php
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
class Framework_MockBuilderTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testMockBuilderRequiresClassName()
|
||||
{
|
||||
$mock = $this->getMockBuilder(Mockable::class)->getMock();
|
||||
|
||||
$this->assertTrue($mock instanceof Mockable);
|
||||
}
|
||||
|
||||
public function testByDefaultMocksAllMethods()
|
||||
{
|
||||
$mock = $this->getMockBuilder(Mockable::class)->getMock();
|
||||
|
||||
$this->assertNull($mock->mockableMethod());
|
||||
$this->assertNull($mock->anotherMockableMethod());
|
||||
}
|
||||
|
||||
public function testMethodsToMockCanBeSpecified()
|
||||
{
|
||||
$mock = $this->getMockBuilder(Mockable::class)
|
||||
->setMethods(['mockableMethod'])
|
||||
->getMock();
|
||||
|
||||
$this->assertNull($mock->mockableMethod());
|
||||
$this->assertTrue($mock->anotherMockableMethod());
|
||||
}
|
||||
|
||||
public function testMethodExceptionsToMockCanBeSpecified()
|
||||
{
|
||||
$mock = $this->getMockBuilder(Mockable::class)
|
||||
->setMethodsExcept(['mockableMethod'])
|
||||
->getMock();
|
||||
|
||||
$this->assertTrue($mock->mockableMethod());
|
||||
$this->assertNull($mock->anotherMockableMethod());
|
||||
}
|
||||
|
||||
public function testEmptyMethodExceptionsToMockCanBeSpecified()
|
||||
{
|
||||
$mock = $this->getMockBuilder(Mockable::class)
|
||||
->setMethodsExcept()
|
||||
->getMock();
|
||||
|
||||
$this->assertNull($mock->mockableMethod());
|
||||
$this->assertNull($mock->anotherMockableMethod());
|
||||
}
|
||||
|
||||
public function testByDefaultDoesNotPassArgumentsToTheConstructor()
|
||||
{
|
||||
$mock = $this->getMockBuilder(Mockable::class)->getMock();
|
||||
|
||||
$this->assertEquals([null, null], $mock->constructorArgs);
|
||||
}
|
||||
|
||||
public function testMockClassNameCanBeSpecified()
|
||||
{
|
||||
$mock = $this->getMockBuilder(Mockable::class)
|
||||
->setMockClassName('ACustomClassName')
|
||||
->getMock();
|
||||
|
||||
$this->assertTrue($mock instanceof ACustomClassName);
|
||||
}
|
||||
|
||||
public function testConstructorArgumentsCanBeSpecified()
|
||||
{
|
||||
$mock = $this->getMockBuilder(Mockable::class)
|
||||
->setConstructorArgs([23, 42])
|
||||
->getMock();
|
||||
|
||||
$this->assertEquals([23, 42], $mock->constructorArgs);
|
||||
}
|
||||
|
||||
public function testOriginalConstructorCanBeDisabled()
|
||||
{
|
||||
$mock = $this->getMockBuilder(Mockable::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->assertNull($mock->constructorArgs);
|
||||
}
|
||||
|
||||
public function testByDefaultOriginalCloneIsPreserved()
|
||||
{
|
||||
$mock = $this->getMockBuilder(Mockable::class)
|
||||
->getMock();
|
||||
|
||||
$cloned = clone $mock;
|
||||
|
||||
$this->assertTrue($cloned->cloned);
|
||||
}
|
||||
|
||||
public function testOriginalCloneCanBeDisabled()
|
||||
{
|
||||
$mock = $this->getMockBuilder(Mockable::class)
|
||||
->disableOriginalClone()
|
||||
->getMock();
|
||||
|
||||
$mock->cloned = false;
|
||||
$cloned = clone $mock;
|
||||
|
||||
$this->assertFalse($cloned->cloned);
|
||||
}
|
||||
|
||||
public function testProvidesAFluentInterface()
|
||||
{
|
||||
$spec = $this->getMockBuilder(Mockable::class)
|
||||
->setMethods(['mockableMethod'])
|
||||
->setConstructorArgs([])
|
||||
->setMockClassName('DummyClassName')
|
||||
->disableOriginalConstructor()
|
||||
->disableOriginalClone()
|
||||
->disableAutoload();
|
||||
|
||||
$this->assertTrue($spec instanceof PHPUnit_Framework_MockObject_MockBuilder);
|
||||
}
|
||||
}
|
63
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Builder/InvocationMockerTest.php
vendored
Normal file
63
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Builder/InvocationMockerTest.php
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
class Framework_MockObject_Builder_InvocationMockerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testWillReturnWithOneValue()
|
||||
{
|
||||
$mock = $this->getMockBuilder(stdClass::class)
|
||||
->setMethods(['foo'])
|
||||
->getMock();
|
||||
|
||||
$mock->expects($this->any())
|
||||
->method('foo')
|
||||
->willReturn(1);
|
||||
|
||||
$this->assertEquals(1, $mock->foo());
|
||||
}
|
||||
|
||||
public function testWillReturnWithMultipleValues()
|
||||
{
|
||||
$mock = $this->getMockBuilder(stdClass::class)
|
||||
->setMethods(['foo'])
|
||||
->getMock();
|
||||
|
||||
$mock->expects($this->any())
|
||||
->method('foo')
|
||||
->willReturn(1, 2, 3);
|
||||
|
||||
$this->assertEquals(1, $mock->foo());
|
||||
$this->assertEquals(2, $mock->foo());
|
||||
$this->assertEquals(3, $mock->foo());
|
||||
}
|
||||
|
||||
public function testWillReturnOnConsecutiveCalls()
|
||||
{
|
||||
$mock = $this->getMockBuilder(stdClass::class)
|
||||
->setMethods(['foo'])
|
||||
->getMock();
|
||||
|
||||
$mock->expects($this->any())
|
||||
->method('foo')
|
||||
->willReturnOnConsecutiveCalls(1, 2, 3);
|
||||
|
||||
$this->assertEquals(1, $mock->foo());
|
||||
$this->assertEquals(2, $mock->foo());
|
||||
$this->assertEquals(3, $mock->foo());
|
||||
}
|
||||
|
||||
public function testWillReturnByReference()
|
||||
{
|
||||
$mock = $this->getMockBuilder(stdClass::class)
|
||||
->setMethods(['foo'])
|
||||
->getMock();
|
||||
|
||||
$mock->expects($this->any())
|
||||
->method('foo')
|
||||
->willReturnReference($value);
|
||||
|
||||
$this->assertSame(null, $mock->foo());
|
||||
$value = 'foo';
|
||||
$this->assertSame('foo', $mock->foo());
|
||||
$value = 'bar';
|
||||
$this->assertSame('bar', $mock->foo());
|
||||
}
|
||||
}
|
129
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/232.phpt
vendored
Normal file
129
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/232.phpt
vendored
Normal file
@ -0,0 +1,129 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
trait BaseTrait
|
||||
{
|
||||
protected function hello()
|
||||
{
|
||||
return 'hello';
|
||||
}
|
||||
}
|
||||
|
||||
trait ChildTrait
|
||||
{
|
||||
use BaseTrait
|
||||
{
|
||||
hello as private hi;
|
||||
}
|
||||
|
||||
protected function hello()
|
||||
{
|
||||
return 'hi';
|
||||
}
|
||||
|
||||
protected function world()
|
||||
{
|
||||
return $this->hi();
|
||||
}
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
use ChildTrait;
|
||||
|
||||
public function speak()
|
||||
{
|
||||
return $this->world();
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['speak'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function speak()
|
||||
{
|
||||
$arguments = array();
|
||||
$count = func_num_args();
|
||||
|
||||
if ($count > 0) {
|
||||
$_arguments = func_get_args();
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$arguments[] = $_arguments[$i];
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'speak', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->expects($matcher);
|
||||
}
|
||||
|
||||
public function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
147
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/abstract_class.phpt
vendored
Normal file
147
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/abstract_class.phpt
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
abstract class Foo
|
||||
{
|
||||
public function one()
|
||||
{
|
||||
}
|
||||
|
||||
abstract public function two();
|
||||
|
||||
abstract protected function three();
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['one', 'two', 'three'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function one()
|
||||
{
|
||||
$arguments = array();
|
||||
$count = func_num_args();
|
||||
|
||||
if ($count > 0) {
|
||||
$_arguments = func_get_args();
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$arguments[] = $_arguments[$i];
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'one', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function two()
|
||||
{
|
||||
$arguments = array();
|
||||
$count = func_num_args();
|
||||
|
||||
if ($count > 0) {
|
||||
$_arguments = func_get_args();
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$arguments[] = $_arguments[$i];
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'two', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function three()
|
||||
{
|
||||
$arguments = array();
|
||||
$count = func_num_args();
|
||||
|
||||
if ($count > 0) {
|
||||
$_arguments = func_get_args();
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$arguments[] = $_arguments[$i];
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'three', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->expects($matcher);
|
||||
}
|
||||
|
||||
public function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
125
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/class.phpt
vendored
Normal file
125
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/class.phpt
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function bar(Foo $foo)
|
||||
{
|
||||
}
|
||||
|
||||
public function baz(Foo $foo)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar', 'baz'];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
77
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/class_call_parent_clone.phpt
vendored
Normal file
77
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/class_call_parent_clone.phpt
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function __clone()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
76
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/class_dont_call_parent_clone.phpt
vendored
Normal file
76
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/class_dont_call_parent_clone.phpt
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', false)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function __clone()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
false
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
interface IFoo
|
||||
{
|
||||
public function __construct($bar);
|
||||
}
|
||||
|
||||
class Foo implements IFoo
|
||||
{
|
||||
public function __construct($bar)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
interface IFoo
|
||||
{
|
||||
public function __construct($bar);
|
||||
}
|
||||
|
||||
class Foo implements IFoo
|
||||
{
|
||||
public function __construct($bar)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
103
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/class_partial.phpt
vendored
Normal file
103
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/class_partial.phpt
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array('bar'), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function bar(Foo $foo)
|
||||
{
|
||||
}
|
||||
|
||||
public function baz(Foo $foo)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array('bar'),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function method()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['method'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function method()
|
||||
{
|
||||
$arguments = array();
|
||||
$count = func_num_args();
|
||||
|
||||
if ($count > 0) {
|
||||
$_arguments = func_get_args();
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$arguments[] = $_arguments[$i];
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'method', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->expects($matcher);
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('ClassWithMethodWithVariadicArguments', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class ClassWithMethodWithVariadicArguments
|
||||
{
|
||||
public function methodWithVariadicArguments($a, ...$parameters)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'ClassWithMethodWithVariadicArguments',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends ClassWithMethodWithVariadicArguments implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['methodwithvariadicarguments'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function methodWithVariadicArguments($a, ...$parameters)
|
||||
{
|
||||
$arguments = array($a);
|
||||
$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(
|
||||
'ClassWithMethodWithVariadicArguments', 'methodWithVariadicArguments', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->expects($matcher);
|
||||
}
|
||||
|
||||
public function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
97
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/interface.phpt
vendored
Normal file
97
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/interface.phpt
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
interface Foo
|
||||
{
|
||||
public function bar(Foo $foo);
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
126
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/invocation_object_clone_object.phpt
vendored
Normal file
126
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/invocation_object_clone_object.phpt
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function bar(Foo $foo)
|
||||
{
|
||||
}
|
||||
|
||||
public function baz(Foo $foo)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar', 'baz'];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
127
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/namespaced_class.phpt
vendored
Normal file
127
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/namespaced_class.phpt
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function bar(Foo $foo)
|
||||
{
|
||||
}
|
||||
|
||||
public function baz(Foo $foo)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar', 'baz'];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function __clone()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', false)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function __clone()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
false
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
interface IFoo
|
||||
{
|
||||
public function __construct($bar);
|
||||
}
|
||||
|
||||
class Foo implements IFoo
|
||||
{
|
||||
public function __construct($bar)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
interface IFoo
|
||||
{
|
||||
public function __construct($bar);
|
||||
}
|
||||
|
||||
class Foo implements IFoo
|
||||
{
|
||||
public function __construct($bar)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
105
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/namespaced_class_partial.phpt
vendored
Normal file
105
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/namespaced_class_partial.phpt
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array('bar'), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function bar(Foo $foo)
|
||||
{
|
||||
}
|
||||
|
||||
public function baz(Foo $foo)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array('bar'),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
99
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/namespaced_interface.phpt
vendored
Normal file
99
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/namespaced_interface.phpt
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
interface Foo
|
||||
{
|
||||
public function bar(Foo $foo);
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo implements PHPUnit_Framework_MockObject_MockObject, NS\Foo
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
74
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/nonexistent_class.phpt
vendored
Normal file
74
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/nonexistent_class.phpt
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NonExistentClass', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NonExistentClass',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class NonExistentClass
|
||||
{
|
||||
}
|
||||
|
||||
class MockFoo extends NonExistentClass implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
namespace NS {
|
||||
|
||||
class Foo
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'\NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
namespace NS {
|
||||
|
||||
class Foo
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
103
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/nullable_types.phpt
vendored
Normal file
103
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/nullable_types.phpt
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!version_compare(PHP_VERSION, '7.1', '>=')) print 'skip: PHP >= 7.1 required';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function bar(?int $x)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function bar(?int $x)
|
||||
{
|
||||
$arguments = array($x);
|
||||
$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 function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
121
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/proxy.phpt
vendored
Normal file
121
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/proxy.phpt
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', null, 'ProxyFoo', true, true, true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function bar(Foo $foo)
|
||||
{
|
||||
}
|
||||
|
||||
public function baz(Foo $foo)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo', array(), 'ProxyFoo', true, true, true, true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class ProxyFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar', 'baz'];
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
$this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'bar', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return call_user_func_array(array($this->__phpunit_originalObject, "bar"), $arguments);
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
$this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'baz', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return call_user_func_array(array($this->__phpunit_originalObject, "baz"), $arguments);
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->expects($matcher);
|
||||
}
|
||||
|
||||
public function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!version_compare(PHP_VERSION, '7.1', '>=')) print 'skip: PHP >= 7.1 required';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
interface Foo
|
||||
{
|
||||
public function bar(string $baz): ?string;
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function bar(string $baz): ?string
|
||||
{
|
||||
$arguments = array($baz);
|
||||
$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, '?string', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->expects($matcher);
|
||||
}
|
||||
|
||||
public function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!version_compare(PHP_VERSION, '7.0', '>=')) print 'skip: PHP >= 7.0 required';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function bar(string $baz): Bar
|
||||
{
|
||||
return 'test';
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function bar(string $baz): Bar
|
||||
{
|
||||
$arguments = array($baz);
|
||||
$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, 'Bar', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->expects($matcher);
|
||||
}
|
||||
|
||||
public function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
101
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/return_type_declarations_self.phpt
vendored
Normal file
101
vendor/phpunit/phpunit-mock-objects/tests/MockObject/Generator/return_type_declarations_self.phpt
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!version_compare(PHP_VERSION, '7.0', '>=')) print 'skip: PHP >= 7.0 required';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
interface Foo
|
||||
{
|
||||
public function bar(string $baz): self;
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function bar(string $baz): Foo
|
||||
{
|
||||
$arguments = array($baz);
|
||||
$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, 'Foo', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->expects($matcher);
|
||||
}
|
||||
|
||||
public function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user