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..
Hi team Can you please give some referece how mocking works in spryker test cases?
Hi team
Can you please give some referece how mocking works in spryker test cases?
Comments
-
Depends what you want to mock?
Unittests?$this->tester->createMockBuilder('<class>');
and all other things you can do with PHPUnit.
Just instead of$this-><phpunit method>()
you need to call$this->tester-><phpunit method>()
as long as the base test class you extend is using the unit extension of codeception.Beside that you can mock factories, configs and faceds for every module using the provided test helpers from spryker: https://docs.spryker.com/docs/scos/dev/guidelines/testing-guidelines/available-test-helpers.html#testify-helpers
There are plenty of documentation parts available on testing and mocking in Spryker: https://docs.spryker.com/docs/scos/dev/guidelines/testing-guidelines/testing-concepts.html
0 -
yes I am trying to mock unit tests
I have written following code in tester class:public function createUtility()
{
return new ImageUrlTemplatingUtility($this->mockGlobalConfigFacade());
}
In code, in above class,ImageUrlTemplatingUtility
have dependency injection of another module facade, I want to mock that.I am trying to do by
public function mockGlobalConfigFacade()
{
return Stub::make('GlobalConfigFacade', ['getGlobalCOnfigValueByKey' => '/files?p_Doc_Ref=#pictureRef#&p_File_Type=rendition_369_jpg']);
}
in
tester
classbut it is giving error that
Stubbed class GlobalConfigFacade doesn't exist.0 -
It is done by making following change in code:
public function mockGlobalConfigFacade()
{
return Stub::make(GlobalConfigFacade::class, ['getGlobalCOnfigValueByKey' => '/files?p_Doc_Ref=#pictureRef#&p_File_Type=rendition_369_jpg']);
}
insead ofpublic function mockGlobalConfigFacade()
{
return Stub::make('GlobalConfigFacade', ['getGlobalCOnfigValueByKey' => '/files?p_Doc_Ref=#pictureRef#&p_File_Type=rendition_369_jpg']);
}
Please confirm whether it is correct way to do same.
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 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
- 26 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
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random