I'm trying to mock this method: getCurrentCurrency() from "core/store" (Mage_Core_Model_Store) in my unit test. Just a simple stub, nothing more.
private function _stubGetCurrentCurrency() {
$mock = $this->getModelMock(
'core/store',
array(
'getCurrentCurrency'
)
);
$mock
->expects($this->any())
->method('getCurrentCurrency')
->will($this->returnCallback(array($this, 'signal')));
$this->replaceByMock(
'singleton',
'core/store',
$mock
);
}
function signal() {
echo "\n- Signal invoked -\n";
}
However it doesn't seem to work for me - when I do $this->_stubGetCurrentCurrency(); I don't see the signal() is being called at all. I've ascertained that the original method is being invoked instead. Looks like I'm missing something, but I can't find what's wrong.
I also have stubs for "sales/order_invoice" canCapture() and "salesrule/observer" addProductAttributes() in that test - they are instantiated in the same manner and both work perfectly fine.
Can anyone point out my miss? Thank you.
replaceByMock()should be 'model', not 'singleton'. However, I couldn't get this to work neither, even with$this->app()->reinitStores(). Did you find a solution?