View helper not found in PHPUnit tests

I have following directory structure for view helper in my omeka plugin:

 --MyPlugin
       --views
         --helpers
            --HelperName.php

In HelperName.php file naming convention is

class MyPlugin_View_Helper_HelperName extends Zend_View_Helper_Abstract

When I run plugin via browser, plugin working fine without any error, but when I invoke phpunit for same plugin via command line I am getting error something like:

Zend_Loader_PluginLoader_Exception: Plugin by name 'HelperName' was not found in the registry; used paths:
HistoryLog_View_Helper_: /var/www/TFG-CeniehAriadne/omeka/plugins/HistoryLog/views/helpers/
Omeka_View_Helper_: /var/www/TFG-CeniehAriadne/omeka/application/views/helpers/
Zend_View_Helper_: Zend/View/Helper/

What am I doing wrong?

Thanks in advance.

Is HistoryLog the plugin you’re working on, or is it another?

It’s another.

The path “HistoryLog_View_Helper” comes out in error because my plugin requires it (I’ve installed it in the setUp() method before setup my plugin).

setUp method

public function setUp()
    {
        parent::setUp();

        // authenticate and set the current user
        $this->user = $this->db->getTable('User')->find(1);
        $this->_authenticateUser($this->user);
        
        // plugin helper
        $pluginHelper = new Omeka_Test_Helper_Plugin;
        // required plugins
        if(!plugin_is_active('HistoryLog')) $pluginHelper->install('HistoryLog');
        // setup main plugin
        $pluginHelper->setUp(self::PLUGIN_NAME);
        
        Omeka_Test_Resource_Db::$runInstaller = true;
    }

Could this be the mistake?

Thank you for your quick answer.

I’m not totally sure what’s going on here… the systems that set up the helper paths and things like that are the same for all plugins, which would seem to rule out an issue with the Plugin test helper stuff in general, since it’s loading the other plugin’s path correctly.

I think it’s a bit hard to tell in isolation what’s happening from a snippet, not knowing what the test code is that’s failing or the full trace of the error or the rest of the code, and so on. I suppose you could always call addHelperPath directly on the View object to manually add the appropriate path and work around this, but you shouldn’t have to.

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.