PHPUnit mock magento magic functions
In magento it often happens that when you are writing code in block, that product model uses magic function, for the new product attribute created by you.
How can we mock these functions so that we can test our class efficiently
$map = [ ['getFrontendLabel', , 'Frontend Label'] ]; /** getFrontendLabel is function name,  is array parameter, 'Frontend Label' is return */ $attribute ->method('__call') ->willReturnMap($map);
Map call functions with parameters
code in model will look like: $product->setCollectShippingRates(true); unit test code will look like below
// true is the first parameter passed to function setCollectShippingRates
$map = [ ['setCollectShippingRates', [true], 'some return'], ]; $mock->method('__call')->willReturnMap($map);