diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-03-04 15:11:27 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-03-04 15:11:27 -0500 |
commit | a2d8887421f2369b27b775c871aff9991c3ab090 (patch) | |
tree | 75c997c5244c97a1a3b02ec0e97d0dc6536afceb /app/Model/Category.php | |
parent | 4df6f534a163806cb0ee2cee601bb54d1c3ca190 (diff) |
Added unit test for Category model
Diffstat (limited to 'app/Model/Category.php')
-rw-r--r-- | app/Model/Category.php | 15 |
1 files changed, 9 insertions, 6 deletions
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(); |