prophecy: Spies do not register as allowed method calls when stubbing is specified
Normally Spied-on methods are included in the list of expected calls. However, this breaks if stubbing takes place beforehand
Spec:
class SpiesExampleSpec extends ObjectBehavior
{
function it_does_not_expect_spied_on_methods(\DateTime $time)
{
$time->getOffset()->willReturn(-1800);
$this->modifyTimestamp($time);
$time->setTimestamp(1234)->shouldHaveBeenCalled();
}
}
Object:
class SpiesExample
{
public function modifyTimestamp(\DateTime $time)
{
$time->getOffset();
$time->setTimestamp(1234);
}
}
Output:
10 ! it does not expect spies
method call:
Double\DateTime\P1->setTimestamp(1234)
was not expected.
Expected calls are:
- getOffset()
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 2
- Comments: 15 (13 by maintainers)
Commits related to this issue
- Fix issue #120 by delaying unexpected method call evaluation — committed to elvetemedve/prophecy by deleted user 5 years ago
- Fix issue #120 by delaying unexpected method call evaluation — committed to elvetemedve/prophecy by deleted user 5 years ago
- Fix issue #120 by delaying unexpected method call evaluation — committed to elvetemedve/prophecy by deleted user 5 years ago
- Merge pull request #441 from elvetemedve/hotfix/spies-do-not-register-as-allowed-method-calls Fix issue #120 by delaying unexpected method call evaluation — committed to phpspec/prophecy by ciaranmcnulty 5 years ago
Can this be closed, now that #441 is merged?