Fix phpunit

This commit is contained in:
Laurent Destailleur 2018-03-12 19:32:57 +01:00
parent bf36d671ba
commit 612d36a2f8

View File

@ -38,16 +38,6 @@ if (empty($user->id)) {
$conf->global->MAIN_DISABLE_ALL_MAILS=1; $conf->global->MAIN_DISABLE_ALL_MAILS=1;
if (empty($user->id)) {
print "Load permissions for admin user nb 1\n";
$user->fetch(1);
$user->getrights();
}
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
/** /**
* Class for PHPUnit tests * Class for PHPUnit tests
* *
@ -55,7 +45,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
* @backupStaticAttributes enabled * @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/ */
class TicketsupTest extends \PHPUnit_Framework_TestCase class TicketsupTest extends PHPUnit_Framework_TestCase
{ {
protected $savconf; protected $savconf;
protected $savuser; protected $savuser;
@ -139,7 +129,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$db=$this->savdb; $db=$this->savdb;
// Try to create one with bad values // Try to create one with bad values
$localobject=new \Ticketsup($this->savdb); $localobject=new Ticketsup($this->savdb);
$localobject->initAsSpecimen(); $localobject->initAsSpecimen();
$localobject->fk_statut = '\'1=1'; $localobject->fk_statut = '\'1=1';
$result=$localobject->create($user); $result=$localobject->create($user);
@ -148,14 +138,13 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(-1, $result, $localobject->error); $this->assertEquals(-1, $result, $localobject->error);
// Try to create one with correct values // Try to create one with correct values
$localobject=new \Ticketsup($this->savdb); $localobject=new Ticketsup($this->savdb);
$localobject->initAsSpecimen(); $localobject->initAsSpecimen();
$result=$localobject->create($user); $result=$localobject->create($user);
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
$this->assertGreaterThan(0, $result, $localobject->error); $this->assertGreaterThan(0, $result, $localobject->error);
return $result; return $result;
} }
@ -176,7 +165,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
$localobject=new \Ticketsup($this->savdb); $localobject=new Ticketsup($this->savdb);
$result=$localobject->fetch($id); $result=$localobject->fetch($id);
print __METHOD__." id=".$id." result=".$result."\n"; print __METHOD__." id=".$id." result=".$result."\n";
@ -410,7 +399,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
$localobject=new \Ticketsup($this->savdb); $localobject=new Ticketsup($this->savdb);
$result=$localobject->fetch($id); $result=$localobject->fetch($id);
$result=$localobject->delete($user); $result=$localobject->delete($user);