70 lines
2.4 KiB
Text
70 lines
2.4 KiB
Text
Ce répertoire sert aux tests unitaires avec PHPUNIT, il faut d'abord changer dans le bootstrap.php pour que le path soit correct.
|
|
Il faut configurer pour pouvoir l'utiliser :
|
|
1 . Activer PHPUNIT,
|
|
2 . dans GLOBAL PATH (propriété du projet) ajouter le fichier phpunit.phar
|
|
3. Donner unit-test comme répertoire de test
|
|
|
|
Paramètrage
|
|
===========
|
|
|
|
Pour tester ,
|
|
|
|
* installer phpunit et adapter le chemin dans le fichier test-file.php
|
|
* copier le fichier bootstrap.example.php vers bootstrap.php
|
|
* copier le fichier global.example.php vers global.php
|
|
* adapter ces 2 fichiers global.php et bootstrap.php
|
|
|
|
|
|
Fichiers
|
|
===========
|
|
|
|
* boostrap.example.php , exemple de fichier bootstrap pour phpunit
|
|
* global.example.php , exemple de fichier pour votre environnement : utilisateur et dossier
|
|
* facility.class.php , classe pour des outils utilisables dans vos tests
|
|
* test-file.sh script appelant phpunit
|
|
* debug-php.sh pour debugguer les tests
|
|
|
|
|
|
Global.php
|
|
==========
|
|
|
|
Donner le dossier
|
|
$_REQUEST['dossier']
|
|
|
|
Utilisateur pour Noalyss
|
|
$_SESSION['g_user']='phpcompta';
|
|
|
|
Mot de passe pour g_user
|
|
$_SESSION['g_pass']='dany';
|
|
|
|
Bootstrap
|
|
=========
|
|
Ensuite copier bootstrap.php.example vers bootstrap.php et modifier les variables (le dossier à utiliser, include_path ...)
|
|
|
|
|
|
Testing commande en ligne
|
|
=========================
|
|
|
|
test (depuis repertoire include)
|
|
php <chemin>/phpunit.phar --tap --colors --bootstrap ../bootstrap.php class_acc_accountTest.php
|
|
|
|
Tous les fichiers
|
|
for i in *.php;do php <chemin>/phpunit.phar --tap --colors --bootstrap ../bootstrap.php $i;done
|
|
|
|
|
|
Génération pour tous les fichiers
|
|
=================================
|
|
Permet de voir les lignes de code qui ont été testées
|
|
php <chemin>/phpunit.phar --coverage-html html --bootstrap bootstrap.php include
|
|
|
|
exemple depuis NETBEANS "/usr/bin/php" "/home/dany/Program/phpunit-skelgen.phar" "--ansi" "generate-test" "--bootstrap=/home/dany/developpement/phpcompta/noalyss/unit-test/bootstrap.php" "View_SQL" "/home/dany/developpement/phpcompta/noalyss/include/lib/view_sql.class.php" "View_SQLTest" "/home/dany/developpement/phpcompta/noalyss/unit-test/include/lib/view_sql.classTest.php"
|
|
|
|
Note développeur
|
|
================
|
|
Pour avoir tous les fichiers à inclure
|
|
--------------------------------------
|
|
Depuis ici, faites
|
|
|
|
cd ../include
|
|
|
|
find class lib -type f | awk '{print "require_once NOALYSS_INCLUDE.--/"$1"--;";}'|sed -e 's/--/"/g' >> ../unit-test/bootstrap.php
|