Laravel version update
Laravel version update
This commit is contained in:
15
vendor/phpunit/phpunit-mock-objects/.github/ISSUE_TEMPLATE.md
vendored
Normal file
15
vendor/phpunit/phpunit-mock-objects/.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
| Q | A
|
||||
| -----------------------------| ---------------
|
||||
| phpunit-mock-objects version | x.y.z
|
||||
| PHPUnit version | x.y.z
|
||||
| PHP version | x.y.z
|
||||
| Installation Method | Composer / PHAR
|
||||
|
||||
<!--
|
||||
- Please fill in this template according to your issue.
|
||||
- Please keep the table shown above at the top of your issue.
|
||||
- Please post code as text (using proper markup). Do not post screenshots of code.
|
||||
- For support request or how-tos, visit https://phpunit.de/support.html
|
||||
- Otherwise, replace this comment by the description of your issue.
|
||||
-->
|
||||
|
10
vendor/phpunit/phpunit-mock-objects/.gitignore
vendored
10
vendor/phpunit/phpunit-mock-objects/.gitignore
vendored
@@ -1,8 +1,4 @@
|
||||
build/coverage
|
||||
build/logs
|
||||
cache.properties
|
||||
phpunit.xml
|
||||
/vendor
|
||||
/composer.lock
|
||||
/composer.phar
|
||||
/.idea
|
||||
/.php_cs.cache
|
||||
/composer.lock
|
||||
/vendor
|
||||
|
87
vendor/phpunit/phpunit-mock-objects/.php_cs
vendored
Normal file
87
vendor/phpunit/phpunit-mock-objects/.php_cs
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
$header = <<<'EOF'
|
||||
This file is part of the phpunit-mock-objects 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.
|
||||
EOF;
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRiskyAllowed(true)
|
||||
->setRules(
|
||||
[
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'binary_operator_spaces' => [
|
||||
'align_double_arrow' => true,
|
||||
'align_equals' => true
|
||||
],
|
||||
'blank_line_after_namespace' => true,
|
||||
'blank_line_before_statement' => [
|
||||
'statements' => [
|
||||
'break',
|
||||
'continue',
|
||||
'return',
|
||||
'throw',
|
||||
'try',
|
||||
],
|
||||
],
|
||||
'braces' => true,
|
||||
'cast_spaces' => true,
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
'elseif' => true,
|
||||
'encoding' => true,
|
||||
'full_opening_tag' => true,
|
||||
'function_declaration' => true,
|
||||
'header_comment' => ['header' => $header, 'separate' => 'none'],
|
||||
'indentation_type' => true,
|
||||
'line_ending' => true,
|
||||
'lowercase_constants' => true,
|
||||
'lowercase_keywords' => true,
|
||||
'method_argument_space' => true,
|
||||
'native_function_invocation' => true,
|
||||
'no_alias_functions' => true,
|
||||
'no_blank_lines_after_class_opening' => true,
|
||||
'no_blank_lines_after_phpdoc' => true,
|
||||
'no_closing_tag' => true,
|
||||
'no_empty_phpdoc' => true,
|
||||
'no_empty_statement' => true,
|
||||
'no_extra_consecutive_blank_lines' => true,
|
||||
'no_leading_namespace_whitespace' => true,
|
||||
'no_singleline_whitespace_before_semicolons' => true,
|
||||
'no_spaces_after_function_name' => true,
|
||||
'no_spaces_inside_parenthesis' => true,
|
||||
'no_trailing_comma_in_list_call' => true,
|
||||
'no_trailing_whitespace' => true,
|
||||
'no_unused_imports' => true,
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
'ordered_imports' => true,
|
||||
'phpdoc_align' => true,
|
||||
'phpdoc_indent' => true,
|
||||
'phpdoc_no_access' => true,
|
||||
'phpdoc_no_empty_return' => true,
|
||||
'phpdoc_no_package' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'phpdoc_separation' => true,
|
||||
'phpdoc_to_comment' => true,
|
||||
'phpdoc_trim' => true,
|
||||
'phpdoc_types' => true,
|
||||
'phpdoc_var_without_name' => true,
|
||||
'self_accessor' => true,
|
||||
'simplified_null_return' => true,
|
||||
'single_blank_line_at_eof' => true,
|
||||
'single_import_per_statement' => true,
|
||||
'single_line_after_imports' => true,
|
||||
'single_quote' => true,
|
||||
'ternary_operator_spaces' => true,
|
||||
'trim_array_spaces' => true,
|
||||
'visibility_required' => true,
|
||||
]
|
||||
)
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
->files()
|
||||
->in(__DIR__ . '/src')
|
||||
->name('*.php')
|
||||
);
|
42
vendor/phpunit/phpunit-mock-objects/.travis.yml
vendored
42
vendor/phpunit/phpunit-mock-objects/.travis.yml
vendored
@@ -1,26 +1,34 @@
|
||||
language: php
|
||||
|
||||
before_script:
|
||||
- composer self-update
|
||||
- composer install --no-interaction --prefer-source --dev
|
||||
|
||||
script: ./vendor/bin/phpunit --configuration ./build/travis-ci.xml
|
||||
sudo: false
|
||||
|
||||
php:
|
||||
- 5.3.3
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- hhvm
|
||||
- 7.1
|
||||
- 7.2
|
||||
- master
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- DEPENDENCIES="high"
|
||||
- DEPENDENCIES="low"
|
||||
global:
|
||||
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-ansi --no-progress --no-suggest"
|
||||
|
||||
before_install:
|
||||
- composer self-update
|
||||
- composer clear-cache
|
||||
|
||||
install:
|
||||
- if [[ "$DEPENDENCIES" = 'high' ]]; then travis_retry composer update $DEFAULT_COMPOSER_FLAGS; fi
|
||||
- if [[ "$DEPENDENCIES" = 'low' ]]; then travis_retry composer update $DEFAULT_COMPOSER_FLAGS --prefer-lowest; fi
|
||||
|
||||
script:
|
||||
- ./vendor/bin/phpunit --coverage-clover=coverage.xml
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
webhooks:
|
||||
urls:
|
||||
- https://webhooks.gitter.im/e/6668f52f3dd4e3f81960
|
||||
on_success: always
|
||||
on_failure: always
|
||||
on_start: false
|
||||
|
||||
|
@@ -1,5 +1 @@
|
||||
Pull Requests for bug fixes should be made against the current release branch (1.2).
|
||||
|
||||
Pull Requests for new features should be made against master.
|
||||
|
||||
For further notes please refer to [https://github.com/sebastianbergmann/phpunit/blob/master/CONTRIBUTING.md](https://github.com/sebastianbergmann/phpunit/blob/master/CONTRIBUTING.md)
|
||||
Please refer to [https://github.com/sebastianbergmann/phpunit/blob/master/.github/CONTRIBUTING.md](https://github.com/sebastianbergmann/phpunit/blob/master/.github/CONTRIBUTING.md) for details on how to contribute to this project.
|
||||
|
4
vendor/phpunit/phpunit-mock-objects/LICENSE
vendored
4
vendor/phpunit/phpunit-mock-objects/LICENSE
vendored
@@ -1,6 +1,6 @@
|
||||
PHPUnit_MockObject
|
||||
phpunit-mock-objects
|
||||
|
||||
Copyright (c) 2002-2015, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
Copyright (c) 2002-2017, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
22
vendor/phpunit/phpunit-mock-objects/README.md
vendored
22
vendor/phpunit/phpunit-mock-objects/README.md
vendored
@@ -1,21 +1,7 @@
|
||||
[](https://travis-ci.org/sebastianbergmann/phpunit-mock-objects)
|
||||
[](https://packagist.org/packages/phpunit/phpunit-mock-objects)
|
||||
[](https://php.net/)
|
||||
[](https://phpunit.de/build-status.html)
|
||||
|
||||
# PHPUnit_MockObject
|
||||
|
||||
**PHPUnit_MockObject** is the default mock object library for PHPUnit.
|
||||
|
||||
## Requirements
|
||||
|
||||
* PHP 5.3.3 is required but using the latest version of PHP is highly recommended
|
||||
|
||||
## Installation
|
||||
|
||||
To add PHPUnit_MockObject as a local, per-project dependency to your project, simply add a dependency on `phpunit/phpunit-mock-objects` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on PHPUnit_MockObject 2.3:
|
||||
|
||||
{
|
||||
"require": {
|
||||
"phpunit/phpunit-mock-objects": "2.3.*"
|
||||
}
|
||||
}
|
||||
# phpunit-mock-objects
|
||||
|
||||
**phpunit-mock-objects** is the default mock object library for PHPUnit.
|
||||
|
53
vendor/phpunit/phpunit-mock-objects/build.xml
vendored
53
vendor/phpunit/phpunit-mock-objects/build.xml
vendored
@@ -1,42 +1,19 @@
|
||||
<?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"/>
|
||||
<project name="phpunit-mock-objects" default="setup">
|
||||
<target name="setup" depends="clean,composer"/>
|
||||
|
||||
<delete>
|
||||
<fileset dir="${basedir}/build">
|
||||
<include name="**/*.phar" />
|
||||
</fileset>
|
||||
</delete>
|
||||
</target>
|
||||
<target name="clean" description="Cleanup build artifacts">
|
||||
<delete dir="${basedir}/vendor"/>
|
||||
<delete file="${basedir}/composer.lock"/>
|
||||
</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>
|
||||
<target name="composer" depends="clean" description="Install dependencies with Composer">
|
||||
<exec executable="composer" taskname="composer">
|
||||
<arg value="update"/>
|
||||
<arg value="--no-interaction"/>
|
||||
<arg value="--no-progress"/>
|
||||
<arg value="--no-ansi"/>
|
||||
<arg value="--no-suggest"/>
|
||||
</exec>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
|
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.2/phpunit.xsd"
|
||||
bootstrap="../tests/bootstrap.php"
|
||||
backupGlobals="false"
|
||||
verbose="true">
|
||||
<testsuite name="PHPUnit Mock Objects">
|
||||
<directory suffix="Test.php">../tests</directory>
|
||||
<directory suffix=".phpt">../tests</directory>
|
||||
</testsuite>
|
||||
</phpunit>
|
||||
|
@@ -11,22 +11,29 @@
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"email": "sebastian@phpunit.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit-mock-objects/issues",
|
||||
"irc": "irc://irc.freenode.net/phpunit"
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit-mock-objects/issues"
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-text-template": "~1.2",
|
||||
"doctrine/instantiator": "^1.0.2",
|
||||
"sebastian/exporter": "~1.2"
|
||||
"php": "^7.0",
|
||||
"phpunit/php-text-template": "^1.2.1",
|
||||
"doctrine/instantiator": "^1.0.5",
|
||||
"sebastian/exporter": "^3.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.4"
|
||||
"phpunit/phpunit": "^6.5"
|
||||
},
|
||||
"conflict": {
|
||||
"phpunit/phpunit": "<6.0"
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true
|
||||
},
|
||||
"suggest": {
|
||||
"ext-soap": "*"
|
||||
@@ -43,7 +50,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3.x-dev"
|
||||
"dev-master": "5.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
28
vendor/phpunit/phpunit-mock-objects/phpunit.xml
vendored
Normal file
28
vendor/phpunit/phpunit-mock-objects/phpunit.xml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.5/phpunit.xsd"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
beStrictAboutCoversAnnotation="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
beStrictAboutTodoAnnotatedTests="true"
|
||||
verbose="true">
|
||||
<testsuites>
|
||||
<testsuite name="small">
|
||||
<directory suffix="Test.php">tests</directory>
|
||||
</testsuite>
|
||||
|
||||
<testsuite name="large">
|
||||
<directory suffix=".phpt">tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
<php>
|
||||
<const name="PHPUNIT_TESTSUITE" value="true"/>
|
||||
</php>
|
||||
</phpunit>
|
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.2/phpunit.xsd"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
backupGlobals="false"
|
||||
verbose="true">
|
||||
<testsuite name="PHPUnit Mock Objects">
|
||||
<directory suffix="Test.php">tests</directory>
|
||||
<directory suffix=".phpt">tests</directory>
|
||||
</testsuite>
|
||||
|
||||
<logging>
|
||||
<log type="coverage-html" target="build/coverage"/>
|
||||
</logging>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Builder;
|
||||
|
||||
/**
|
||||
* Builder interface for unique identifiers.
|
||||
@@ -14,17 +15,16 @@
|
||||
* 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
|
||||
* PHPUnit\Framework\MockObject\Builder\Match::after().
|
||||
*/
|
||||
interface PHPUnit_Framework_MockObject_Builder_Identity
|
||||
interface Identity
|
||||
{
|
||||
/**
|
||||
* Sets the identification of the expectation to $id.
|
||||
*
|
||||
* @note The identifier is unique per mock object.
|
||||
* @param string $id Unique identifiation of expectation.
|
||||
*
|
||||
* @param string $id Unique identification of expectation.
|
||||
*/
|
||||
public function id($id);
|
||||
}
|
299
vendor/phpunit/phpunit-mock-objects/src/Builder/InvocationMocker.php
vendored
Normal file
299
vendor/phpunit/phpunit-mock-objects/src/Builder/InvocationMocker.php
vendored
Normal file
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Builder;
|
||||
|
||||
use PHPUnit\Framework\Constraint\Constraint;
|
||||
use PHPUnit\Framework\MockObject\Matcher;
|
||||
use PHPUnit\Framework\MockObject\Matcher\Invocation;
|
||||
use PHPUnit\Framework\MockObject\RuntimeException;
|
||||
use PHPUnit\Framework\MockObject\Stub;
|
||||
use PHPUnit\Framework\MockObject\Stub\MatcherCollection;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
class InvocationMocker implements MethodNameMatch
|
||||
{
|
||||
/**
|
||||
* @var MatcherCollection
|
||||
*/
|
||||
private $collection;
|
||||
|
||||
/**
|
||||
* @var Matcher
|
||||
*/
|
||||
private $matcher;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $configurableMethods = [];
|
||||
|
||||
/**
|
||||
* @param MatcherCollection $collection
|
||||
* @param Invocation $invocationMatcher
|
||||
* @param array $configurableMethods
|
||||
*/
|
||||
public function __construct(MatcherCollection $collection, Invocation $invocationMatcher, array $configurableMethods)
|
||||
{
|
||||
$this->collection = $collection;
|
||||
$this->matcher = new Matcher($invocationMatcher);
|
||||
|
||||
$this->collection->addMatcher($this->matcher);
|
||||
|
||||
$this->configurableMethods = $configurableMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Matcher
|
||||
*/
|
||||
public function getMatcher()
|
||||
{
|
||||
return $this->matcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*/
|
||||
public function id($id)
|
||||
{
|
||||
$this->collection->registerId($id, $this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Stub $stub
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*/
|
||||
public function will(Stub $stub)
|
||||
{
|
||||
$this->matcher->setStub($stub);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param mixed $nextValues, ...
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*/
|
||||
public function willReturn($value, ...$nextValues)
|
||||
{
|
||||
if (\count($nextValues) === 0) {
|
||||
$stub = new Stub\ReturnStub($value);
|
||||
} else {
|
||||
$stub = new Stub\ConsecutiveCalls(
|
||||
\array_merge([$value], $nextValues)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $reference
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*/
|
||||
public function willReturnReference(&$reference)
|
||||
{
|
||||
$stub = new Stub\ReturnReference($reference);
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $valueMap
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*/
|
||||
public function willReturnMap(array $valueMap)
|
||||
{
|
||||
$stub = new Stub\ReturnValueMap($valueMap);
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $argumentIndex
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*/
|
||||
public function willReturnArgument($argumentIndex)
|
||||
{
|
||||
$stub = new Stub\ReturnArgument($argumentIndex);
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable $callback
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*/
|
||||
public function willReturnCallback($callback)
|
||||
{
|
||||
$stub = new Stub\ReturnCallback($callback);
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InvocationMocker
|
||||
*/
|
||||
public function willReturnSelf()
|
||||
{
|
||||
$stub = new Stub\ReturnSelf;
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $values, ...
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*/
|
||||
public function willReturnOnConsecutiveCalls(...$values)
|
||||
{
|
||||
$stub = new Stub\ConsecutiveCalls($values);
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Exception $exception
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*/
|
||||
public function willThrowException(\Exception $exception)
|
||||
{
|
||||
$stub = new Stub\Exception($exception);
|
||||
|
||||
return $this->will($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*/
|
||||
public function after($id)
|
||||
{
|
||||
$this->matcher->setAfterMatchBuilderId($id);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array ...$arguments
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function with(...$arguments)
|
||||
{
|
||||
$this->canDefineParameters();
|
||||
|
||||
$this->matcher->setParametersMatcher(new Matcher\Parameters($arguments));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array ...$arguments
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function withConsecutive(...$arguments)
|
||||
{
|
||||
$this->canDefineParameters();
|
||||
|
||||
$this->matcher->setParametersMatcher(new Matcher\ConsecutiveParameters($arguments));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InvocationMocker
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function withAnyParameters()
|
||||
{
|
||||
$this->canDefineParameters();
|
||||
|
||||
$this->matcher->setParametersMatcher(new Matcher\AnyParameters);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Constraint|string $constraint
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function method($constraint)
|
||||
{
|
||||
if ($this->matcher->hasMethodNameMatcher()) {
|
||||
throw new RuntimeException(
|
||||
'Method name matcher is already defined, cannot redefine'
|
||||
);
|
||||
}
|
||||
|
||||
if (\is_string($constraint) && !\in_array(\strtolower($constraint), $this->configurableMethods)) {
|
||||
throw new 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->setMethodNameMatcher(new Matcher\MethodName($constraint));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a parameters matcher can be defined, throw exceptions otherwise.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function canDefineParameters()
|
||||
{
|
||||
if (!$this->matcher->hasMethodNameMatcher()) {
|
||||
throw new RuntimeException(
|
||||
'Method name matcher is not defined, cannot define parameter ' .
|
||||
'matcher without one'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->matcher->hasParametersMatcher()) {
|
||||
throw new RuntimeException(
|
||||
'Parameter matcher is already defined, cannot redefine'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
26
vendor/phpunit/phpunit-mock-objects/src/Builder/Match.php
vendored
Normal file
26
vendor/phpunit/phpunit-mock-objects/src/Builder/Match.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Builder;
|
||||
|
||||
/**
|
||||
* Builder interface for invocation order matches.
|
||||
*/
|
||||
interface Match extends 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 Stub
|
||||
*/
|
||||
public function after($id);
|
||||
}
|
26
vendor/phpunit/phpunit-mock-objects/src/Builder/MethodNameMatch.php
vendored
Normal file
26
vendor/phpunit/phpunit-mock-objects/src/Builder/MethodNameMatch.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Builder;
|
||||
|
||||
/**
|
||||
* Builder interface for matcher of method names.
|
||||
*/
|
||||
interface MethodNameMatch extends ParametersMatch
|
||||
{
|
||||
/**
|
||||
* Adds a new method name match and returns the parameter match object for
|
||||
* further matching possibilities.
|
||||
*
|
||||
* @param \PHPUnit\Framework\Constraint\Constraint $name Constraint for matching method, if a string is passed it will use the PHPUnit_Framework_Constraint_IsEqual
|
||||
*
|
||||
* @return ParametersMatch
|
||||
*/
|
||||
public function method($name);
|
||||
}
|
37
vendor/phpunit/phpunit-mock-objects/src/Builder/NamespaceMatch.php
vendored
Normal file
37
vendor/phpunit/phpunit-mock-objects/src/Builder/NamespaceMatch.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Builder;
|
||||
|
||||
/**
|
||||
* Interface for builders which can register builders with a given identification.
|
||||
*
|
||||
* This interface relates to Identity.
|
||||
*/
|
||||
interface NamespaceMatch
|
||||
{
|
||||
/**
|
||||
* Looks up the match builder with identification $id and returns it.
|
||||
*
|
||||
* @param string $id The identification of the match builder
|
||||
*
|
||||
* @return 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 Match $builder The builder which is being registered
|
||||
*/
|
||||
public function registerId($id, Match $builder);
|
||||
}
|
@@ -1,38 +1,39 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Builder;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Matcher\AnyParameters;
|
||||
|
||||
/**
|
||||
* 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
|
||||
interface ParametersMatch extends Match
|
||||
{
|
||||
/**
|
||||
* Sets the parameters to match for, each parameter to this funtion will
|
||||
* Sets the parameters to match for, each parameter to this function will
|
||||
* be part of match. To perform specific matches or constraints create a
|
||||
* new PHPUnit_Framework_Constraint and use it for the parameter.
|
||||
* new PHPUnit\Framework\Constraint\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.
|
||||
* 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));
|
||||
* $b->with('smock', new PHPUnit\Framework\Constraint\IsEqual(42));
|
||||
* </code>
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Builder_ParametersMatch
|
||||
* @return ParametersMatch
|
||||
*/
|
||||
public function with();
|
||||
public function with(...$arguments);
|
||||
|
||||
/**
|
||||
* Sets a matcher which allows any kind of parameters.
|
||||
@@ -40,10 +41,10 @@ interface PHPUnit_Framework_MockObject_Builder_ParametersMatch extends PHPUnit_F
|
||||
* Some examples:
|
||||
* <code>
|
||||
* // match any number of parameters
|
||||
* $b->withAnyParamers();
|
||||
* $b->withAnyParameters();
|
||||
* </code>
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_Matcher_AnyParameters
|
||||
* @return AnyParameters
|
||||
*/
|
||||
public function withAnyParameters();
|
||||
}
|
@@ -1,26 +1,28 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Builder;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Stub as BaseStub;
|
||||
|
||||
/**
|
||||
* 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
|
||||
interface Stub extends Identity
|
||||
{
|
||||
/**
|
||||
* Stubs the matching method with the stub object $stub. Any invocations of
|
||||
* the matched method will now be handled by the stub instead.
|
||||
*
|
||||
* @param PHPUnit_Framework_MockObject_Stub $stub The stub object.
|
||||
* @return PHPUnit_Framework_MockObject_Builder_Identity
|
||||
* @param BaseStub $stub
|
||||
*
|
||||
* @return Identity
|
||||
*/
|
||||
public function will(PHPUnit_Framework_MockObject_Stub $stub);
|
||||
public function will(BaseStub $stub);
|
||||
}
|
@@ -1,18 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject;
|
||||
|
||||
/**
|
||||
* Interface for invocations.
|
||||
*
|
||||
* @since Interface available since Release 1.0.0
|
||||
*/
|
||||
interface PHPUnit_Framework_MockObject_Invocation
|
||||
class BadMethodCallException extends \BadMethodCallException implements Exception
|
||||
{
|
||||
}
|
@@ -1,18 +1,17 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject;
|
||||
|
||||
/**
|
||||
* Interface for exceptions used by PHPUnit_MockObject.
|
||||
*
|
||||
* @since Interface available since Release 2.0.6
|
||||
*/
|
||||
interface PHPUnit_Framework_MockObject_Exception
|
||||
interface Exception
|
||||
{
|
||||
}
|
14
vendor/phpunit/phpunit-mock-objects/src/Exception/RuntimeException.php
vendored
Normal file
14
vendor/phpunit/phpunit-mock-objects/src/Exception/RuntimeException.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject;
|
||||
|
||||
class RuntimeException extends \RuntimeException implements Exception
|
||||
{
|
||||
}
|
17
vendor/phpunit/phpunit-mock-objects/src/ForwardCompatibility/MockObject.php
vendored
Normal file
17
vendor/phpunit/phpunit-mock-objects/src/ForwardCompatibility/MockObject.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
|
||||
namespace PHPUnit\Framework\MockObject;
|
||||
|
||||
use PHPUnit_Framework_MockObject_MockObject;
|
||||
|
||||
interface MockObject extends PHPUnit_Framework_MockObject_MockObject
|
||||
{
|
||||
}
|
@@ -1,255 +0,0 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Stub_MatcherCollection $collection
|
||||
* @param PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher
|
||||
*/
|
||||
public function __construct(PHPUnit_Framework_MockObject_Stub_MatcherCollection $collection, PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher)
|
||||
{
|
||||
$this->collection = $collection;
|
||||
$this->matcher = new PHPUnit_Framework_MockObject_Matcher(
|
||||
$invocationMatcher
|
||||
);
|
||||
|
||||
$this->collection->addMatcher($this->matcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Framework_MockObject_Matcher
|
||||
*/
|
||||
public function getMatcher()
|
||||
{
|
||||
return $this->matcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function id($id)
|
||||
{
|
||||
$this->collection->registerId($id, $this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Stub $stub
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function will(PHPUnit_Framework_MockObject_Stub $stub)
|
||||
{
|
||||
$this->matcher->stub = $stub;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function willReturn($value)
|
||||
{
|
||||
$stub = new PHPUnit_Framework_MockObject_Stub_Return(
|
||||
$value
|
||||
);
|
||||
|
||||
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 $value, ...
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function willReturnOnConsecutiveCalls()
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
||||
$stub = new PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls($args);
|
||||
|
||||
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_Exception
|
||||
*/
|
||||
private function canDefineParameters()
|
||||
{
|
||||
if ($this->matcher->methodNameMatcher === null) {
|
||||
throw new PHPUnit_Framework_Exception(
|
||||
'Method name matcher is not defined, cannot define parameter ' .
|
||||
' matcher without one'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->matcher->parametersMatcher !== null) {
|
||||
throw new PHPUnit_Framework_Exception(
|
||||
'Parameter matcher is already defined, cannot redefine'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $argument, ...
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function with()
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
||||
$this->canDefineParameters();
|
||||
|
||||
$this->matcher->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_Parameters($args);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed ...$argument
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
*/
|
||||
public function withConsecutive()
|
||||
{
|
||||
|
||||
$args = func_get_args();
|
||||
|
||||
$this->canDefineParameters();
|
||||
|
||||
$this->matcher->parametersMatcher =
|
||||
new PHPUnit_Framework_MockObject_Matcher_ConsecutiveParameters($args);
|
||||
|
||||
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_Exception(
|
||||
'Method name matcher is already defined, cannot redefine'
|
||||
);
|
||||
}
|
||||
|
||||
$this->matcher->methodNameMatcher = new PHPUnit_Framework_MockObject_Matcher_MethodName($constraint);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
<?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);
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
<?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);
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
<?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 identifiction of the match builder.
|
||||
* @return PHPUnit_Framework_MockObject_Builder_Match
|
||||
*/
|
||||
public function lookupId($id);
|
||||
|
||||
/**
|
||||
* Registers the match builder $builder with the identification $id. The
|
||||
* builder can later be looked up using lookupId() to figure out if it
|
||||
* has been invoked.
|
||||
*
|
||||
* @param string $id
|
||||
* The identification of the match builder.
|
||||
* @param PHPUnit_Framework_MockObject_Builder_Match $builder
|
||||
* The builder which is being registered.
|
||||
*/
|
||||
public function registerId($id, PHPUnit_Framework_MockObject_Builder_Match $builder);
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
<?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
|
||||
{
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
<?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
|
||||
{
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,5 +0,0 @@
|
||||
|
||||
{modifier} function {reference}{method_name}({arguments_decl})
|
||||
{
|
||||
throw new PHPUnit_Framework_MockObject_BadMethodCallException;
|
||||
}
|
@@ -1,152 +0,0 @@
|
||||
<?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 = array(
|
||||
'mysqli' => true,
|
||||
'SQLite' => true,
|
||||
'sqlite3' => true,
|
||||
'tidy' => true,
|
||||
'xmlwriter' => true,
|
||||
'xsl' => true
|
||||
);
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $uncloneableClasses = array(
|
||||
'Closure',
|
||||
'COMPersistHelper',
|
||||
'IteratorIterator',
|
||||
'RecursiveIteratorIterator',
|
||||
'SplFileObject',
|
||||
'PDORow',
|
||||
'ZipArchive'
|
||||
);
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $className;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $methodName;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $parameters;
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $methodname
|
||||
* @param array $parameters
|
||||
* @param bool $cloneObjects
|
||||
*/
|
||||
public function __construct($className, $methodName, array $parameters, $cloneObjects = false)
|
||||
{
|
||||
$this->className = $className;
|
||||
$this->methodName = $methodName;
|
||||
$this->parameters = $parameters;
|
||||
|
||||
if (!$cloneObjects) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->parameters as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->parameters[$key] = $this->cloneObject($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
$exporter = new Exporter;
|
||||
|
||||
return sprintf(
|
||||
'%s::%s(%s)',
|
||||
$this->className,
|
||||
$this->methodName,
|
||||
implode(
|
||||
', ',
|
||||
array_map(
|
||||
array($exporter, 'shortenedExport'),
|
||||
$this->parameters
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $original
|
||||
* @return object
|
||||
*/
|
||||
protected function cloneObject($original)
|
||||
{
|
||||
$cloneable = null;
|
||||
$object = new ReflectionObject($original);
|
||||
|
||||
// Check the blacklist before asking PHP reflection to work around
|
||||
// https://bugs.php.net/bug.php?id=53967
|
||||
if ($object->isInternal() &&
|
||||
isset(self::$uncloneableExtensions[$object->getExtensionName()])) {
|
||||
$cloneable = false;
|
||||
}
|
||||
|
||||
if ($cloneable === null) {
|
||||
foreach (self::$uncloneableClasses as $class) {
|
||||
if ($original instanceof $class) {
|
||||
$cloneable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($cloneable === null && method_exists($object, 'isCloneable')) {
|
||||
$cloneable = $object->isCloneable();
|
||||
}
|
||||
|
||||
if ($cloneable === null && $object->hasMethod('__clone')) {
|
||||
$method = $object->getMethod('__clone');
|
||||
$cloneable = $method->isPublic();
|
||||
}
|
||||
|
||||
if ($cloneable === null) {
|
||||
$cloneable = true;
|
||||
}
|
||||
|
||||
if ($cloneable) {
|
||||
try {
|
||||
return clone $original;
|
||||
} catch (Exception $e) {
|
||||
return $original;
|
||||
}
|
||||
} else {
|
||||
return $original;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
<?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);
|
||||
}
|
@@ -1,67 +0,0 @@
|
||||
<?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 occured.
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
* @abstract
|
||||
*/
|
||||
abstract class PHPUnit_Framework_MockObject_Matcher_InvokedRecorder implements PHPUnit_Framework_MockObject_Matcher_Invocation
|
||||
{
|
||||
/**
|
||||
* @var PHPUnit_Framework_MockObject_Invocation[]
|
||||
*/
|
||||
protected $invocations = array();
|
||||
|
||||
/**
|
||||
* @return 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;
|
||||
}
|
||||
}
|
@@ -1,127 +0,0 @@
|
||||
<?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 = array();
|
||||
|
||||
/**
|
||||
* @var PHPUnit_Framework_MockObject_Invocation
|
||||
*/
|
||||
protected $invocation;
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct(array $parameters)
|
||||
{
|
||||
foreach ($parameters as $parameter) {
|
||||
if (!($parameter instanceof PHPUnit_Framework_Constraint)) {
|
||||
$parameter = new PHPUnit_Framework_Constraint_IsEqual(
|
||||
$parameter
|
||||
);
|
||||
}
|
||||
|
||||
$this->parameters[] = $parameter;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
$text = 'with parameter';
|
||||
|
||||
foreach ($this->parameters as $index => $parameter) {
|
||||
if ($index > 0) {
|
||||
$text .= ' and';
|
||||
}
|
||||
|
||||
$text .= ' ' . $index . ' ' . $parameter->toString();
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
* @return bool
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
$this->invocation = $invocation;
|
||||
|
||||
return $this->verify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the invocation $invocation matches the current rules. If it
|
||||
* does the matcher will get the invoked() method called which should check
|
||||
* if an expectation is met.
|
||||
*
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
* Object containing information on a mocked or stubbed method which
|
||||
* was invoked.
|
||||
* @return bool
|
||||
* @throws PHPUnit_Framework_ExpectationFailedException
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
if ($this->invocation === null) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
'Mocked method does not exist.'
|
||||
);
|
||||
}
|
||||
|
||||
if (count($this->invocation->parameters) < count($this->parameters)) {
|
||||
$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;
|
||||
}
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
<?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();
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
<?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);
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
<?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);
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
<?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';
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
<?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_Exception(
|
||||
'The current object can only be returned when mocking an ' .
|
||||
'object, not a static class.'
|
||||
);
|
||||
}
|
||||
|
||||
return $invocation->object;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'return the current object';
|
||||
}
|
||||
}
|
1182
vendor/phpunit/phpunit-mock-objects/src/Generator.php
vendored
Normal file
1182
vendor/phpunit/phpunit-mock-objects/src/Generator.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
vendor/phpunit/phpunit-mock-objects/src/Generator/deprecation.tpl.dist
vendored
Normal file
2
vendor/phpunit/phpunit-mock-objects/src/Generator/deprecation.tpl.dist
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
@trigger_error({deprecation}, E_USER_DEPRECATED);
|
@@ -2,9 +2,10 @@
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = {configurable};
|
||||
|
||||
{clone}{mocked_methods}
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
public function expects(\PHPUnit\Framework\MockObject\Matcher\Invocation $matcher)
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->expects($matcher);
|
||||
}
|
||||
@@ -16,8 +17,8 @@
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -28,9 +29,12 @@
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}{epilogue}
|
@@ -1,7 +1,7 @@
|
||||
|
||||
public function method()
|
||||
{
|
||||
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
|
||||
{modifier} function {reference}{method_name}({arguments_decl})
|
||||
{
|
||||
{modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
|
||||
{{deprecation}
|
||||
$arguments = array({arguments_call});
|
||||
$count = func_num_args();
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'{class_name}', '{method_name}', $arguments, $this, {clone_arguments}
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'{class_name}', '{method_name}', $arguments, '{return_type}', $this, {clone_arguments}
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
20
vendor/phpunit/phpunit-mock-objects/src/Generator/mocked_method_void.tpl.dist
vendored
Normal file
20
vendor/phpunit/phpunit-mock-objects/src/Generator/mocked_method_void.tpl.dist
vendored
Normal file
@@ -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\ObjectInvocation(
|
||||
'{class_name}', '{method_name}', $arguments, '{return_type}', $this, {clone_arguments}
|
||||
)
|
||||
);
|
||||
}
|
5
vendor/phpunit/phpunit-mock-objects/src/Generator/mocked_static_method.tpl.dist
vendored
Normal file
5
vendor/phpunit/phpunit-mock-objects/src/Generator/mocked_static_method.tpl.dist
vendored
Normal file
@@ -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');
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
|
||||
{modifier} function {reference}{method_name}({arguments_decl})
|
||||
{modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
|
||||
{
|
||||
$arguments = array({arguments_call});
|
||||
$count = func_num_args();
|
||||
@@ -13,9 +13,9 @@
|
||||
}
|
||||
|
||||
$this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'{class_name}', '{method_name}', $arguments, $this, {clone_arguments}
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'{class_name}', '{method_name}', $arguments, '{return_type}', $this, {clone_arguments}
|
||||
)
|
||||
);
|
||||
|
||||
return call_user_func_array(array($this->__phpunit_originalObject, "{method_name}"), $arguments);
|
22
vendor/phpunit/phpunit-mock-objects/src/Generator/proxied_method_void.tpl.dist
vendored
Normal file
22
vendor/phpunit/phpunit-mock-objects/src/Generator/proxied_method_void.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\ObjectInvocation(
|
||||
'{class_name}', '{method_name}', $arguments, '{return_type}', $this, {clone_arguments}
|
||||
)
|
||||
);
|
||||
|
||||
call_user_func_array(array($this->__phpunit_originalObject, "{method_name}"), $arguments);
|
||||
}
|
31
vendor/phpunit/phpunit-mock-objects/src/Invocation/Invocation.php
vendored
Normal file
31
vendor/phpunit/phpunit-mock-objects/src/Invocation/Invocation.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject;
|
||||
|
||||
/**
|
||||
* Interface for invocations.
|
||||
*/
|
||||
interface Invocation
|
||||
{
|
||||
/**
|
||||
* @return mixed Mocked return value.
|
||||
*/
|
||||
public function generateReturnValue();
|
||||
|
||||
public function getClassName(): string;
|
||||
|
||||
public function getMethodName(): string;
|
||||
|
||||
public function getParameters(): array;
|
||||
|
||||
public function getReturnType(): string;
|
||||
|
||||
public function isReturnTypeNullable(): bool;
|
||||
}
|
@@ -1,35 +1,41 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Invocation;
|
||||
|
||||
/**
|
||||
* 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
|
||||
class ObjectInvocation extends StaticInvocation
|
||||
{
|
||||
/**
|
||||
* @var object
|
||||
*/
|
||||
public $object;
|
||||
private $object;
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $methodname
|
||||
* @param string $methodName
|
||||
* @param array $parameters
|
||||
* @param string $returnType
|
||||
* @param object $object
|
||||
* @param object $cloneObjects
|
||||
* @param bool $cloneObjects
|
||||
*/
|
||||
public function __construct($className, $methodName, array $parameters, $object, $cloneObjects = false)
|
||||
public function __construct($className, $methodName, array $parameters, $returnType, $object, $cloneObjects = false)
|
||||
{
|
||||
parent::__construct($className, $methodName, $parameters, $cloneObjects);
|
||||
parent::__construct($className, $methodName, $parameters, $returnType, $cloneObjects);
|
||||
|
||||
$this->object = $object;
|
||||
}
|
||||
|
||||
public function getObject()
|
||||
{
|
||||
return $this->object;
|
||||
}
|
||||
}
|
255
vendor/phpunit/phpunit-mock-objects/src/Invocation/StaticInvocation.php
vendored
Normal file
255
vendor/phpunit/phpunit-mock-objects/src/Invocation/StaticInvocation.php
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Invocation;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Generator;
|
||||
use PHPUnit\Framework\MockObject\Invocation;
|
||||
use PHPUnit\Framework\SelfDescribing;
|
||||
use ReflectionObject;
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
|
||||
/**
|
||||
* Represents a static invocation.
|
||||
*/
|
||||
class StaticInvocation implements Invocation, SelfDescribing
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $uncloneableExtensions = [
|
||||
'mysqli' => true,
|
||||
'SQLite' => true,
|
||||
'sqlite3' => true,
|
||||
'tidy' => true,
|
||||
'xmlwriter' => true,
|
||||
'xsl' => true
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $uncloneableClasses = [
|
||||
'Closure',
|
||||
'COMPersistHelper',
|
||||
'IteratorIterator',
|
||||
'RecursiveIteratorIterator',
|
||||
'SplFileObject',
|
||||
'PDORow',
|
||||
'ZipArchive'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $className;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $methodName;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $parameters;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $returnType;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isReturnTypeNullable = 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->isReturnTypeNullable = true;
|
||||
}
|
||||
|
||||
$this->returnType = $returnType;
|
||||
|
||||
if (!$cloneObjects) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->parameters as $key => $value) {
|
||||
if (\is_object($value)) {
|
||||
$this->parameters[$key] = $this->cloneObject($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getClassName(): string
|
||||
{
|
||||
return $this->className;
|
||||
}
|
||||
|
||||
public function getMethodName(): string
|
||||
{
|
||||
return $this->methodName;
|
||||
}
|
||||
|
||||
public function getParameters(): array
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
public function getReturnType(): string
|
||||
{
|
||||
return $this->returnType;
|
||||
}
|
||||
|
||||
public function isReturnTypeNullable(): bool
|
||||
{
|
||||
return $this->isReturnTypeNullable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed Mocked return value
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
* @throws \PHPUnit\Framework\MockObject\RuntimeException
|
||||
* @throws \PHPUnit\Framework\Exception
|
||||
*/
|
||||
public function generateReturnValue()
|
||||
{
|
||||
if ($this->isReturnTypeNullable) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (\strtolower($this->returnType)) {
|
||||
case '':
|
||||
case 'void':
|
||||
return;
|
||||
|
||||
case 'string':
|
||||
return '';
|
||||
|
||||
case 'float':
|
||||
return 0.0;
|
||||
|
||||
case 'int':
|
||||
return 0;
|
||||
|
||||
case 'bool':
|
||||
return false;
|
||||
|
||||
case 'array':
|
||||
return [];
|
||||
|
||||
case 'object':
|
||||
return new \stdClass;
|
||||
|
||||
case 'callable':
|
||||
case 'closure':
|
||||
return function () {
|
||||
};
|
||||
|
||||
case 'traversable':
|
||||
case 'generator':
|
||||
case 'iterable':
|
||||
$generator = function () {
|
||||
yield;
|
||||
};
|
||||
|
||||
return $generator();
|
||||
|
||||
default:
|
||||
$generator = new Generator;
|
||||
|
||||
return $generator->getMock($this->returnType, [], [], '', false);
|
||||
}
|
||||
}
|
||||
|
||||
public function toString(): string
|
||||
{
|
||||
$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) : ''
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $original
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
private 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) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,45 +1,61 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject;
|
||||
|
||||
use Exception;
|
||||
use PHPUnit\Framework\MockObject\Builder\InvocationMocker as BuilderInvocationMocker;
|
||||
use PHPUnit\Framework\MockObject\Builder\Match;
|
||||
use PHPUnit\Framework\MockObject\Builder\NamespaceMatch;
|
||||
use PHPUnit\Framework\MockObject\Matcher\Invocation as MatcherInvocation;
|
||||
use PHPUnit\Framework\MockObject\Stub\MatcherCollection;
|
||||
|
||||
/**
|
||||
* Mocker for invocations which are sent from
|
||||
* PHPUnit_Framework_MockObject_MockObject objects.
|
||||
* 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
|
||||
class InvocationMocker implements MatcherCollection, Invokable, NamespaceMatch
|
||||
{
|
||||
/**
|
||||
* @var PHPUnit_Framework_MockObject_Matcher_Invocation[]
|
||||
* @var MatcherInvocation[]
|
||||
*/
|
||||
protected $matchers = array();
|
||||
private $matchers = [];
|
||||
|
||||
/**
|
||||
* @var PHPUnit_Framework_MockObject_Builder_Match[]
|
||||
* @var Match[]
|
||||
*/
|
||||
protected $builderMap = array();
|
||||
private $builderMap = [];
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher
|
||||
* @var string[]
|
||||
*/
|
||||
public function addMatcher(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
private $configurableMethods = [];
|
||||
|
||||
/**
|
||||
* @param array $configurableMethods
|
||||
*/
|
||||
public function __construct(array $configurableMethods)
|
||||
{
|
||||
$this->configurableMethods = $configurableMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MatcherInvocation $matcher
|
||||
*/
|
||||
public function addMatcher(MatcherInvocation $matcher)
|
||||
{
|
||||
$this->matchers[] = $matcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since Method available since Release 1.1.0
|
||||
*/
|
||||
public function hasMatchers()
|
||||
{
|
||||
foreach ($this->matchers as $matcher) {
|
||||
@@ -52,7 +68,8 @@ class PHPUnit_Framework_MockObject_InvocationMocker implements PHPUnit_Framework
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return bool|null
|
||||
*/
|
||||
public function lookupId($id)
|
||||
@@ -65,14 +82,15 @@ class PHPUnit_Framework_MockObject_InvocationMocker implements PHPUnit_Framework
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id
|
||||
* @param PHPUnit_Framework_MockObject_Builder_Match $builder
|
||||
* @throws PHPUnit_Framework_Exception
|
||||
* @param mixed $id
|
||||
* @param Match $builder
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function registerId($id, PHPUnit_Framework_MockObject_Builder_Match $builder)
|
||||
public function registerId($id, Match $builder)
|
||||
{
|
||||
if (isset($this->builderMap[$id])) {
|
||||
throw new PHPUnit_Framework_Exception(
|
||||
throw new RuntimeException(
|
||||
'Match builder with id <' . $id . '> is already registered.'
|
||||
);
|
||||
}
|
||||
@@ -81,31 +99,31 @@ class PHPUnit_Framework_MockObject_InvocationMocker implements PHPUnit_Framework
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher
|
||||
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
|
||||
* @param MatcherInvocation $matcher
|
||||
*
|
||||
* @return BuilderInvocationMocker
|
||||
*/
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
public function expects(MatcherInvocation $matcher)
|
||||
{
|
||||
return new PHPUnit_Framework_MockObject_Builder_InvocationMocker(
|
||||
return new BuilderInvocationMocker(
|
||||
$this,
|
||||
$matcher
|
||||
$matcher,
|
||||
$this->configurableMethods
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
* @param Invocation $invocation
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
public function invoke(Invocation $invocation)
|
||||
{
|
||||
$exception = null;
|
||||
$hasReturnValue = false;
|
||||
|
||||
if (strtolower($invocation->methodName) == '__tostring') {
|
||||
$returnValue = '';
|
||||
} else {
|
||||
$returnValue = null;
|
||||
}
|
||||
$returnValue = null;
|
||||
|
||||
foreach ($this->matchers as $match) {
|
||||
try {
|
||||
@@ -126,14 +144,23 @@ class PHPUnit_Framework_MockObject_InvocationMocker implements PHPUnit_Framework
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
if ($hasReturnValue) {
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
if (\strtolower($invocation->getMethodName()) === '__tostring') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $invocation->generateReturnValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
* @param Invocation $invocation
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
public function matches(Invocation $invocation)
|
||||
{
|
||||
foreach ($this->matchers as $matcher) {
|
||||
if (!$matcher->matches($invocation)) {
|
||||
@@ -146,6 +173,8 @@ class PHPUnit_Framework_MockObject_InvocationMocker implements PHPUnit_Framework
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws \PHPUnit\Framework\ExpectationFailedException
|
||||
*/
|
||||
public function verify()
|
||||
{
|
38
vendor/phpunit/phpunit-mock-objects/src/Invokable.php
vendored
Normal file
38
vendor/phpunit/phpunit-mock-objects/src/Invokable.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject;
|
||||
|
||||
/**
|
||||
* Interface for classes which can be invoked.
|
||||
*
|
||||
* The invocation will be taken from a mock object and passed to an object
|
||||
* of this class.
|
||||
*/
|
||||
interface Invokable extends Verifiable
|
||||
{
|
||||
/**
|
||||
* Invokes the invocation object $invocation so that it can be checked for
|
||||
* expectations or matched against stubs.
|
||||
*
|
||||
* @param Invocation $invocation The invocation object passed from mock object
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function invoke(Invocation $invocation);
|
||||
|
||||
/**
|
||||
* Checks if the invocation matches.
|
||||
*
|
||||
* @param Invocation $invocation The invocation object passed from mock object
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matches(Invocation $invocation);
|
||||
}
|
@@ -1,12 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
use PHPUnit\Framework\MockObject\Matcher\AnyParameters;
|
||||
use PHPUnit\Framework\MockObject\Matcher\Invocation as MatcherInvocation;
|
||||
use PHPUnit\Framework\MockObject\Matcher\InvokedCount;
|
||||
use PHPUnit\Framework\MockObject\Matcher\MethodName;
|
||||
use PHPUnit\Framework\MockObject\Matcher\Parameters;
|
||||
use PHPUnit\Framework\TestFailure;
|
||||
|
||||
/**
|
||||
* Main matcher which defines a full expectation using method, parameter and
|
||||
@@ -16,55 +26,275 @@
|
||||
* 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
|
||||
class Matcher implements MatcherInvocation
|
||||
{
|
||||
/**
|
||||
* @var PHPUnit_Framework_MockObject_Matcher_Invocation
|
||||
* @var MatcherInvocation
|
||||
*/
|
||||
public $invocationMatcher;
|
||||
private $invocationMatcher;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
public $afterMatchBuilderId = null;
|
||||
private $afterMatchBuilderId = null;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $afterMatchBuilderIsInvoked = false;
|
||||
private $afterMatchBuilderIsInvoked = false;
|
||||
|
||||
/**
|
||||
* @var PHPUnit_Framework_MockObject_Matcher_MethodName
|
||||
* @var MethodName
|
||||
*/
|
||||
public $methodNameMatcher = null;
|
||||
private $methodNameMatcher = null;
|
||||
|
||||
/**
|
||||
* @var PHPUnit_Framework_MockObject_Matcher_Parameters
|
||||
* @var Parameters
|
||||
*/
|
||||
public $parametersMatcher = null;
|
||||
private $parametersMatcher = null;
|
||||
|
||||
/**
|
||||
* @var PHPUnit_Framework_MockObject_Stub
|
||||
* @var Stub
|
||||
*/
|
||||
public $stub = null;
|
||||
private $stub = null;
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher
|
||||
* @param MatcherInvocation $invocationMatcher
|
||||
*/
|
||||
public function __construct(PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher)
|
||||
public function __construct(MatcherInvocation $invocationMatcher)
|
||||
{
|
||||
$this->invocationMatcher = $invocationMatcher;
|
||||
}
|
||||
|
||||
public function hasMatchers(): bool
|
||||
{
|
||||
return $this->invocationMatcher !== null && !$this->invocationMatcher instanceof AnyInvokedCount;
|
||||
}
|
||||
|
||||
public function hasMethodNameMatcher(): bool
|
||||
{
|
||||
return $this->methodNameMatcher !== null;
|
||||
}
|
||||
|
||||
public function getMethodNameMatcher(): MethodName
|
||||
{
|
||||
return $this->methodNameMatcher;
|
||||
}
|
||||
|
||||
public function setMethodNameMatcher(MethodName $matcher)
|
||||
{
|
||||
$this->methodNameMatcher = $matcher;
|
||||
}
|
||||
|
||||
public function hasParametersMatcher(): bool
|
||||
{
|
||||
return $this->parametersMatcher !== null;
|
||||
}
|
||||
|
||||
public function getParametersMatcher(): Parameters
|
||||
{
|
||||
return $this->parametersMatcher;
|
||||
}
|
||||
|
||||
public function setParametersMatcher($matcher)
|
||||
{
|
||||
$this->parametersMatcher = $matcher;
|
||||
}
|
||||
|
||||
public function setStub($stub)
|
||||
{
|
||||
$this->stub = $stub;
|
||||
}
|
||||
|
||||
public function setAfterMatchBuilderId($id)
|
||||
{
|
||||
$this->afterMatchBuilderId = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Invocation $invocation
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws RuntimeException
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
public function invoked(Invocation $invocation)
|
||||
{
|
||||
if ($this->invocationMatcher === null) {
|
||||
throw new RuntimeException(
|
||||
'No invocation matcher is set'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->methodNameMatcher === null) {
|
||||
throw new RuntimeException('No method matcher is set');
|
||||
}
|
||||
|
||||
if ($this->afterMatchBuilderId !== null) {
|
||||
$builder = $invocation->getObject()
|
||||
->__phpunit_getInvocationMocker()
|
||||
->lookupId($this->afterMatchBuilderId);
|
||||
|
||||
if (!$builder) {
|
||||
throw new 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 (ExpectationFailedException $e) {
|
||||
throw new 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 Invocation $invocation
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
public function matches(Invocation $invocation)
|
||||
{
|
||||
if ($this->afterMatchBuilderId !== null) {
|
||||
$builder = $invocation->getObject()
|
||||
->__phpunit_getInvocationMocker()
|
||||
->lookupId($this->afterMatchBuilderId);
|
||||
|
||||
if (!$builder) {
|
||||
throw new 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 RuntimeException(
|
||||
'No invocation matcher is set'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->methodNameMatcher === null) {
|
||||
throw new RuntimeException('No method matcher is set');
|
||||
}
|
||||
|
||||
if (!$this->invocationMatcher->matches($invocation)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!$this->methodNameMatcher->matches($invocation)) {
|
||||
return false;
|
||||
}
|
||||
} catch (ExpectationFailedException $e) {
|
||||
throw new ExpectationFailedException(
|
||||
\sprintf(
|
||||
"Expectation failed for %s when %s\n%s",
|
||||
$this->methodNameMatcher->toString(),
|
||||
$this->invocationMatcher->toString(),
|
||||
$e->getMessage()
|
||||
),
|
||||
$e->getComparisonFailure()
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
if ($this->invocationMatcher === null) {
|
||||
throw new RuntimeException(
|
||||
'No invocation matcher is set'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->methodNameMatcher === null) {
|
||||
throw new RuntimeException('No method matcher is set');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->invocationMatcher->verify();
|
||||
|
||||
if ($this->parametersMatcher === null) {
|
||||
$this->parametersMatcher = new AnyParameters;
|
||||
}
|
||||
|
||||
$invocationIsAny = $this->invocationMatcher instanceof AnyInvokedCount;
|
||||
$invocationIsNever = $this->invocationMatcher instanceof InvokedCount && $this->invocationMatcher->isNever();
|
||||
|
||||
if (!$invocationIsAny && !$invocationIsNever) {
|
||||
$this->parametersMatcher->verify();
|
||||
}
|
||||
} catch (ExpectationFailedException $e) {
|
||||
throw new ExpectationFailedException(
|
||||
\sprintf(
|
||||
"Expectation failed for %s when %s.\n%s",
|
||||
$this->methodNameMatcher->toString(),
|
||||
$this->invocationMatcher->toString(),
|
||||
TestFailure::exceptionToString($e)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
$list = array();
|
||||
$list = [];
|
||||
|
||||
if ($this->invocationMatcher !== null) {
|
||||
$list[] = $this->invocationMatcher->toString();
|
||||
@@ -86,186 +316,6 @@ class PHPUnit_Framework_MockObject_Matcher implements PHPUnit_Framework_MockObje
|
||||
$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_Exception(
|
||||
'No invocation matcher is set'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->methodNameMatcher === null) {
|
||||
throw new PHPUnit_Framework_Exception('No method matcher is set');
|
||||
}
|
||||
|
||||
if ($this->afterMatchBuilderId !== null) {
|
||||
$builder = $invocation->object
|
||||
->__phpunit_getInvocationMocker()
|
||||
->lookupId($this->afterMatchBuilderId);
|
||||
|
||||
if (!$builder) {
|
||||
throw new PHPUnit_Framework_Exception(
|
||||
sprintf(
|
||||
'No builder found for match builder identification <%s>',
|
||||
$this->afterMatchBuilderId
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$matcher = $builder->getMatcher();
|
||||
|
||||
if ($matcher && $matcher->invocationMatcher->hasBeenInvoked()) {
|
||||
$this->afterMatchBuilderIsInvoked = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->invocationMatcher->invoked($invocation);
|
||||
|
||||
try {
|
||||
if ($this->parametersMatcher !== null &&
|
||||
!$this->parametersMatcher->matches($invocation)) {
|
||||
$this->parametersMatcher->verify();
|
||||
}
|
||||
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
sprintf(
|
||||
"Expectation failed for %s when %s\n%s",
|
||||
$this->methodNameMatcher->toString(),
|
||||
$this->invocationMatcher->toString(),
|
||||
$e->getMessage()
|
||||
),
|
||||
$e->getComparisonFailure()
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->stub) {
|
||||
return $this->stub->invoke($invocation);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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_Exception(
|
||||
sprintf(
|
||||
'No builder found for match builder identification <%s>',
|
||||
$this->afterMatchBuilderId
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$matcher = $builder->getMatcher();
|
||||
|
||||
if (!$matcher) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$matcher->invocationMatcher->hasBeenInvoked()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->invocationMatcher === null) {
|
||||
throw new PHPUnit_Framework_Exception(
|
||||
'No invocation matcher is set'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->methodNameMatcher === null) {
|
||||
throw new PHPUnit_Framework_Exception('No method matcher is set');
|
||||
}
|
||||
|
||||
if (!$this->invocationMatcher->matches($invocation)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!$this->methodNameMatcher->matches($invocation)) {
|
||||
return false;
|
||||
}
|
||||
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
sprintf(
|
||||
"Expectation failed for %s when %s\n%s",
|
||||
$this->methodNameMatcher->toString(),
|
||||
$this->invocationMatcher->toString(),
|
||||
$e->getMessage()
|
||||
),
|
||||
$e->getComparisonFailure()
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws PHPUnit_Framework_Exception
|
||||
* @throws PHPUnit_Framework_ExpectationFailedException
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
if ($this->invocationMatcher === null) {
|
||||
throw new PHPUnit_Framework_Exception(
|
||||
'No invocation matcher is set'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->methodNameMatcher === null) {
|
||||
throw new PHPUnit_Framework_Exception('No method matcher is set');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->invocationMatcher->verify();
|
||||
|
||||
if ($this->parametersMatcher === null) {
|
||||
$this->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_AnyParameters;
|
||||
}
|
||||
|
||||
$invocationIsAny = get_class($this->invocationMatcher) === 'PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount';
|
||||
$invocationIsNever = get_class($this->invocationMatcher) === '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;
|
||||
return \implode(' ', $list);
|
||||
}
|
||||
}
|
@@ -1,20 +1,19 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Matcher;
|
||||
|
||||
/**
|
||||
* 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
|
||||
class AnyInvokedCount extends InvokedRecorder
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
@@ -24,8 +23,6 @@ class PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount extends PHPUnit_Frame
|
||||
return 'invoked zero or more times';
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
}
|
@@ -1,19 +1,20 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Matcher;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
|
||||
|
||||
/**
|
||||
* 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
|
||||
class AnyParameters extends StatelessInvocation
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
@@ -24,10 +25,11 @@ class PHPUnit_Framework_MockObject_Matcher_AnyParameters extends PHPUnit_Framewo
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
* @param BaseInvocation $invocation
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
public function matches(BaseInvocation $invocation)
|
||||
{
|
||||
return true;
|
||||
}
|
@@ -1,12 +1,18 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Matcher;
|
||||
|
||||
use PHPUnit\Framework\Constraint\Constraint;
|
||||
use PHPUnit\Framework\Constraint\IsEqual;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
|
||||
|
||||
/**
|
||||
* Invocation matcher which looks for sets of specific parameters in the invocations.
|
||||
@@ -18,29 +24,32 @@
|
||||
* 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
|
||||
class ConsecutiveParameters extends StatelessInvocation
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_parameterGroups = array();
|
||||
private $parameterGroups = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_invocations = array();
|
||||
private $invocations = [];
|
||||
|
||||
/**
|
||||
* @param array $parameterGroups
|
||||
*
|
||||
* @throws \PHPUnit\Framework\Exception
|
||||
*/
|
||||
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);
|
||||
if (!$parameter instanceof Constraint) {
|
||||
$parameter = new IsEqual($parameter);
|
||||
}
|
||||
$this->_parameterGroups[$index][] = $parameter;
|
||||
|
||||
$this->parameterGroups[$index][] = $parameter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,19 +59,21 @@ class PHPUnit_Framework_MockObject_Matcher_ConsecutiveParameters extends PHPUnit
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
$text = 'with consecutive parameters';
|
||||
|
||||
return $text;
|
||||
return 'with consecutive parameters';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
* @param BaseInvocation $invocation
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \PHPUnit\Framework\ExpectationFailedException
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
public function matches(BaseInvocation $invocation)
|
||||
{
|
||||
$this->_invocations[] = $invocation;
|
||||
$callIndex = count($this->_invocations) - 1;
|
||||
$this->invocations[] = $invocation;
|
||||
$callIndex = \count($this->invocations) - 1;
|
||||
|
||||
$this->verifyInvocation($invocation, $callIndex);
|
||||
|
||||
return false;
|
||||
@@ -70,7 +81,7 @@ class PHPUnit_Framework_MockObject_Matcher_ConsecutiveParameters extends PHPUnit
|
||||
|
||||
public function verify()
|
||||
{
|
||||
foreach ($this->_invocations as $callIndex => $invocation) {
|
||||
foreach ($this->invocations as $callIndex => $invocation) {
|
||||
$this->verifyInvocation($invocation, $callIndex);
|
||||
}
|
||||
}
|
||||
@@ -78,29 +89,29 @@ class PHPUnit_Framework_MockObject_Matcher_ConsecutiveParameters extends PHPUnit
|
||||
/**
|
||||
* Verify a single invocation
|
||||
*
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
* @param int $callIndex
|
||||
* @throws PHPUnit_Framework_ExpectationFailedException
|
||||
* @param BaseInvocation $invocation
|
||||
* @param int $callIndex
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
private function verifyInvocation(PHPUnit_Framework_MockObject_Invocation $invocation, $callIndex)
|
||||
private function verifyInvocation(BaseInvocation $invocation, $callIndex)
|
||||
{
|
||||
|
||||
if (isset($this->_parameterGroups[$callIndex])) {
|
||||
$parameters = $this->_parameterGroups[$callIndex];
|
||||
if (isset($this->parameterGroups[$callIndex])) {
|
||||
$parameters = $this->parameterGroups[$callIndex];
|
||||
} else {
|
||||
// no parameter assertion for this call index
|
||||
// no parameter assertion for this call index
|
||||
return;
|
||||
}
|
||||
|
||||
if ($invocation === null) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
throw new ExpectationFailedException(
|
||||
'Mocked method does not exist.'
|
||||
);
|
||||
}
|
||||
|
||||
if (count($invocation->parameters) < count($parameters)) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
sprintf(
|
||||
if (\count($invocation->getParameters()) < \count($parameters)) {
|
||||
throw new ExpectationFailedException(
|
||||
\sprintf(
|
||||
'Parameter count for invocation %s is too low.',
|
||||
$invocation->toString()
|
||||
)
|
||||
@@ -109,8 +120,8 @@ class PHPUnit_Framework_MockObject_Matcher_ConsecutiveParameters extends PHPUnit
|
||||
|
||||
foreach ($parameters as $i => $parameter) {
|
||||
$parameter->evaluate(
|
||||
$invocation->parameters[$i],
|
||||
sprintf(
|
||||
$invocation->getParameters()[$i],
|
||||
\sprintf(
|
||||
'Parameter %s for invocation #%d %s does not match expected ' .
|
||||
'value.',
|
||||
$i,
|
@@ -1,20 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Matcher;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
|
||||
use PHPUnit\Framework\MockObject\Verifiable;
|
||||
use PHPUnit\Framework\SelfDescribing;
|
||||
|
||||
/**
|
||||
* 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
|
||||
interface Invocation extends SelfDescribing, Verifiable
|
||||
{
|
||||
/**
|
||||
* Registers the invocation $invocation in the object as being invoked.
|
||||
@@ -27,22 +30,20 @@ interface PHPUnit_Framework_MockObject_Matcher_Invocation extends PHPUnit_Framew
|
||||
*
|
||||
* 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.
|
||||
* @param BaseInvocation $invocation Object containing information on a mocked or stubbed method which was invoked
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation);
|
||||
public function invoked(BaseInvocation $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.
|
||||
* @param BaseInvocation $invocation Object containing information on a mocked or stubbed method which was invoked
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation);
|
||||
public function matches(BaseInvocation $invocation);
|
||||
}
|
@@ -1,12 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Matcher;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
|
||||
|
||||
/**
|
||||
* Invocation matcher which checks if a method was invoked at a certain index.
|
||||
@@ -17,20 +21,18 @@
|
||||
* 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
|
||||
class InvokedAtIndex implements Invocation
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $sequenceIndex;
|
||||
private $sequenceIndex;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $currentIndex = -1;
|
||||
private $currentIndex = -1;
|
||||
|
||||
/**
|
||||
* @param int $sequenceIndex
|
||||
@@ -49,10 +51,11 @@ class PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex implements PHPUnit_Fra
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
* @param BaseInvocation $invocation
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
public function matches(BaseInvocation $invocation)
|
||||
{
|
||||
$this->currentIndex++;
|
||||
|
||||
@@ -60,9 +63,9 @@ class PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex implements PHPUnit_Fra
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
* @param BaseInvocation $invocation
|
||||
*/
|
||||
public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
public function invoked(BaseInvocation $invocation)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -70,13 +73,13 @@ class PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex implements PHPUnit_Fra
|
||||
* 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
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
if ($this->currentIndex < $this->sequenceIndex) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
sprintf(
|
||||
throw new ExpectationFailedException(
|
||||
\sprintf(
|
||||
'The expected invocation at index %s was never reached.',
|
||||
$this->sequenceIndex
|
||||
)
|
@@ -1,20 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Matcher;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
/**
|
||||
* 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
|
||||
class InvokedAtLeastCount extends InvokedRecorder
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
@@ -41,16 +42,16 @@ class PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastCount extends PHPUnit_F
|
||||
* 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
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
$count = $this->getInvocationCount();
|
||||
|
||||
if ($count < $this->requiredInvocations) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
throw new ExpectationFailedException(
|
||||
'Expected invocation at least ' . $this->requiredInvocations .
|
||||
' times but it occured ' . $count . ' time(s).'
|
||||
' times but it occurred ' . $count . ' time(s).'
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,22 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Matcher;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
/**
|
||||
* 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
|
||||
class InvokedAtLeastOnce extends InvokedRecorder
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
@@ -30,15 +31,15 @@ class PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce extends PHPUnit_Fr
|
||||
* 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
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
$count = $this->getInvocationCount();
|
||||
|
||||
if ($count < 1) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
'Expected invocation at least once but it never occured.'
|
||||
throw new ExpectationFailedException(
|
||||
'Expected invocation at least once but it never occurred.'
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,20 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Matcher;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
/**
|
||||
* 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
|
||||
class InvokedAtMostCount extends InvokedRecorder
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
@@ -41,16 +42,16 @@ class PHPUnit_Framework_MockObject_Matcher_InvokedAtMostCount extends PHPUnit_Fr
|
||||
* 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
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
$count = $this->getInvocationCount();
|
||||
|
||||
if ($count > $this->allowedInvocations) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
throw new ExpectationFailedException(
|
||||
'Expected invocation at most ' . $this->allowedInvocations .
|
||||
' times but it occured ' . $count . ' time(s).'
|
||||
' times but it occurred ' . $count . ' time(s).'
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,12 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Matcher;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
|
||||
|
||||
/**
|
||||
* Invocation matcher which checks if a method has been invoked a certain amount
|
||||
@@ -15,15 +19,13 @@
|
||||
* 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
|
||||
class InvokedCount extends InvokedRecorder
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $expectedCount;
|
||||
private $expectedCount;
|
||||
|
||||
/**
|
||||
* @param int $expectedCount
|
||||
@@ -38,7 +40,7 @@ class PHPUnit_Framework_MockObject_Matcher_InvokedCount extends PHPUnit_Framewor
|
||||
*/
|
||||
public function isNever()
|
||||
{
|
||||
return $this->expectedCount == 0;
|
||||
return $this->expectedCount === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,10 +52,11 @@ class PHPUnit_Framework_MockObject_Matcher_InvokedCount extends PHPUnit_Framewor
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
* @throws PHPUnit_Framework_ExpectationFailedException
|
||||
* @param BaseInvocation $invocation
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
public function invoked(BaseInvocation $invocation)
|
||||
{
|
||||
parent::invoked($invocation);
|
||||
|
||||
@@ -63,25 +66,24 @@ class PHPUnit_Framework_MockObject_Matcher_InvokedCount extends PHPUnit_Framewor
|
||||
$message = $invocation->toString() . ' ';
|
||||
|
||||
switch ($this->expectedCount) {
|
||||
case 0: {
|
||||
case 0:
|
||||
$message .= 'was not expected to be called.';
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: {
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$message .= 'was not expected to be called more than once.';
|
||||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
$message .= sprintf(
|
||||
break;
|
||||
|
||||
default:
|
||||
$message .= \sprintf(
|
||||
'was not expected to be called more than %d times.',
|
||||
$this->expectedCount
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
throw new PHPUnit_Framework_ExpectationFailedException($message);
|
||||
throw new ExpectationFailedException($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,15 +91,15 @@ class PHPUnit_Framework_MockObject_Matcher_InvokedCount extends PHPUnit_Framewor
|
||||
* 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
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
$count = $this->getInvocationCount();
|
||||
|
||||
if ($count !== $this->expectedCount) {
|
||||
throw new PHPUnit_Framework_ExpectationFailedException(
|
||||
sprintf(
|
||||
throw new ExpectationFailedException(
|
||||
\sprintf(
|
||||
'Method was expected to be called %d times, ' .
|
||||
'actually called %d times.',
|
||||
$this->expectedCount,
|
68
vendor/phpunit/phpunit-mock-objects/src/Matcher/InvokedRecorder.php
vendored
Normal file
68
vendor/phpunit/phpunit-mock-objects/src/Matcher/InvokedRecorder.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Matcher;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
abstract class InvokedRecorder implements Invocation
|
||||
{
|
||||
/**
|
||||
* @var BaseInvocation[]
|
||||
*/
|
||||
private $invocations = [];
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getInvocationCount()
|
||||
{
|
||||
return \count($this->invocations);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BaseInvocation[]
|
||||
*/
|
||||
public function getInvocations()
|
||||
{
|
||||
return $this->invocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasBeenInvoked()
|
||||
{
|
||||
return \count($this->invocations) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BaseInvocation $invocation
|
||||
*/
|
||||
public function invoked(BaseInvocation $invocation)
|
||||
{
|
||||
$this->invocations[] = $invocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BaseInvocation $invocation
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matches(BaseInvocation $invocation)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -1,12 +1,18 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Matcher;
|
||||
|
||||
use PHPUnit\Framework\Constraint\Constraint;
|
||||
use PHPUnit\Framework\Constraint\IsEqual;
|
||||
use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
|
||||
use PHPUnit\Util\InvalidArgumentHelper;
|
||||
|
||||
/**
|
||||
* Invocation matcher which looks for a specific method name in the invocations.
|
||||
@@ -14,28 +20,28 @@
|
||||
* 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
|
||||
class MethodName extends StatelessInvocation
|
||||
{
|
||||
/**
|
||||
* @var PHPUnit_Framework_Constraint
|
||||
* @var Constraint
|
||||
*/
|
||||
protected $constraint;
|
||||
private $constraint;
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_Constraint|string
|
||||
* @throws PHPUnit_Framework_Constraint
|
||||
* @param Constraint|string
|
||||
*
|
||||
* @throws Constraint
|
||||
* @throws \PHPUnit\Framework\Exception
|
||||
*/
|
||||
public function __construct($constraint)
|
||||
{
|
||||
if (!$constraint instanceof PHPUnit_Framework_Constraint) {
|
||||
if (!is_string($constraint)) {
|
||||
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
|
||||
if (!$constraint instanceof Constraint) {
|
||||
if (!\is_string($constraint)) {
|
||||
throw InvalidArgumentHelper::factory(1, 'string');
|
||||
}
|
||||
|
||||
$constraint = new PHPUnit_Framework_Constraint_IsEqual(
|
||||
$constraint = new IsEqual(
|
||||
$constraint,
|
||||
0,
|
||||
10,
|
||||
@@ -56,11 +62,12 @@ class PHPUnit_Framework_MockObject_Matcher_MethodName extends PHPUnit_Framework_
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_MockObject_Invocation $invocation
|
||||
* @param BaseInvocation $invocation
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
public function matches(BaseInvocation $invocation)
|
||||
{
|
||||
return $this->constraint->evaluate($invocation->methodName, '', true);
|
||||
return $this->constraint->evaluate($invocation->getMethodName(), '', true);
|
||||
}
|
||||
}
|
165
vendor/phpunit/phpunit-mock-objects/src/Matcher/Parameters.php
vendored
Normal file
165
vendor/phpunit/phpunit-mock-objects/src/Matcher/Parameters.php
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Matcher;
|
||||
|
||||
use PHPUnit\Framework\Constraint\Constraint;
|
||||
use PHPUnit\Framework\Constraint\IsAnything;
|
||||
use PHPUnit\Framework\Constraint\IsEqual;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
|
||||
|
||||
/**
|
||||
* 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().
|
||||
*/
|
||||
class Parameters extends StatelessInvocation
|
||||
{
|
||||
/**
|
||||
* @var Constraint[]
|
||||
*/
|
||||
private $parameters = [];
|
||||
|
||||
/**
|
||||
* @var BaseInvocation
|
||||
*/
|
||||
private $invocation;
|
||||
|
||||
/**
|
||||
* @var ExpectationFailedException
|
||||
*/
|
||||
private $parameterVerificationResult;
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
*
|
||||
* @throws \PHPUnit\Framework\Exception
|
||||
*/
|
||||
public function __construct(array $parameters)
|
||||
{
|
||||
foreach ($parameters as $parameter) {
|
||||
if (!($parameter instanceof Constraint)) {
|
||||
$parameter = new 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 BaseInvocation $invocation
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function matches(BaseInvocation $invocation)
|
||||
{
|
||||
$this->invocation = $invocation;
|
||||
$this->parameterVerificationResult = null;
|
||||
|
||||
try {
|
||||
$this->parameterVerificationResult = $this->verify();
|
||||
|
||||
return $this->parameterVerificationResult;
|
||||
} catch (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 ExpectationFailedException
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
if (isset($this->parameterVerificationResult)) {
|
||||
return $this->guardAgainstDuplicateEvaluationOfParameterConstraints();
|
||||
}
|
||||
|
||||
if ($this->invocation === null) {
|
||||
throw new ExpectationFailedException('Mocked method does not exist.');
|
||||
}
|
||||
|
||||
if (\count($this->invocation->getParameters()) < \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]) === IsAnything::class) {
|
||||
$message .= "\nTo allow 0 or more parameters with any value, omit ->with() or use ->withAnyParameters() instead.";
|
||||
}
|
||||
|
||||
throw new ExpectationFailedException(
|
||||
\sprintf($message, $this->invocation->toString())
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($this->parameters as $i => $parameter) {
|
||||
$parameter->evaluate(
|
||||
$this->invocation->getParameters()[$i],
|
||||
\sprintf(
|
||||
'Parameter %s for invocation %s does not match expected ' .
|
||||
'value.',
|
||||
$i,
|
||||
$this->invocation->toString()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
private function guardAgainstDuplicateEvaluationOfParameterConstraints()
|
||||
{
|
||||
if ($this->parameterVerificationResult instanceof \Exception) {
|
||||
throw $this->parameterVerificationResult;
|
||||
}
|
||||
|
||||
return (bool) $this->parameterVerificationResult;
|
||||
}
|
||||
}
|
@@ -1,12 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Matcher;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
|
||||
|
||||
/**
|
||||
* Invocation matcher which does not care about previous state from earlier
|
||||
@@ -14,11 +17,8 @@
|
||||
*
|
||||
* 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
|
||||
abstract class StatelessInvocation implements Invocation
|
||||
{
|
||||
/**
|
||||
* Registers the invocation $invocation in the object as being invoked.
|
||||
@@ -31,12 +31,11 @@ abstract class PHPUnit_Framework_MockObject_Matcher_StatelessInvocation implemen
|
||||
*
|
||||
* 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.
|
||||
* @param BaseInvocation $invocation Object containing information on a mocked or stubbed method which was invoked
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
public function invoked(BaseInvocation $invocation)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -45,9 +44,8 @@ abstract class PHPUnit_Framework_MockObject_Matcher_StatelessInvocation implemen
|
||||
* 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.
|
||||
* @param Invocation $invocation Object containing information on a mocked or stubbed method which was invoked
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function verify()
|
@@ -1,22 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Implementation of the Builder pattern for Mock objects.
|
||||
*
|
||||
* @since File available since Release 1.0.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_MockBuilder
|
||||
class MockBuilder
|
||||
{
|
||||
/**
|
||||
* @var PHPUnit_Framework_TestCase
|
||||
* @var TestCase
|
||||
*/
|
||||
private $testCase;
|
||||
|
||||
@@ -28,7 +29,12 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $methods = array();
|
||||
private $methods = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $methodsExcept = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
@@ -38,7 +44,7 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $constructorArgs = array();
|
||||
private $constructorArgs = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
@@ -71,23 +77,34 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
private $proxyTarget = null;
|
||||
|
||||
/**
|
||||
* @param PHPUnit_Framework_TestCase $testCase
|
||||
* @param array|string $type
|
||||
* @var bool
|
||||
*/
|
||||
public function __construct(PHPUnit_Framework_TestCase $testCase, $type)
|
||||
private $allowMockingUnknownTypes = true;
|
||||
|
||||
/**
|
||||
* @var Generator
|
||||
*/
|
||||
private $generator;
|
||||
|
||||
/**
|
||||
* @param TestCase $testCase
|
||||
* @param array|string $type
|
||||
*/
|
||||
public function __construct(TestCase $testCase, $type)
|
||||
{
|
||||
$this->testCase = $testCase;
|
||||
$this->type = $type;
|
||||
$this->testCase = $testCase;
|
||||
$this->type = $type;
|
||||
$this->generator = new Generator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a mock object using a fluent interface.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockObject
|
||||
* @return MockObject
|
||||
*/
|
||||
public function getMock()
|
||||
{
|
||||
return $this->testCase->getMock(
|
||||
$object = $this->generator->getMock(
|
||||
$this->type,
|
||||
$this->methods,
|
||||
$this->constructorArgs,
|
||||
@@ -97,18 +114,23 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
$this->autoload,
|
||||
$this->cloneArguments,
|
||||
$this->callOriginalMethods,
|
||||
$this->proxyTarget
|
||||
$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
|
||||
* @return MockObject
|
||||
*/
|
||||
public function getMockForAbstractClass()
|
||||
{
|
||||
return $this->testCase->getMockForAbstractClass(
|
||||
$object = $this->generator->getMockForAbstractClass(
|
||||
$this->type,
|
||||
$this->constructorArgs,
|
||||
$this->mockClassName,
|
||||
@@ -118,16 +140,20 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
$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
|
||||
* @return MockObject
|
||||
*/
|
||||
public function getMockForTrait()
|
||||
{
|
||||
return $this->testCase->getMockForTrait(
|
||||
$object = $this->generator->getMockForTrait(
|
||||
$this->type,
|
||||
$this->constructorArgs,
|
||||
$this->mockClassName,
|
||||
@@ -137,26 +163,53 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
$this->methods,
|
||||
$this->cloneArguments
|
||||
);
|
||||
|
||||
$this->testCase->registerMockObject($object);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the subset of methods to mock. Default is to mock all of them.
|
||||
* Specifies the subset of methods to mock. Default is to mock none of them.
|
||||
*
|
||||
* @param array|null $methods
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
* @param array|null $methods
|
||||
*
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function setMethods($methods)
|
||||
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 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
|
||||
* @param array $args
|
||||
*
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function setConstructorArgs(array $args)
|
||||
{
|
||||
@@ -168,8 +221,9 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* Specifies the name for the mock class.
|
||||
*
|
||||
* @param string $name
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
* @param string $name
|
||||
*
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function setMockClassName($name)
|
||||
{
|
||||
@@ -181,7 +235,7 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* Disables the invocation of the original constructor.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function disableOriginalConstructor()
|
||||
{
|
||||
@@ -193,8 +247,7 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* Enables the invocation of the original constructor.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
* @since Method available since Release 1.2.0
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function enableOriginalConstructor()
|
||||
{
|
||||
@@ -206,7 +259,7 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* Disables the invocation of the original clone constructor.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function disableOriginalClone()
|
||||
{
|
||||
@@ -218,8 +271,7 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* Enables the invocation of the original clone constructor.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
* @since Method available since Release 1.2.0
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function enableOriginalClone()
|
||||
{
|
||||
@@ -231,7 +283,7 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* Disables the use of class autoloading while creating the mock object.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function disableAutoload()
|
||||
{
|
||||
@@ -243,8 +295,7 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* Enables the use of class autoloading while creating the mock object.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
* @since Method available since Release 1.2.0
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function enableAutoload()
|
||||
{
|
||||
@@ -256,8 +307,7 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* Disables the cloning of arguments passed to mocked methods.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
* @since Method available since Release 1.2.0
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function disableArgumentCloning()
|
||||
{
|
||||
@@ -269,8 +319,7 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* Enables the cloning of arguments passed to mocked methods.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
* @since Method available since Release 1.2.0
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function enableArgumentCloning()
|
||||
{
|
||||
@@ -282,8 +331,7 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* Enables the invocation of the original methods.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
* @since Method available since Release 2.0.0
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function enableProxyingToOriginalMethods()
|
||||
{
|
||||
@@ -295,8 +343,7 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* Disables the invocation of the original methods.
|
||||
*
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
* @since Method available since Release 2.0.0
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function disableProxyingToOriginalMethods()
|
||||
{
|
||||
@@ -309,9 +356,9 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
/**
|
||||
* Sets the proxy target.
|
||||
*
|
||||
* @param object $object
|
||||
* @return PHPUnit_Framework_MockObject_MockBuilder
|
||||
* @since Method available since Release 2.0.0
|
||||
* @param object $object
|
||||
*
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function setProxyTarget($object)
|
||||
{
|
||||
@@ -319,4 +366,24 @@ class PHPUnit_Framework_MockObject_MockBuilder
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function allowMockingUnknownTypes()
|
||||
{
|
||||
$this->allowMockingUnknownTypes = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function disallowMockingUnknownTypes()
|
||||
{
|
||||
$this->allowMockingUnknownTypes = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
55
vendor/phpunit/phpunit-mock-objects/src/MockObject.php
vendored
Normal file
55
vendor/phpunit/phpunit-mock-objects/src/MockObject.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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 PHPUnit\Framework\ExpectationFailedException;
|
||||
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
|
||||
use PHPUnit\Framework\MockObject\Matcher\Invocation;
|
||||
|
||||
/**
|
||||
* Interface for all mock objects which are generated by
|
||||
* MockBuilder.
|
||||
*
|
||||
* @method InvocationMocker method($constraint)
|
||||
*/
|
||||
interface PHPUnit_Framework_MockObject_MockObject /*extends Verifiable*/
|
||||
{
|
||||
/**
|
||||
* Registers a new expectation in the mock object and returns the match
|
||||
* object which can be infused with further details.
|
||||
*
|
||||
* @param Invocation $matcher
|
||||
*
|
||||
* @return InvocationMocker
|
||||
*/
|
||||
public function expects(Invocation $matcher);
|
||||
|
||||
/**
|
||||
* @return InvocationMocker
|
||||
*/
|
||||
public function __phpunit_setOriginalObject($originalObject);
|
||||
|
||||
/**
|
||||
* @return 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 ExpectationFailedException
|
||||
*/
|
||||
public function __phpunit_verify();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function __phpunit_hasMatchers();
|
||||
}
|
31
vendor/phpunit/phpunit-mock-objects/src/Stub.php
vendored
Normal file
31
vendor/phpunit/phpunit-mock-objects/src/Stub.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject;
|
||||
|
||||
use PHPUnit\Framework\SelfDescribing;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
interface Stub extends SelfDescribing
|
||||
{
|
||||
/**
|
||||
* Fakes the processing of the invocation $invocation by returning a
|
||||
* specific value.
|
||||
*
|
||||
* @param Invocation $invocation The invocation which was mocked and matched by the current method and argument matchers
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function invoke(Invocation $invocation);
|
||||
}
|
@@ -1,35 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Invocation;
|
||||
use PHPUnit\Framework\MockObject\Stub;
|
||||
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
|
||||
class ConsecutiveCalls implements Stub
|
||||
{
|
||||
protected $stack;
|
||||
protected $value;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $stack;
|
||||
|
||||
public function __construct($stack)
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $value;
|
||||
|
||||
public function __construct(array $stack)
|
||||
{
|
||||
$this->stack = $stack;
|
||||
}
|
||||
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
public function invoke(Invocation $invocation)
|
||||
{
|
||||
$this->value = array_shift($this->stack);
|
||||
$this->value = \array_shift($this->stack);
|
||||
|
||||
if ($this->value instanceof PHPUnit_Framework_MockObject_Stub) {
|
||||
if ($this->value instanceof Stub) {
|
||||
$this->value = $this->value->invoke($invocation);
|
||||
}
|
||||
|
||||
@@ -40,7 +48,7 @@ class PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls implements PHPUnit_Fram
|
||||
{
|
||||
$exporter = new Exporter;
|
||||
|
||||
return sprintf(
|
||||
return \sprintf(
|
||||
'return user-specified value %s',
|
||||
$exporter->export($this->value)
|
||||
);
|
@@ -1,30 +1,31 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Invocation;
|
||||
use PHPUnit\Framework\MockObject\Stub;
|
||||
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
|
||||
class Exception implements Stub
|
||||
{
|
||||
protected $exception;
|
||||
private $exception;
|
||||
|
||||
public function __construct(Exception $exception)
|
||||
public function __construct(\Throwable $exception)
|
||||
{
|
||||
$this->exception = $exception;
|
||||
}
|
||||
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
public function invoke(Invocation $invocation)
|
||||
{
|
||||
throw $this->exception;
|
||||
}
|
||||
@@ -33,7 +34,7 @@ class PHPUnit_Framework_MockObject_Stub_Exception implements PHPUnit_Framework_M
|
||||
{
|
||||
$exporter = new Exporter;
|
||||
|
||||
return sprintf(
|
||||
return \sprintf(
|
||||
'raise user-specified exception %s',
|
||||
$exporter->export($this->exception)
|
||||
);
|
26
vendor/phpunit/phpunit-mock-objects/src/Stub/MatcherCollection.php
vendored
Normal file
26
vendor/phpunit/phpunit-mock-objects/src/Stub/MatcherCollection.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Matcher\Invocation;
|
||||
|
||||
/**
|
||||
* Stubs a method by returning a user-defined value.
|
||||
*/
|
||||
interface MatcherCollection
|
||||
{
|
||||
/**
|
||||
* Adds a new matcher to the collection which can be used as an expectation
|
||||
* or a stub.
|
||||
*
|
||||
* @param Invocation $matcher Matcher for invocations to mock objects
|
||||
*/
|
||||
public function addMatcher(Invocation $matcher);
|
||||
}
|
43
vendor/phpunit/phpunit-mock-objects/src/Stub/ReturnArgument.php
vendored
Normal file
43
vendor/phpunit/phpunit-mock-objects/src/Stub/ReturnArgument.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Invocation;
|
||||
use PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
/**
|
||||
* Stubs a method by returning an argument that was passed to the mocked method.
|
||||
*/
|
||||
class ReturnArgument implements Stub
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $argumentIndex;
|
||||
|
||||
public function __construct($argumentIndex)
|
||||
{
|
||||
$this->argumentIndex = $argumentIndex;
|
||||
}
|
||||
|
||||
public function invoke(Invocation $invocation)
|
||||
{
|
||||
if (isset($invocation->getParameters()[$this->argumentIndex])) {
|
||||
return $invocation->getParameters()[$this->argumentIndex];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return \sprintf('return argument #%d', $this->argumentIndex);
|
||||
}
|
||||
}
|
52
vendor/phpunit/phpunit-mock-objects/src/Stub/ReturnCallback.php
vendored
Normal file
52
vendor/phpunit/phpunit-mock-objects/src/Stub/ReturnCallback.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Invocation;
|
||||
use PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
class ReturnCallback implements Stub
|
||||
{
|
||||
private $callback;
|
||||
|
||||
public function __construct($callback)
|
||||
{
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
public function invoke(Invocation $invocation)
|
||||
{
|
||||
return \call_user_func_array($this->callback, $invocation->getParameters());
|
||||
}
|
||||
|
||||
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]
|
||||
);
|
||||
}
|
||||
|
||||
return 'return result of user defined callback ' . $this->callback .
|
||||
' with the passed arguments';
|
||||
}
|
||||
}
|
45
vendor/phpunit/phpunit-mock-objects/src/Stub/ReturnReference.php
vendored
Normal file
45
vendor/phpunit/phpunit-mock-objects/src/Stub/ReturnReference.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Invocation;
|
||||
use PHPUnit\Framework\MockObject\Stub;
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
|
||||
/**
|
||||
* Stubs a method by returning a user-defined reference to a value.
|
||||
*/
|
||||
class ReturnReference implements Stub
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $reference;
|
||||
|
||||
public function __construct(&$reference)
|
||||
{
|
||||
$this->reference = &$reference;
|
||||
}
|
||||
|
||||
public function invoke(Invocation $invocation)
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
$exporter = new Exporter;
|
||||
|
||||
return \sprintf(
|
||||
'return user-specified reference %s',
|
||||
$exporter->export($this->reference)
|
||||
);
|
||||
}
|
||||
}
|
38
vendor/phpunit/phpunit-mock-objects/src/Stub/ReturnSelf.php
vendored
Normal file
38
vendor/phpunit/phpunit-mock-objects/src/Stub/ReturnSelf.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Invocation;
|
||||
use PHPUnit\Framework\MockObject\Invocation\ObjectInvocation;
|
||||
use PHPUnit\Framework\MockObject\RuntimeException;
|
||||
use PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
/**
|
||||
* Stubs a method by returning the current object.
|
||||
*/
|
||||
class ReturnSelf implements Stub
|
||||
{
|
||||
public function invoke(Invocation $invocation)
|
||||
{
|
||||
if (!$invocation instanceof ObjectInvocation) {
|
||||
throw new RuntimeException(
|
||||
'The current object can only be returned when mocking an ' .
|
||||
'object, not a static class.'
|
||||
);
|
||||
}
|
||||
|
||||
return $invocation->getObject();
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'return the current object';
|
||||
}
|
||||
}
|
@@ -1,30 +1,34 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Invocation;
|
||||
use PHPUnit\Framework\MockObject\Stub;
|
||||
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
|
||||
class ReturnStub implements Stub
|
||||
{
|
||||
protected $value;
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $value;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
public function invoke(Invocation $invocation)
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
@@ -33,7 +37,7 @@ class PHPUnit_Framework_MockObject_Stub_Return implements PHPUnit_Framework_Mock
|
||||
{
|
||||
$exporter = new Exporter;
|
||||
|
||||
return sprintf(
|
||||
return \sprintf(
|
||||
'return user-specified value %s',
|
||||
$exporter->export($this->value)
|
||||
);
|
@@ -1,38 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Invocation;
|
||||
use PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
/**
|
||||
* 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
|
||||
class ReturnValueMap implements Stub
|
||||
{
|
||||
protected $valueMap;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $valueMap;
|
||||
|
||||
public function __construct(array $valueMap)
|
||||
{
|
||||
$this->valueMap = $valueMap;
|
||||
}
|
||||
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
public function invoke(Invocation $invocation)
|
||||
{
|
||||
$parameterCount = count($invocation->parameters);
|
||||
$parameterCount = \count($invocation->getParameters());
|
||||
|
||||
foreach ($this->valueMap as $map) {
|
||||
if (!is_array($map) || $parameterCount != count($map) - 1) {
|
||||
if (!\is_array($map) || $parameterCount !== (\count($map) - 1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$return = array_pop($map);
|
||||
if ($invocation->parameters === $map) {
|
||||
$return = \array_pop($map);
|
||||
|
||||
if ($invocation->getParameters() === $map) {
|
||||
return $return;
|
||||
}
|
||||
}
|
@@ -1,25 +1,26 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
namespace PHPUnit\Framework\MockObject;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
/**
|
||||
* Interface for classes which must verify a given expectation.
|
||||
*
|
||||
* @since Interface available since Release 1.0.0
|
||||
*/
|
||||
interface PHPUnit_Framework_MockObject_Verifiable
|
||||
interface 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
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
public function verify();
|
||||
}
|
74
vendor/phpunit/phpunit-mock-objects/tests/Builder/InvocationMockerTest.php
vendored
Normal file
74
vendor/phpunit/phpunit-mock-objects/tests/Builder/InvocationMockerTest.php
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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 PHPUnit\Framework\TestCase;
|
||||
|
||||
class InvocationMockerTest extends 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());
|
||||
}
|
||||
}
|
@@ -1,9 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (version_compare(PHP_VERSION, '5.4.0', '<')) print 'skip: PHP >= 5.4.0 required';
|
||||
?>
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
trait BaseTrait
|
||||
@@ -44,23 +40,24 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['speak'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -81,22 +78,22 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'speak', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'speak', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -108,8 +105,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -120,10 +117,13 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
112
vendor/phpunit/phpunit-mock-objects/tests/Generator/3154_namespaced_constant_resolving.phpt
vendored
Normal file
112
vendor/phpunit/phpunit-mock-objects/tests/Generator/3154_namespaced_constant_resolving.phpt
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
--TEST--
|
||||
https://github.com/sebastianbergmann/phpunit-mock-objects/issues/420
|
||||
https://github.com/sebastianbergmann/phpunit/issues/3154
|
||||
--FILE--
|
||||
<?php
|
||||
namespace Is\Namespaced;
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (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.
|
||||
*/
|
||||
|
||||
const A_CONSTANT = 17;
|
||||
const PHP_VERSION = "0.0.0";
|
||||
|
||||
class Issue3154
|
||||
{
|
||||
public function a(int $i = PHP_INT_MAX, int $j = A_CONSTANT, string $v = \PHP_VERSION, string $z = '#'): string
|
||||
{
|
||||
return $z."sum: ".($i+$j).$v;
|
||||
}
|
||||
}
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
Issue3154::class,
|
||||
[],
|
||||
'Issue3154Mock',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
--EXPECT--
|
||||
class Issue3154Mock extends Is\Namespaced\Issue3154 implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['a'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function a(int $i = PHP_INT_MAX, int $j = Is\Namespaced\A_CONSTANT, string $v = PHP_VERSION, string $z = '#'): string
|
||||
{
|
||||
$arguments = array($i, $j, $v, $z);
|
||||
$count = func_num_args();
|
||||
|
||||
if ($count > 4) {
|
||||
$_arguments = func_get_args();
|
||||
|
||||
for ($i = 4; $i < $count; $i++) {
|
||||
$arguments[] = $_arguments[$i];
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Is\Namespaced\Issue3154', 'a', $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;
|
||||
}
|
||||
}
|
||||
}
|
101
vendor/phpunit/phpunit-mock-objects/tests/Generator/397.phpt
vendored
Normal file
101
vendor/phpunit/phpunit-mock-objects/tests/Generator/397.phpt
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
--TEST--
|
||||
https://github.com/sebastianbergmann/phpunit-mock-objects/issues/397
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!version_compare(PHP_VERSION, '7.1', '>=')) print 'skip: PHP >= 7.1 required';
|
||||
--FILE--
|
||||
<?php
|
||||
class C
|
||||
{
|
||||
public function m(?self $other): self
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
C::class,
|
||||
[],
|
||||
'MockC',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
--EXPECTF--
|
||||
class MockC extends C implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['m'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function m(?C $other): C
|
||||
{
|
||||
$arguments = array($other);
|
||||
$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\ObjectInvocation(
|
||||
'C', 'm', $arguments, 'C', $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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
abstract class Foo
|
||||
@@ -15,23 +15,24 @@ abstract class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['one', 'two', 'three'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -52,9 +53,9 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'one', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'one', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
@@ -74,9 +75,9 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'two', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'two', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
@@ -96,22 +97,22 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'three', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'three', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -123,8 +124,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -135,9 +136,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -15,23 +15,24 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar', 'baz'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -52,9 +53,9 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'bar', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'bar', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
@@ -74,22 +75,22 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'baz', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'baz', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -101,8 +102,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -113,9 +114,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -11,22 +11,23 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -34,14 +35,14 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
parent::__clone();
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -53,8 +54,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -65,9 +66,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -11,36 +11,37 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -52,8 +53,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -64,9 +65,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', FALSE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', false)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -11,36 +11,37 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
FALSE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
false
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -52,8 +53,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -64,9 +65,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -11,36 +11,37 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -52,8 +53,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -64,9 +65,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,7 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
interface IFoo
|
||||
{
|
||||
public function __construct($bar);
|
||||
@@ -18,36 +16,37 @@ class Foo implements IFoo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -59,8 +58,8 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -71,9 +70,12 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,7 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
interface IFoo
|
||||
{
|
||||
public function __construct($bar);
|
||||
@@ -18,36 +16,37 @@ class Foo implements IFoo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -59,8 +58,8 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -71,9 +70,12 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array('bar'), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array('bar'), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -15,23 +15,24 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array('bar'),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'Foo',
|
||||
array('bar'),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -52,22 +53,22 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'bar', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'bar', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -79,8 +80,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -91,9 +92,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
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