You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The methods for creating test stubs, createStub($type) for example, are documented to return Stub&$type whereas the methods for creating mock objects, createMock($type) for example, are documented to return MockObject&$type.
However, the methods for creating test stubs generate and return MockObject&$type for legacy reasons at the moment. This means that the expects() method is currently available on objects created using createStub(), for example. This allows the configuration of mock object expectations on objects that are created using a method where its name implies the intent of creating a test stub. However, expectations configured on test stubs created using createStub(), for example, are not verified.
Timeline
deprecation in PHPUnit 11 (calling expects() on a test double created using a method for creating test stubs triggers a deprecation)
removal in PHPUnit 12 (calling expects() on a test double created using a method for creating test stubs triggers an error)
The text was updated successfully, but these errors were encountered:
PHPUnit\Framework\TestCase
provides methods for dynamically creating two types of test doubles: test stubs and mock objects:createStub()
createStubForIntersectionOfInterfaces()
createConfiguredStub()
createMock()
createMockForIntersectionOfInterfaces()
createConfiguredMock()
createPartialMock()
The methods for creating test stubs,
createStub($type)
for example, are documented to returnStub&$type
whereas the methods for creating mock objects,createMock($type)
for example, are documented to returnMockObject&$type
.However, the methods for creating test stubs generate and return
MockObject&$type
for legacy reasons at the moment. This means that theexpects()
method is currently available on objects created usingcreateStub()
, for example. This allows the configuration of mock object expectations on objects that are created using a method where its name implies the intent of creating a test stub. However, expectations configured on test stubs created usingcreateStub()
, for example, are not verified.Timeline
expects()
on a test double created using a method for creating test stubs triggers a deprecation)expects()
on a test double created using a method for creating test stubs triggers an error)The text was updated successfully, but these errors were encountered: