Skip to content

Commit 8086c07

Browse files
Closes #5818
1 parent b82007c commit 8086c07

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

ChangeLog-10.5.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes of the PHPUnit 10.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
44

5+
## [10.5.19] - 2024-MM-DD
6+
7+
### Fixed
8+
9+
* [#5818](https://github.com/sebastianbergmann/phpunit/issues/5818): Calling `method()` on a test stub created using `createStubForIntersectionOfInterfaces()` throws an unexpected exception
10+
511
## [10.5.18] - 2024-04-14
612

713
### Deprecated
@@ -193,6 +199,7 @@ All notable changes of the PHPUnit 10.5 release series are documented in this fi
193199

194200
* [#5563](https://github.com/sebastianbergmann/phpunit/issues/5563): `createMockForIntersectionOfInterfaces()` does not automatically register mock object for expectation verification
195201

202+
[10.5.19]: https://github.com/sebastianbergmann/phpunit/compare/10.5.18...10.5
196203
[10.5.18]: https://github.com/sebastianbergmann/phpunit/compare/10.5.17...10.5.18
197204
[10.5.17]: https://github.com/sebastianbergmann/phpunit/compare/10.5.16...10.5.17
198205
[10.5.16]: https://github.com/sebastianbergmann/phpunit/compare/10.5.15...10.5.16

src/Framework/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2313,7 +2313,7 @@ protected static function createStub(string $originalClassName): Stub
23132313
*/
23142314
protected static function createStubForIntersectionOfInterfaces(array $interfaces): Stub
23152315
{
2316-
$stub = (new MockGenerator)->testDoubleForInterfaceIntersection($interfaces, false);
2316+
$stub = (new MockGenerator)->testDoubleForInterfaceIntersection($interfaces, true);
23172317

23182318
Event\Facade::emitter()->testCreatedStubForIntersectionOfInterfaces($interfaces);
23192319

tests/unit/Framework/MockObject/Creation/CreateMockForIntersectionOfInterfacesTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ public function testCreatesMockObjectForIntersectionOfInterfaces(): void
3333
$this->assertInstanceOf(AnInterface::class, $double);
3434
$this->assertInstanceOf(AnotherInterface::class, $double);
3535
$this->assertInstanceOf(Stub::class, $double);
36+
37+
$double->method('doSomething')->willReturn(true);
38+
$double->method('doSomethingElse')->willReturn(true);
39+
40+
$this->assertTrue($double->doSomething());
41+
$this->assertTrue($double->doSomethingElse());
3642
}
3743

3844
public function testCannotCreateMockObjectForIntersectionOfInterfacesWhenLessThanTwoInterfacesAreSpecified(): void

tests/unit/Framework/MockObject/Creation/CreateStubForIntersectionOfInterfacesTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ public function testCreatesTestStubForIntersectionOfInterfaces(): void
3333
$this->assertInstanceOf(AnInterface::class, $double);
3434
$this->assertInstanceOf(AnotherInterface::class, $double);
3535
$this->assertInstanceOf(Stub::class, $double);
36+
37+
$double->method('doSomething')->willReturn(true);
38+
$double->method('doSomethingElse')->willReturn(true);
39+
40+
$this->assertTrue($double->doSomething());
41+
$this->assertTrue($double->doSomethingElse());
3642
}
3743

3844
public function testCannotCreateTestStubForIntersectionOfInterfacesWhenLessThanTwoInterfacesAreSpecified(): void

0 commit comments

Comments
 (0)