Fix must use the constant, not hard coded value.

This commit is contained in:
Laurent Destailleur 2016-06-25 21:40:45 +02:00
parent 09a868af3f
commit d23a8a56ea
3 changed files with 10 additions and 10 deletions

View File

@ -43,13 +43,13 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
class Categorie extends CommonObject class Categorie extends CommonObject
{ {
// Categories types // Categories types
const TYPE_PRODUCT = 0; const TYPE_PRODUCT = 0; // TODO Replace with value 'product'
const TYPE_SUPPLIER = 1; const TYPE_SUPPLIER = 1; // TODO Replace this value with 'supplier'
const TYPE_CUSTOMER = 2; const TYPE_CUSTOMER = 2; // TODO Replace this value with 'customer'
const TYPE_MEMBER = 3; const TYPE_MEMBER = 3; // TODO Replace this value with 'member'
const TYPE_CONTACT = 4; const TYPE_CONTACT = 4; // TODO Replace this value with 'contact'
const TYPE_USER = 4; // categorie contact and user are same ! const TYPE_USER = 4; // categorie contact and user are same ! TODO Replace this value with 'user'
const TYPE_ACCOUNT = 5; // bank account const TYPE_ACCOUNT = 5; // for bank account TODO Replace this value with 'account'
/** /**
* @var array ID mapping from type string * @var array ID mapping from type string
@ -63,7 +63,7 @@ class Categorie extends CommonObject
'member' => 3, 'member' => 3,
'contact' => 4, 'contact' => 4,
'user' => 4, 'user' => 4,
'account' => 5, 'account' => 5,
); );
/** /**
* @var array Foreign keys mapping from type string * @var array Foreign keys mapping from type string

View File

@ -2224,7 +2224,7 @@ else
print '<td>'; print '<td>';
$cate_arbo = $form->select_all_categories( Categorie::TYPE_CONTACT, null, null, null, null, 1 ); $cate_arbo = $form->select_all_categories( Categorie::TYPE_CONTACT, null, null, null, null, 1 );
$c = new Categorie( $db ); $c = new Categorie( $db );
$cats = $c->containing( $object->id, 'user' ); $cats = $c->containing($object->id, Categorie::TYPE_USER);
foreach ($cats as $cat) { foreach ($cats as $cat) {
$arrayselected[] = $cat->id; $arrayselected[] = $cat->id;
} }

View File

@ -200,7 +200,7 @@ class CategorieTest extends PHPUnit_Framework_TestCase
// Get list of categories for product // Get list of categories for product
$localcateg=new Categorie($this->savdb); $localcateg=new Categorie($this->savdb);
$listofcateg=$localcateg->containing($localobject2->id, 'product', 'label'); $listofcateg=$localcateg->containing($localobject2->id, Categorie::TYPE_PRODUCT, 'label');
$this->assertTrue(in_array('Specimen Category for product',$listofcateg), 'Categ not found linked to product when it should'); $this->assertTrue(in_array('Specimen Category for product',$listofcateg), 'Categ not found linked to product when it should');
return $id; return $id;