New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createStub(), createConfiguredStub(), createPartialStub() #3120
Labels
event/code-sprint/2019-09
PHPUnit Code Sprint: September 2019
feature/test-doubles
Stubs and Mock Objects
type/enhancement
A new idea that should be implemented
Comments
Open
sebastianbergmann
added a commit
that referenced
this issue
Jun 28, 2019
…Object\MockObject for #3120
Mine. |
Note: #3810 does only implement I will create separate patches for |
sebastianbergmann
pushed a commit
that referenced
this issue
Sep 6, 2019
sebastianbergmann
pushed a commit
that referenced
this issue
Sep 6, 2019
sebastianbergmann
pushed a commit
that referenced
this issue
Sep 6, 2019
… false positive The method `InvocationMocker#will()` is LSP-compliant with the parent types, but a bug in psalm reports it as a false positive. Ref: vimeo/psalm#2102
sebastianbergmann
pushed a commit
that referenced
this issue
Sep 6, 2019
I was too eager in using an appropriate type declaration on `InvocationMocker`, but that has to wait for newer PHP releases.
sebastianbergmann
pushed a commit
that referenced
this issue
Sep 6, 2019
Once we have PHP 7.4, we can move these type declarations into the interface signature again, but for now, the existing inheritance leads to a crash on PHP < 7.4.
sebastianbergmann
pushed a commit
that referenced
this issue
Sep 6, 2019
sebastianbergmann
pushed a commit
that referenced
this issue
Sep 6, 2019
sebastianbergmann
pushed a commit
that referenced
this issue
Sep 6, 2019
sebastianbergmann
pushed a commit
that referenced
this issue
Sep 6, 2019
`InvocationStubber` methods cannot have return type declarations until then.
sebastianbergmann
pushed a commit
that referenced
this issue
Sep 6, 2019
This was referenced Apr 11, 2020
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
event/code-sprint/2019-09
PHPUnit Code Sprint: September 2019
feature/test-doubles
Stubs and Mock Objects
type/enhancement
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
getMock()
, thengetMockBuilder()
, and nowcreateMock()
etc. — creates a stub. If, and only if, theexpects()
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
createStub()
,createConfiguredStub()
,createPartialStub()
methods is feasible. These methods should create test double objects that do not have theexpects()
method and therefore are stubs that cannot become mocks.The text was updated successfully, but these errors were encountered: