mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Clean phpunit tests
This commit is contained in:
parent
a23addd21e
commit
671257e8e3
|
|
@ -48,34 +48,6 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
|||
*/
|
||||
class AccountingAccountTest extends CommonClassTest
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @param string $name Name
|
||||
* @return AccountingAccountTest
|
||||
*/
|
||||
public function __construct($name = '')
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* setUpBeforeClass
|
||||
*
|
||||
|
|
|
|||
|
|
@ -48,34 +48,6 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
|||
*/
|
||||
class ActionCommTest extends CommonClassTest
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @param string $name Name
|
||||
* @return ActionCommTest
|
||||
*/
|
||||
public function __construct($name = '')
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* setUpBeforeClass
|
||||
*
|
||||
|
|
@ -94,6 +66,7 @@ class ActionCommTest extends CommonClassTest
|
|||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testActionCommCreate
|
||||
*
|
||||
|
|
|
|||
|
|
@ -50,34 +50,6 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
|||
*/
|
||||
class AdherentTest extends CommonClassTest
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @param string $name Name
|
||||
* @return AdherentTest
|
||||
*/
|
||||
public function __construct($name = '')
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* setUpBeforeClass
|
||||
*
|
||||
|
|
@ -104,43 +76,6 @@ class AdherentTest extends CommonClassTest
|
|||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDownAfterClass
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* testAdherentTypeCreate
|
||||
|
|
|
|||
|
|
@ -49,85 +49,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
|||
class AdminLibTest extends CommonClassTest
|
||||
{
|
||||
protected $backupGlobalsBlacklist = array('conf', 'user', 'langs', 'db');
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @param string $name Name
|
||||
* @return AdminLibTest
|
||||
*/
|
||||
public function __construct($name = '')
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* setUpBeforeClass
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDownAfterClass
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* testVersionCompare
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ class CommonClassTest extends PHPUnit\Framework\TestCase
|
|||
* We save global variables into local variables
|
||||
*
|
||||
* @param string $name Name
|
||||
* @return ActionCommTest
|
||||
*/
|
||||
public function __construct($name = '')
|
||||
{
|
||||
|
|
@ -84,11 +83,6 @@ class CommonClassTest extends PHPUnit\Framework\TestCase
|
|||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
if (!isModEnabled('agenda')) {
|
||||
print __METHOD__." module agenda must be enabled.\n";
|
||||
die(1);
|
||||
}
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ class FunctionsLibTest extends CommonClassTest
|
|||
// An attempt for SQL injection
|
||||
$filter='if(now()=sysdate()%2Csleep(6)%2C0)';
|
||||
$sql = forgeSQLFromUniversalSearchCriteria($filter);
|
||||
$this->assertEquals('Filter syntax error - Bad syntax of the search string', $sql);
|
||||
$this->assertEquals('Filter error - Bad syntax of the search string', $sql);
|
||||
|
||||
// A real search string
|
||||
$filter='(((statut:=:1) or (entity:in:__AAA__)) and (abc:<:2.0) and (abc:!=:1.23))';
|
||||
|
|
@ -310,7 +310,7 @@ class FunctionsLibTest extends CommonClassTest
|
|||
// Check that parenthesis are NOT allowed inside the last operand. Very important.
|
||||
$filter = "(t.fieldint:=:(1,2))";
|
||||
$sql = forgeSQLFromUniversalSearchCriteria($filter);
|
||||
$this->assertEquals("Filter syntax error - Bad syntax of the search string", $sql);
|
||||
$this->assertEquals("Filter error - Bad syntax of the search string", $sql);
|
||||
|
||||
// Check that ' is escaped into the last operand
|
||||
$filter = "(t.fieldstring:=:'aaa'ttt')";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user