EcomDev_PHPUnit icon indicating copy to clipboard operation
EcomDev_PHPUnit copied to clipboard

Mocking does not work on magic methods

Open ScreamingDev opened this issue 11 years ago • 0 comments

Varien_Object has magic methods to get and set data. Mocking this does not seem to work:

 $templateText = md5(uniqid());
        $coreEmailTemplateMock = $this->getModelMock('core/email_template');
        $coreEmailTemplateMock->expects($this->any())->method('getTemplateText')->will($this->returnValue($templateText));
        $this->replaceByMock('model', 'core/email_template', $coreEmailTemplateMock);

        $this->assertEquals($templateText, Mage::getModel('core/email_template')->getTemplateText());

while the same with the existent "isEmpty" as method does work

ScreamingDev avatar Sep 10 '13 20:09 ScreamingDev