Testing in magento 1.9 is painful. But somehow I am trying to figure out using PHPUnit.
I have a method which I want to test. And for unit testing I want to mock all the dependency that this method has.
In PHPUnit, there is a way to mock another class method using dependency injection. But the problem comes when my another class which I am trying to mock is my helper class itself.
I call my helper class method like this : Mage::helper('ClassXMLname')->getMyMethod()
.
So, my problems are :
- Is there any way apart from dependency injection so that I can mock my helper class method, and my method takes that mocked method while testing?
- If going in dependency injection, how can we dependency inject a helper class in our class?
Any answer on this will really help people still struggling with magento 1.9 . Thanks in advance.
Edit : Similar thing could be said about Models
, which we call using Mage::getModel('Module/classname')
.