Skip to content
Advertisement

Tag: mockery

Laravel: Test not Using Mocked Method

I want getNumber to return 200 in the test case, but when I run the test and inspect the result with $response->dump() I can see that the mock is not overriding the method as it is showing array:1 [0 => 100]. What am I missing? Controller: Model: Test: I am using Laravel 8 and referencing this documentation: https://laravel.com/docs/8.x/mocking#mocking-objects Answer In

Carbon object in mockery php test

Thank you for your time. I have stripped out the fluff from the code/test. The furthest I have got with this is that setAttribute requires two strings as paramĀ“s, but i am passing in an Carbon object, which Mockery as a test suite does not like? Is this the case, is there a better way to test dates with Mockery/PHPUnit?

Mockery: how does a passive partial mock differ from the default mock?

In the very last paragraphs of this (great) quick reference to Mockery, the author explains some behaviour modifiers for a mock which are not default, but may be useful. These include the makePartial() call and the shouldDeferMissing() call. How do these differ from the default behaviour? When you create a mock (Mockery::mock(‘myClass’)), and don’t add any method expectations, all method

Advertisement