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
5b49e2c
commit 6d40a46
Showing
10 changed files
with
183 additions
and
68 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/InterfaceWithMethodReturningDisjunctiveNormalFormType.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 InterfaceWithMethodReturningDisjunctiveNormalFormType | ||
{ | ||
public function returnsDisjunctiveNormalFormType(): (AnInterface&AnotherInterface)|true; | ||
} |
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
68 changes: 68 additions & 0 deletions
68
tests/end-to-end/mock-objects/generator/parameter_dnf.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,68 @@ | ||
--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 A | ||
{ | ||
} | ||
|
||
interface B | ||
{ | ||
} | ||
|
||
class Foo | ||
{ | ||
public function bar((A&B)|int|null $baz) | ||
{ | ||
} | ||
} | ||
|
||
require_once __DIR__ . '/../../../../vendor/autoload.php'; | ||
|
||
$generator = new \PHPUnit\Framework\MockObject\Generator; | ||
|
||
$mock = $generator->generate( | ||
Foo::class, | ||
[], | ||
'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((A&B)|int|null $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; | ||
} | ||
} |
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
68 changes: 68 additions & 0 deletions
68
tests/end-to-end/mock-objects/generator/return_type_declarations_dnf.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,68 @@ | ||
--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 A | ||
{ | ||
} | ||
|
||
interface B | ||
{ | ||
} | ||
|
||
class Foo | ||
{ | ||
public function bar(): (A&B)|int|null | ||
{ | ||
} | ||
} | ||
|
||
require_once __DIR__ . '/../../../bootstrap.php'; | ||
|
||
$generator = new \PHPUnit\Framework\MockObject\Generator; | ||
|
||
$mock = $generator->generate( | ||
Foo::class, | ||
[], | ||
'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(): (A&B)|int|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, '(A&B)|int|null', $this, true | ||
) | ||
); | ||
|
||
return $__phpunit_result; | ||
} | ||
} |
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