Skip to content

Feature/question: Verifying that calls are made in order. #130

@ezzatron

Description

@ezzatron

I'm trying to migrate from Phake, and one feature I can't find a replacement for is Phake::inOrder().

The basic idea being that unless method calls happen in a specific order, the assertion fails. I had a look into writing my own prediction, but they seem to be tied to a specific method, and this type of assertion potentially spans multiple methods, or even objects.

I'm not really a huge fan of the way Phake handles this anyway. Phake::inOrder() will ignore other method calls in between the ones you specify, which is not always desirable. Sometimes you want to verify that an exact set of calls were made, and no others.

A really good example of some call order verification tools is Sinon.JS's spy API and spy call API. Amongst other features they support things like:

  • spy.firstCall
  • spy.secondCall
  • spy.thirdCall
  • spy.lastCall
  • spy.calledBefore(anotherSpy)
  • spy.calledAfter(anotherSpy)
  • spyCall = spy.getCall(n)

Is there any existing feature that helps with this kind of verification? Or would such features be worth making a PR?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions