Questions tagged [mocks]
The mocks tag has no usage guidance.
8
questions
2
votes
1answer
80 views
Mocked shared instance incomplete on second identical integration test
I'm writing an integration test on a plugin that changes the action of an existing form.
The plugin calls a helper method that decides whether the url should be changed and returns the result.
I ...
1
vote
2answers
708 views
How to create mock for factory classes?
In unit testing I want to create mock object for factory classes e.g.
$this->getMockBuilder(\Magento\Framework\Controller\Result\RawFactory::class)->disableOriginalConstructor()->getMock();
but I ...
4
votes
1answer
249 views
How to create an order using mock object in phpunit in Magento?
I am preparing phpunit tests. I need to create an order using mocking and that order i need to pass in my function.
Please suggest, How can i achieve this ?
2
votes
1answer
606 views
Magento 2 - PHPUnit using mocking or without mocking?
I am developing an eCommerce web application using magento2. During the development I came to know magento2 useses mockbuilder or mock objects for testing it's modules functionality.
Which is fare in ...
1
vote
1answer
781 views
Magento 2: Mocking method, return value not working
I am trying to learn unit testing. I wrote simple module to get better understanding about mocking. The test should return "Cat" but it return "Dog".
I can not see what is wrong with the code?
In ...
1
vote
1answer
523 views
Magento 2 : mocking `getParam()` in unit test not working
I'm breaking my head for hours now over a simple thing I've done hundreds of times: mocking another model. Can anyone see what's wrong with this?
$mockedRequest = $this
->...
1
vote
1answer
408 views
How to mock an external resource in Magento 2?
I want to write unit test for a module which contains these functions:
public function abc($Str)
{
$n = $this->def();
...
return x;
}
public function def()
{
...
$productRepo=...
6
votes
1answer
1k views
How to properly use getCollectionMock
TL;DR:
I would love an example of how Magento\Framework\TestFramework\Unit\Helper\ObjectManager::getCollectionMock() can be used for unit tests that involve collections and/or collection factories and ...