Enhance PHPUnit tests

This commit is contained in:
Laurent Destailleur 2011-09-23 12:21:00 +00:00
parent d90a1ad56b
commit 2a456b08d5
30 changed files with 101 additions and 223 deletions

View File

@ -24,11 +24,13 @@
/**
* Check user and password
* @param usertotest Login
* @param passwordtotest Password
* @param entitytotest Entity
* @return string Login if ok, '' if ko.
* Check validity of user/password/entity
* If test is ko, reason must be filled into $_SESSION["dol_loginmesg"]
*
* @param string $usertotest Login
* @param string $passwordtotest Password
* @param int $entitytotest Number of instance (always 1 if module multicompany not enabled)
* @return string Login if OK, '' if KO
*/
function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest=1)
{

View File

@ -23,10 +23,13 @@
/**
* \brief Check user and password
* \param usertotest Login
* \param passwordtotest Password
* \return string Login if ok, '' if ko.
* Check validity of user/password/entity
* If test is ko, reason must be filled into $_SESSION["dol_loginmesg"]
*
* @param string $usertotest Login
* @param string $passwordtotest Password
* @param int $entitytotest Number of instance (always 1 if module multicompany not enabled)
* @return string Login if OK, '' if KO
*/
function check_user_password_empty($usertotest,$passwordtotest)
{

View File

@ -24,23 +24,26 @@
/**
\brief Check user and password
\param usertotest Login
\param passwordtotest Password
\return string Login if ok, '' if ko.
*/
* Check validity of user/password/entity
* If test is ko, reason must be filled into $_SESSION["dol_loginmesg"]
*
* @param string $usertotest Login
* @param string $passwordtotest Password
* @param int $entitytotest Number of instance (always 1 if module multicompany not enabled)
* @return string Login if OK, '' if KO
*/
function check_user_password_forceuser($usertotest,$passwordtotest)
{
// Variable dolibarr_auto_user must be defined in conf.php file
global $dolibarr_auto_user;
dol_syslog("functions_forceuser::check_user_password_forceuser");
$login=$dolibarr_auto_user;
if (empty($login)) $login='auto';
if ($_SESSION["dol_loginmesg"]) $login='';
return $login;
}

View File

@ -23,10 +23,13 @@
/**
\brief Check user and password
\param usertotest Login
\param passwordtotest Password
\return string Login if ok, '' if ko.
* Check validity of user/password/entity
* If test is ko, reason must be filled into $_SESSION["dol_loginmesg"]
*
* @param string $usertotest Login
* @param string $passwordtotest Password
* @param int $entitytotest Number of instance (always 1 if module multicompany not enabled)
* @return string Login if OK, '' if KO
*/
function check_user_password_http($usertotest,$passwordtotest)
{
@ -37,7 +40,7 @@ function check_user_password_http($usertotest,$passwordtotest)
{
$login=$_SERVER["REMOTE_USER"];
}
return $login;
}

View File

@ -24,11 +24,13 @@
/**
* @brief Check user and password
* @param usertotest Login
* @param passwordtotest Password
* @return string Login if ok, '' if ko.
* @remarks If test is ko, reason must be filled into $_SESSION["dol_loginmesg"]
* Check validity of user/password/entity
* If test is ko, reason must be filled into $_SESSION["dol_loginmesg"]
*
* @param string $usertotest Login
* @param string $passwordtotest Password
* @param int $entitytotest Number of instance (always 1 if module multicompany not enabled)
* @return string Login if OK, '' if KO
*/
function check_user_password_ldap($usertotest,$passwordtotest)
{

View File

@ -24,10 +24,13 @@
/**
* \brief Check user and password
* \param usertotest Login
* \param passwordtotest Password
* \return string Login if ok, '' if ko.
* Check validity of user/password/entity
* If test is ko, reason must be filled into $_SESSION["dol_loginmesg"]
*
* @param string $usertotest Login
* @param string $passwordtotest Password
* @param int $entitytotest Number of instance (always 1 if module multicompany not enabled)
* @return string Login if OK, '' if KO
*/
function check_user_password_myopenid($usertotest,$passwordtotest)
{

View File

@ -39,13 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
* @xcovers Interfaces
* @xcovers CommonObject
* @xcovers Adherent
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -63,40 +63,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers DoliDb
* @xcovers User
* @xcovers Translate
* @xcovers Conf
* @xcovers CommonObject
* @xcovers Facture
* @xcovers Commande
* @xcovers Propal
* @xcovers Expedition
* @xcovers Fichinter
* @xcovers Project
*
* @xcovers ModelePDFFactures
* @xcovers pdf_crabe
* @xcovers pdf_oursin
*
* @xcovers ModelePDFCommandes
* @xcovers pdf_edison
* @xcovers pdf_einstein
*
* @xcovers ModelePDFPropales
* @xcovers pdf_propale_azur
* @xcovers pdf_propale_jaune
*
* @xcovers ModelePDFProjects
* @xcovers pdf_baleine
*
* @xcovers ModelePDFFicheinter
* @xcovers pdf_soleil
*
* @xcovers ModelePDFExpedition
* @xcovers pdf_expedition_merou
* @xcovers pdf_expedition_rouget
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -39,13 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
* @xcovers Interfaces
* @xcovers CommonObject
* @xcovers Adherent
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -39,13 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
* @xcovers Interfaces
* @xcovers CommonObject
* @xcovers Categorie
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -39,13 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
* @xcovers Interfaces
* @xcovers CommonObject
* @xcovers ChargeSociales
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -40,9 +40,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers CommandeFournisseur
* @xcovers CommandeFournisseurLigne
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -39,9 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers Commande
* @xcovers OrderLine
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -40,12 +40,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers DoliDb
* @xcovers User
* @xcovers Translate
* @xcovers Conf
* @xcovers CommonObject
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -39,8 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers CompanyBankAccount
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -39,14 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
* @xcovers Interfaces
* @xcovers CommonObject
* @xcovers Contrat
* @xcovers ContratLigne
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -39,7 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
* When not cover is provided. We use everything.
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -39,6 +39,8 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.

View File

@ -42,7 +42,7 @@ if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is
/**
* When no cover is provided. We use everything.
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled
@ -140,7 +140,7 @@ class ExportTest extends PHPUnit_Framework_TestCase
$objexport->array_export_alias[0]=$array_alias;
dol_mkdir($conf->export->dir_temp);
$model='csv';
// Build export file
@ -178,7 +178,7 @@ class ExportTest extends PHPUnit_Framework_TestCase
$datatoexport='societe_1';
$array_selected = array("s.rowid"=>1, "s.nom"=>2); // Mut be fields found into declaration of dataset
$model='csv';
$objexport=new Export($db);
$result=$objexport->load_arrays($user,$datatoexport);

View File

@ -39,14 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers DoliDb
* @xcovers User
* @xcovers Translate
* @xcovers Conf
* @xcovers Interfaces
* @xcovers CommonObject
* @xcovers FactureFournisseur
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -39,23 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers DoliDb
* @xcovers User
* @xcovers Translate
* @xcovers Conf
* @xcovers Interfaces
* @xcovers CommonObject
* @xcovers Facture
* @xcovers FactureLigne
* @xcovers ModeleNumRefFactures
* @xcovers InterfaceLogevents
* @xcovers InterfaceActionsAuto
* @xcovers InterfaceLdapsynchro
* @xcovers InterfaceNotification
* @xcovers InterfacePhenixsynchro
* @xcovers InterfacePropalWorkflow
* @xcovers InterfaceWebcalsynchro
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -41,6 +41,7 @@ if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is
/**
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -41,7 +41,7 @@ if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is
/**
* When no cover is provided. We use everything.
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -38,55 +38,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers DolibarrModules
* @xcovers modAccounting
* @xcovers modAdherent
* @xcovers modAgenda
* @xcovers modBanque
* @xcovers modBarcode
* @xcovers modBookmark
* @xcovers modBoutique
* @xcovers modCashDesk
* @xcovers modCategorie
* @xcovers modClickToDial
* @xcovers modCommande
* @xcovers modComptabilite
* @xcovers modContrat
* @xcovers modDeplacement
* @xcovers modDocument
* @xcovers modDon
* @xcovers modECM
* @xcovers modExpedition
* @xcovers modExport
* @xcovers modExternalRss
* @xcovers modExternalSite
* @cxovers modFacture
* @xcovers modFckeditor
* @xcovers modFicheinter
* @xcovers modFournisseur
* @xcovers modFTP
* @xcovers modGeoIPMaxmind
* @xcovers modGravatar
* @xcovers modImport
* @xcovers modLabel
* @xcovers modLdap
* @xcovers modMailing
* @xcovers modMantis
* @xcovers modNotification
* @xcovers modPaybox
* @xcovers modPaypal
* @xcovers modPrelevement
* @xcovers modProduct
* @xcovers modProjet
* @xcovers modPropale
* @xcovers modService
* @xcovers modSociete
* @xcovers modStock
* @xcovers modSyslog
* @xcovers modTax
* @xcovers modUser
* @xcovers modWebServices
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -39,9 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers Propal
* @xcovers PropaleLigne
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -28,6 +28,7 @@ global $conf,$user,$langs,$db;
require_once 'PHPUnit/Autoload.php';
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/lib/functions.lib.php';
require_once dirname(__FILE__).'/../../htdocs/lib/security.lib.php';
if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
@ -42,13 +43,7 @@ if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is
/**
*
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
* @xcovers Interfaces
* @xcovers CommonObject
* @xcovers Adherent
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled
@ -109,6 +104,7 @@ class SecurityTest extends PHPUnit_Framework_TestCase
print __METHOD__."\n";
}
/**
*/
protected function tearDown()
@ -155,6 +151,31 @@ class SecurityTest extends PHPUnit_Framework_TestCase
return $result;
}
/**
*/
public function testCheckLoginPassEntity()
{
$login=checkLoginPassEntity('loginbidon','passwordbidon',1,array('dolibarr'));
print __METHOD__." login=".$login."\n";
$this->assertEquals($login,'');
$login=checkLoginPassEntity('admin','passwordbidon',1,array('dolibarr'));
print __METHOD__." login=".$login."\n";
$this->assertEquals($login,'');
$login=checkLoginPassEntity('admin','admin',1,array('dolibarr')); // Should works because admin/admin exists
print __METHOD__." login=".$login."\n";
$this->assertEquals($login,'admin');
$login=checkLoginPassEntity('admin','admin',1,array('http','dolibarr')); // Should work because of second authetntication method
print __METHOD__." login=".$login."\n";
$this->assertEquals($login,'admin');
$login=checkLoginPassEntity('admin','admin',1,array('forceuser'));
print __METHOD__." login=".$login."\n";
$this->assertEquals($login,''); // Expected '' because should failed because login 'auto' does not exists
}
/**
*/
/* public function testAnalyseSqlAndScript()

View File

@ -39,10 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers DoliDb
* @xcovers Conf
* @xcovers Societe
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -39,13 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
* @xcovers Interfaces
* @xcovers CommonObject
* @xcovers UserGroup
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -39,13 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
*
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
* @xcovers Interfaces
* @xcovers CommonObject
* @xcovers User
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled

View File

@ -41,7 +41,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
* When no cover is provided. We use everything.
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled