Skip to content

Commit f4bd49d

Browse files
Closes #5536
1 parent 96ae8f6 commit f4bd49d

File tree

72 files changed

+6
-224
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+6
-224
lines changed

src/Framework/MockObject/Generator/Generator.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
use IteratorAggregate;
3535
use PHPUnit\Framework\MockObject\ConfigurableMethod;
3636
use PHPUnit\Framework\MockObject\DoubledCloneMethod;
37-
use PHPUnit\Framework\MockObject\GeneratedAsMockObject;
38-
use PHPUnit\Framework\MockObject\GeneratedAsTestStub;
3937
use PHPUnit\Framework\MockObject\Method;
4038
use PHPUnit\Framework\MockObject\MockObject;
4139
use PHPUnit\Framework\MockObject\MockObjectApi;
@@ -90,7 +88,7 @@ final class Generator
9088
* @throws RuntimeException
9189
* @throws UnknownTypeException
9290
*/
93-
public function testDouble(string $type, bool $mockObject, bool $markAsMockObject, ?array $methods = [], array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $returnValueGeneration = true): MockObject|Stub
91+
public function testDouble(string $type, bool $mockObject, ?array $methods = [], array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $returnValueGeneration = true): MockObject|Stub
9492
{
9593
if ($type === Traversable::class) {
9694
$type = Iterator::class;
@@ -103,7 +101,6 @@ public function testDouble(string $type, bool $mockObject, bool $markAsMockObjec
103101
$mock = $this->generate(
104102
$type,
105103
$mockObject,
106-
$markAsMockObject,
107104
$methods,
108105
$mockClassName,
109106
$callOriginalClone,
@@ -188,7 +185,6 @@ public function testDoubleForInterfaceIntersection(array $interfaces, bool $mock
188185
return $this->testDouble(
189186
$intersectionName,
190187
$mockObject,
191-
$mockObject,
192188
returnValueGeneration: $returnValueGeneration,
193189
);
194190
}
@@ -204,13 +200,12 @@ public function testDoubleForInterfaceIntersection(array $interfaces, bool $mock
204200
*
205201
* @see https://github.com/sebastianbergmann/phpunit/issues/5476
206202
*/
207-
public function generate(string $type, bool $mockObject, bool $markAsMockObject, array $methods = null, string $mockClassName = '', bool $callOriginalClone = true): MockClass
203+
public function generate(string $type, bool $mockObject, array $methods = null, string $mockClassName = '', bool $callOriginalClone = true): MockClass
208204
{
209205
if ($mockClassName !== '') {
210206
return $this->generateCodeForTestDoubleClass(
211207
$type,
212208
$mockObject,
213-
$markAsMockObject,
214209
$methods,
215210
$mockClassName,
216211
$callOriginalClone,
@@ -220,7 +215,6 @@ public function generate(string $type, bool $mockObject, bool $markAsMockObject,
220215
$key = md5(
221216
$type .
222217
($mockObject ? 'MockObject' : 'TestStub') .
223-
($markAsMockObject ? 'MockObject' : 'TestStub') .
224218
serialize($methods) .
225219
serialize($callOriginalClone),
226220
);
@@ -229,7 +223,6 @@ public function generate(string $type, bool $mockObject, bool $markAsMockObject,
229223
self::$cache[$key] = $this->generateCodeForTestDoubleClass(
230224
$type,
231225
$mockObject,
232-
$markAsMockObject,
233226
$methods,
234227
$mockClassName,
235228
$callOriginalClone,
@@ -305,7 +298,7 @@ private function getObject(MockType $mockClass, bool $callOriginalConstructor =
305298
* @throws ReflectionException
306299
* @throws RuntimeException
307300
*/
308-
private function generateCodeForTestDoubleClass(string $type, bool $mockObject, bool $markAsMockObject, ?array $explicitMethods, string $mockClassName, bool $callOriginalClone): MockClass
301+
private function generateCodeForTestDoubleClass(string $type, bool $mockObject, ?array $explicitMethods, string $mockClassName, bool $callOriginalClone): MockClass
309302
{
310303
$classTemplate = $this->loadTemplate('test_double_class.tpl');
311304
$additionalInterfaces = [];
@@ -462,12 +455,6 @@ private function generateCodeForTestDoubleClass(string $type, bool $mockObject,
462455
$traits[] = MockObjectApi::class;
463456
}
464457

465-
if ($markAsMockObject) {
466-
$traits[] = GeneratedAsMockObject::class;
467-
} else {
468-
$traits[] = GeneratedAsTestStub::class;
469-
}
470-
471458
if ($mockMethods->hasMethod('method') || (isset($class) && $class->hasMethod('method'))) {
472459
throw new MethodNamedMethodException;
473460
}

src/Framework/MockObject/MockBuilder.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public function getMock(): MockObject
8686
$object = $this->generator->testDouble(
8787
$this->type,
8888
true,
89-
true,
9089
!$this->emptyMethodsArray ? $this->methods : null,
9190
$this->constructorArgs,
9291
$this->mockClassName ?? '',

src/Framework/MockObject/Runtime/Api/GeneratedAsMockObject.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Framework/MockObject/Runtime/Api/GeneratedAsTestStub.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Framework/MockObject/Runtime/Api/MockObjectApi.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
*/
1010
namespace PHPUnit\Framework\MockObject;
1111

12-
use function assert;
13-
use PHPUnit\Event\Code\NoTestCaseObjectOnCallStackException;
14-
use PHPUnit\Event\Code\TestMethodBuilder;
15-
use PHPUnit\Event\Facade as EventFacade;
1612
use PHPUnit\Framework\MockObject\Builder\InvocationMocker as InvocationMockerBuilder;
1713
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
1814

@@ -45,27 +41,6 @@ abstract public function __phpunit_unsetInvocationMocker(): void;
4541

4642
public function expects(InvocationOrder $matcher): InvocationMockerBuilder
4743
{
48-
assert($this instanceof StubInternal);
49-
50-
if (!$this->__phpunit_wasGeneratedAsMockObject()) {
51-
$message = 'Expectations configured on test doubles that are created as test stubs are no longer verified since PHPUnit 10. Test doubles that are created as test stubs will no longer have the expects() method in PHPUnit 12. Update your test code to use createMock() instead of createStub(), for example.';
52-
53-
try {
54-
$test = TestMethodBuilder::fromCallStack();
55-
56-
if (!isset(self::$__phpunit_deprecation_emitted_for_test[$test->id()])) {
57-
EventFacade::emitter()->testTriggeredPhpunitDeprecation(
58-
$test,
59-
$message,
60-
);
61-
62-
self::$__phpunit_deprecation_emitted_for_test[$test->id()] = true;
63-
}
64-
} catch (NoTestCaseObjectOnCallStackException) {
65-
EventFacade::emitter()->testRunnerTriggeredDeprecation($message);
66-
}
67-
}
68-
6944
return $this->__phpunit_getInvocationHandler()->expects($matcher);
7045
}
7146
}

src/Framework/MockObject/Runtime/Interface/StubInternal.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@ public function __phpunit_getInvocationHandler(): InvocationHandler;
2121
public function __phpunit_setReturnValueGeneration(bool $returnValueGeneration): void;
2222

2323
public function __phpunit_unsetInvocationMocker(): void;
24-
25-
public function __phpunit_wasGeneratedAsMockObject(): bool;
2624
}

src/Framework/MockObject/Runtime/ReturnValueGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private function newInstanceOf(string $stubClassName, string $className, string
204204
private function testDoubleFor(string $type, string $className, string $methodName): Stub
205205
{
206206
try {
207-
return (new Generator)->testDouble($type, false, false, [], [], '', false);
207+
return (new Generator)->testDouble($type, false, [], [], '', false);
208208
} catch (Throwable $t) {
209209
throw new RuntimeException(
210210
sprintf(

src/Framework/TestCase.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,6 @@ final protected function createMock(string $originalClassName): MockObject
11891189
$mock = (new MockGenerator)->testDouble(
11901190
$originalClassName,
11911191
true,
1192-
true,
11931192
callOriginalConstructor: false,
11941193
callOriginalClone: false,
11951194
returnValueGeneration: self::generateReturnValuesForTestDoubles(),
@@ -2181,7 +2180,6 @@ final protected static function createStub(string $originalClassName): Stub
21812180
{
21822181
$stub = (new MockGenerator)->testDouble(
21832182
$originalClassName,
2184-
true,
21852183
false,
21862184
callOriginalConstructor: false,
21872185
callOriginalClone: false,

tests/end-to-end/mock-objects/generator/232.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ $generator = new \PHPUnit\Framework\MockObject\Generator\Generator;
4545
$mock = $generator->generate(
4646
'Foo',
4747
true,
48-
true,
4948
[],
5049
'MockFoo',
5150
true,
@@ -60,7 +59,6 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte
6059
{
6160
use PHPUnit\Framework\MockObject\StubApi;
6261
use PHPUnit\Framework\MockObject\MockObjectApi;
63-
use PHPUnit\Framework\MockObject\GeneratedAsMockObject;
6462
use PHPUnit\Framework\MockObject\Method;
6563
use PHPUnit\Framework\MockObject\DoubledCloneMethod;
6664

tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ $generator = new \PHPUnit\Framework\MockObject\Generator\Generator;
3030
$mock = $generator->generate(
3131
Issue3154::class,
3232
true,
33-
true,
3433
[],
3534
'Issue3154Mock',
3635
true,
@@ -45,7 +44,6 @@ class Issue3154Mock extends Is\Namespaced\Issue3154 implements PHPUnit\Framework
4544
{
4645
use PHPUnit\Framework\MockObject\StubApi;
4746
use PHPUnit\Framework\MockObject\MockObjectApi;
48-
use PHPUnit\Framework\MockObject\GeneratedAsMockObject;
4947
use PHPUnit\Framework\MockObject\Method;
5048
use PHPUnit\Framework\MockObject\DoubledCloneMethod;
5149

tests/end-to-end/mock-objects/generator/3967.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ $generator = new \PHPUnit\Framework\MockObject\Generator\Generator;
1818
$mock = $generator->generate(
1919
'Baz',
2020
true,
21-
true,
2221
[],
2322
'MockBaz',
2423
true,
@@ -33,7 +32,6 @@ class MockBaz extends Exception implements Baz, PHPUnit\Framework\MockObject\Moc
3332
{
3433
use PHPUnit\Framework\MockObject\StubApi;
3534
use PHPUnit\Framework\MockObject\MockObjectApi;
36-
use PHPUnit\Framework\MockObject\GeneratedAsMockObject;
3735
use PHPUnit\Framework\MockObject\Method;
3836
use PHPUnit\Framework\MockObject\ProxiedCloneMethod;
3937

tests/end-to-end/mock-objects/generator/397.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $generator = new \PHPUnit\Framework\MockObject\Generator\Generator;
1616
$mock = $generator->generate(
1717
C::class,
1818
true,
19-
true,
2019
[],
2120
'MockC',
2221
true,
@@ -31,7 +30,6 @@ class MockC extends C implements PHPUnit\Framework\MockObject\MockObjectInternal
3130
{
3231
use PHPUnit\Framework\MockObject\StubApi;
3332
use PHPUnit\Framework\MockObject\MockObjectApi;
34-
use PHPUnit\Framework\MockObject\GeneratedAsMockObject;
3533
use PHPUnit\Framework\MockObject\Method;
3634
use PHPUnit\Framework\MockObject\DoubledCloneMethod;
3735

tests/end-to-end/mock-objects/generator/4139.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require_once __DIR__ . '/../../../bootstrap.php';
1010

1111
$generator = new \PHPUnit\Framework\MockObject\Generator\Generator;
1212

13-
$mock = $generator->generate(InterfaceWithConstructor::class, true, true);
13+
$mock = $generator->generate(InterfaceWithConstructor::class, true);
1414

1515
print $mock->classCode();
1616
--EXPECTF--
@@ -20,7 +20,6 @@ class %s implements PHPUnit\Framework\MockObject\MockObjectInternal, InterfaceWi
2020
{
2121
use PHPUnit\Framework\MockObject\StubApi;
2222
use PHPUnit\Framework\MockObject\MockObjectApi;
23-
use PHPUnit\Framework\MockObject\GeneratedAsMockObject;
2423
use PHPUnit\Framework\MockObject\Method;
2524
use PHPUnit\Framework\MockObject\DoubledCloneMethod;
2625

tests/end-to-end/mock-objects/generator/abstract_class.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ $generator = new \PHPUnit\Framework\MockObject\Generator\Generator;
2020
$mock = $generator->generate(
2121
'Foo',
2222
true,
23-
true,
2423
[],
2524
'MockFoo',
2625
true,
@@ -35,7 +34,6 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte
3534
{
3635
use PHPUnit\Framework\MockObject\StubApi;
3736
use PHPUnit\Framework\MockObject\MockObjectApi;
38-
use PHPUnit\Framework\MockObject\GeneratedAsMockObject;
3937
use PHPUnit\Framework\MockObject\Method;
4038
use PHPUnit\Framework\MockObject\DoubledCloneMethod;
4139

tests/end-to-end/mock-objects/generator/class.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ $generator = new \PHPUnit\Framework\MockObject\Generator\Generator;
2020
$mock = $generator->generate(
2121
'Foo',
2222
true,
23-
true,
2423
[],
2524
'MockFoo',
2625
true,
@@ -35,7 +34,6 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte
3534
{
3635
use PHPUnit\Framework\MockObject\StubApi;
3736
use PHPUnit\Framework\MockObject\MockObjectApi;
38-
use PHPUnit\Framework\MockObject\GeneratedAsMockObject;
3937
use PHPUnit\Framework\MockObject\Method;
4038
use PHPUnit\Framework\MockObject\DoubledCloneMethod;
4139

tests/end-to-end/mock-objects/generator/class_call_parent_clone.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $generator = new \PHPUnit\Framework\MockObject\Generator\Generator;
1616
$mock = $generator->generate(
1717
'Foo',
1818
true,
19-
true,
2019
[],
2120
'MockFoo',
2221
true
@@ -30,7 +29,6 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte
3029
{
3130
use PHPUnit\Framework\MockObject\StubApi;
3231
use PHPUnit\Framework\MockObject\MockObjectApi;
33-
use PHPUnit\Framework\MockObject\GeneratedAsMockObject;
3432
use PHPUnit\Framework\MockObject\Method;
3533
use PHPUnit\Framework\MockObject\ProxiedCloneMethod;
3634
}

tests/end-to-end/mock-objects/generator/class_call_parent_constructor.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $generator = new \PHPUnit\Framework\MockObject\Generator\Generator;
1616
$mock = $generator->generate(
1717
'Foo',
1818
true,
19-
true,
2019
[],
2120
'MockFoo',
2221
true
@@ -30,7 +29,6 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte
3029
{
3130
use PHPUnit\Framework\MockObject\StubApi;
3231
use PHPUnit\Framework\MockObject\MockObjectApi;
33-
use PHPUnit\Framework\MockObject\GeneratedAsMockObject;
3432
use PHPUnit\Framework\MockObject\Method;
3533
use PHPUnit\Framework\MockObject\DoubledCloneMethod;
3634
}

tests/end-to-end/mock-objects/generator/class_dont_call_parent_clone.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $generator = new \PHPUnit\Framework\MockObject\Generator\Generator;
1616
$mock = $generator->generate(
1717
'Foo',
1818
true,
19-
true,
2019
[],
2120
'MockFoo',
2221
false
@@ -30,7 +29,6 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte
3029
{
3130
use PHPUnit\Framework\MockObject\StubApi;
3231
use PHPUnit\Framework\MockObject\MockObjectApi;
33-
use PHPUnit\Framework\MockObject\GeneratedAsMockObject;
3432
use PHPUnit\Framework\MockObject\Method;
3533
use PHPUnit\Framework\MockObject\DoubledCloneMethod;
3634
}

tests/end-to-end/mock-objects/generator/class_dont_call_parent_constructor.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $generator = new \PHPUnit\Framework\MockObject\Generator\Generator;
1616
$mock = $generator->generate(
1717
'Foo',
1818
true,
19-
true,
2019
[],
2120
'MockFoo',
2221
true
@@ -30,7 +29,6 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte
3029
{
3130
use PHPUnit\Framework\MockObject\StubApi;
3231
use PHPUnit\Framework\MockObject\MockObjectApi;
33-
use PHPUnit\Framework\MockObject\GeneratedAsMockObject;
3432
use PHPUnit\Framework\MockObject\Method;
3533
use PHPUnit\Framework\MockObject\DoubledCloneMethod;
3634
}

0 commit comments

Comments
 (0)