-
Notifications
You must be signed in to change notification settings - Fork 47
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
WithConsecutiveRector is not working as expected #327
Comments
Cool I missed that. Now it looks way better. $mock = $this->createMock(PersonService::class);
$matcher = $this->exactly(2);
$mock->expects($matcher)
->method('prepare')->willReturnCallback(function ($parameters) use ($matcher) : void {
match ($matcher->getInvocationCount()) {
1 => $this->assertEquals([1, 2], $parameters),
2 => $this->assertEquals([3, 4], $parameters),
};
});
$mock->prepare(9, 9);
$mock->prepare(9, 9); Which has only one little issue which is easy to fix: - ->method('prepare')->willReturnCallback(function ($parameters) use ($matcher) : void {
+ ->method('prepare')->willReturnCallback(function (...$parameters) use ($matcher) : void { |
/cc @f-albert could you check if @nicolashohm suggestion above is correct and can you try apply it? Thank you. |
Closing as outdated and lack of feedback last 4 months. Thanks for understanding 👍 This rule is quite a challange :) if you come across a weird case, please submit a test fixture here: |
I saw
WithConsecutiveRector
added in #246 to the PHPUnit 10 rule set, and was keen to use it. But unfortunately, it's not working.I took the example from
tests/Rector/StmtsAwareInterface/WithConsecutiveRector/Fixture/some_class.php.inc
and defined PersonService like this:Original test:
=> Test fails as expected with:
after running the
WithConsecutiveRector
:=> Test is successful even though it shouldn't cause 9 is not equals to the expected value.
the result I get from the rector is already different from what's in the documentation. So I also checked if it would work with the result the documentation provides:
=> Test is successful again, even though it still shouldn't.
Let me know if I missed something. Otherwise, I've unfortunately no idea how to fix this rector.
The text was updated successfully, but these errors were encountered: