Im trying to integrate unit test within my project because expending the site code base to go from supporting 1 site, to 3 sites, and we want to be sure everything works well on every site.
I started with a basic setup but this throws the next exception already.
Zend_Controller_Exception : Action Helper by name Layout not found#0 C:\xampp\htdocs\***\library\Zend\Controller\Action\HelperBroker.php(293): Zend_Controller_Action_HelperBroker::_loadHelper('Layout')
#1 C:\xampp\htdocs\***\library\Zend\Controller\Action\HelperBroker.php(339): Zend_Controller_Action_HelperBroker->getHelper('layout')
#2 C:\xampp\htdocs\***\library\Zend\Controller\Action.php(389): Zend_Controller_Action_HelperBroker->__get('layout')
#3 C:\xampp\htdocs\***\application\modules\default\controllers\ErrorController.php(17): Zend_Controller_Action->getHelper('layout')
#4 C:\xampp\htdocs\***\library\Zend\Controller\Action.php(133): ErrorController->init()
#5 C:\xampp\htdocs\***\library\Zend\Controller\Dispatcher\Standard.php(268): Zend_Controller_Action->__construct(Object(Zend_Controller_Request_HttpTestCase), Object(Zend_Controller_Response_HttpTestCase), Array)
#6 C:\xampp\htdocs\***\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_HttpTestCase), Object(Zend_Controller_Response_HttpTestCase))
#7 C:\xampp\htdocs\***\library\Zend\Test\PHPUnit\ControllerTestCase.php(208): Zend_Controller_Front->dispatch()
#8 C:\xampp\htdocs\***\tests\application\controllers\IndexControllerTest.php(25): Zend_Test_PHPUnit_ControllerTestCase->dispatch('/')
My file structure is as follow
- application
- config
- languages
- modules
- templates
- Bootstrap.php
- data
- library
- public
- tests
- application
- controllers
- IndexControllerTest.php
- ControllerTest.php
- data
- log
- Bootstrap.php
- phpunit.xml
- index.php
My Bootstrap.php (in tests folder) looks as follow
<?php
error_reporting( E_ALL | E_STRICT);
ini_set('display_startup_errors',1);
ini_set('display_errors', 1);
if (!defined('BASE_PATH')) {
define('BASE_PATH', realpath(dirname(__FILE__)));
}
if (!defined('APPLICATION_PATH')) {
define('APPLICATION_PATH', BASE_PATH . '/../application');
}
if (!defined('APPLICATION_ENV')) {
define('APPLICATION_ENV', 'testing');
}
if (!defined('LIBRARY_PATH')){
define('LIBRARY_PATH', BASE_PATH . '/../library');
}
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
set_include_path(implode(PATH_SEPARATOR, array(
'.',
LIBRARY_PATH,
get_include_path()
)));
// Include and launch the autoloader
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('Zend');
// Create application, bootstrap, and run
require_once 'Zend/Application.php';
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/config/config.php');
$application->bootstrap();
//
Zend_Session::$_unitTestEnabled = true;
Zend_Session::start();
clearstatcache();
also phpunit.xml doesn't seem to run as my logs get writen to data/logs/log.log instead of /log/coverage.
I'm running the unit tests using the run function in phpstorm and my configuration is as follow
Test name: Test Test runner: C:\xampp\htdocs***\tests, Test Scope: Directory Use alternative configuration file: C:\xampp\htdocs***\tests\phpunit.xml - PHPUnit library: Load from include path - Test runner: Default configuration file: C:\xampp\htdocs***\test\phpunit.xml
I'm not sure how to fix the Layout not found and if my configuration is right.
Aucun commentaire:
Enregistrer un commentaire