-
Notifications
You must be signed in to change notification settings - Fork 242
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
Spies do not register as allowed method calls when stubbing is specified #120
Comments
The Mock version passes as expected: function it_does_not_expect_spies(\DateTime $time)
{
$time->getOffset()->willReturn(-1800);
$time->setTimestamp(1234)->shouldBeCalled();
$this->modifyTimestamp($time);
} |
can you run |
phpspec/phpspec dev-master 5520c91 |
Bumping prophecy to dev-master shows the same result |
To be clear, this version works fine: Spec: class SpiesExampleSpec extends ObjectBehavior
{
function it_does_not_expect_spied_on_methods(\DateTime $time)
{
$this->modifyTimestamp($time);
$time->setTimestamp(1234)->shouldHaveBeenCalled();
}
} Object: class SpiesExample
{
public function modifyTimestamp(\DateTime $time)
{
$time->setTimestamp(1234);
}
} It seems to be the mixture of stubs + spies |
ok, this looks like a really weird bug |
From here: It looks like at call time there will be an exception if the method is not mocked or stubbed, unless there are zero mocks/stubs. |
Fixing it would involve moving that check to much later in the process |
but then, how could it pass in the second case ? |
Which case is the second case?
|
@everzet do you have an idea to fix this ? |
I would say record the calls and evaluate whether they were expected or not later on rather than immediately. Or turn off the 'expected call' checking and just return null for unexpected ones (trolling Konstantin now) ;-) |
I just ran in to this issue as well (I have a stub that I expect a method to be called on, but |
Any news on this bug here in 2019? |
…-as-allowed-method-calls Fix issue #120 by delaying unexpected method call evaluation
Can this be closed, now that #441 is merged? |
Normally Spied-on methods are included in the list of expected calls. However, this breaks if stubbing takes place beforehand
Spec:
Object:
Output:
The text was updated successfully, but these errors were encountered: