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
1d2a88d
commit c1c9d4d
Showing
99 changed files
with
2,973 additions
and
3 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
21 changes: 21 additions & 0 deletions
21
src/Framework/MockObject/Api/MockedCloneMethodWithVoidReturnType.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,21 @@ | ||
<?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\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(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Framework/MockObject/Api/UnmockedCloneMethodWithVoidReturnType.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,23 @@ | ||
<?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\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(); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
...nd-to-end/mock-objects/generator/232.phpt → ...-end/mock-objects/generator/232-php7.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
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,89 @@ | ||
--TEST-- | ||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true) | ||
--SKIPIF-- | ||
<?php declare(strict_types=1); | ||
if (PHP_MAJOR_VERSION < 8) { | ||
print 'skip: PHP 8 is required.'; | ||
} | ||
--FILE-- | ||
<?php declare(strict_types=1); | ||
trait BaseTrait | ||
{ | ||
protected function hello() | ||
{ | ||
return 'hello'; | ||
} | ||
} | ||
|
||
trait ChildTrait | ||
{ | ||
use BaseTrait | ||
{ | ||
hello as private hi; | ||
} | ||
|
||
protected function hello() | ||
{ | ||
return 'hi'; | ||
} | ||
|
||
protected function world() | ||
{ | ||
return $this->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; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...r/3154_namespaced_constant_resolving.phpt → ...4_namespaced_constant_resolving-php7.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
74 changes: 74 additions & 0 deletions
74
tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving-php8.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,74 @@ | ||
--TEST-- | ||
https://github.com/sebastianbergmann/phpunit-mock-objects/issues/420 | ||
https://github.com/sebastianbergmann/phpunit/issues/3154 | ||
--SKIPIF-- | ||
<?php declare(strict_types=1); | ||
if (PHP_MAJOR_VERSION < 8) { | ||
print 'skip: PHP 8 is required.'; | ||
} | ||
--FILE-- | ||
<?php declare(strict_types=1); | ||
namespace Is\Namespaced; | ||
/* | ||
* 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. | ||
*/ | ||
|
||
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; | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
...nd-to-end/mock-objects/generator/397.phpt → ...-end/mock-objects/generator/397-php7.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
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,60 @@ | ||
--TEST-- | ||
https://github.com/sebastianbergmann/phpunit-mock-objects/issues/397 | ||
--SKIPIF-- | ||
<?php declare(strict_types=1); | ||
if (PHP_MAJOR_VERSION < 8) { | ||
print 'skip: PHP 8 is required.'; | ||
} | ||
--FILE-- | ||
<?php declare(strict_types=1); | ||
class C | ||
{ | ||
public function m(?self $other): self | ||
{ | ||
} | ||
} | ||
|
||
require_once __DIR__ . '/../../../bootstrap.php'; | ||
|
||
$generator = new \PHPUnit\Framework\MockObject\Generator; | ||
|
||
$mock = $generator->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; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...d-to-end/mock-objects/generator/4139.phpt → ...end/mock-objects/generator/4139-php7.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
Oops, something went wrong.