What are the Slack Archives?
Itβs a history of our time together in the Slack Community! Thereβs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonβt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
I am getting the following error with the code sniffer when sniffing my UnitTests class `Return type

I am getting the following error with the code sniffer when sniffing my UnitTests classReturn type annotation is missing the class that is mocked
This is the function where the sniffer gives the error:
/** * @return \PHPUnit\Framework\MockObject\MockObject */ public function getMockSpyGlossaryTranslationQuery() { return $this->getMockBuilder(SpyGlossaryTranslationQuery::class) ->getMock(); }
Can you please tell me what is missing in the docs?
Comments
-
I think it's not the docs, but the
public function getMockSpyGlossaryTranslationQuery()
line. It probably should have something like: MockObject
at the end. Like this:public function getMockSpyGlossaryTranslationQuery(): MockObject
0 -
Or, reading that error message again, more likely, it would need some annotation referring to
SpyGlossaryTranslationQuery::class
, as that is the class you're mocking.0 -
@U04FXCTCWPP Thanks for the hint. It turns out I need to write
@return SpyGlossaryTranslationQuery
instead in the docs0 -
Yep, that makes sense. π
0 -
@U048WDEP3R7 Also, an alternative approach that you might want to consider (I've been using this for quite a long time now):
/** * @return \Orm\Zed\Glossary\Persistence\SpyGlossaryTranslationQuery */ public function createSpyGlossaryTranslationQueryMock(): SpyGlossaryTranslationQuery { /** @var \Orm\Zed\Glossary\Persistence\SpyGlossaryTranslationQuery $queryMock */ $queryMock = $this->make(SpyGlossaryTranslationQuery::class); return $queryMock; }
0 -
Thanks @U04FXCTCWPP. This works the same as the code I wrote right? Looks better and cleaner.
0 -
I would assume, yes, but I can't say for certain as I haven't used your version yet. Maybe just try it and see if it works for you. π
0 -
@U04FXCTCWPP thanks. will do π
0 -
You're welcome. π
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 77 Spryker News
- 940 Developer Corner
- 796 Spryker Development
- 90 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 28 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 33 Product & Business Questions
- 69 Spryker Safari Questions
- 50 Random