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

Most upvoted comments

Can this be closed, now that #441 is merged?