The createTestProxy() method can be used to create a so-called test proxy: an object where all methods of the original class are replaced with an implementation that can be configured to expect an invocation but otherwise retains its original behaviour. They are "documented" here.
While the idea for test proxies was appealing, I have never seen this feature used "in the wild" to a degree that would warrant keeping it around.
To reduce complexity inside PHPUnit's test double functionality, TestCase::createTestProxy() will be deprecated and then removed:
- soft deprecation in PHPUnit 10.1 (add
@deprecated annotation to the method declaration)
- deprecation in PHPUnit 11 (using the method will trigger a deprecation)
- removal in PHPUnit 12
The
createTestProxy()method can be used to create a so-called test proxy: an object where all methods of the original class are replaced with an implementation that can be configured to expect an invocation but otherwise retains its original behaviour. They are "documented" here.While the idea for test proxies was appealing, I have never seen this feature used "in the wild" to a degree that would warrant keeping it around.
To reduce complexity inside PHPUnit's test double functionality,
TestCase::createTestProxy()will be deprecated and then removed:@deprecatedannotation to the method declaration)