views:

29

answers:

1

Hello,

This is a very specific question and I have googled lots for a potential solution but nothing that points me in the right direction. I have written a Zend_Controller_Action_Helper to help me process some forms in my application. Now in the application it works fine but it seams to of broke my tests. If I comment out the lines that add the helper into the broker everything works fine but that sort of defeats the object. The error I get is

Fatal error: Class 'PHPUnit_Framework_Error_Notice' not found in /Users/chris/NetBeansProjects/myProject/library/ProcessForm.php on line 25

What I don't understand is why is it throwing this error on line 25 which is specifically

public function processForm($aParam)

So I suppose I should paste some code to show you some of the app. I am adding this Helper in the bootstrap of my application like so..

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initHelpers()
    {
        // If I comment out these lines it all works
        require_once 'ProcessForm.php';
        Zend_Controller_Action_HelperBroker::addHelper(
            new ProcessForm()
        );
    }
}

My PHPUnit bootstrap file looks like this

require_once 'Zend/Application.php';
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';

abstract class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
{

    protected $application;

    public function setUp()
    {
        $this->bootstrap = array($this, 'appBootstrap');
        parent::setUp();
        $this->getFrontController()->setParam('bootstrap', $this->application->getBootstrap());
    }

    public function appBootstrap()
    {
        $this->application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
        $this->application->bootstrap();
    }


}

The actual helper looks like this

class ProcessForm extends Zend_Controller_Action_Helper_Abstract
{
    /**
     * @var Zend_Loader_PluginLoader
     */
    public $pluginLoader;

    /**
     * Constructor: initialize plugin loader
     *
     * @return void
     */
    public function __construct()
    {
        $this->pluginLoader = new Zend_Loader_PluginLoader();
    }

    public function processForm($aParam)
    {
    }

    public function direct($aParam)
    {
        return $this->processForm($aParam);
    }
}
A: 

I found the problem the solution turns out that (I think its a php 5.3 thing) if I rename the main function to something else it seams to work. E.g.

class ProcessForm extends Zend_Controller_Action_Helper_Abstract
{
    /**
    * @var Zend_Loader_PluginLoader
    */
    public $pluginLoader;

    /**
    * Constructor: initialize plugin loader
    *
    * @return void
    */
    public function __construct()
    {
        $this->pluginLoader = new Zend_Loader_PluginLoader();
    }

    public function doThis($aParam)
    {
    }

    public function direct($aParam)
    {
        return $this->doThis($aParam);
    }
}

I think this is because in php 5.3 you are allowed to construct your class with either __construct or myClass but this functionality is now being deprecated if I am correct.

Catharsis