diff --git a/test/phpunit/TicketsupTest.php b/test/phpunit/TicketsupTest.php index d45c72b14d5df..9e807b855db8f 100644 --- a/test/phpunit/TicketsupTest.php +++ b/test/phpunit/TicketsupTest.php @@ -25,19 +25,19 @@ namespace test\unit; global $conf,$user,$langs,$db; -//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver +//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver //require_once 'PHPUnit/Autoload.php'; -$res = false; -if (file_exists(dirname(__FILE__).'/../../../../htdocs/master.inc.php')) { - $res = require_once dirname(__FILE__).'/../../../../htdocs/master.inc.php'; -} elseif (file_exists(dirname(__FILE__).'/../../../../../htdocs/master.inc.php')) { - $res = require_once dirname(__FILE__).'/../../../../../htdocs/master.inc.php'; -} else { - die('Include of mains fails'); -} +require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/user/class/usergroup.class.php'; +require_once dirname(__FILE__).'/../../htdocs/ticketsup/class/ticketsup.class.php'; +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; -require_once dirname(__FILE__).'/../../class/ticketsup.class.php'; if (empty($user->id)) { @@ -144,10 +144,10 @@ public function testTicketsupCreate() $localobject->initAsSpecimen(); $localobject->fk_statut = '\'1=1'; $result=$localobject->create($user); - + print __METHOD__." result=".$result."\n"; $this->assertEquals($result, -1); - + // Try to create one with correct values $localobject=new \Ticketsup($this->savdb); $localobject->initAsSpecimen(); @@ -155,7 +155,7 @@ public function testTicketsupCreate() print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); - + return $result; } @@ -209,7 +209,7 @@ public function testTicketsupmarkAsRead($localobject) $this->assertLessThan($result, 0); return $localobject; } - + /** * testTicketsupsetProject * @@ -226,16 +226,16 @@ public function testTicketsupsetProject($localobject) $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + $project_id = 1; - + $result=$localobject->setProject($project_id); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - + $this->assertLessThan($result, 0); return $localobject; } - + /** * testTicketsupsetContract * @@ -252,16 +252,16 @@ public function testTicketsupsetContract($localobject) $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + $contract_id = 1; - + $result=$localobject->setContract($contract_id); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - + $this->assertLessThan($result, 0); return $localobject; } - + /** * testTicketsupsetProgression * @@ -278,16 +278,16 @@ public function testTicketsupsetProgression($localobject) $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + $percent = 80; $result=$localobject->setProgression($percent); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - + $this->assertLessThan($result, 0); return $localobject; } - + /** * testTicketsupassignUser * @@ -304,17 +304,17 @@ public function testTicketsupassignUser($localobject) $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + $user_id_to_assign = 1; - + $result=$localobject->assignUser($user, $user_id_to_assign); ; print __METHOD__." id=".$localobject->id." result=".$result."\n"; - + $this->assertLessThan($result, 0); return $localobject; } - + /** * testTicketsupassignUserOther * @@ -331,17 +331,17 @@ public function testTicketsupassignUserOther($localobject) $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + $user_id_to_assign = 2; - + $result=$localobject->assignUser($user, $user_id_to_assign); ; print __METHOD__." id=".$localobject->id." result=".$result."\n"; - + $this->assertLessThan($result, 0); return $localobject; } - + /** * testTicketsupcreateTicketLog * @@ -358,13 +358,13 @@ public function testTicketsupcreateTicketLog($localobject) $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - - + + $message = 'Test ticket log'; $noemail = 1; $result=$localobject->createTicketLog($user, $message, $noemail); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - + $this->assertLessThan($result, 0); return $localobject; } @@ -385,15 +385,15 @@ public function testTicketsupclose($localobject) $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + $result=$localobject->close(); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - + $this->assertLessThan($result, 0); return $localobject->id; } - - + + /** * testTicketsupDelete * @@ -405,7 +405,7 @@ public function testTicketsupclose($localobject) */ public function testTicketsupDelete($id) { - + global $conf,$user,$langs,$db; $conf=$this->savconf; $user=$this->savuser;