Zend_Loader Vs Autoloader with Zend_Test and PHPUnit

I am setting up testing using PHPUnit and the Zend Framework, and I have a problem with autoload.

Firstly, I'm not sure why I need to configure autoload in my phpunit bootstrap.php. In production environment, index.php file does not load it? (My test cases extend Zend_Test_PHPUnit_ControllerTestCase).

Secondly, it’s hard for me to replace Zend_Loader with Zend_Loader_Autoload.

If I use this code in my bootstrap ...

require_once "Zend/Loader.php";
Zend_Loader::registerAutoload();

... tests work fine, but with a warning that Zend_Loader is out of date.

If I use this code, however ...

require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();

Tests cannot find the library class and fatal error results.

application.ini Namespaces [] = "CP_". , Loader , Autoloader. ...

?

!

+5
1

PHPUnit cli/php.ini . , ​​, php.ini, cli/php.ini.

, ini . - :

$resourceLoader = new Zend_Loader_Autoloader_Resource(array(
    'basePath' => APPLICATION_PATH,
    'namespace' => '',
    'resourceTypes' => array(
        'cplib' => array(
            'path' => 'library/CP',
            'namespace' => 'CP_'
        ),
    ),
));
+5

All Articles