createMockForIntersectionOfInterfaces()
does not automatically register mock object for expectation verification
#5563
Labels
feature/test-doubles
Test Stubs and Mock Objects
type/bug
Something is broken
version/10
Something affects PHPUnit 10
Summary
When creating a mock using
$this->createMockForIntersectionOfInterfaces()
, the created MockObject is not registered in the test case. Because of this, failing expectations are not triggered when the test completes.Current behavior
createMockForIntersectionOfInterfaces()
does not callregisterMockObject
, which means failing expectations are not flagged as a test failure.Expected behavior
createMockForIntersectionOfInterfaces()
callsregisterMockObject
just likecreateMock()
does.How to reproduce
Running PHPUnit outputs:
Note: PHPUnit exits with exit code 0, meaning if this is the only "failing" test, CI will happily proceed.
Manually registering the mocks (something
createMock()
does automatically for you) by enabling the registerMockObject lines works as expected:Now the expectation causes a test failure and PHPUnit exits with exit code 1, interrupting CI flow as it should.
The text was updated successfully, but these errors were encountered: