- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 2.2k
 
Description
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 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)