Skip to content
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

Bug in 1.10 with prophecy-phpunit call predictions #88

Open
zolex opened this issue Aug 29, 2024 · 1 comment
Open

Bug in 1.10 with prophecy-phpunit call predictions #88

zolex opened this issue Aug 29, 2024 · 1 comment

Comments

@zolex
Copy link

zolex commented Aug 29, 2024

We have a messenger test, that predicts 2 calls using prophecy-phpunit.

these two calls are part of a message handler:

$this->appLogger->debug('RECEIVED MESSAGE');
// ...
$this->appLogger->debug('PROCESSED MESSAGE');

and the test goes something like this:

$appLogger = $this->prophesize(LoggerInterface::class);
$appLogger->debug(Argument::is('RECEIVED MESSAGE'))->shouldBeCalledOnce();
$appLogger->debug(Argument::is('PROCESSED MESSAGE'))->shouldBeCalledOnce();
self::getContainer()->set(LoggerInterface::class, $appLogger->reveal());

$this->transport()->throwExceptions();
$this->transport()->send($message);
$this->transport()->queue()->assertCount(1);
$this->transport()->process(1);
$this->transport()->queue()->assertCount(0);

in version 1.9.3 this still works like a charm, but when upgrading to 1.10, the second call prediction fails with the message that it has not been called. with step debugging I can see that it actually is called (and the object at that time is the test-double) but somehow the call is not recorded. this only happens when this package is updated. all other packages stay the same and are latest stable, also no code is changed.

@nikophil
Copy link
Member

hi @zolex

this is surprising, since this really sounds not related to this package. But if you're 100% sure the problem occurs when only this package is updated, it surely is related 😅

could you assert that there are exactly the same instances of the test doubles in the test code and in the handler?
but where would they come from if they are not the same? don't know 🤷

I don't use prophecy so I can't really help here. I don't see why release 1.10.0 would breaks anything related to mocking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants