Comments (2)
Hey @alexandre-da-costa,
My apologies for the late response.
Usually, when a methods return type is
static
orself
we use->andReturnSelf()
.http://docs.mockery.io/en/stable/reference/expectations.html#declaring-return-value-expectations
eg.
$I->mock(HubSpotList::class) ->shouldReceive('findOrFail') ->andReturnSelf();
Hello, thank you for the answer. It helped me to see the real mistake.
The problem is that the method should be final, not fluid. So the mistake was using static for it, instead of the final class.
I.e. for the base findOrFail()
I should use HubSpotObject
which is the base class, and for child classes overriding it, I just use the child class as return type, in the example HubSpotList
.
Doing that made the mock work like expected :)
Much appreciated.
from mockery.
Hey @alexandre-da-costa,
My apologies for the late response.
Usually, when a methods return type is static
or self
we use ->andReturnSelf()
.
http://docs.mockery.io/en/stable/reference/expectations.html#declaring-return-value-expectations
eg.
$I->mock(HubSpotList::class)
->shouldReceive('findOrFail')
->andReturnSelf();
from mockery.
Related Issues (20)
- mockery/mockery: 1.4.x-dev not found HOT 3
- Factory methods for `IsEqual` and `IsSame` matchers HOT 1
- support for PHPUnit constraints HOT 2
- Add "set property" method to mock object? HOT 1
- Disabled travis-ci and sensiolabs webhooks
- [New feature] Running code after mock method was called HOT 2
- InvalidCountException even though the mock method is called HOT 1
- [Feature request] Add array-like objects support to argument matchers
- Deprecations about drop support Metadata doc-comment in PHPUnit 12 HOT 2
- Latest release totally broken HOT 14
- PHPStan error with mock method in 1.6.8 HOT 1
- Invalid `Mockery::mock()`/`spy()` phpdoc (= phpstan errors) HOT 6
- Issues with partial construction trait methods on 1.6.10 - change in behaviour HOT 1
- Cannot use 'false' as class name as it is reserved HOT 2
- Typings for setConstantsMap does not allow array HOT 1
- Mocking final classes reports unresolvable type by PHPStan HOT 1
- Error when mocking anonymous classes HOT 5
- Received `*::__construct()` but no expectations were specified HOT 1
- 1.6.12 typehint issue with spy methods HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mockery.