From d23a8a56ea90c791c724a05fe87dd79887665983 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 25 Jun 2016 21:40:45 +0200 Subject: [PATCH] Fix must use the constant, not hard coded value. --- htdocs/categories/class/categorie.class.php | 16 ++++++++-------- htdocs/user/card.php | 2 +- test/phpunit/CategorieTest.php | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 7c7c35d4b05..8636232b405 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -43,13 +43,13 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; class Categorie extends CommonObject { // Categories types - const TYPE_PRODUCT = 0; - const TYPE_SUPPLIER = 1; - const TYPE_CUSTOMER = 2; - const TYPE_MEMBER = 3; - const TYPE_CONTACT = 4; - const TYPE_USER = 4; // categorie contact and user are same ! - const TYPE_ACCOUNT = 5; // bank account + const TYPE_PRODUCT = 0; // TODO Replace with value 'product' + const TYPE_SUPPLIER = 1; // TODO Replace this value with 'supplier' + const TYPE_CUSTOMER = 2; // TODO Replace this value with 'customer' + const TYPE_MEMBER = 3; // TODO Replace this value with 'member' + const TYPE_CONTACT = 4; // TODO Replace this value with 'contact' + const TYPE_USER = 4; // categorie contact and user are same ! TODO Replace this value with 'user' + const TYPE_ACCOUNT = 5; // for bank account TODO Replace this value with 'account' /** * @var array ID mapping from type string @@ -63,7 +63,7 @@ class Categorie extends CommonObject 'member' => 3, 'contact' => 4, 'user' => 4, - 'account' => 5, + 'account' => 5, ); /** * @var array Foreign keys mapping from type string diff --git a/htdocs/user/card.php b/htdocs/user/card.php index fcc73597754..b035358716e 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2224,7 +2224,7 @@ else print '<td>'; $cate_arbo = $form->select_all_categories( Categorie::TYPE_CONTACT, null, null, null, null, 1 ); $c = new Categorie( $db ); - $cats = $c->containing( $object->id, 'user' ); + $cats = $c->containing($object->id, Categorie::TYPE_USER); foreach ($cats as $cat) { $arrayselected[] = $cat->id; } diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index d9e030ef9ef..574a8d793f9 100644 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -200,7 +200,7 @@ class CategorieTest extends PHPUnit_Framework_TestCase // Get list of categories for product $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'); return $id; -- GitLab