mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Tests: Backport two changes from PHPUnit 9.3:
* Replace the `Match` interface with `ParametersMatch`, to avoid parse errors due to `match` being a reserved keyword in PHP 8. * Replace `ReflectionParameter::getClass()` usage, which is deprecated in PHP 8. This allows tests relying on the `getMockForAbstractClass()` and `getMockBuilder()` methods to run again on PHP 8. When the test suite is updated for compatibility with PHPUnit 9.x, these overrides can be removed. Follow-up to [48972]. See #50913, #50902. git-svn-id: https://develop.svn.wordpress.org/trunk@49037 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
|
||||
@trigger_error({deprecation}, E_USER_DEPRECATED);
|
||||
@@ -0,0 +1,46 @@
|
||||
{prologue}{class_declaration}
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = {configurable};
|
||||
private $__phpunit_returnValueGeneration = true;
|
||||
|
||||
{clone}{mocked_methods}
|
||||
public function expects(\PHPUnit\Framework\MockObject\Matcher\Invocation $matcher)
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->expects($matcher);
|
||||
}
|
||||
{method}
|
||||
public function __phpunit_setOriginalObject($originalObject)
|
||||
{
|
||||
$this->__phpunit_originalObject = $originalObject;
|
||||
}
|
||||
|
||||
public function __phpunit_setReturnValueGeneration(bool $returnValueGeneration)
|
||||
{
|
||||
$this->__phpunit_returnValueGeneration = $returnValueGeneration;
|
||||
}
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable, $this->__phpunit_returnValueGeneration);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
}
|
||||
|
||||
public function __phpunit_hasMatchers()
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify(bool $unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}{epilogue}
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
public function method()
|
||||
{
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
|
||||
return call_user_func_array([$expects, 'method'], func_get_args());
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
{modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
|
||||
{{deprecation}
|
||||
$__phpunit_arguments = [{arguments_call}];
|
||||
$__phpunit_count = func_num_args();
|
||||
|
||||
if ($__phpunit_count > {arguments_count}) {
|
||||
$__phpunit_arguments_tmp = func_get_args();
|
||||
|
||||
for ($__phpunit_i = {arguments_count}; $__phpunit_i < $__phpunit_count; $__phpunit_i++) {
|
||||
$__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i];
|
||||
}
|
||||
}
|
||||
|
||||
$__phpunit_result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'{class_name}', '{method_name}', $__phpunit_arguments, '{return_type}', $this, {clone_arguments}
|
||||
)
|
||||
);
|
||||
|
||||
return $__phpunit_result;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
{modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
|
||||
{{deprecation}
|
||||
$__phpunit_arguments = [{arguments_call}];
|
||||
$__phpunit_count = func_num_args();
|
||||
|
||||
if ($__phpunit_count > {arguments_count}) {
|
||||
$__phpunit_arguments_tmp = func_get_args();
|
||||
|
||||
for ($__phpunit_i = {arguments_count}; $__phpunit_i < $__phpunit_count; $__phpunit_i++) {
|
||||
$__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i];
|
||||
}
|
||||
}
|
||||
|
||||
$this->__phpunit_getInvocationMocker()->invoke(
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'{class_name}', '{method_name}', $__phpunit_arguments, '{return_type}', $this, {clone_arguments}
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
{modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
|
||||
{
|
||||
throw new \PHPUnit\Framework\MockObject\BadMethodCallException('Static method "{method_name}" cannot be invoked on mock object');
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
{modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
|
||||
{
|
||||
$__phpunit_arguments = [{arguments_call}];
|
||||
$__phpunit_count = func_num_args();
|
||||
|
||||
if ($__phpunit_count > {arguments_count}) {
|
||||
$__phpunit_arguments_tmp = func_get_args();
|
||||
|
||||
for ($__phpunit_i = {arguments_count}; $__phpunit_i < $__phpunit_count; $__phpunit_i++) {
|
||||
$__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i];
|
||||
}
|
||||
}
|
||||
|
||||
$__phpunit_invocation = new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'{class_name}', '{method_name}', $__phpunit_arguments, '{return_type}', $this, {clone_arguments}
|
||||
);
|
||||
|
||||
$__phpunit_invocation->setProxiedCall();
|
||||
|
||||
$this->__phpunit_getInvocationMocker()->invoke($__phpunit_invocation);
|
||||
|
||||
unset($__phpunit_invocation);
|
||||
|
||||
return call_user_func_array(array($this->__phpunit_originalObject, "{method_name}"), $__phpunit_arguments);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
{modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
|
||||
{
|
||||
$__phpunit_arguments = [{arguments_call}];
|
||||
$__phpunit_count = func_num_args();
|
||||
|
||||
if ($__phpunit_count > {arguments_count}) {
|
||||
$__phpunit_arguments_tmp = func_get_args();
|
||||
|
||||
for ($__phpunit_i = {arguments_count}; $__phpunit_i < $__phpunit_count; $__phpunit_i++) {
|
||||
$__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i];
|
||||
}
|
||||
}
|
||||
|
||||
$__phpunit_invocation = new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'{class_name}', '{method_name}', $__phpunit_arguments, '{return_type}', $this, {clone_arguments}
|
||||
);
|
||||
|
||||
$__phpunit_invocation->setProxiedCall();
|
||||
|
||||
$this->__phpunit_getInvocationMocker()->invoke($__phpunit_invocation);
|
||||
|
||||
unset($__phpunit_invocation);
|
||||
|
||||
call_user_func_array(array($this->__phpunit_originalObject, "{method_name}"), $__phpunit_arguments);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{prologue}class {class_name}
|
||||
{
|
||||
use {trait_name};
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
parent::__clone();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{namespace}class {class_name} extends \SoapClient
|
||||
{
|
||||
public function __construct($wsdl, array $options)
|
||||
{
|
||||
parent::__construct('{wsdl}', $options);
|
||||
}
|
||||
{methods}}
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
public function {method_name}({arguments})
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user