/ phpunit Public
createStub(), createConfiguredStub(), createPartialStub() #3120
PHPUnit Code Sprint: September 2019
Stubs and Mock Objects
A new idea that should be implemented
PHPUnit's built-in test doubles functionality pre-dates the de-facto standard classification for test doubles established by Gerard Meszaros in his book "xUnit Test Patterns".
The API of PHPUnit's built-in test doubles functionality for creating test doubles — originally
getMockBuilder(), and now
createMock()etc. — creates a stub. If, and only if, the
expects()method is called on this stub to set up expectations then that stub becomes a mock.
The fact that the test double returned by
createMock()is initially "just" a stub can be confusing, especially for developers new to PHPUnit in particular and/or unit testing and test doubles in general.
It should be explored whether the addition of
createPartialStub()methods is feasible. These methods should create test double objects that do not have the
expects()method and therefore are stubs that cannot become mocks.
The text was updated successfully, but these errors were encountered: