-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab74dd8
commit b7c0877
Showing
14 changed files
with
441 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
tests/_files/mock-object/InterfaceWithMethodReturningFalse.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\TestFixture\MockObject; | ||
|
||
interface InterfaceWithMethodReturningFalse | ||
{ | ||
public function returnsFalse(): false; | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/_files/mock-object/InterfaceWithMethodReturningNull.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\TestFixture\MockObject; | ||
|
||
interface InterfaceWithMethodReturningNull | ||
{ | ||
public function returnsNull(): null; | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/_files/mock-object/InterfaceWithMethodReturningTrue.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\TestFixture\MockObject; | ||
|
||
interface InterfaceWithMethodReturningTrue | ||
{ | ||
public function returnsTrue(): true; | ||
} |
56 changes: 56 additions & 0 deletions
56
tests/end-to-end/mock-objects/generator/parameter_false.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--TEST-- | ||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) | ||
--SKIPIF-- | ||
<?php declare(strict_types=1); | ||
if (version_compare('8.2.0-dev', PHP_VERSION, '>')) { | ||
print 'skip: PHP 8.2 is required.'; | ||
} | ||
--FILE-- | ||
<?php declare(strict_types=1); | ||
interface Foo | ||
{ | ||
public function bar(false $baz): void; | ||
} | ||
|
||
require_once __DIR__ . '/../../../../vendor/autoload.php'; | ||
|
||
$generator = new \PHPUnit\Framework\MockObject\Generator; | ||
|
||
$mock = $generator->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(false $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 | ||
) | ||
); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
tests/end-to-end/mock-objects/generator/parameter_null.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--TEST-- | ||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) | ||
--SKIPIF-- | ||
<?php declare(strict_types=1); | ||
if (version_compare('8.2.0-dev', PHP_VERSION, '>')) { | ||
print 'skip: PHP 8.2 is required.'; | ||
} | ||
--FILE-- | ||
<?php declare(strict_types=1); | ||
interface Foo | ||
{ | ||
public function bar(null $baz): void; | ||
} | ||
|
||
require_once __DIR__ . '/../../../../vendor/autoload.php'; | ||
|
||
$generator = new \PHPUnit\Framework\MockObject\Generator; | ||
|
||
$mock = $generator->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(null $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 | ||
) | ||
); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
tests/end-to-end/mock-objects/generator/parameter_true.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--TEST-- | ||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) | ||
--SKIPIF-- | ||
<?php declare(strict_types=1); | ||
if (version_compare('8.2.0-dev', PHP_VERSION, '>')) { | ||
print 'skip: PHP 8.2 is required.'; | ||
} | ||
--FILE-- | ||
<?php declare(strict_types=1); | ||
interface Foo | ||
{ | ||
public function bar(true $baz): void; | ||
} | ||
|
||
require_once __DIR__ . '/../../../../vendor/autoload.php'; | ||
|
||
$generator = new \PHPUnit\Framework\MockObject\Generator; | ||
|
||
$mock = $generator->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(true $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 | ||
) | ||
); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
tests/end-to-end/mock-objects/generator/return_type_declarations_false.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--TEST-- | ||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) | ||
--SKIPIF-- | ||
<?php declare(strict_types=1); | ||
if (version_compare('8.2.0-dev', PHP_VERSION, '>')) { | ||
print 'skip: PHP 8.2 is required.'; | ||
} | ||
--FILE-- | ||
<?php declare(strict_types=1); | ||
interface Foo | ||
{ | ||
public function bar(): false; | ||
} | ||
|
||
require_once __DIR__ . '/../../../../vendor/autoload.php'; | ||
|
||
$generator = new \PHPUnit\Framework\MockObject\Generator; | ||
|
||
$mock = $generator->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(): false | ||
{ | ||
$__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, 'false', $this, true | ||
) | ||
); | ||
|
||
return $__phpunit_result; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
tests/end-to-end/mock-objects/generator/return_type_declarations_null.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--TEST-- | ||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) | ||
--SKIPIF-- | ||
<?php declare(strict_types=1); | ||
if (version_compare('8.2.0-dev', PHP_VERSION, '>')) { | ||
print 'skip: PHP 8.2 is required.'; | ||
} | ||
--FILE-- | ||
<?php declare(strict_types=1); | ||
interface Foo | ||
{ | ||
public function bar(): null; | ||
} | ||
|
||
require_once __DIR__ . '/../../../../vendor/autoload.php'; | ||
|
||
$generator = new \PHPUnit\Framework\MockObject\Generator; | ||
|
||
$mock = $generator->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(): null | ||
{ | ||
$__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, 'null', $this, true | ||
) | ||
); | ||
|
||
return $__phpunit_result; | ||
} | ||
} |
Oops, something went wrong.