Skip to content
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

UndefinedMethod for shouldReceive method #10

Open
matiux opened this issue Jun 22, 2020 · 1 comment
Open

UndefinedMethod for shouldReceive method #10

matiux opened this issue Jun 22, 2020 · 1 comment

Comments

@matiux
Copy link

matiux commented Jun 22, 2020

When I call shouldReceive method on a mocked class I get the UndefinedMethod error.

I have already seen this issue but it is not clear to me how to solve

@matiux
Copy link
Author

matiux commented Jun 23, 2020

Update:

If I mock class and call shouldReceive in same test method, it works

function testMyClass 
{
   $myClass = Mockery::mock(MyClass::class);
   $myClass->shouldReceive('doSomething');
}

otherwise, if I declare the mock as instance variable in setUp method, and call shouldReceive in test method, psalm doesn't work getting UndefinedMethod

private $myClass;

function setUp()
{
   $this->myClass = Mockery::mock(MyClass::class);
}

function testMyClass 
{
   
   $this->myClass->shouldReceive('doSomething');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant