-
Notifications
You must be signed in to change notification settings - Fork 5
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
Use reflection for mocked objects injection #4
Comments
Duplicate of #1. |
I was waiting for someone else to take interest in this :) As of Peridot 1.15.0 it is possible for plugins to provide arguments to spec functions - so we could pass a prophecy object as an argument. I think the complexity would come from the fact that the result of |
Prophet will return ObjectProphecy without doubler only if mocking class/interface doesn't exists. If class exists, you can get doubled object with |
I believe you are correct, but the double will not have access to spies or method prophecies correct? The example above would not be possible. |
Yes, you are right... The only possible way to call 'willReturn' is function (Wings $wings) {
$wings->getProphet()->swing()->willReturn('fly like an eagle');
} Or... <?php
describe('Bird', function() {
beforeEach(function(Wings $wings) {
// $wings is actually ObjectProphecy, or wrapped one
$this->$bird = new Bird($wings->reveal()); // or ->unwrap() or ->getMock()
});
it('should fly', function(Wings $wings) {
$wings->swing()->shouldBeCalled();
$this->bird->fly();
});
}); Unless testing class is wrapped with some proxy, it is very complicated to make this the same way as in phpspec. |
Challenge accepted! I'll spend a little time playing with a lightweight proxy implementation. |
PhpSpec has it's great sugar for injection mocked objects. Is it possible to implement such thing in Peridot?
For example
The text was updated successfully, but these errors were encountered: