From a2d8887421f2369b27b775c871aff9991c3ab090 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 4 Mar 2016 15:11:27 -0500 Subject: Added unit test for Category model --- app/Model/Category.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'app/Model/Category.php') diff --git a/app/Model/Category.php b/app/Model/Category.php index 883fc282..6368f507 100644 --- a/app/Model/Category.php +++ b/app/Model/Category.php @@ -22,12 +22,11 @@ class Category extends Base * * @access public * @param integer $category_id Category id - * @param integer $project_id Project id * @return boolean */ - public function exists($category_id, $project_id) + public function exists($category_id) { - return $this->db->table(self::TABLE)->eq('id', $category_id)->eq('project_id', $project_id)->exists(); + return $this->db->table(self::TABLE)->eq('id', $category_id)->exists(); } /** @@ -115,25 +114,29 @@ class Category extends Base } /** - * Create default cetegories during project creation (transaction already started in Project::create()) + * Create default categories during project creation (transaction already started in Project::create()) * * @access public * @param integer $project_id + * @return boolean */ public function createDefaultCategories($project_id) { + $results = array(); $categories = explode(',', $this->config->get('project_categories')); foreach ($categories as $category) { $category = trim($category); if (! empty($category)) { - $this->db->table(self::TABLE)->insert(array( + $results[] = $this->db->table(self::TABLE)->insert(array( 'project_id' => $project_id, 'name' => $category, )); } } + + return in_array(false, $results, true); } /** @@ -195,7 +198,7 @@ class Category extends Base { $categories = $this->db ->table(self::TABLE) - ->columns('name') + ->columns('name', 'description') ->eq('project_id', $src_project_id) ->asc('name') ->findAll(); -- cgit v1.2.3