Skip to content
This repository was archived by the owner on May 27, 2023. It is now read-only.

Helper can not be mocked #134

Merged
merged 1 commit into from
Sep 28, 2013
Merged

Helper can not be mocked #134

merged 1 commit into from
Sep 28, 2013

Conversation

ScreamingDev
Copy link
Contributor

Because the correct method wasn't used.

@IvanChepurnyi
Copy link
Member

Which helpers do you mean? It works great for specifying full class alias of helper.

@ScreamingDev
Copy link
Contributor Author

I tried to mock my own Helper/Data.php and the returned class were named "...LeMike_DevMode_Helper_012456" which is obviously wrong.

Even $this->replaceByMock('helper', 'core', $helperCoreMock); and I had to write 'core/data' instead which is not very common if you think of Mage::helper('core') for example.

getHelperClassName is the only method in magento that resolves the name for helper correct.

@IvanChepurnyi
Copy link
Member

$this->replaceByMock() should not store value in registry with /data in the end, if version of Magento is greater than CE 1.6. Otherwise it won't be mocked. If you check the core code, you will get the point.

    public static function helper($name)
    {
        $registryKey = '_helper/' . $name;
        if (!self::registry($registryKey)) {
            $helperClass = self::getConfig()->getHelperClassName($name);
            self::register($registryKey, new $helperClass);
        }
        return self::registry($registryKey);
    }

As for getHelperMock, I will merge the change.

IvanChepurnyi added a commit that referenced this pull request Sep 28, 2013
@IvanChepurnyi IvanChepurnyi merged commit 59c739a into EcomDev:dev Sep 28, 2013
@ScreamingDev ScreamingDev deleted the dev-helperFix branch September 28, 2013 00:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants