diff --git a/.psalm/baseline.xml b/.psalm/baseline.xml index 5874f62456b..8959e902162 100644 --- a/.psalm/baseline.xml +++ b/.psalm/baseline.xml @@ -255,7 +255,6 @@ - __getFunctions()]]> diff --git a/src/Framework/MockObject/Generator/Exception/ClassIsReadonlyException.php b/src/Framework/MockObject/Exception/CannotCloneTestDoubleForReadonlyClassException.php similarity index 53% rename from src/Framework/MockObject/Generator/Exception/ClassIsReadonlyException.php rename to src/Framework/MockObject/Exception/CannotCloneTestDoubleForReadonlyClassException.php index 7cf07fe9c79..00c0c0b120e 100644 --- a/src/Framework/MockObject/Generator/Exception/ClassIsReadonlyException.php +++ b/src/Framework/MockObject/Exception/CannotCloneTestDoubleForReadonlyClassException.php @@ -7,22 +7,19 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -namespace PHPUnit\Framework\MockObject\Generator; - -use function sprintf; +namespace PHPUnit\Framework\MockObject; /** * @internal This class is not covered by the backward compatibility promise for PHPUnit + * + * @codeCoverageIgnore */ -final class ClassIsReadonlyException extends \PHPUnit\Framework\Exception implements Exception +final class CannotCloneTestDoubleForReadonlyClassException extends \PHPUnit\Framework\Exception implements Exception { - public function __construct(string $className) + public function __construct() { parent::__construct( - sprintf( - 'Class "%s" is declared "readonly" and cannot be doubled', - $className, - ), + 'Cloning test doubles for readonly classes is not supported on PHP 8.2', ); } } diff --git a/src/Framework/MockObject/Generator/Generator.php b/src/Framework/MockObject/Generator/Generator.php index 526415dd972..772065a4425 100644 --- a/src/Framework/MockObject/Generator/Generator.php +++ b/src/Framework/MockObject/Generator/Generator.php @@ -48,18 +48,22 @@ use PHPUnit\Framework\InvalidArgumentException; use PHPUnit\Framework\MockObject\ConfigurableMethod; use PHPUnit\Framework\MockObject\DoubledCloneMethod; +use PHPUnit\Framework\MockObject\ErrorCloneMethod; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\GeneratedAsTestStub; use PHPUnit\Framework\MockObject\Method; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\MockObjectInternal; +use PHPUnit\Framework\MockObject\MutableStubApi; use PHPUnit\Framework\MockObject\ProxiedCloneMethod; use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\MockObject\StubApi; use PHPUnit\Framework\MockObject\StubInternal; +use PHPUnit\Framework\MockObject\TestDoubleState; use ReflectionClass; use ReflectionMethod; +use ReflectionObject; use SoapClient; use SoapFault; use Throwable; @@ -99,7 +103,6 @@ final class Generator * @throws ClassAlreadyExistsException * @throws ClassIsEnumerationException * @throws ClassIsFinalException - * @throws ClassIsReadonlyException * @throws DuplicateMethodException * @throws InvalidMethodNameException * @throws OriginalConstructorInvocationRequiredException @@ -232,7 +235,6 @@ public function testDoubleForInterfaceIntersection(array $interfaces, bool $mock * @throws ClassAlreadyExistsException * @throws ClassIsEnumerationException * @throws ClassIsFinalException - * @throws ClassIsReadonlyException * @throws DuplicateMethodException * @throws InvalidArgumentException * @throws InvalidMethodNameException @@ -293,7 +295,6 @@ interface_exists($originalClassName, $callAutoload)) { * @throws ClassAlreadyExistsException * @throws ClassIsEnumerationException * @throws ClassIsFinalException - * @throws ClassIsReadonlyException * @throws DuplicateMethodException * @throws InvalidArgumentException * @throws InvalidMethodNameException @@ -381,7 +382,6 @@ public function objectForTrait(string $traitName, string $traitClassName = '', b /** * @throws ClassIsEnumerationException * @throws ClassIsFinalException - * @throws ClassIsReadonlyException * @throws ReflectionException * @throws RuntimeException * @@ -580,12 +580,20 @@ private function getObject(MockType $mockClass, string $type = '', bool $callOri $className = $mockClass->generate(); $object = $this->instantiate($className, $callOriginalConstructor, $arguments); - if ($callOriginalMethods) { - $this->instantiateProxyTarget($proxyTarget, $object, $type, $arguments); - } + if ($object instanceof StubInternal && $mockClass instanceof MockClass) { + /** + * @psalm-suppress MissingThrowsDocblock + * + * @noinspection PhpUnhandledExceptionInspection + */ + (new ReflectionObject($object))->getProperty('__phpunit_state')->setValue( + $object, + new TestDoubleState($mockClass->configurableMethods(), $returnValueGeneration), + ); - if ($object instanceof StubInternal) { - $object->__phpunit_setReturnValueGeneration($returnValueGeneration); + if ($callOriginalMethods) { + $this->instantiateProxyTarget($proxyTarget, $object, $type, $arguments); + } } return $object; @@ -594,7 +602,6 @@ private function getObject(MockType $mockClass, string $type = '', bool $callOri /** * @throws ClassIsEnumerationException * @throws ClassIsFinalException - * @throws ClassIsReadonlyException * @throws ReflectionException * @throws RuntimeException */ @@ -605,6 +612,7 @@ private function generateCodeForTestDoubleClass(string $type, bool $mockObject, $doubledCloneMethod = false; $proxiedCloneMethod = false; $isClass = false; + $isReadonly = false; $isInterface = false; $class = null; $mockMethods = new MockMethodSet; @@ -646,7 +654,7 @@ private function generateCodeForTestDoubleClass(string $type, bool $mockObject, } if ($class->isReadOnly()) { - throw new ClassIsReadonlyException($_mockClassName['fullClassName']); + $isReadonly = true; } // @see https://github.com/sebastianbergmann/phpunit/issues/2995 @@ -754,7 +762,16 @@ private function generateCodeForTestDoubleClass(string $type, bool $mockObject, } /** @psalm-var trait-string[] $traits */ - $traits = [StubApi::class]; + $traits = []; + $isPhp82 = PHP_MAJOR_VERSION === 8 && PHP_MINOR_VERSION === 2; + + if (!$isReadonly && $isPhp82) { + // @codeCoverageIgnoreStart + $traits[] = MutableStubApi::class; + // @codeCoverageIgnoreEnd + } else { + $traits[] = StubApi::class; + } if ($mockObject) { $traits[] = MockObjectApi::class; @@ -788,12 +805,16 @@ private function generateCodeForTestDoubleClass(string $type, bool $mockObject, $traits[] = Method::class; } - if ($doubledCloneMethod) { - $traits[] = DoubledCloneMethod::class; - } - - if ($proxiedCloneMethod) { - $traits[] = ProxiedCloneMethod::class; + if ($isPhp82 && $isReadonly) { + // @codeCoverageIgnoreStart + $traits[] = ErrorCloneMethod::class; + // @codeCoverageIgnoreEnd + } else { + if ($doubledCloneMethod) { + $traits[] = DoubledCloneMethod::class; + } elseif ($proxiedCloneMethod) { + $traits[] = ProxiedCloneMethod::class; + } } $useStatements = ''; @@ -816,6 +837,7 @@ private function generateCodeForTestDoubleClass(string $type, bool $mockObject, $_mockClassName, $isInterface, $additionalInterfaces, + $isReadonly, ), 'use_statements' => $useStatements, 'mock_class_name' => $_mockClassName['className'], @@ -862,7 +884,7 @@ private function generateClassName(string $type, string $className, string $pref ]; } - private function generateTestDoubleClassDeclaration(bool $mockObject, array $mockClassName, bool $isInterface, array $additionalInterfaces = []): string + private function generateTestDoubleClassDeclaration(bool $mockObject, array $mockClassName, bool $isInterface, array $additionalInterfaces, bool $isReadonly): string { if ($mockObject) { $additionalInterfaces[] = MockObjectInternal::class; @@ -870,7 +892,12 @@ private function generateTestDoubleClassDeclaration(bool $mockObject, array $moc $additionalInterfaces[] = StubInternal::class; } - $buffer = 'class '; + if ($isReadonly) { + $buffer = 'readonly class '; + } else { + $buffer = 'class '; + } + $interfaces = implode(', ', $additionalInterfaces); if ($isInterface) { @@ -1041,7 +1068,7 @@ private function instantiateProxyTarget(?object $proxyTarget, object $object, st } } - $object->__phpunit_setOriginalObject($proxyTarget); + $object->__phpunit_state()->setProxyTarget($proxyTarget); } /** diff --git a/src/Framework/MockObject/Generator/MockClass.php b/src/Framework/MockObject/Generator/MockClass.php index 99bfe3ca749..9edd9067398 100644 --- a/src/Framework/MockObject/Generator/MockClass.php +++ b/src/Framework/MockObject/Generator/MockClass.php @@ -9,7 +9,6 @@ */ namespace PHPUnit\Framework\MockObject\Generator; -use function call_user_func; use function class_exists; use PHPUnit\Framework\MockObject\ConfigurableMethod; @@ -48,14 +47,6 @@ public function generate(): string { if (!class_exists($this->mockName, false)) { eval($this->classCode); - - call_user_func( - [ - $this->mockName, - '__phpunit_initConfigurableMethods', - ], - ...$this->configurableMethods, - ); } return $this->mockName; @@ -65,4 +56,12 @@ public function classCode(): string { return $this->classCode; } + + /** + * @psalm-return list + */ + public function configurableMethods(): array + { + return $this->configurableMethods; + } } diff --git a/src/Framework/MockObject/Generator/templates/proxied_method.tpl b/src/Framework/MockObject/Generator/templates/proxied_method.tpl index 94db4665e83..c971b9ba1bc 100644 --- a/src/Framework/MockObject/Generator/templates/proxied_method.tpl +++ b/src/Framework/MockObject/Generator/templates/proxied_method.tpl @@ -33,5 +33,5 @@ ) ); - $__phpunit_result = call_user_func_array([$this->__phpunit_originalObject, "{method_name}"], $__phpunit_arguments);{return_result} + $__phpunit_result = call_user_func_array([$this->__phpunit_state()->proxyTarget(), "{method_name}"], $__phpunit_arguments);{return_result} } diff --git a/src/Framework/MockObject/MockBuilder.php b/src/Framework/MockObject/MockBuilder.php index ecb9d7afff1..e1e3dfc5068 100644 --- a/src/Framework/MockObject/MockBuilder.php +++ b/src/Framework/MockObject/MockBuilder.php @@ -19,7 +19,6 @@ use PHPUnit\Framework\MockObject\Generator\ClassAlreadyExistsException; use PHPUnit\Framework\MockObject\Generator\ClassIsEnumerationException; use PHPUnit\Framework\MockObject\Generator\ClassIsFinalException; -use PHPUnit\Framework\MockObject\Generator\ClassIsReadonlyException; use PHPUnit\Framework\MockObject\Generator\DuplicateMethodException; use PHPUnit\Framework\MockObject\Generator\Generator; use PHPUnit\Framework\MockObject\Generator\InvalidMethodNameException; @@ -81,7 +80,6 @@ public function __construct(TestCase $testCase, string $type) * @throws ClassAlreadyExistsException * @throws ClassIsEnumerationException * @throws ClassIsFinalException - * @throws ClassIsReadonlyException * @throws DuplicateMethodException * @throws InvalidArgumentException * @throws InvalidMethodNameException diff --git a/src/Framework/MockObject/Runtime/Api/DoubledCloneMethod.php b/src/Framework/MockObject/Runtime/Api/DoubledCloneMethod.php index bb02daf8743..c1aae784b53 100644 --- a/src/Framework/MockObject/Runtime/Api/DoubledCloneMethod.php +++ b/src/Framework/MockObject/Runtime/Api/DoubledCloneMethod.php @@ -16,6 +16,10 @@ trait DoubledCloneMethod { public function __clone(): void { - $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationHandler(); + $this->__phpunit_state = clone $this->__phpunit_state; + + $this->__phpunit_state()->cloneInvocationHandler(); } + + abstract public function __phpunit_state(): TestDoubleState; } diff --git a/src/Framework/MockObject/Runtime/Api/ErrorCloneMethod.php b/src/Framework/MockObject/Runtime/Api/ErrorCloneMethod.php new file mode 100644 index 00000000000..ed93e60e295 --- /dev/null +++ b/src/Framework/MockObject/Runtime/Api/ErrorCloneMethod.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Framework\MockObject; + +/** + * @internal This trait is not covered by the backward compatibility promise for PHPUnit + * + * @codeCoverageIgnore + */ +trait ErrorCloneMethod +{ + public function __clone(): void + { + throw new CannotCloneTestDoubleForReadonlyClassException; + } +} diff --git a/src/Framework/MockObject/Runtime/Api/Method.php b/src/Framework/MockObject/Runtime/Api/Method.php index 2112fb3edbb..ebb28a74022 100644 --- a/src/Framework/MockObject/Runtime/Api/Method.php +++ b/src/Framework/MockObject/Runtime/Api/Method.php @@ -19,6 +19,8 @@ */ trait Method { + abstract public function __phpunit_getInvocationHandler(): InvocationHandler; + public function method(): InvocationMocker { $expects = $this->__phpunit_getInvocationHandler()->expects(new AnyInvokedCount); diff --git a/src/Framework/MockObject/Runtime/Api/MockObjectApi.php b/src/Framework/MockObject/Runtime/Api/MockObjectApi.php index 25fb4b9c6a1..837c263cef9 100644 --- a/src/Framework/MockObject/Runtime/Api/MockObjectApi.php +++ b/src/Framework/MockObject/Runtime/Api/MockObjectApi.php @@ -21,21 +21,12 @@ */ trait MockObjectApi { - private static array $__phpunit_deprecation_emitted_for_test = []; - private object $__phpunit_originalObject; - /** @noinspection MagicMethodsValidityInspection */ public function __phpunit_hasMatchers(): bool { return $this->__phpunit_getInvocationHandler()->hasMatchers(); } - /** @noinspection MagicMethodsValidityInspection */ - public function __phpunit_setOriginalObject(object $originalObject): void - { - $this->__phpunit_originalObject = $originalObject; - } - /** @noinspection MagicMethodsValidityInspection */ public function __phpunit_verify(bool $unsetInvocationMocker = true): void { @@ -46,6 +37,8 @@ public function __phpunit_verify(bool $unsetInvocationMocker = true): void } } + abstract public function __phpunit_state(): TestDoubleState; + abstract public function __phpunit_getInvocationHandler(): InvocationHandler; abstract public function __phpunit_unsetInvocationMocker(): void; @@ -60,16 +53,18 @@ public function expects(InvocationOrder $matcher): InvocationMockerBuilder try { $test = TestMethodBuilder::fromCallStack(); - if (!isset(self::$__phpunit_deprecation_emitted_for_test[$test->id()])) { + if (!$this->__phpunit_state()->wasDeprecationAlreadyEmittedFor($test->id())) { EventFacade::emitter()->testTriggeredPhpunitDeprecation( $test, $message, ); - self::$__phpunit_deprecation_emitted_for_test[$test->id()] = true; + $this->__phpunit_state()->deprecationWasEmittedFor($test->id()); } + // @codeCoverageIgnoreStart } catch (NoTestCaseObjectOnCallStackException) { EventFacade::emitter()->testRunnerTriggeredDeprecation($message); + // @codeCoverageIgnoreEnd } } diff --git a/src/Framework/MockObject/Runtime/Api/MutableStubApi.php b/src/Framework/MockObject/Runtime/Api/MutableStubApi.php new file mode 100644 index 00000000000..e88bf7558f0 --- /dev/null +++ b/src/Framework/MockObject/Runtime/Api/MutableStubApi.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Framework\MockObject; + +/** + * @internal This trait is not covered by the backward compatibility promise for PHPUnit + * + * @codeCoverageIgnore + */ +trait MutableStubApi +{ + private TestDoubleState $__phpunit_state; + + public function __phpunit_state(): TestDoubleState + { + return $this->__phpunit_state; + } + + /** @noinspection MagicMethodsValidityInspection */ + public function __phpunit_getInvocationHandler(): InvocationHandler + { + return $this->__phpunit_state->invocationHandler(); + } + + /** @noinspection MagicMethodsValidityInspection */ + public function __phpunit_unsetInvocationMocker(): void + { + $this->__phpunit_state->unsetInvocationHandler(); + } +} diff --git a/src/Framework/MockObject/Runtime/Api/ProxiedCloneMethod.php b/src/Framework/MockObject/Runtime/Api/ProxiedCloneMethod.php index ae0dbc78c08..e573031f4ac 100644 --- a/src/Framework/MockObject/Runtime/Api/ProxiedCloneMethod.php +++ b/src/Framework/MockObject/Runtime/Api/ProxiedCloneMethod.php @@ -16,8 +16,12 @@ trait ProxiedCloneMethod { public function __clone(): void { - $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationHandler(); + $this->__phpunit_state = clone $this->__phpunit_state; + + $this->__phpunit_state()->cloneInvocationHandler(); parent::__clone(); } + + abstract public function __phpunit_state(): TestDoubleState; } diff --git a/src/Framework/MockObject/Runtime/Api/StubApi.php b/src/Framework/MockObject/Runtime/Api/StubApi.php index 64bed690164..5e39fecbc1f 100644 --- a/src/Framework/MockObject/Runtime/Api/StubApi.php +++ b/src/Framework/MockObject/Runtime/Api/StubApi.php @@ -14,41 +14,22 @@ */ trait StubApi { - /** - * @psalm-var list - */ - private static array $__phpunit_configurableMethods; - private bool $__phpunit_returnValueGeneration = true; - private ?InvocationHandler $__phpunit_invocationMocker = null; + private readonly TestDoubleState $__phpunit_state; - /** @noinspection MagicMethodsValidityInspection */ - public static function __phpunit_initConfigurableMethods(ConfigurableMethod ...$configurableMethods): void - { - static::$__phpunit_configurableMethods = $configurableMethods; - } - - /** @noinspection MagicMethodsValidityInspection */ - public function __phpunit_setReturnValueGeneration(bool $returnValueGeneration): void + public function __phpunit_state(): TestDoubleState { - $this->__phpunit_returnValueGeneration = $returnValueGeneration; + return $this->__phpunit_state; } /** @noinspection MagicMethodsValidityInspection */ public function __phpunit_getInvocationHandler(): InvocationHandler { - if ($this->__phpunit_invocationMocker === null) { - $this->__phpunit_invocationMocker = new InvocationHandler( - static::$__phpunit_configurableMethods, - $this->__phpunit_returnValueGeneration, - ); - } - - return $this->__phpunit_invocationMocker; + return $this->__phpunit_state->invocationHandler(); } /** @noinspection MagicMethodsValidityInspection */ public function __phpunit_unsetInvocationMocker(): void { - $this->__phpunit_invocationMocker = null; + $this->__phpunit_state->unsetInvocationHandler(); } } diff --git a/src/Framework/MockObject/Runtime/Api/TestDoubleState.php b/src/Framework/MockObject/Runtime/Api/TestDoubleState.php new file mode 100644 index 00000000000..43396b27abe --- /dev/null +++ b/src/Framework/MockObject/Runtime/Api/TestDoubleState.php @@ -0,0 +1,87 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Framework\MockObject; + +use function assert; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class TestDoubleState +{ + private static array $deprecationEmittedForTest = []; + + /** + * @psalm-var list + */ + private readonly array $configurableMethods; + private readonly bool $generateReturnValues; + private ?InvocationHandler $invocationHandler = null; + private ?object $proxyTarget = null; + + /** + * @psalm-param list $configurableMethods + */ + public function __construct(array $configurableMethods, bool $generateReturnValues) + { + $this->configurableMethods = $configurableMethods; + $this->generateReturnValues = $generateReturnValues; + } + + public function invocationHandler(): InvocationHandler + { + if ($this->invocationHandler !== null) { + return $this->invocationHandler; + } + + $this->invocationHandler = new InvocationHandler( + $this->configurableMethods, + $this->generateReturnValues, + ); + + return $this->invocationHandler; + } + + public function cloneInvocationHandler(): void + { + if ($this->invocationHandler === null) { + return; + } + + $this->invocationHandler = clone $this->invocationHandler; + } + + public function unsetInvocationHandler(): void + { + $this->invocationHandler = null; + } + + public function setProxyTarget(object $proxyTarget): void + { + $this->proxyTarget = $proxyTarget; + } + + public function proxyTarget(): object + { + assert($this->proxyTarget !== null); + + return $this->proxyTarget; + } + + public function deprecationWasEmittedFor(string $testId): void + { + self::$deprecationEmittedForTest[$testId] = true; + } + + public function wasDeprecationAlreadyEmittedFor(string $testId): bool + { + return isset(self::$deprecationEmittedForTest[$testId]); + } +} diff --git a/src/Framework/MockObject/Runtime/Interface/MockObjectInternal.php b/src/Framework/MockObject/Runtime/Interface/MockObjectInternal.php index bb84ffaccb6..0952566774a 100644 --- a/src/Framework/MockObject/Runtime/Interface/MockObjectInternal.php +++ b/src/Framework/MockObject/Runtime/Interface/MockObjectInternal.php @@ -16,7 +16,5 @@ interface MockObjectInternal extends MockObject, StubInternal { public function __phpunit_hasMatchers(): bool; - public function __phpunit_setOriginalObject(object $originalObject): void; - public function __phpunit_verify(bool $unsetInvocationMocker = true): void; } diff --git a/src/Framework/MockObject/Runtime/Interface/StubInternal.php b/src/Framework/MockObject/Runtime/Interface/StubInternal.php index 10445265ada..57e46f3df09 100644 --- a/src/Framework/MockObject/Runtime/Interface/StubInternal.php +++ b/src/Framework/MockObject/Runtime/Interface/StubInternal.php @@ -14,12 +14,10 @@ */ interface StubInternal extends Stub { - public static function __phpunit_initConfigurableMethods(ConfigurableMethod ...$configurableMethods): void; + public function __phpunit_state(): TestDoubleState; public function __phpunit_getInvocationHandler(): InvocationHandler; - public function __phpunit_setReturnValueGeneration(bool $returnValueGeneration): void; - public function __phpunit_unsetInvocationMocker(): void; public function __phpunit_wasGeneratedAsMockObject(): bool; diff --git a/tests/_files/mock-object/ReadonlyClass.php b/tests/_files/mock-object/ExtendableReadonlyClass.php similarity index 91% rename from tests/_files/mock-object/ReadonlyClass.php rename to tests/_files/mock-object/ExtendableReadonlyClass.php index e968645c547..1a1673ba3ee 100644 --- a/tests/_files/mock-object/ReadonlyClass.php +++ b/tests/_files/mock-object/ExtendableReadonlyClass.php @@ -9,7 +9,7 @@ */ namespace PHPUnit\TestFixture\MockObject; -readonly class ReadonlyClass +readonly class ExtendableReadonlyClass { public function __construct(private mixed $value) { diff --git a/tests/_files/mock-object/ExtendableReadonlyClassWithCloneMethod.php b/tests/_files/mock-object/ExtendableReadonlyClassWithCloneMethod.php new file mode 100644 index 00000000000..5f8d9701c03 --- /dev/null +++ b/tests/_files/mock-object/ExtendableReadonlyClassWithCloneMethod.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\MockObject; + +use Exception; + +readonly class ExtendableReadonlyClassWithCloneMethod +{ + /** + * @throws Exception + */ + public function __clone(): void + { + throw new Exception(__METHOD__); + } + + public function doSomething(): bool + { + return true; + } +} diff --git a/tests/end-to-end/_files/clone-readonly-php-82/Php82CloneReadonlyTestDoubleTest.php b/tests/end-to-end/_files/clone-readonly-php-82/Php82CloneReadonlyTestDoubleTest.php new file mode 100644 index 00000000000..6a75c33ca09 --- /dev/null +++ b/tests/end-to-end/_files/clone-readonly-php-82/Php82CloneReadonlyTestDoubleTest.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture; + +use PHPUnit\Framework\TestCase; +use PHPUnit\TestFixture\MockObject\ExtendableReadonlyClass; + +final class Php82CloneReadonlyTestDoubleTest extends TestCase +{ + public function testOne(): void + { + $stub = $this->createStub(ExtendableReadonlyClass::class); + + clone $stub; + } +} diff --git a/tests/end-to-end/mock-objects/clone-readonly-php-82.phpt b/tests/end-to-end/mock-objects/clone-readonly-php-82.phpt new file mode 100644 index 00000000000..a920a46c6bd --- /dev/null +++ b/tests/end-to-end/mock-objects/clone-readonly-php-82.phpt @@ -0,0 +1,34 @@ +--TEST-- +PHPUnit emits an error when a test double for a readonly class is cloned on PHP 8.2 +--SKIPIF-- +')) { + print 'skip: This test requires PHP 8.2' . PHP_EOL; +} +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +E 1 / 1 (100%) + +Time: %s, Memory: %s + +There was 1 error: + +1) PHPUnit\TestFixture\Php82CloneReadonlyTestDoubleTest::testOne +PHPUnit\Framework\MockObject\CannotCloneTestDoubleForReadonlyClassException: Cloning test doubles for readonly classes is not supported on PHP 8.2 + +%sPhp82CloneReadonlyTestDoubleTest.php:%d + +ERRORS! +Tests: 1, Assertions: 0, Errors: 1. diff --git a/tests/end-to-end/mock-objects/generator/232.phpt b/tests/end-to-end/mock-objects/generator/232.phpt index 03ddde0d92e..d59ae530146 100644 --- a/tests/end-to-end/mock-objects/generator/232.phpt +++ b/tests/end-to-end/mock-objects/generator/232.phpt @@ -58,7 +58,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt b/tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt index 090f60f1342..24dfee4fb52 100644 --- a/tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt +++ b/tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt @@ -43,7 +43,7 @@ declare(strict_types=1); class Issue3154Mock extends Is\Namespaced\Issue3154 implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/3967.phpt b/tests/end-to-end/mock-objects/generator/3967.phpt index 3348d603590..2ba1339231e 100644 --- a/tests/end-to-end/mock-objects/generator/3967.phpt +++ b/tests/end-to-end/mock-objects/generator/3967.phpt @@ -26,12 +26,12 @@ $mock = $generator->generate( ); print $mock->classCode(); ---EXPECT-- +--EXPECTF-- declare(strict_types=1); class MockBaz extends Exception implements Baz, PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/397.phpt b/tests/end-to-end/mock-objects/generator/397.phpt index 87d169ba8dc..a4c2619700d 100644 --- a/tests/end-to-end/mock-objects/generator/397.phpt +++ b/tests/end-to-end/mock-objects/generator/397.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockC extends C implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/4139.phpt b/tests/end-to-end/mock-objects/generator/4139.phpt index 8698fa306b7..04caf588fba 100644 --- a/tests/end-to-end/mock-objects/generator/4139.phpt +++ b/tests/end-to-end/mock-objects/generator/4139.phpt @@ -18,7 +18,7 @@ declare(strict_types=1); class %s implements PHPUnit\Framework\MockObject\MockObjectInternal, InterfaceWithConstructor { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/abstract_class.phpt b/tests/end-to-end/mock-objects/generator/abstract_class.phpt index 11c84f79e8b..a1856f71419 100644 --- a/tests/end-to-end/mock-objects/generator/abstract_class.phpt +++ b/tests/end-to-end/mock-objects/generator/abstract_class.phpt @@ -33,7 +33,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class.phpt b/tests/end-to-end/mock-objects/generator/class.phpt index 2e2f0d7874b..b855d4ef5ec 100644 --- a/tests/end-to-end/mock-objects/generator/class.phpt +++ b/tests/end-to-end/mock-objects/generator/class.phpt @@ -33,7 +33,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class_call_parent_clone.phpt b/tests/end-to-end/mock-objects/generator/class_call_parent_clone.phpt index 21c6e32bf48..bcabe9d2843 100644 --- a/tests/end-to-end/mock-objects/generator/class_call_parent_clone.phpt +++ b/tests/end-to-end/mock-objects/generator/class_call_parent_clone.phpt @@ -28,7 +28,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class_call_parent_constructor.phpt b/tests/end-to-end/mock-objects/generator/class_call_parent_constructor.phpt index 1b9a017a478..48d06d9a8cf 100644 --- a/tests/end-to-end/mock-objects/generator/class_call_parent_constructor.phpt +++ b/tests/end-to-end/mock-objects/generator/class_call_parent_constructor.phpt @@ -28,7 +28,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class_dont_call_parent_clone.phpt b/tests/end-to-end/mock-objects/generator/class_dont_call_parent_clone.phpt index f42a165b7db..46ca8c7724d 100644 --- a/tests/end-to-end/mock-objects/generator/class_dont_call_parent_clone.phpt +++ b/tests/end-to-end/mock-objects/generator/class_dont_call_parent_clone.phpt @@ -28,7 +28,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class_dont_call_parent_constructor.phpt b/tests/end-to-end/mock-objects/generator/class_dont_call_parent_constructor.phpt index 1b9a017a478..48d06d9a8cf 100644 --- a/tests/end-to-end/mock-objects/generator/class_dont_call_parent_constructor.phpt +++ b/tests/end-to-end/mock-objects/generator/class_dont_call_parent_constructor.phpt @@ -28,7 +28,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class_implementing_interface_call_parent_constructor.phpt b/tests/end-to-end/mock-objects/generator/class_implementing_interface_call_parent_constructor.phpt index 8ec3ad96886..9d1281cacc9 100644 --- a/tests/end-to-end/mock-objects/generator/class_implementing_interface_call_parent_constructor.phpt +++ b/tests/end-to-end/mock-objects/generator/class_implementing_interface_call_parent_constructor.phpt @@ -33,7 +33,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class_implementing_interface_dont_call_parent_constructor.phpt b/tests/end-to-end/mock-objects/generator/class_implementing_interface_dont_call_parent_constructor.phpt index 8ec3ad96886..9d1281cacc9 100644 --- a/tests/end-to-end/mock-objects/generator/class_implementing_interface_dont_call_parent_constructor.phpt +++ b/tests/end-to-end/mock-objects/generator/class_implementing_interface_dont_call_parent_constructor.phpt @@ -33,7 +33,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt b/tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt index 7b94c8b34ea..0a4b6e22de4 100644 --- a/tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt +++ b/tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class_partial.phpt b/tests/end-to-end/mock-objects/generator/class_partial.phpt index 5b9ebf428eb..9608e262356 100644 --- a/tests/end-to-end/mock-objects/generator/class_partial.phpt +++ b/tests/end-to-end/mock-objects/generator/class_partial.phpt @@ -33,7 +33,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class_with_deprecated_method.phpt b/tests/end-to-end/mock-objects/generator/class_with_deprecated_method.phpt index dad53c92112..d6b0d09986c 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_deprecated_method.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_deprecated_method.phpt @@ -33,7 +33,7 @@ declare(strict_types=1); class MockFoo extends ClassWithDeprecatedMethod implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class_with_final_method.phpt b/tests/end-to-end/mock-objects/generator/class_with_final_method.phpt index ed0763c0258..eb77a418efd 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_final_method.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_final_method.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo extends ClassWithFinalMethod implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class_with_method_named_method.phpt b/tests/end-to-end/mock-objects/generator/class_with_method_named_method.phpt index dad34aff72a..99fad68c024 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_method_named_method.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_method_named_method.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\DoubledCloneMethod; diff --git a/tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments.phpt b/tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments.phpt index 99d946bc091..d689aee8a68 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo extends ClassWithMethodWithNullableTypehintedVariadicArguments implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments.phpt b/tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments.phpt index d34502db55f..ef939db74c1 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo extends ClassWithMethodWithTypehintedVariadicArguments implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments.phpt b/tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments.phpt index 8f661168dd6..a5ad0eeee73 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo extends ClassWithMethodWithVariadicArguments implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value.phpt b/tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value.phpt index 1c3a8b01965..7ddfc743644 100644 --- a/tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value.phpt +++ b/tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/interface.phpt b/tests/end-to-end/mock-objects/generator/interface.phpt index db45055380b..d6e78304899 100644 --- a/tests/end-to-end/mock-objects/generator/interface.phpt +++ b/tests/end-to-end/mock-objects/generator/interface.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/invocation_object_clone_object.phpt b/tests/end-to-end/mock-objects/generator/invocation_object_clone_object.phpt index ec8193536a1..bf75e92a725 100644 --- a/tests/end-to-end/mock-objects/generator/invocation_object_clone_object.phpt +++ b/tests/end-to-end/mock-objects/generator/invocation_object_clone_object.phpt @@ -34,7 +34,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/namespaced_class.phpt b/tests/end-to-end/mock-objects/generator/namespaced_class.phpt index fffce781aeb..80b3f742388 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class.phpt @@ -35,7 +35,7 @@ declare(strict_types=1); class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/namespaced_class_call_parent_clone.phpt b/tests/end-to-end/mock-objects/generator/namespaced_class_call_parent_clone.phpt index 59286197333..56c061bd5dc 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class_call_parent_clone.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class_call_parent_clone.phpt @@ -30,7 +30,7 @@ declare(strict_types=1); class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/namespaced_class_call_parent_constructor.phpt b/tests/end-to-end/mock-objects/generator/namespaced_class_call_parent_constructor.phpt index 11ade685327..5eae28b476e 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class_call_parent_constructor.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class_call_parent_constructor.phpt @@ -30,7 +30,7 @@ declare(strict_types=1); class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/namespaced_class_dont_call_parent_clone.phpt b/tests/end-to-end/mock-objects/generator/namespaced_class_dont_call_parent_clone.phpt index f503112da54..d76a158590e 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class_dont_call_parent_clone.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class_dont_call_parent_clone.phpt @@ -30,7 +30,7 @@ declare(strict_types=1); class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/namespaced_class_dont_call_parent_constructor.phpt b/tests/end-to-end/mock-objects/generator/namespaced_class_dont_call_parent_constructor.phpt index 11ade685327..5eae28b476e 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class_dont_call_parent_constructor.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class_dont_call_parent_constructor.phpt @@ -30,7 +30,7 @@ declare(strict_types=1); class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/namespaced_class_implementing_interface_call_parent_constructor.phpt b/tests/end-to-end/mock-objects/generator/namespaced_class_implementing_interface_call_parent_constructor.phpt index 840f7733d34..1d716858923 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class_implementing_interface_call_parent_constructor.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class_implementing_interface_call_parent_constructor.phpt @@ -35,7 +35,7 @@ declare(strict_types=1); class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/namespaced_class_implementing_interface_dont_call_parent_constructor.phpt b/tests/end-to-end/mock-objects/generator/namespaced_class_implementing_interface_dont_call_parent_constructor.phpt index 840f7733d34..1d716858923 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class_implementing_interface_dont_call_parent_constructor.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class_implementing_interface_dont_call_parent_constructor.phpt @@ -35,7 +35,7 @@ declare(strict_types=1); class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt b/tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt index 18207efafc8..5849422422c 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt @@ -35,7 +35,7 @@ declare(strict_types=1); class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt b/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt index 63a843a56cc..3df7ddab0df 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, NS\Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/nonexistent_class.phpt b/tests/end-to-end/mock-objects/generator/nonexistent_class.phpt index a674e6697b8..c3589956d97 100644 --- a/tests/end-to-end/mock-objects/generator/nonexistent_class.phpt +++ b/tests/end-to-end/mock-objects/generator/nonexistent_class.phpt @@ -26,7 +26,7 @@ class NonExistentClass class MockFoo extends NonExistentClass implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/nonexistent_class_with_namespace.phpt b/tests/end-to-end/mock-objects/generator/nonexistent_class_with_namespace.phpt index 4c981d9b713..481bbe8440f 100644 --- a/tests/end-to-end/mock-objects/generator/nonexistent_class_with_namespace.phpt +++ b/tests/end-to-end/mock-objects/generator/nonexistent_class_with_namespace.phpt @@ -32,7 +32,7 @@ namespace { class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/nonexistent_class_with_namespace_starting_with_separator.phpt b/tests/end-to-end/mock-objects/generator/nonexistent_class_with_namespace_starting_with_separator.phpt index 0a31e9fc572..688be3c2f33 100644 --- a/tests/end-to-end/mock-objects/generator/nonexistent_class_with_namespace_starting_with_separator.phpt +++ b/tests/end-to-end/mock-objects/generator/nonexistent_class_with_namespace_starting_with_separator.phpt @@ -32,7 +32,7 @@ namespace { class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/nullable_types.phpt b/tests/end-to-end/mock-objects/generator/nullable_types.phpt index 99b5ead7d13..d831a0d2c67 100644 --- a/tests/end-to-end/mock-objects/generator/nullable_types.phpt +++ b/tests/end-to-end/mock-objects/generator/nullable_types.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/nullable_union_type_parameter.phpt b/tests/end-to-end/mock-objects/generator/nullable_union_type_parameter.phpt index 6665fff142a..bc181a61911 100644 --- a/tests/end-to-end/mock-objects/generator/nullable_union_type_parameter.phpt +++ b/tests/end-to-end/mock-objects/generator/nullable_union_type_parameter.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/nullable_union_type_return.phpt b/tests/end-to-end/mock-objects/generator/nullable_union_type_return.phpt index 026f32a9034..a92cb119eac 100644 --- a/tests/end-to-end/mock-objects/generator/nullable_union_type_return.phpt +++ b/tests/end-to-end/mock-objects/generator/nullable_union_type_return.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/parameter_dnf.phpt b/tests/end-to-end/mock-objects/generator/parameter_dnf.phpt index 1350cd0a66a..35ba79bdc27 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_dnf.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_dnf.phpt @@ -37,7 +37,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/parameter_false.phpt b/tests/end-to-end/mock-objects/generator/parameter_false.phpt index bcbb03ce2eb..9f76d1dff26 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_false.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_false.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/parameter_intersection.phpt b/tests/end-to-end/mock-objects/generator/parameter_intersection.phpt index 43bb3f0af11..aff259a262d 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_intersection.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_intersection.phpt @@ -37,7 +37,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/parameter_null.phpt b/tests/end-to-end/mock-objects/generator/parameter_null.phpt index 75ed0ba9eec..553b12517e1 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_null.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_null.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/parameter_true.phpt b/tests/end-to-end/mock-objects/generator/parameter_true.phpt index 26613ce0dd0..07f1ae0ab8f 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_true.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_true.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/parameter_union.phpt b/tests/end-to-end/mock-objects/generator/parameter_union.phpt index 5b084e65686..f716a1b9eb2 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_union.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_union.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/proxy.phpt b/tests/end-to-end/mock-objects/generator/proxy.phpt index c2cb97cf7b6..291a43b0839 100644 --- a/tests/end-to-end/mock-objects/generator/proxy.phpt +++ b/tests/end-to-end/mock-objects/generator/proxy.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class ProxyFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; @@ -67,7 +67,7 @@ class ProxyFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInt ) ); - $__phpunit_result = call_user_func_array([$this->__phpunit_originalObject, "bar"], $__phpunit_arguments); + $__phpunit_result = call_user_func_array([$this->__phpunit_state()->proxyTarget(), "bar"], $__phpunit_arguments); return $__phpunit_result; } @@ -106,7 +106,7 @@ class ProxyFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInt ) ); - $__phpunit_result = call_user_func_array([$this->__phpunit_originalObject, "baz"], $__phpunit_arguments); + $__phpunit_result = call_user_func_array([$this->__phpunit_state()->proxyTarget(), "baz"], $__phpunit_arguments); return $__phpunit_result; } diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_closure.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_closure.phpt index 404c3d7a92d..e57b53afe96 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_closure.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_closure.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_dnf.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_dnf.phpt index 3e47f127d30..9610d24e23b 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_dnf.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_dnf.phpt @@ -37,7 +37,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_false.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_false.phpt index b2ea6df804c..033cfbcc56c 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_false.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_false.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_final.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_final.phpt index 18ed55d6566..d8cdfbeed45 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_final.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_final.phpt @@ -34,7 +34,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_generator.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_generator.phpt index cd6d6eab6cb..d530707cd2f 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_generator.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_generator.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_intersection.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_intersection.phpt index 51c3e940885..cd3afcad7ba 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_intersection.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_intersection.phpt @@ -37,7 +37,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_never.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_never.phpt index 6df9510fe62..165958536bf 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_never.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_never.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_null.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_null.phpt index a4be09a2ecf..9d248560b2d 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_null.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_null.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_nullable.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_nullable.phpt index f66e816bc50..72c0305dbc0 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_nullable.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_nullable.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_object_method.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_object_method.phpt index b6cacb4359a..00a866b83fb 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_object_method.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_object_method.phpt @@ -30,7 +30,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_parent.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_parent.phpt index ecbdcaf3034..2b66496867e 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_parent.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_parent.phpt @@ -34,7 +34,7 @@ declare(strict_types=1); class MockBar extends Bar implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_self.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_self.phpt index 46c648c5ed2..ac6a40dafee 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_self.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_self.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_static.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_static.phpt index d9d85fe44bd..0df54517b8f 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_static.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_static.phpt @@ -37,7 +37,7 @@ declare(strict_types=1); class MockClassWithStaticReturnTypes extends ClassWithStaticReturnTypes implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_static_method.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_static_method.phpt index 156026a34e7..0ff838193b1 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_static_method.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_static_method.phpt @@ -30,7 +30,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_true.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_true.phpt index 071335c5a17..1e26dca6cfe 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_true.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_true.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_union.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_union.phpt index 99f0fc58e02..461fcfd8110 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_union.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_union.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_void.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_void.phpt index 08932c0d94d..faa46e75cdf 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_void.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_void.phpt @@ -27,7 +27,7 @@ declare(strict_types=1); class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt b/tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt index c3daff546a1..154640d91b1 100644 --- a/tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt +++ b/tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt @@ -29,7 +29,7 @@ declare(strict_types=1); class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInternal { - use PHPUnit\Framework\MockObject\StubApi; + use PHPUnit\Framework\MockObject\%SStubApi; use PHPUnit\Framework\MockObject\MockObjectApi; use PHPUnit\Framework\MockObject\GeneratedAsMockObject; use PHPUnit\Framework\MockObject\Method; diff --git a/tests/end-to-end/mock-objects/mock-method/call_original.phpt b/tests/end-to-end/mock-objects/mock-method/call_original.phpt index 4beb2faabfb..bbc67bd6dd0 100644 --- a/tests/end-to-end/mock-objects/mock-method/call_original.phpt +++ b/tests/end-to-end/mock-objects/mock-method/call_original.phpt @@ -55,7 +55,7 @@ print $code; ) ); - $__phpunit_result = call_user_func_array([$this->__phpunit_originalObject, "bar"], $__phpunit_arguments); + $__phpunit_result = call_user_func_array([$this->__phpunit_state()->proxyTarget(), "bar"], $__phpunit_arguments); return $__phpunit_result; } diff --git a/tests/end-to-end/mock-objects/mock-method/call_original_with_argument.phpt b/tests/end-to-end/mock-objects/mock-method/call_original_with_argument.phpt index 8dfab7f39ae..1ef50e1080a 100644 --- a/tests/end-to-end/mock-objects/mock-method/call_original_with_argument.phpt +++ b/tests/end-to-end/mock-objects/mock-method/call_original_with_argument.phpt @@ -55,7 +55,7 @@ private function bar($arg) ) ); - $__phpunit_result = call_user_func_array([$this->__phpunit_originalObject, "bar"], $__phpunit_arguments); + $__phpunit_result = call_user_func_array([$this->__phpunit_state()->proxyTarget(), "bar"], $__phpunit_arguments); return $__phpunit_result; } diff --git a/tests/end-to-end/mock-objects/mock-method/call_original_with_argument_variadic.phpt b/tests/end-to-end/mock-objects/mock-method/call_original_with_argument_variadic.phpt index bf99664c952..bc31d806e7a 100644 --- a/tests/end-to-end/mock-objects/mock-method/call_original_with_argument_variadic.phpt +++ b/tests/end-to-end/mock-objects/mock-method/call_original_with_argument_variadic.phpt @@ -55,7 +55,7 @@ private function bar(...$args) ) ); - $__phpunit_result = call_user_func_array([$this->__phpunit_originalObject, "bar"], $__phpunit_arguments); + $__phpunit_result = call_user_func_array([$this->__phpunit_state()->proxyTarget(), "bar"], $__phpunit_arguments); return $__phpunit_result; } diff --git a/tests/end-to-end/mock-objects/mock-method/call_original_with_return_type_void.phpt b/tests/end-to-end/mock-objects/mock-method/call_original_with_return_type_void.phpt index f92156737e6..f3bf9c7c7fb 100644 --- a/tests/end-to-end/mock-objects/mock-method/call_original_with_return_type_void.phpt +++ b/tests/end-to-end/mock-objects/mock-method/call_original_with_return_type_void.phpt @@ -55,5 +55,5 @@ print $code; ) ); - $__phpunit_result = call_user_func_array([$this->__phpunit_originalObject, "bar"], $__phpunit_arguments); + $__phpunit_result = call_user_func_array([$this->__phpunit_state()->proxyTarget(), "bar"], $__phpunit_arguments); } diff --git a/tests/unit/Framework/MockObject/Creation/CreateMockTest.php b/tests/unit/Framework/MockObject/Creation/CreateMockTest.php index 0c29c46fcf2..a6f2de64020 100644 --- a/tests/unit/Framework/MockObject/Creation/CreateMockTest.php +++ b/tests/unit/Framework/MockObject/Creation/CreateMockTest.php @@ -14,14 +14,13 @@ use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\MockObject\Generator\ClassIsEnumerationException; use PHPUnit\Framework\MockObject\Generator\ClassIsFinalException; -use PHPUnit\Framework\MockObject\Generator\ClassIsReadonlyException; use PHPUnit\Framework\MockObject\Generator\UnknownTypeException; use PHPUnit\Framework\TestCase; use PHPUnit\TestFixture\MockObject\AnInterface; use PHPUnit\TestFixture\MockObject\Enumeration; use PHPUnit\TestFixture\MockObject\ExtendableClass; +use PHPUnit\TestFixture\MockObject\ExtendableReadonlyClass; use PHPUnit\TestFixture\MockObject\FinalClass; -use PHPUnit\TestFixture\MockObject\ReadonlyClass; #[Group('test-doubles')] #[Group('test-doubles/creation')] @@ -36,6 +35,7 @@ public function testCreatesMockObjectForInterface(): void $this->assertInstanceOf(AnInterface::class, $double); $this->assertInstanceOf(Stub::class, $double); + $this->assertInstanceOf(MockObject::class, $double); } public function testCreatesMockObjectForExtendableClass(): void @@ -44,6 +44,16 @@ public function testCreatesMockObjectForExtendableClass(): void $this->assertInstanceOf(ExtendableClass::class, $double); $this->assertInstanceOf(Stub::class, $double); + $this->assertInstanceOf(MockObject::class, $double); + } + + public function testCreatesMockObjectForReadonlyClass(): void + { + $double = $this->createMock(ExtendableReadonlyClass::class); + + $this->assertInstanceOf(ExtendableReadonlyClass::class, $double); + $this->assertInstanceOf(Stub::class, $double); + $this->assertInstanceOf(MockObject::class, $double); } public function testReturnValueGenerationIsEnabledByDefault(): void @@ -60,13 +70,6 @@ public function testCannotCreateMockObjectForFinalClass(): void $this->createMock(FinalClass::class); } - public function testCannotCreateMockObjectForReadonlyClass(): void - { - $this->expectException(ClassIsReadonlyException::class); - - $this->createMock(ReadonlyClass::class); - } - public function testCannotCreateMockObjectForEnumeration(): void { $this->expectException(ClassIsEnumerationException::class); diff --git a/tests/unit/Framework/MockObject/Creation/CreateStubTest.php b/tests/unit/Framework/MockObject/Creation/CreateStubTest.php index 085ee03a4ac..71a5b5d1644 100644 --- a/tests/unit/Framework/MockObject/Creation/CreateStubTest.php +++ b/tests/unit/Framework/MockObject/Creation/CreateStubTest.php @@ -14,14 +14,13 @@ use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\MockObject\Generator\ClassIsEnumerationException; use PHPUnit\Framework\MockObject\Generator\ClassIsFinalException; -use PHPUnit\Framework\MockObject\Generator\ClassIsReadonlyException; use PHPUnit\Framework\MockObject\Generator\UnknownTypeException; use PHPUnit\Framework\TestCase; use PHPUnit\TestFixture\MockObject\AnInterface; use PHPUnit\TestFixture\MockObject\Enumeration; use PHPUnit\TestFixture\MockObject\ExtendableClass; +use PHPUnit\TestFixture\MockObject\ExtendableReadonlyClass; use PHPUnit\TestFixture\MockObject\FinalClass; -use PHPUnit\TestFixture\MockObject\ReadonlyClass; #[Group('test-doubles')] #[Group('test-doubles/creation')] @@ -46,6 +45,14 @@ public function testCreatesTestStubForExtendableClass(): void $this->assertInstanceOf(Stub::class, $double); } + public function testCreatesTestStubForReadonlyClass(): void + { + $double = $this->createStub(ExtendableReadonlyClass::class); + + $this->assertInstanceOf(ExtendableReadonlyClass::class, $double); + $this->assertInstanceOf(Stub::class, $double); + } + public function testReturnValueGenerationIsEnabledByDefault(): void { $double = $this->createStub(AnInterface::class); @@ -60,13 +67,6 @@ public function testCannotCreateTestStubForFinalClass(): void $this->createStub(FinalClass::class); } - public function testCannotCreateTestStubForReadonlyClass(): void - { - $this->expectException(ClassIsReadonlyException::class); - - $this->createStub(ReadonlyClass::class); - } - public function testCannotCreateTestStubForEnumeration(): void { $this->expectException(ClassIsEnumerationException::class); diff --git a/tests/unit/Framework/MockObject/TestDoubleTestCase.php b/tests/unit/Framework/MockObject/TestDoubleTestCase.php index aa4142ab3ac..1284f7f96bb 100644 --- a/tests/unit/Framework/MockObject/TestDoubleTestCase.php +++ b/tests/unit/Framework/MockObject/TestDoubleTestCase.php @@ -11,9 +11,11 @@ use Exception; use PHPUnit\Framework\Attributes\IgnorePhpunitDeprecations; +use PHPUnit\Framework\Attributes\RequiresPhp; use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\TestCase; use PHPUnit\TestFixture\MockObject\ExtendableClassWithCloneMethod; +use PHPUnit\TestFixture\MockObject\ExtendableReadonlyClassWithCloneMethod; use PHPUnit\TestFixture\MockObject\InterfaceWithMethodThatExpectsObject; use PHPUnit\TestFixture\MockObject\InterfaceWithMethodThatHasDefaultParameterValues; use PHPUnit\TestFixture\MockObject\InterfaceWithNeverReturningMethod; @@ -258,6 +260,27 @@ final public function testOriginalCloneMethodCanOptionallyBeCalledWhenTestDouble clone $double; } + #[TestDox('Original __clone() method is not called by default when test double object is cloned (readonly class)')] + #[RequiresPhp('8.3')] + final public function testOriginalCloneMethodIsNotCalledByDefaultWhenTestDoubleObjectOfReadonlyClassIsCloned(): void + { + $double = clone $this->createTestDouble(ExtendableReadonlyClassWithCloneMethod::class); + + $this->assertFalse($double->doSomething()); + } + + #[TestDox('Original __clone() method can optionally be called when test double object is cloned (readonly class)')] + #[RequiresPhp('8.3')] + final public function testOriginalCloneMethodCanOptionallyBeCalledWhenTestDoubleObjectOfReadonlyClassIsCloned(): void + { + $double = $this->getMockBuilder(ExtendableReadonlyClassWithCloneMethod::class)->enableOriginalClone()->getMock(); + + $this->expectException(Exception::class); + $this->expectExceptionMessage(ExtendableReadonlyClassWithCloneMethod::class . '::__clone'); + + clone $double; + } + /** * @psalm-template RealInstanceType of object *