code syntax

This commit is contained in:
Frédéric FRANCE
2021-01-14 15:09:08 +01:00
parent 43161be711
commit b1a1cd4be6
83 changed files with 14010 additions and 13774 deletions

View File

@@ -29,8 +29,7 @@ global $conf,$user,$langs,$db;
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/product/stock/class/entrepot.class.php';
if (empty($user->id))
{
if (empty($user->id)) {
print "Load permissions for admin user nb 1\n";
$user->fetch(1);
$user->getrights();
@@ -74,146 +73,148 @@ class EntrepotTest extends PHPUnit\Framework\TestCase
print "\n";
}
/**
* setUpBeforeClass
*
* @return void
*/
public static function setUpBeforeClass()
{
global $conf,$user,$langs,$db;
/**
* setUpBeforeClass
*
* @return void
*/
public static function setUpBeforeClass()
{
global $conf,$user,$langs,$db;
if (empty($conf->stock->enabled)) { print __METHOD__." Module Stock must be enabled.\n"; die(); }
if (empty($conf->stock->enabled)) {
print __METHOD__." Module Stock must be enabled.\n"; die();
}
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
print __METHOD__."\n";
}
print __METHOD__."\n";
}
/**
* tearDownAfterClass
*
* @return void
*/
public static function tearDownAfterClass()
{
global $conf,$user,$langs,$db;
/**
* tearDownAfterClass
*
* @return void
*/
public static function tearDownAfterClass()
{
global $conf,$user,$langs,$db;
$db->rollback();
print __METHOD__."\n";
}
}
/**
* Init phpunit tests
*
* @return void
*/
protected function setUp()
{
global $conf,$user,$langs,$db;
protected function setUp()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
print __METHOD__."\n";
}
}
/**
* End phpunit tests
*
* @return void
*/
protected function tearDown()
{
print __METHOD__."\n";
}
protected function tearDown()
{
print __METHOD__."\n";
}
/**
* testEntrepotCreate
*
* @return void
*/
public function testEntrepotCreate()
{
global $conf,$user,$langs,$db;
/**
* testEntrepotCreate
*
* @return void
*/
public function testEntrepotCreate()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Entrepot($this->savdb);
$localobject->initAsSpecimen();
$result=$localobject->create($user);
$localobject->initAsSpecimen();
$result=$localobject->create($user);
print __METHOD__." result=".$result."\n";
$this->assertGreaterThan(0, $result);
print __METHOD__." result=".$result."\n";
$this->assertGreaterThan(0, $result);
return $result;
}
return $result;
}
/**
* testEntrepotFetch
*
* @param int $id Id entrepot
* @return Entrepot
*
* @depends testEntrepotCreate
* The depends says test is run only if previous is ok
*/
public function testEntrepotFetch($id)
{
global $conf,$user,$langs,$db;
/**
* testEntrepotFetch
*
* @param int $id Id entrepot
* @return Entrepot
*
* @depends testEntrepotCreate
* The depends says test is run only if previous is ok
*/
public function testEntrepotFetch($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Entrepot($this->savdb);
$result=$localobject->fetch($id);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
$result=$localobject->fetch($id);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $localobject;
}
return $localobject;
}
/**
* testEntrepotUpdate
*
* @param Entrepot $localobject Entrepot
* @return void
*
* @depends testEntrepotFetch
* The depends says test is run only if previous is ok
*/
public function testEntrepotUpdate($localobject)
{
global $conf,$user,$langs,$db;
/**
* testEntrepotUpdate
*
* @param Entrepot $localobject Entrepot
* @return void
*
* @depends testEntrepotFetch
* The depends says test is run only if previous is ok
*/
public function testEntrepotUpdate($localobject)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject->note='New note after update';
$result=$localobject->update($localobject->id, $user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$result=$localobject->update($localobject->id, $user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $localobject;
}
return $localobject;
}
/**
* testEntrepotOther
*
* @param Entrepot $localobject Entrepot
* @return void
*
* @depends testEntrepotUpdate
* The depends says test is run only if previous is ok
*/
public function testEntrepotOther($localobject)
{
global $conf,$user,$langs,$db;
/**
* testEntrepotOther
*
* @param Entrepot $localobject Entrepot
* @return void
*
* @depends testEntrepotUpdate
* The depends says test is run only if previous is ok
*/
public function testEntrepotOther($localobject)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
@@ -222,33 +223,33 @@ class EntrepotTest extends PHPUnit\Framework\TestCase
$result = $localobject->get_full_arbo();
$this->assertEquals('WAREHOUSE SPECIMEN', $result);
return $localobject->id;
}
return $localobject->id;
}
/**
* testEntrepotDelete
*
* @param int $id Id of entrepot
* @return void
*
* @depends testEntrepotOther
* The depends says test is run only if previous is ok
*/
public function testEntrepotDelete($id)
{
global $conf,$user,$langs,$db;
/**
* testEntrepotDelete
*
* @param int $id Id of entrepot
* @return void
*
* @depends testEntrepotOther
* The depends says test is run only if previous is ok
*/
public function testEntrepotDelete($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Entrepot($this->savdb);
$result=$localobject->fetch($id);
$result=$localobject->fetch($id);
$result=$localobject->delete($user);
$result=$localobject->delete($user);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0, $localobject->errorsToString());
$this->assertLessThan($result, 0, $localobject->errorsToString());
return $result;
}
return $result;
}
}