More PHPUnit tests
This commit is contained in:
parent
c6a22b79ea
commit
e3197230c5
@ -28,6 +28,7 @@ global $conf,$user,$langs,$db;
|
|||||||
require_once 'PHPUnit/Autoload.php';
|
require_once 'PHPUnit/Autoload.php';
|
||||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||||
require_once dirname(__FILE__).'/../../htdocs/categories/class/categorie.class.php';
|
require_once dirname(__FILE__).'/../../htdocs/categories/class/categorie.class.php';
|
||||||
|
require_once dirname(__FILE__).'/../../htdocs/product/class/product.class.php';
|
||||||
|
|
||||||
if (empty($user->id))
|
if (empty($user->id))
|
||||||
{
|
{
|
||||||
@ -123,6 +124,10 @@ class CategorieTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertLessThan($result, 0);
|
$this->assertLessThan($result, 0);
|
||||||
print __METHOD__." result=".$result."\n";
|
print __METHOD__." result=".$result."\n";
|
||||||
|
|
||||||
|
// TODO Add test on error when creating duplicate
|
||||||
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,6 +135,41 @@ class CategorieTest extends PHPUnit_Framework_TestCase
|
|||||||
* @depends testCategorieCreate
|
* @depends testCategorieCreate
|
||||||
* The depends says test is run only if previous is ok
|
* The depends says test is run only if previous is ok
|
||||||
*/
|
*/
|
||||||
|
public function testCategorieProduct($id)
|
||||||
|
{
|
||||||
|
global $conf,$user,$langs,$db;
|
||||||
|
$conf=$this->savconf;
|
||||||
|
$user=$this->savuser;
|
||||||
|
$langs=$this->savlangs;
|
||||||
|
$db=$this->savdb;
|
||||||
|
|
||||||
|
$localobjecttmp=new Categorie($this->savdb);
|
||||||
|
$localobjecttmp->initAsSpecimen();
|
||||||
|
$localobjecttmp->label='Specimen Category for product';
|
||||||
|
$localobjecttmp->type=0; // product category
|
||||||
|
$catid=$localobjecttmp->create($user);
|
||||||
|
|
||||||
|
print __METHOD__." catid=".$catid."\n";
|
||||||
|
$this->assertLessThanOrEqual($catid, 0);
|
||||||
|
|
||||||
|
// Category
|
||||||
|
$localobject2=new Product($this->savdb);
|
||||||
|
$localobject2->initAsSpecimen();
|
||||||
|
$localobject2->ref.='-CATEG';
|
||||||
|
$localobject2->tva_npr=1;
|
||||||
|
$localobject2->catid=$catid;
|
||||||
|
$result=$localobject2->create($user);
|
||||||
|
|
||||||
|
print __METHOD__." result=".$result."\n";
|
||||||
|
$this->assertLessThanOrEqual($result, 0);
|
||||||
|
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testCategorieProduct
|
||||||
|
* The depends says test is run only if previous is ok
|
||||||
|
*/
|
||||||
public function testCategorieFetch($id)
|
public function testCategorieFetch($id)
|
||||||
{
|
{
|
||||||
global $conf,$user,$langs,$db;
|
global $conf,$user,$langs,$db;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user