Skip to content

Commit

Permalink
Closes #5818
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Apr 17, 2024
1 parent b82007c commit 8086c07
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ChangeLog-10.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

## [10.5.19] - 2024-MM-DD

### Fixed

* [#5818](https://github.com/sebastianbergmann/phpunit/issues/5818): Calling `method()` on a test stub created using `createStubForIntersectionOfInterfaces()` throws an unexpected exception

## [10.5.18] - 2024-04-14

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

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

[10.5.19]: https://github.com/sebastianbergmann/phpunit/compare/10.5.18...10.5
[10.5.18]: https://github.com/sebastianbergmann/phpunit/compare/10.5.17...10.5.18
[10.5.17]: https://github.com/sebastianbergmann/phpunit/compare/10.5.16...10.5.17
[10.5.16]: https://github.com/sebastianbergmann/phpunit/compare/10.5.15...10.5.16
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2313,7 +2313,7 @@ protected static function createStub(string $originalClassName): Stub
*/
protected static function createStubForIntersectionOfInterfaces(array $interfaces): Stub
{
$stub = (new MockGenerator)->testDoubleForInterfaceIntersection($interfaces, false);
$stub = (new MockGenerator)->testDoubleForInterfaceIntersection($interfaces, true);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public function testCreatesMockObjectForIntersectionOfInterfaces(): void
$this->assertInstanceOf(AnInterface::class, $double);
$this->assertInstanceOf(AnotherInterface::class, $double);
$this->assertInstanceOf(Stub::class, $double);

$double->method('doSomething')->willReturn(true);
$double->method('doSomethingElse')->willReturn(true);

$this->assertTrue($double->doSomething());
$this->assertTrue($double->doSomethingElse());
}

public function testCannotCreateMockObjectForIntersectionOfInterfacesWhenLessThanTwoInterfacesAreSpecified(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public function testCreatesTestStubForIntersectionOfInterfaces(): void
$this->assertInstanceOf(AnInterface::class, $double);
$this->assertInstanceOf(AnotherInterface::class, $double);
$this->assertInstanceOf(Stub::class, $double);

$double->method('doSomething')->willReturn(true);
$double->method('doSomethingElse')->willReturn(true);

$this->assertTrue($double->doSomething());
$this->assertTrue($double->doSomethingElse());
}

public function testCannotCreateTestStubForIntersectionOfInterfacesWhenLessThanTwoInterfacesAreSpecified(): void
Expand Down

0 comments on commit 8086c07

Please sign in to comment.