diff --git a/ChangeLog-8.5.md b/ChangeLog-8.5.md index b136d044522..fcae3f0989f 100644 --- a/ChangeLog-8.5.md +++ b/ChangeLog-8.5.md @@ -2,6 +2,12 @@ All notable changes of the PHPUnit 8.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. +## [8.5.26] - 2022-MM-DD + +### Fixed + +* [#4938](https://github.com/sebastianbergmann/phpunit/issues/4938): Test Double code generator does not handle `void` return type declaration on `__clone()` methods + ## [8.5.25] - 2022-03-16 ### Fixed @@ -213,6 +219,7 @@ All notable changes of the PHPUnit 8.5 release series are documented in this fil * [#3967](https://github.com/sebastianbergmann/phpunit/issues/3967): Cannot double interface that extends interface that extends `\Throwable` * [#3968](https://github.com/sebastianbergmann/phpunit/pull/3968): Test class run in a separate PHP process are passing when `exit` called inside +[8.5.26]: https://github.com/sebastianbergmann/phpunit/compare/8.5.25...8.5 [8.5.25]: https://github.com/sebastianbergmann/phpunit/compare/8.5.24...8.5.25 [8.5.24]: https://github.com/sebastianbergmann/phpunit/compare/8.5.23...8.5.24 [8.5.23]: https://github.com/sebastianbergmann/phpunit/compare/8.5.22...8.5.23 diff --git a/src/Framework/MockObject/Api/MockedCloneMethodWithVoidReturnType.php b/src/Framework/MockObject/Api/MockedCloneMethodWithVoidReturnType.php new file mode 100644 index 00000000000..adbf82f3949 --- /dev/null +++ b/src/Framework/MockObject/Api/MockedCloneMethodWithVoidReturnType.php @@ -0,0 +1,21 @@ + + * + * 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 + */ +trait MockedCloneMethodWithVoidReturnType +{ + public function __clone(): void + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationHandler(); + } +} diff --git a/src/Framework/MockObject/Api/UnmockedCloneMethodWithVoidReturnType.php b/src/Framework/MockObject/Api/UnmockedCloneMethodWithVoidReturnType.php new file mode 100644 index 00000000000..af90e4fe9e9 --- /dev/null +++ b/src/Framework/MockObject/Api/UnmockedCloneMethodWithVoidReturnType.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 + */ +trait UnmockedCloneMethodWithVoidReturnType +{ + public function __clone(): void + { + $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationHandler(); + + parent::__clone(); + } +} diff --git a/src/Framework/MockObject/Generator.php b/src/Framework/MockObject/Generator.php index 285b010fe25..1ae58cf640b 100644 --- a/src/Framework/MockObject/Generator.php +++ b/src/Framework/MockObject/Generator.php @@ -954,11 +954,19 @@ private function generateMock($type, ?array $explicitMethods, string $mockClassN $cloneTrait = ''; if ($mockedCloneMethod) { - $cloneTrait = PHP_EOL . ' use \PHPUnit\Framework\MockObject\MockedCloneMethodWithoutReturnType;'; + if (PHP_MAJOR_VERSION >= 8) { + $cloneTrait = PHP_EOL . ' use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType;'; + } else { + $cloneTrait = PHP_EOL . ' use \PHPUnit\Framework\MockObject\MockedCloneMethodWithoutReturnType;'; + } } if ($unmockedCloneMethod) { - $cloneTrait = PHP_EOL . ' use \PHPUnit\Framework\MockObject\UnmockedCloneMethodWithoutReturnType;'; + if (PHP_MAJOR_VERSION >= 8) { + $cloneTrait = PHP_EOL . ' use \PHPUnit\Framework\MockObject\UnmockedCloneMethodWithVoidReturnType;'; + } else { + $cloneTrait = PHP_EOL . ' use \PHPUnit\Framework\MockObject\UnmockedCloneMethodWithoutReturnType;'; + } } $classTemplate->setVar( diff --git a/tests/end-to-end/mock-objects/generator/232.phpt b/tests/end-to-end/mock-objects/generator/232-php7.phpt similarity index 93% rename from tests/end-to-end/mock-objects/generator/232.phpt rename to tests/end-to-end/mock-objects/generator/232-php7.phpt index 824498a7ef9..05df467fbdc 100644 --- a/tests/end-to-end/mock-objects/generator/232.phpt +++ b/tests/end-to-end/mock-objects/generator/232-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- hi(); + } +} + +class Foo +{ + use ChildTrait; + + public function speak() + { + return $this->world(); + } +} + +require_once __DIR__ . '/../../../bootstrap.php'; + +$generator = new \PHPUnit\Framework\MockObject\Generator; + +$mock = $generator->generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function speak() + { + $__phpunit_arguments = []; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 0) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'speak', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 94% rename from tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt rename to tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving-php7.phpt index f7417012288..084f7e368ae 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-php7.phpt @@ -1,6 +1,11 @@ --TEST-- https://github.com/sebastianbergmann/phpunit-mock-objects/issues/420 https://github.com/sebastianbergmann/phpunit/issues/3154 +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +const A_CONSTANT = 17; +const PHP_VERSION = ""; + +class Issue3154 +{ + public function a(int $i = PHP_INT_MAX, int $j = A_CONSTANT, string $v = \PHP_VERSION, string $z = '#'): string + { + return $z."sum: ".($i+$j).$v; + } +} +require_once __DIR__ . '/../../../bootstrap.php'; + +$generator = new \PHPUnit\Framework\MockObject\Generator; + +$mock = $generator->generate( + Issue3154::class, + [], + 'Issue3154Mock', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class Issue3154Mock extends Is\Namespaced\Issue3154 implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function a(int $i = %d, int $j = 17, string $v = '%s', string $z = '#'): string + { + $__phpunit_arguments = [$i, $j, $v, $z]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 4) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 4; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Is\Namespaced\Issue3154', 'a', $__phpunit_arguments, ': string', $this, true + ) + ); + + return $__phpunit_result; + } +} diff --git a/tests/end-to-end/mock-objects/generator/3967.phpt b/tests/end-to-end/mock-objects/generator/3967.phpt index 21b11a26f0a..6b2f93e35c4 100644 --- a/tests/end-to-end/mock-objects/generator/3967.phpt +++ b/tests/end-to-end/mock-objects/generator/3967.phpt @@ -36,7 +36,7 @@ class MockBaz extends Exception implements Baz, PHPUnit\Framework\MockObject\Moc { use \PHPUnit\Framework\MockObject\Api; use \PHPUnit\Framework\MockObject\Method; - use \PHPUnit\Framework\MockObject\UnmockedCloneMethodWithoutReturnType; + use \PHPUnit\Framework\MockObject\UnmockedCloneMethodWithVoidReturnType; public function foo(): string { diff --git a/tests/end-to-end/mock-objects/generator/397.phpt b/tests/end-to-end/mock-objects/generator/397-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/397.phpt rename to tests/end-to-end/mock-objects/generator/397-php7.phpt index 2dc588cb6ec..ac89a03d2f0 100644 --- a/tests/end-to-end/mock-objects/generator/397.phpt +++ b/tests/end-to-end/mock-objects/generator/397-php7.phpt @@ -1,5 +1,10 @@ --TEST-- https://github.com/sebastianbergmann/phpunit-mock-objects/issues/397 +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + C::class, + [], + 'MockC', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockC extends C implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function m(?C $other): C + { + $__phpunit_arguments = [$other]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'C', 'm', $__phpunit_arguments, ': C', $this, true + ) + ); + + return $__phpunit_result; + } +} diff --git a/tests/end-to-end/mock-objects/generator/4139.phpt b/tests/end-to-end/mock-objects/generator/4139-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/4139.phpt rename to tests/end-to-end/mock-objects/generator/4139-php7.phpt index a882829cb92..3d35966fd42 100644 --- a/tests/end-to-end/mock-objects/generator/4139.phpt +++ b/tests/end-to-end/mock-objects/generator/4139-php7.phpt @@ -1,5 +1,10 @@ --TEST-- https://github.com/sebastianbergmann/phpunit/issues/4139 +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate(InterfaceWithConstructor::class); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class %s implements PHPUnit\Framework\MockObject\MockObject, InterfaceWithConstructor +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function __construct() + { + $__phpunit_arguments = []; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 0) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'InterfaceWithConstructor', '__construct', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} diff --git a/tests/end-to-end/mock-objects/generator/abstract_class.phpt b/tests/end-to-end/mock-objects/generator/abstract_class-php7.phpt similarity index 96% rename from tests/end-to-end/mock-objects/generator/abstract_class.phpt rename to tests/end-to-end/mock-objects/generator/abstract_class-php7.phpt index 8b214219628..fda1d0debc9 100644 --- a/tests/end-to-end/mock-objects/generator/abstract_class.phpt +++ b/tests/end-to-end/mock-objects/generator/abstract_class-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function one() + { + $__phpunit_arguments = []; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 0) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'one', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } + + public function two() + { + $__phpunit_arguments = []; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 0) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'two', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } + + protected function three() + { + $__phpunit_arguments = []; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 0) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'three', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} diff --git a/tests/end-to-end/mock-objects/generator/class.phpt b/tests/end-to-end/mock-objects/generator/class-php7.phpt similarity index 94% rename from tests/end-to-end/mock-objects/generator/class.phpt rename to tests/end-to-end/mock-objects/generator/class-php7.phpt index 0ef7aa40542..1e4f9ff8cf3 100644 --- a/tests/end-to-end/mock-objects/generator/class.phpt +++ b/tests/end-to-end/mock-objects/generator/class-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(Foo $foo) + { + $__phpunit_arguments = [$foo]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } + + public function baz(Foo $foo) + { + $__phpunit_arguments = [$foo]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'baz', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 86% rename from tests/end-to-end/mock-objects/generator/class_call_parent_clone.phpt rename to tests/end-to-end/mock-objects/generator/class_call_parent_clone-php7.phpt index 1d5fc011312..0512614797e 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\UnmockedCloneMethodWithVoidReturnType; +} 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-php7.phpt similarity index 85% rename from tests/end-to-end/mock-objects/generator/class_call_parent_constructor.phpt rename to tests/end-to-end/mock-objects/generator/class_call_parent_constructor-php7.phpt index 5f05f71b4b0..d50b555317c 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} 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-php7.phpt similarity index 86% rename from tests/end-to-end/mock-objects/generator/class_dont_call_parent_clone.phpt rename to tests/end-to-end/mock-objects/generator/class_dont_call_parent_clone-php7.phpt index 3a93bae5882..d4a200fc559 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', false) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + false +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} 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-php7.phpt similarity index 85% rename from tests/end-to-end/mock-objects/generator/class_dont_call_parent_constructor.phpt rename to tests/end-to-end/mock-objects/generator/class_dont_call_parent_constructor-php7.phpt index 5f05f71b4b0..d50b555317c 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} 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-php7.phpt similarity index 87% rename from tests/end-to-end/mock-objects/generator/class_implementing_interface_call_parent_constructor.phpt rename to tests/end-to-end/mock-objects/generator/class_implementing_interface_call_parent_constructor-php7.phpt index 1b4b4e62576..a9efc67ae94 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} 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-php7.phpt similarity index 87% rename from tests/end-to-end/mock-objects/generator/class_implementing_interface_dont_call_parent_constructor.phpt rename to tests/end-to-end/mock-objects/generator/class_implementing_interface_dont_call_parent_constructor-php7.phpt index 1b4b4e62576..a9efc67ae94 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} 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-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt rename to tests/end-to-end/mock-objects/generator/class_nonexistent_method-php7.phpt index 60e65b8cbee..4882e6f1fd7 100644 --- a/tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt +++ b/tests/end-to-end/mock-objects/generator/class_nonexistent_method-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', array('bar'), 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + array('bar'), + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar() + { + $__phpunit_arguments = []; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 0) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} diff --git a/tests/end-to-end/mock-objects/generator/class_partial.phpt b/tests/end-to-end/mock-objects/generator/class_partial-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/class_partial.phpt rename to tests/end-to-end/mock-objects/generator/class_partial-php7.phpt index 0439f1e06ec..c9478111fd5 100644 --- a/tests/end-to-end/mock-objects/generator/class_partial.phpt +++ b/tests/end-to-end/mock-objects/generator/class_partial-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', array('bar'), 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + array('bar'), + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(Foo $foo) + { + $__phpunit_arguments = [$foo]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 93% rename from tests/end-to-end/mock-objects/generator/class_with_deprecated_method.phpt rename to tests/end-to-end/mock-objects/generator/class_with_deprecated_method-php7.phpt index fec9307c0fa..49937410a97 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('ClassWithDeprecatedMethod', [], 'MockFoo', TRUE, TRUE) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'ClassWithDeprecatedMethod', + [], + 'MockFoo', + TRUE, + TRUE +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends ClassWithDeprecatedMethod implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function deprecatedMethod() + { + @trigger_error('The ClassWithDeprecatedMethod::deprecatedMethod method is deprecated (this method is deprecated).', E_USER_DEPRECATED); + + $__phpunit_arguments = []; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 0) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'ClassWithDeprecatedMethod', 'deprecatedMethod', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 87% rename from tests/end-to-end/mock-objects/generator/class_with_final_method.phpt rename to tests/end-to-end/mock-objects/generator/class_with_final_method-php7.phpt index 5536fe2347d..de19b88e95d 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('ClassWithFinalMethod', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'ClassWithFinalMethod', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends ClassWithFinalMethod implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} 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-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/class_with_method_named_method.phpt rename to tests/end-to-end/mock-objects/generator/class_with_method_named_method-php7.phpt index 3e69cefa691..f3c2b5e5b1a 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function method() + { + $__phpunit_arguments = []; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 0) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'method', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 94% rename from tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments.phpt rename to tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments-php7.phpt index 144ec36bf94..2d7396750f0 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('ClassWithMethodWithVariadicArguments', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'ClassWithMethodWithNullableTypehintedVariadicArguments', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends ClassWithMethodWithNullableTypehintedVariadicArguments implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function methodWithNullableTypehintedVariadicArguments($a, ?string ...$parameters) + { + $__phpunit_arguments = [$a]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'ClassWithMethodWithNullableTypehintedVariadicArguments', 'methodWithNullableTypehintedVariadicArguments', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 93% rename from tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments.phpt rename to tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments-php7.phpt index 749521dc272..606f23a5198 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('ClassWithMethodWithVariadicArguments', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'ClassWithMethodWithTypehintedVariadicArguments', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends ClassWithMethodWithTypehintedVariadicArguments implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function methodWithTypehintedVariadicArguments($a, string ...$parameters) + { + $__phpunit_arguments = [$a]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'ClassWithMethodWithTypehintedVariadicArguments', 'methodWithTypehintedVariadicArguments', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 93% rename from tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments.phpt rename to tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments-php7.phpt index 114a808b761..a3ed0f400c8 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('ClassWithMethodWithVariadicArguments', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'ClassWithMethodWithVariadicArguments', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends ClassWithMethodWithVariadicArguments implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function methodWithVariadicArguments($a, ...$parameters) + { + $__phpunit_arguments = [$a]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'ClassWithMethodWithVariadicArguments', 'methodWithVariadicArguments', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value.phpt rename to tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value-php7.phpt index 4fe1d3ba8d9..86b152cc7b3 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(int $baz = %d) + { + $__phpunit_arguments = [$baz]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} diff --git a/tests/end-to-end/mock-objects/generator/interface.phpt b/tests/end-to-end/mock-objects/generator/interface-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/interface.phpt rename to tests/end-to-end/mock-objects/generator/interface-php7.phpt index ba889718857..e73605dc675 100644 --- a/tests/end-to-end/mock-objects/generator/interface.phpt +++ b/tests/end-to-end/mock-objects/generator/interface-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo implements PHPUnit\Framework\MockObject\MockObject, Foo +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(Foo $foo) + { + $__phpunit_arguments = [$foo]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 95% rename from tests/end-to-end/mock-objects/generator/invocation_object_clone_object.phpt rename to tests/end-to-end/mock-objects/generator/invocation_object_clone_object-php7.phpt index 2384269f6f1..ea575a76ed4 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(Foo $foo) + { + $__phpunit_arguments = [$foo]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } + + public function baz(Foo $foo) + { + $__phpunit_arguments = [$foo]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'baz', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} diff --git a/tests/end-to-end/mock-objects/generator/namespaced_class.phpt b/tests/end-to-end/mock-objects/generator/namespaced_class-php7.phpt similarity index 95% rename from tests/end-to-end/mock-objects/generator/namespaced_class.phpt rename to tests/end-to-end/mock-objects/generator/namespaced_class-php7.phpt index f6304359d67..964f0463285 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'NS\Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(NS\Foo $foo) + { + $__phpunit_arguments = [$foo]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'NS\Foo', 'bar', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } + + public function baz(NS\Foo $foo) + { + $__phpunit_arguments = [$foo]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'NS\Foo', 'baz', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 86% rename from tests/end-to-end/mock-objects/generator/namespaced_class_call_parent_clone.phpt rename to tests/end-to-end/mock-objects/generator/namespaced_class_call_parent_clone-php7.phpt index 9916fc5d80d..4378cc48144 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', [], 'MockFoo', true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'NS\Foo', + [], + 'MockFoo', + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\UnmockedCloneMethodWithVoidReturnType; +} 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_call_parent_constructor-php7.phpt similarity index 86% rename from tests/end-to-end/mock-objects/generator/namespaced_class_dont_call_parent_constructor.phpt rename to tests/end-to-end/mock-objects/generator/namespaced_class_call_parent_constructor-php7.phpt index 0135e56b378..ad2fafd7f1d 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_call_parent_constructor-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', [], 'MockFoo', true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'NS\Foo', + [], + 'MockFoo', + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} 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-php7.phpt similarity index 86% rename from tests/end-to-end/mock-objects/generator/namespaced_class_dont_call_parent_clone.phpt rename to tests/end-to-end/mock-objects/generator/namespaced_class_dont_call_parent_clone-php7.phpt index 1f4956ef6e1..fc776ae7127 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', [], 'MockFoo', false) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'NS\Foo', + [], + 'MockFoo', + false +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} 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_dont_call_parent_constructor-php7.phpt similarity index 86% rename from tests/end-to-end/mock-objects/generator/namespaced_class_call_parent_constructor.phpt rename to tests/end-to-end/mock-objects/generator/namespaced_class_dont_call_parent_constructor-php7.phpt index 0135e56b378..ad2fafd7f1d 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_dont_call_parent_constructor-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', [], 'MockFoo', true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'NS\Foo', + [], + 'MockFoo', + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} 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_call_parent_constructor-php7.phpt similarity index 87% rename from tests/end-to-end/mock-objects/generator/namespaced_class_implementing_interface_dont_call_parent_constructor.phpt rename to tests/end-to-end/mock-objects/generator/namespaced_class_implementing_interface_call_parent_constructor-php7.phpt index 0bfae8f90e2..34f68051192 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_call_parent_constructor-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', [], 'MockFoo', true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'NS\Foo', + [], + 'MockFoo', + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} 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_dont_call_parent_constructor-php7.phpt similarity index 87% rename from tests/end-to-end/mock-objects/generator/namespaced_class_implementing_interface_call_parent_constructor.phpt rename to tests/end-to-end/mock-objects/generator/namespaced_class_implementing_interface_dont_call_parent_constructor-php7.phpt index 0bfae8f90e2..34f68051192 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_dont_call_parent_constructor-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', [], 'MockFoo', true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'NS\Foo', + [], + 'MockFoo', + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} 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-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt rename to tests/end-to-end/mock-objects/generator/namespaced_class_partial-php7.phpt index d302015324d..67959012193 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class_partial-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', array('bar'), 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'NS\Foo', + array('bar'), + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(NS\Foo $foo) + { + $__phpunit_arguments = [$foo]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'NS\Foo', 'bar', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} diff --git a/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt b/tests/end-to-end/mock-objects/generator/namespaced_interface-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/namespaced_interface.phpt rename to tests/end-to-end/mock-objects/generator/namespaced_interface-php7.phpt index e06ab7a41d8..e3c844509ed 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_interface-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'NS\Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo implements PHPUnit\Framework\MockObject\MockObject, NS\Foo +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(NS\Foo $foo) + { + $__phpunit_arguments = [$foo]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'NS\Foo', 'bar', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} diff --git a/tests/end-to-end/mock-objects/generator/nonexistent_class.phpt b/tests/end-to-end/mock-objects/generator/nonexistent_class-php7.phpt similarity index 86% rename from tests/end-to-end/mock-objects/generator/nonexistent_class.phpt rename to tests/end-to-end/mock-objects/generator/nonexistent_class-php7.phpt index 4d4262a5563..373c5beffe2 100644 --- a/tests/end-to-end/mock-objects/generator/nonexistent_class.phpt +++ b/tests/end-to-end/mock-objects/generator/nonexistent_class-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('NonExistentClass', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'NonExistentClass', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class NonExistentClass +{ +} + +class MockFoo extends NonExistentClass implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} 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-php7.phpt similarity index 86% rename from tests/end-to-end/mock-objects/generator/nonexistent_class_with_namespace.phpt rename to tests/end-to-end/mock-objects/generator/nonexistent_class_with_namespace-php7.phpt index 0c593c4414c..4c82908fd56 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'NS\Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +namespace NS { + +class Foo +{ +} + +} + +namespace { + +class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} + +} 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-php7.phpt similarity index 86% rename from tests/end-to-end/mock-objects/generator/nonexistent_class_with_namespace_starting_with_separator.phpt rename to tests/end-to-end/mock-objects/generator/nonexistent_class_with_namespace_starting_with_separator-php7.phpt index ed1bf3b30ef..ce7427f1a5e 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + '\NS\Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +namespace NS { + +class Foo +{ +} + +} + +namespace { + +class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; +} + +} diff --git a/tests/end-to-end/mock-objects/generator/nullable_types.phpt b/tests/end-to-end/mock-objects/generator/nullable_types-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/nullable_types.phpt rename to tests/end-to-end/mock-objects/generator/nullable_types-php7.phpt index 599c4002337..a7b5b6d3189 100644 --- a/tests/end-to-end/mock-objects/generator/nullable_types.phpt +++ b/tests/end-to-end/mock-objects/generator/nullable_types-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(?int $x) + { + $__phpunit_arguments = [$x]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +} diff --git a/tests/end-to-end/mock-objects/generator/proxy.phpt b/tests/end-to-end/mock-objects/generator/proxy-php7.phpt similarity index 95% rename from tests/end-to-end/mock-objects/generator/proxy.phpt rename to tests/end-to-end/mock-objects/generator/proxy-php7.phpt index a9697596e28..17e3f2b0735 100644 --- a/tests/end-to-end/mock-objects/generator/proxy.phpt +++ b/tests/end-to-end/mock-objects/generator/proxy-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', null, 'ProxyFoo', true, true, true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', [], 'ProxyFoo', true, true, true, true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class ProxyFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(Foo $foo) + { + $__phpunit_arguments = [$foo]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, '', $this, true, true + ) + ); + + return call_user_func_array(array($this->__phpunit_originalObject, "bar"), $__phpunit_arguments); + } + + public function baz(Foo $foo) + { + $__phpunit_arguments = [$foo]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'baz', $__phpunit_arguments, '', $this, true, true + ) + ); + + return call_user_func_array(array($this->__phpunit_originalObject, "baz"), $__phpunit_arguments); + } +} 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-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/return_type_declarations_closure.phpt rename to tests/end-to-end/mock-objects/generator/return_type_declarations_closure-php7.phpt index bf8ce6e30f9..f39ff514521 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo implements PHPUnit\Framework\MockObject\MockObject, Foo +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(): Closure + { + $__phpunit_arguments = []; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 0) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, ': Closure', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/return_type_declarations_final.phpt rename to tests/end-to-end/mock-objects/generator/return_type_declarations_final-php7.phpt index f330a20773f..9d328b99177 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(): FinalClass + { + $__phpunit_arguments = []; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 0) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, ': FinalClass', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/return_type_declarations_generator.phpt rename to tests/end-to-end/mock-objects/generator/return_type_declarations_generator-php7.phpt index ae82043c62f..13ec3a31b30 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo implements PHPUnit\Framework\MockObject\MockObject, Foo +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(): Generator + { + $__phpunit_arguments = []; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 0) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, ': Generator', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/return_type_declarations_nullable.phpt rename to tests/end-to-end/mock-objects/generator/return_type_declarations_nullable-php7.phpt index c0818e91d03..3f8075d3e4d 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo implements PHPUnit\Framework\MockObject\MockObject, Foo +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(string $baz): ?string + { + $__phpunit_arguments = [$baz]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, ': ?string', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/return_type_declarations_object_method.phpt rename to tests/end-to-end/mock-objects/generator/return_type_declarations_object_method-php7.phpt index 8409eea6d37..a72a5144ace 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(string $baz): Bar + { + $__phpunit_arguments = [$baz]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, ': Bar', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/return_type_declarations_parent.phpt rename to tests/end-to-end/mock-objects/generator/return_type_declarations_parent-php7.phpt index bd0b30481b6..57cbc7748f7 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Bar', [], 'MockBar', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Bar', + [], + 'MockBar', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockBar extends Bar implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function baz(): Foo + { + $__phpunit_arguments = []; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 0) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Bar', 'baz', $__phpunit_arguments, ': Foo', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/return_type_declarations_self.phpt rename to tests/end-to-end/mock-objects/generator/return_type_declarations_self-php7.phpt index 81d2953c366..7b704da6f40 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo implements PHPUnit\Framework\MockObject\MockObject, Foo +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(string $baz): Foo + { + $__phpunit_arguments = [$baz]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, ': Foo', $this, true + ) + ); + + return $__phpunit_result; + } +} 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-php7.phpt similarity index 89% rename from tests/end-to-end/mock-objects/generator/return_type_declarations_static_method.phpt rename to tests/end-to-end/mock-objects/generator/return_type_declarations_static_method-php7.phpt index 8510fa82cd5..72d96b310db 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public static function bar(string $baz): Bar + { + throw new \PHPUnit\Framework\MockObject\BadMethodCallException('Static method "bar" cannot be invoked on mock object'); + } +} 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-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/return_type_declarations_void.phpt rename to tests/end-to-end/mock-objects/generator/return_type_declarations_void-php7.phpt index 82aee6b7770..c33c9fe1c76 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-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo implements PHPUnit\Framework\MockObject\MockObject, Foo +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(string $baz): void + { + $__phpunit_arguments = [$baz]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, ': void', $this, true + ) + ); + } +} 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-php7.phpt similarity index 92% rename from tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt rename to tests/end-to-end/mock-objects/generator/scalar_type_declarations-php7.phpt index c66018b794b..0f206492a11 100644 --- a/tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt +++ b/tests/end-to-end/mock-objects/generator/scalar_type_declarations-php7.phpt @@ -1,5 +1,10 @@ --TEST-- \PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) +--SKIPIF-- += 8) { + print 'skip: PHP 7 is required.'; +} --FILE-- generate( + 'Foo', + [], + 'MockFoo', + true, + true +); + +print $mock->getClassCode(); +--EXPECTF-- +declare(strict_types=1); + +class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject +{ + use \PHPUnit\Framework\MockObject\Api; + use \PHPUnit\Framework\MockObject\Method; + use \PHPUnit\Framework\MockObject\MockedCloneMethodWithVoidReturnType; + + public function bar(string $baz) + { + $__phpunit_arguments = [$baz]; + $__phpunit_count = func_num_args(); + + if ($__phpunit_count > 1) { + $__phpunit_arguments_tmp = func_get_args(); + + for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { + $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; + } + } + + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( + new \PHPUnit\Framework\MockObject\Invocation( + 'Foo', 'bar', $__phpunit_arguments, '', $this, true + ) + ); + + return $__phpunit_result; + } +}