Test unitaires et bootstrap
Bonjour,
Depuis hier j'essaye de faire tourner phpunit avec un projet Zend.
J'ai suivi divers tutoriaux, tous échouent.
Voici mon /projet/test/phpunit.xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <phpunit bootstrap="./application/bootstrap.php" colors="false">
<testsuite name="projet">
<directory>./application/</directory>
<directory>./library/</directory>
</testsuite>
<filter>
<whitelist>
<directory suffix=".php">../application</directory>
<exclude>
<directory suffix=".phtml">../application/views</directory>
<file>../application/Bootstrap.php</file>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./log/coverage" charset="UTF-8"
yui="true" highlight="false" lowUpperBound="35" highLowerBound="70"/>
</logging>
</phpunit> |
Et mon /projet/test/application/bootstrap.php:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| <?php
//die(realpath(__FILE));
error_reporting( E_ALL | E_STRICT );
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
date_default_timezone_set('Europe/Paris');
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
define('APPLICATION_ENV', 'testing');
define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/../library'));
define('TESTS_PATH', realpath(dirname(__FILE__)));
$_SERVER['SERVER_NAME'] = 'http://127.0.0.1/';
$includePaths = array(LIBRARY_PATH, get_include_path());
set_include_path(implode(PATH_SEPARATOR, $includePaths));
//require_once "Zend/Loader.php";
//Zend_Loader::registerAutoload();
require_once 'Zend/Loader/Autoloader.php';
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Application',
'basePath' => dirname(__FILE__),
));
Zend_Session::$_unitTestEnabled = true;
Zend_Session::start(); |
Lorsque je tente de lancer phpunit, le bootstrap ne semble pas pris en compte (testé en faisant une erreur à l'intérieur).
Du coup, je me retrouve avec des messages:
Citation:
Fatal error: Class 'Zend_Db_Table_Abstract' not found in /projet/application/models/Db/Abstract.php on line 7
Quelqu'un aurait une idée pour me débloquer ?
Utilisation de Zend-Application
Perso, je fais des tests unitaires sur un projet Zend avec Phpunit.
J'ai créé un fichier param.php dans lequel je définie et je lance mon $application->bootstrap();
Cela me permet de charger l'environnement.
Par contre, je ne lance pas le $application->run(); du MVC.
Ce fichier est inclu en début de toutes mes classes de tests.