PHPunit
This commit is contained in:
parent
f1f539d2a7
commit
b5ca4ca391
@ -25,20 +25,20 @@
|
|||||||
namespace test\unit;
|
namespace test\unit;
|
||||||
|
|
||||||
global $conf,$user,$langs,$db;
|
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';
|
//require_once 'PHPUnit/Autoload.php';
|
||||||
$res = false;
|
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||||
if (file_exists(dirname(__FILE__).'/../../../../htdocs/master.inc.php')) {
|
require_once dirname(__FILE__).'/../../htdocs/user/class/usergroup.class.php';
|
||||||
$res = require_once dirname(__FILE__).'/../../../../htdocs/master.inc.php';
|
require_once dirname(__FILE__).'/../../htdocs/ticketsup/class/ticketsup.class.php';
|
||||||
} elseif (file_exists(dirname(__FILE__).'/../../../../../htdocs/master.inc.php')) {
|
|
||||||
$res = require_once dirname(__FILE__).'/../../../../../htdocs/master.inc.php';
|
if (empty($user->id)) {
|
||||||
} else {
|
print "Load permissions for admin user nb 1\n";
|
||||||
die('Include of mains fails');
|
$user->fetch(1);
|
||||||
|
$user->getrights();
|
||||||
}
|
}
|
||||||
|
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||||
|
|
||||||
|
|
||||||
require_once dirname(__FILE__).'/../../class/ticketsup.class.php';
|
|
||||||
|
|
||||||
|
|
||||||
if (empty($user->id)) {
|
if (empty($user->id)) {
|
||||||
print "Load permissions for admin user nb 1\n";
|
print "Load permissions for admin user nb 1\n";
|
||||||
@ -144,10 +144,10 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
|||||||
$localobject->initAsSpecimen();
|
$localobject->initAsSpecimen();
|
||||||
$localobject->fk_statut = '\'1=1';
|
$localobject->fk_statut = '\'1=1';
|
||||||
$result=$localobject->create($user);
|
$result=$localobject->create($user);
|
||||||
|
|
||||||
print __METHOD__." result=".$result."\n";
|
print __METHOD__." result=".$result."\n";
|
||||||
$this->assertEquals($result, -1);
|
$this->assertEquals($result, -1);
|
||||||
|
|
||||||
// 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();
|
||||||
@ -155,7 +155,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
print __METHOD__." result=".$result."\n";
|
print __METHOD__." result=".$result."\n";
|
||||||
$this->assertLessThan($result, 0);
|
$this->assertLessThan($result, 0);
|
||||||
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertLessThan($result, 0);
|
$this->assertLessThan($result, 0);
|
||||||
return $localobject;
|
return $localobject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testTicketsupsetProject
|
* testTicketsupsetProject
|
||||||
*
|
*
|
||||||
@ -226,16 +226,16 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
|||||||
$user=$this->savuser;
|
$user=$this->savuser;
|
||||||
$langs=$this->savlangs;
|
$langs=$this->savlangs;
|
||||||
$db=$this->savdb;
|
$db=$this->savdb;
|
||||||
|
|
||||||
$project_id = 1;
|
$project_id = 1;
|
||||||
|
|
||||||
$result=$localobject->setProject($project_id);
|
$result=$localobject->setProject($project_id);
|
||||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||||
|
|
||||||
$this->assertLessThan($result, 0);
|
$this->assertLessThan($result, 0);
|
||||||
return $localobject;
|
return $localobject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testTicketsupsetContract
|
* testTicketsupsetContract
|
||||||
*
|
*
|
||||||
@ -252,16 +252,16 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
|||||||
$user=$this->savuser;
|
$user=$this->savuser;
|
||||||
$langs=$this->savlangs;
|
$langs=$this->savlangs;
|
||||||
$db=$this->savdb;
|
$db=$this->savdb;
|
||||||
|
|
||||||
$contract_id = 1;
|
$contract_id = 1;
|
||||||
|
|
||||||
$result=$localobject->setContract($contract_id);
|
$result=$localobject->setContract($contract_id);
|
||||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||||
|
|
||||||
$this->assertLessThan($result, 0);
|
$this->assertLessThan($result, 0);
|
||||||
return $localobject;
|
return $localobject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testTicketsupsetProgression
|
* testTicketsupsetProgression
|
||||||
*
|
*
|
||||||
@ -278,16 +278,16 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
|||||||
$user=$this->savuser;
|
$user=$this->savuser;
|
||||||
$langs=$this->savlangs;
|
$langs=$this->savlangs;
|
||||||
$db=$this->savdb;
|
$db=$this->savdb;
|
||||||
|
|
||||||
$percent = 80;
|
$percent = 80;
|
||||||
|
|
||||||
$result=$localobject->setProgression($percent);
|
$result=$localobject->setProgression($percent);
|
||||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||||
|
|
||||||
$this->assertLessThan($result, 0);
|
$this->assertLessThan($result, 0);
|
||||||
return $localobject;
|
return $localobject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testTicketsupassignUser
|
* testTicketsupassignUser
|
||||||
*
|
*
|
||||||
@ -304,17 +304,17 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
|||||||
$user=$this->savuser;
|
$user=$this->savuser;
|
||||||
$langs=$this->savlangs;
|
$langs=$this->savlangs;
|
||||||
$db=$this->savdb;
|
$db=$this->savdb;
|
||||||
|
|
||||||
$user_id_to_assign = 1;
|
$user_id_to_assign = 1;
|
||||||
|
|
||||||
$result=$localobject->assignUser($user, $user_id_to_assign);
|
$result=$localobject->assignUser($user, $user_id_to_assign);
|
||||||
;
|
;
|
||||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||||
|
|
||||||
$this->assertLessThan($result, 0);
|
$this->assertLessThan($result, 0);
|
||||||
return $localobject;
|
return $localobject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testTicketsupassignUserOther
|
* testTicketsupassignUserOther
|
||||||
*
|
*
|
||||||
@ -331,17 +331,17 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
|||||||
$user=$this->savuser;
|
$user=$this->savuser;
|
||||||
$langs=$this->savlangs;
|
$langs=$this->savlangs;
|
||||||
$db=$this->savdb;
|
$db=$this->savdb;
|
||||||
|
|
||||||
$user_id_to_assign = 2;
|
$user_id_to_assign = 2;
|
||||||
|
|
||||||
$result=$localobject->assignUser($user, $user_id_to_assign);
|
$result=$localobject->assignUser($user, $user_id_to_assign);
|
||||||
;
|
;
|
||||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||||
|
|
||||||
$this->assertLessThan($result, 0);
|
$this->assertLessThan($result, 0);
|
||||||
return $localobject;
|
return $localobject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testTicketsupcreateTicketLog
|
* testTicketsupcreateTicketLog
|
||||||
*
|
*
|
||||||
@ -358,13 +358,13 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
|||||||
$user=$this->savuser;
|
$user=$this->savuser;
|
||||||
$langs=$this->savlangs;
|
$langs=$this->savlangs;
|
||||||
$db=$this->savdb;
|
$db=$this->savdb;
|
||||||
|
|
||||||
|
|
||||||
$message = 'Test ticket log';
|
$message = 'Test ticket log';
|
||||||
$noemail = 1;
|
$noemail = 1;
|
||||||
$result=$localobject->createTicketLog($user, $message, $noemail);
|
$result=$localobject->createTicketLog($user, $message, $noemail);
|
||||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||||
|
|
||||||
$this->assertLessThan($result, 0);
|
$this->assertLessThan($result, 0);
|
||||||
return $localobject;
|
return $localobject;
|
||||||
}
|
}
|
||||||
@ -385,15 +385,15 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
|||||||
$user=$this->savuser;
|
$user=$this->savuser;
|
||||||
$langs=$this->savlangs;
|
$langs=$this->savlangs;
|
||||||
$db=$this->savdb;
|
$db=$this->savdb;
|
||||||
|
|
||||||
$result=$localobject->close();
|
$result=$localobject->close();
|
||||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||||
|
|
||||||
$this->assertLessThan($result, 0);
|
$this->assertLessThan($result, 0);
|
||||||
return $localobject->id;
|
return $localobject->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testTicketsupDelete
|
* testTicketsupDelete
|
||||||
*
|
*
|
||||||
@ -405,7 +405,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTicketsupDelete($id)
|
public function testTicketsupDelete($id)
|
||||||
{
|
{
|
||||||
|
|
||||||
global $conf,$user,$langs,$db;
|
global $conf,$user,$langs,$db;
|
||||||
$conf=$this->savconf;
|
$conf=$this->savconf;
|
||||||
$user=$this->savuser;
|
$user=$this->savuser;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user