Closed tkotosz closed 5 years ago
How about willYield($value1, $value2, ...)
instead of willYield([$value1, $value2, ...])
?
The shouldYield
expects array if I remember correctly, so I thought best to expect array here as well.
Is this already merged to master or in near future? I need exactly this in one of my bigger projects.
@stof FYI the test changes (fixing the build) are in a separate PR originally https://github.com/phpspec/prophecy/pull/434 (so I assume that one need to be reviewed and finalized) before this one can go forward
@antonfries In the meantime while this is not merged you can get around the issue by doing this:
Mock method to yield 0 items:
$collaborator->generate()->will(function() {
if (false) { // yield nothing
yield;
}
});
Mock method to yield some items:
$collaborator->generate()->will(function() {
yield MySuperItem::fromInt(1);
yield MySuperItem::fromInt(2);
});
@tkotosz Thanks, that will help me for the first infrastructure parts!
@stof rebased this PR from https://github.com/phpspec/prophecy/pull/434 , fixed the issues related this PR and squashed commits. Can you have a look again?
@stof rebased this PR from master now since the other PR has been merged :)
@stof rebased this PR from master again, to apply the recent build fix
This looks really useful, thanks
Thanks for the merge @ciaranmcnulty :tada:
Adds
willYield
functionality. Usage:Depends on https://github.com/phpspec/prophecy/pull/434 (will rebase this PR once the other one merged)