commitall
This commit is contained in:
48
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ConsecutiveCalls.php
vendored
Normal file
48
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ConsecutiveCalls.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
|
||||
/**
|
||||
* Stubs a method by returning a user-defined stack of values.
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls implements PHPUnit_Framework_MockObject_Stub
|
||||
{
|
||||
protected $stack;
|
||||
protected $value;
|
||||
|
||||
public function __construct($stack)
|
||||
{
|
||||
$this->stack = $stack;
|
||||
}
|
||||
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
$this->value = array_shift($this->stack);
|
||||
|
||||
if ($this->value instanceof PHPUnit_Framework_MockObject_Stub) {
|
||||
$this->value = $this->value->invoke($invocation);
|
||||
}
|
||||
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
$exporter = new Exporter;
|
||||
|
||||
return sprintf(
|
||||
'return user-specified value %s',
|
||||
$exporter->export($this->value)
|
||||
);
|
||||
}
|
||||
}
|
48
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/Exception.php
vendored
Normal file
48
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/Exception.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
|
||||
/**
|
||||
* Stubs a method by raising a user-defined exception.
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Stub_Exception implements PHPUnit_Framework_MockObject_Stub
|
||||
{
|
||||
protected $exception;
|
||||
|
||||
public function __construct($exception)
|
||||
{
|
||||
// TODO Replace check with type declaration when support for PHP 5 is dropped
|
||||
if (!$exception instanceof Throwable && !$exception instanceof Exception) {
|
||||
throw new PHPUnit_Framework_MockObject_RuntimeException(
|
||||
'Exception must be an instance of Throwable (PHP 7) or Exception (PHP 5)'
|
||||
);
|
||||
}
|
||||
|
||||
$this->exception = $exception;
|
||||
}
|
||||
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
throw $this->exception;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
$exporter = new Exporter;
|
||||
|
||||
return sprintf(
|
||||
'raise user-specified exception %s',
|
||||
$exporter->export($this->exception)
|
||||
);
|
||||
}
|
||||
}
|
25
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/MatcherCollection.php
vendored
Normal file
25
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/MatcherCollection.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stubs a method by returning a user-defined value.
|
||||
*
|
||||
* @since Interface available since Release 1.0.0
|
||||
*/
|
||||
interface PHPUnit_Framework_MockObject_Stub_MatcherCollection
|
||||
{
|
||||
/**
|
||||
* Adds a new matcher to the collection which can be used as an expectation
|
||||
* or a stub.
|
||||
*
|
||||
* @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher Matcher for invocations to mock objects
|
||||
*/
|
||||
public function addMatcher(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher);
|
||||
}
|
41
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/Return.php
vendored
Normal file
41
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/Return.php
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
|
||||
/**
|
||||
* Stubs a method by returning a user-defined value.
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Stub_Return implements PHPUnit_Framework_MockObject_Stub
|
||||
{
|
||||
protected $value;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
$exporter = new Exporter;
|
||||
|
||||
return sprintf(
|
||||
'return user-specified value %s',
|
||||
$exporter->export($this->value)
|
||||
);
|
||||
}
|
||||
}
|
38
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnArgument.php
vendored
Normal file
38
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnArgument.php
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stubs a method by returning an argument that was passed to the mocked method.
|
||||
*
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Stub_ReturnArgument extends PHPUnit_Framework_MockObject_Stub_Return
|
||||
{
|
||||
protected $argumentIndex;
|
||||
|
||||
public function __construct($argumentIndex)
|
||||
{
|
||||
$this->argumentIndex = $argumentIndex;
|
||||
}
|
||||
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
if (isset($invocation->parameters[$this->argumentIndex])) {
|
||||
return $invocation->parameters[$this->argumentIndex];
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return sprintf('return argument #%d', $this->argumentIndex);
|
||||
}
|
||||
}
|
51
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnCallback.php
vendored
Normal file
51
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnCallback.php
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Stub_ReturnCallback implements PHPUnit_Framework_MockObject_Stub
|
||||
{
|
||||
protected $callback;
|
||||
|
||||
public function __construct($callback)
|
||||
{
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
return call_user_func_array($this->callback, $invocation->parameters);
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
if (is_array($this->callback)) {
|
||||
if (is_object($this->callback[0])) {
|
||||
$class = get_class($this->callback[0]);
|
||||
$type = '->';
|
||||
} else {
|
||||
$class = $this->callback[0];
|
||||
$type = '::';
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'return result of user defined callback %s%s%s() with the ' .
|
||||
'passed arguments',
|
||||
$class,
|
||||
$type,
|
||||
$this->callback[1]
|
||||
);
|
||||
} else {
|
||||
return 'return result of user defined callback ' . $this->callback .
|
||||
' with the passed arguments';
|
||||
}
|
||||
}
|
||||
}
|
22
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnReference.php
vendored
Normal file
22
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnReference.php
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stubs a method by returning a user-defined reference to a value.
|
||||
*
|
||||
* @since Class available since Release 3.0.7
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Stub_ReturnReference extends PHPUnit_Framework_MockObject_Stub_Return
|
||||
{
|
||||
public function __construct(&$value)
|
||||
{
|
||||
$this->value = &$value;
|
||||
}
|
||||
}
|
34
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnSelf.php
vendored
Normal file
34
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnSelf.php
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stubs a method by returning the current object.
|
||||
*
|
||||
* @since Class available since Release 1.1.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Stub_ReturnSelf implements PHPUnit_Framework_MockObject_Stub
|
||||
{
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
if (!$invocation instanceof PHPUnit_Framework_MockObject_Invocation_Object) {
|
||||
throw new PHPUnit_Framework_MockObject_RuntimeException(
|
||||
'The current object can only be returned when mocking an ' .
|
||||
'object, not a static class.'
|
||||
);
|
||||
}
|
||||
|
||||
return $invocation->object;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'return the current object';
|
||||
}
|
||||
}
|
47
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnValueMap.php
vendored
Normal file
47
vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/ReturnValueMap.php
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stubs a method by returning a value from a map.
|
||||
*
|
||||
* @since Class available since Release 1.1.0
|
||||
*/
|
||||
class PHPUnit_Framework_MockObject_Stub_ReturnValueMap implements PHPUnit_Framework_MockObject_Stub
|
||||
{
|
||||
protected $valueMap;
|
||||
|
||||
public function __construct(array $valueMap)
|
||||
{
|
||||
$this->valueMap = $valueMap;
|
||||
}
|
||||
|
||||
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
|
||||
{
|
||||
$parameterCount = count($invocation->parameters);
|
||||
|
||||
foreach ($this->valueMap as $map) {
|
||||
if (!is_array($map) || $parameterCount != count($map) - 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$return = array_pop($map);
|
||||
if ($invocation->parameters === $map) {
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'return value from a map';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user