Skip to content

Dynamic class methods can not be verified? #24

@iverberk

Description

@iverberk

I'm mocking a Laravel Eloquent model and want to check if the 'findOrFail' method is being invoked. I've managed to make a test double and the 'findOrFail' method does indeed return the value that I specify. However, when I check for the method invocation, it fails.

I did some digging and apparently the $calls variable in ClassProxy/getCallsForMethod is being filled with the following attribute (among others):

["__call"]=>
  array(1) {
    [0]=>
    array(2) {
      [0]=>
      string(10) "findOrFail"
      [1]=>
      array(1) {
        [0]=>
        string(1) "1"
      }
    }
  }

So the method invocation is being recorded but obviously the following code which checks for the invocation fails:

 return isset($calls[$method])
            ? $calls[$method]
            : [];

The method invocation can be found under $calls['__call'] and not $calls['findOrFail']

Is this something that needs to be fixed or can I go about this some other way?

Regards,
Ivo

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