1

I'm using phpunit and need to test the method in a controller but when I try to call it like this:

Vendor_Module_Adminhtml_SomecontrollerController::someMethod();

phpunit fails with this error:

PHP Fatal Error: Class Vendor_Module_Adminhtml_SomecontrollerController not found in ...

Anyone knows how to call to a method in a controller?

Thanks.!

3

Alan Storm got the response here: https://magento.stackexchange.com/a/8751/49865

Basically add the file and instantiate the class.

In my case look like this:

<?php

require_once 'vendor/module/controllers/Adminhtml/myClassController.php';

class vendor_module_controllers_Adminhtml_myClassControllerTest extends PHPUnit_Framework_TestCase
{
    /**
     * @runInSeparateProcess
     */
    public function testOne()
    {
        $controller = new vendor_module_Adminhtml_myClassController(
            Mage::app()->getRequest(),
            Mage::app()->getResponse()
        );
        $controller->methodAction();
    }
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.