Add unit test for TaskAssignCategoryLink

This commit is contained in:
Frederic Guillot
2015-11-15 14:39:12 -05:00
parent 2011c35344
commit a42f1ea2bd
5 changed files with 112 additions and 4 deletions

View File

@@ -241,7 +241,7 @@ abstract class Base extends \Kanboard\Core\Base
}
if (DEBUG) {
$this->container['logger']->debug(get_called_class().' => '.($result ? 'true' : 'false'));
$this->logger->debug(get_called_class().' => '.($result ? 'true' : 'false'));
}
return $result;

View File

@@ -9,6 +9,7 @@ use Kanboard\Model\TaskLink;
*
* @package action
* @author Olivier Maridat
* @author Frederic Guillot
*/
class TaskAssignCategoryLink extends Base
{
@@ -35,7 +36,7 @@ class TaskAssignCategoryLink extends Base
{
return array(
'category_id' => t('Category'),
'link_id' => t('Link id'),
'link_id' => t('Link type'),
);
}
@@ -79,6 +80,11 @@ class TaskAssignCategoryLink extends Base
*/
public function hasRequiredCondition(array $data)
{
return $data['link_id'] == $this->getParam('link_id');
if ($data['link_id'] == $this->getParam('link_id')) {
$task = $this->taskFinder->getById($data['task_id']);
return empty($task['category_id']);
}
return false;
}
}