PHPunit
This commit is contained in:
parent
f1f539d2a7
commit
b5ca4ca391
@ -25,20 +25,20 @@
|
||||
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)) {
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
@ -144,10 +144,10 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
@ -209,7 +209,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testTicketsupsetProject
|
||||
*
|
||||
@ -226,16 +226,16 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testTicketsupDelete($id)
|
||||
{
|
||||
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user