Open shineability opened 6 years ago
You an use the latter, but a setHelperTestDouble
would be a convenient wrapper for manipulating the registry manually. Would you consider making a small PR out of that?
I gladly would, but I see no way to do it at this point without hacking the core :/ All the code related to resolve helper classes seems to be tied to the Mage
class and its static registry methods. Implementing test doubles for model (resources) is possible because you can override the config_model
.
The solution I proposed...
Mage::register('vendor_module/helper', $helperDouble, true)
... is not really convenient, after looking into it a bit more.
_helper/
manually when "overriding" the helper in the registry. My suggestion would be:
Mage::setHelperTestDouble($groupedClassName, $testDouble)
But that won't be possible without hacking the Mage
class.
Any thoughts on this @Vinai?
What I thought of was that the method setHelperTestDouble
is part of the DigitalPianism_TestFramework_Model_Config
simply for convenience.
In that method it would build the helper registry key, Mage::unregister()
it - just in case - and then set the test double into the registry.
The whole M1 testframework is hacky, so this change would be continuing that tradition :)
That’ll work :) I’ll give it a shot...
You can set test doubles for models and resource models. How would you do this for helpers? Shouldn't there be a
setHelperTestDouble
like method that deals with the registry? Or can I just useMage::register('vendor_module/helper', $helperDouble, true)
?