public function testExecute()
 {
     $action = new Action\TaskAssignColorCategory($this->container, 1, Task::EVENT_CREATE_UPDATE);
     $action->setParam('category_id', 1);
     $action->setParam('color_id', 'blue');
     // We create a task in the first column
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $c = new Category($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $c->create(array('name' => 'c1')));
     $this->assertEquals(2, $c->create(array('name' => 'c2')));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green', 'category_id' => 2)));
     // We create an event but we don't do anything
     $event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 1, 'category_id' => 2, 'position' => 2);
     // Our event should NOT be executed
     $this->assertFalse($action->execute($event));
     // Our task should be assigned to the ategory_id=1 and have the green color
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['category_id']);
     $this->assertEquals('green', $task['color_id']);
     // We create an event to move the task
     $event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 1, 'position' => 5, 'category_id' => 1);
     // Our event should be executed
     $this->assertTrue($action->execute($event));
     // Our task should have the blue color
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals('blue', $task['color_id']);
 }
 function viewAction()
 {
     parent::viewAction();
     $obj = new CateModel();
     $this->data['category'] = $obj->getTree($this->data['data']->category);
     return $this->view($this->view, $this->data);
 }
 public function testExecute()
 {
     $action = new Action\TaskMoveColumnCategoryChange($this->container, 1, Task::EVENT_UPDATE);
     $action->setParam('dest_column_id', 3);
     $action->setParam('category_id', 1);
     $this->assertEquals(3, $action->getParam('dest_column_id'));
     $this->assertEquals(1, $action->getParam('category_id'));
     // We create a task in the first column
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $c = new Category($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $c->create(array('name' => 'bug', 'project_id' => 1)));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
     // No category should be assigned + column_id=1
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEmpty($task['category_id']);
     $this->assertEquals(1, $task['column_id']);
     // We create an event to move the task to the 2nd column
     $event = array('task_id' => 1, 'column_id' => 1, 'project_id' => 1, 'category_id' => 1);
     // Our event should be executed
     $this->assertTrue($action->hasCompatibleEvent());
     $this->assertTrue($action->hasRequiredProject($event));
     $this->assertTrue($action->hasRequiredParameters($event));
     $this->assertTrue($action->hasRequiredCondition($event));
     $this->assertTrue($action->isExecutable($event));
     $this->assertTrue($action->execute(new GenericEvent($event)));
     // Our task should be moved to the other column
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(3, $task['column_id']);
 }
示例#4
0
 /**
  * 添加分类
  */
 public function action()
 {
     $this->db()->transaction();
     $addResult = \Model\Category::addCategory();
     $this->db()->commit();
     $this->success('添加分类成功', $this->url(GROUP . '-Category-index'));
 }
示例#5
0
 /**
  * 添加/编辑分类
  */
 public function action()
 {
     $categoryId = $this->g('id');
     if (empty($categoryId)) {
         $this->assign('method', 'POST');
         if ($parent = $this->g('parent')) {
             $this->assign('category_parent', $parent);
             $this->assign('title', '添加子分类');
         } else {
             $this->assign('title', '添加分类');
         }
         $tree = \Model\Category::getSelectCate(array($parent));
     } else {
         $category = \Model\Category::listCategory($categoryId);
         if (empty($category)) {
             $this->error('分类不存在');
         }
         $tree = \Model\Category::getSelectCate(array($category['category_parent']));
         $this->assign('method', 'PUT');
         $this->assign($category);
         $this->assign('title', '编辑分类');
     }
     $this->assign('model', \Model\Content::listContent(['table' => 'model', 'condition' => 'model_attr = 1']));
     $this->assign('tree', $tree);
     $this->layout();
 }
示例#6
0
 /**
  * 编辑分类
  */
 public function action($jump = TRUE, $commit = TRUE)
 {
     $this->db()->transaction();
     $updateResult = \Model\Category::updateCategory();
     $this->db()->commit();
     $this->success('更新分类成功', $this->url(GROUP . '-Category-index'));
 }
示例#7
0
 /**
  * 输出所有分类的数组
  */
 private function getCategoryList()
 {
     $list = \Model\Category::listCategory();
     foreach ($list as $key => $value) {
         $this->categorys[$value['category_id']] = $value;
     }
     $this->assign('categorys', $this->categorys);
 }
示例#8
0
 public function testRemove()
 {
     $t = new Task($this->registry);
     $p = new Project($this->registry);
     $c = new Category($this->registry);
     $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
     $this->assertEquals(1, $c->create(array('name' => 'Category #1', 'project_id' => 1)));
     $this->assertEquals(2, $c->create(array('name' => 'Category #2', 'project_id' => 1)));
     $this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2)));
     $task = $t->getById(1);
     $this->assertTrue(is_array($task));
     $this->assertEquals(2, $task['category_id']);
     $this->assertTrue($c->remove(1));
     $this->assertTrue($c->remove(2));
     // Make sure tasks assigned with that category are reseted
     $task = $t->getById(1);
     $this->assertTrue(is_array($task));
     $this->assertEquals(0, $task['category_id']);
 }
示例#9
0
 public function testCreationWithDefaultCategories()
 {
     $p = new Project($this->container);
     $c = new Config($this->container);
     $cat = new Category($this->container);
     // Multiple categories correctly formatted
     $this->assertTrue($c->save(array('project_categories' => 'Test1, Test2')));
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $project = $p->getById(1);
     $this->assertNotEmpty($project);
     $categories = $cat->getAll(1);
     $this->assertNotEmpty($categories);
     $this->assertEquals(2, count($categories));
     $this->assertEquals('Test1', $categories[0]['name']);
     $this->assertEquals('Test2', $categories[1]['name']);
     // Single category
     $this->assertTrue($c->save(array('project_categories' => 'Test1')));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $categories = $cat->getAll(2);
     $this->assertNotEmpty($categories);
     $this->assertEquals(1, count($categories));
     $this->assertEquals('Test1', $categories[0]['name']);
     // Multiple categories badly formatted
     $this->assertTrue($c->save(array('project_categories' => 'ABC, , DEF 3,  ')));
     $this->assertEquals(3, $p->create(array('name' => 'UnitTest3')));
     $project = $p->getById(3);
     $this->assertNotEmpty($project);
     $categories = $cat->getAll(3);
     $this->assertNotEmpty($categories);
     $this->assertEquals(2, count($categories));
     $this->assertEquals('ABC', $categories[0]['name']);
     $this->assertEquals('DEF 3', $categories[1]['name']);
     // No default categories
     $this->assertTrue($c->save(array('project_categories' => '  ')));
     $this->assertEquals(4, $p->create(array('name' => 'UnitTest4')));
     $project = $p->getById(4);
     $this->assertNotEmpty($project);
     $categories = $cat->getAll(4);
     $this->assertEmpty($categories);
 }
示例#10
0
 public function testExport()
 {
     $tc = new TaskCreation($this->container);
     $p = new Project($this->container);
     $c = new Category($this->container);
     $e = new TaskExport($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'Export Project')));
     $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1)));
     $this->assertNotFalse($c->create(array('name' => 'Category #2', 'project_id' => 1)));
     $this->assertNotFalse($c->create(array('name' => 'Category #3', 'project_id' => 1)));
     for ($i = 1; $i <= 100; $i++) {
         $task = array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => rand(1, 3), 'creator_id' => rand(0, 1), 'owner_id' => rand(0, 1), 'color_id' => rand(0, 1) === 0 ? 'green' : 'purple', 'category_id' => rand(0, 3), 'date_due' => array_rand(array(0, date('Y-m-d'), date('Y-m-d', strtotime('+' . $i . 'day')))), 'score' => rand(0, 21));
         $this->assertEquals($i, $tc->create($task));
     }
     $rows = $e->export(1, strtotime('-1 day'), strtotime('+1 day'));
     $this->assertEquals($i, count($rows));
     $this->assertEquals('Task Id', $rows[0][0]);
     $this->assertEquals(1, $rows[1][0]);
     $this->assertEquals('Task #' . ($i - 1), $rows[$i - 1][11]);
 }
 public function testCloneProjectWithCategories()
 {
     $p = new Project($this->container);
     $c = new Category($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertEquals(1, $c->create(array('name' => 'C1', 'project_id' => 1)));
     $this->assertEquals(2, $c->create(array('name' => 'C2', 'project_id' => 1)));
     $this->assertEquals(3, $c->create(array('name' => 'C3', 'project_id' => 1)));
     $this->assertEquals(2, $p->duplicate(1));
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $this->assertEquals('P1 (Clone)', $project['name']);
     $categories = $c->getAll(2);
     $this->assertNotempty($categories);
     $this->assertEquals(3, count($categories));
     $this->assertEquals(4, $categories[0]['id']);
     $this->assertEquals('C1', $categories[0]['name']);
     $this->assertEquals(5, $categories[1]['id']);
     $this->assertEquals('C2', $categories[1]['name']);
     $this->assertEquals(6, $categories[2]['id']);
     $this->assertEquals('C3', $categories[2]['name']);
 }
示例#12
0
 public function index()
 {
     $twig = Config::getTwig();
     //-- Get Distrubuter  -- //
     $distrName = Request::_get('id');
     $categoryList = Category::getCategoryTree()->content;
     //-- Get Main Categories -- //
     $maincategoryList = $categoryList->childList;
     //-- Define Rendered Result -- //
     $result = array('categoryList' => $maincategoryList, 'distrName' => $distrName);
     //-- Render Result -- //
     return $twig->render('home.html', $result);
 }
示例#13
0
 /**
  * 生成对应的HTML表单内容
  * @param type $field 提交过来的字段
  */
 public function formList($field)
 {
     switch ($field['field_type']) {
         case 'text':
             require 'theme/text.php';
             break;
         case 'textarea':
             require 'theme/textarea.php';
             break;
         case 'editor':
             /**
              * 将属于必填项的表单名称写入数组
              * 在模板的底部进行一个JS的校验.
              */
             static $checkEditor, $checkEditorName;
             if ($field['field_required'] == '1') {
                 /* 表单名称 */
                 $checkEditor[] = $field['field_name'];
                 /* 显示名称 */
                 $checkEditorName[] = $field['display_name'];
             }
             require 'theme/editor.php';
             break;
         case 'date':
             require 'theme/date.php';
             break;
         case 'radio':
             require 'theme/radio.php';
             break;
         case 'checkbox':
             require 'theme/checkbox.php';
             break;
         case 'thumb':
             require 'theme/thumb.php';
             break;
         case 'category':
             \Model\Category::$where = 'm.model_name = "' . MODULE . '"';
             $tree = \Model\Category::getSelectCate($field['value'] ? array($field['value']) : '', true);
             require 'theme/category.php';
             break;
         case 'select':
             require 'theme/select.php';
             break;
         case 'file':
             require 'theme/file.php';
             break;
         case 'img':
             require 'theme/img.php';
             break;
     }
 }
示例#14
0
 public function testMultipleActions()
 {
     $tp = new TaskPosition($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $b = new Board($this->container);
     $p = new Project($this->container);
     $a = new Action($this->container);
     $c = new Category($this->container);
     $g = new GithubWebhook($this->container);
     // We create a project
     $this->assertEquals(1, $p->create(array('name' => 'unit_test')));
     $this->assertEquals(1, $c->create(array('name' => 'unit_test')));
     // We create a new action
     $this->assertEquals(1, $a->create(array('project_id' => 1, 'event_name' => GithubWebhook::EVENT_ISSUE_OPENED, 'action_name' => 'TaskCreation', 'params' => array())));
     $this->assertEquals(2, $a->create(array('project_id' => 1, 'event_name' => GithubWebhook::EVENT_ISSUE_LABEL_CHANGE, 'action_name' => 'TaskAssignCategoryLabel', 'params' => array('label' => 'bug', 'category_id' => 1))));
     $this->assertEquals(3, $a->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignColorCategory', 'params' => array('color_id' => 'red', 'category_id' => 1))));
     // We attach events
     $a->attachEvents();
     $g->setProjectId(1);
     // We create a Github issue
     $issue = array('number' => 123, 'title' => 'Bugs everywhere', 'body' => 'There is a bug!', 'html_url' => 'http://localhost/');
     $this->assertTrue($g->handleIssueOpened($issue));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['is_active']);
     $this->assertEquals(0, $task['category_id']);
     $this->assertEquals('yellow', $task['color_id']);
     // We assign a label to our issue
     $label = array('name' => 'bug');
     $this->assertTrue($g->handleIssueLabeled($issue, $label));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['is_active']);
     $this->assertEquals(1, $task['category_id']);
     $this->assertEquals('red', $task['color_id']);
 }
示例#15
0
 public function testSearchWithCategory()
 {
     $p = new Project($this->container);
     $c = new Category($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFilter($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $c->create(array('name' => 'Feature request', 'project_id' => 1)));
     $this->assertEquals(2, $c->create(array('name' => 'hé hé', 'project_id' => 1)));
     $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1')));
     $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task2', 'category_id' => 1)));
     $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task3', 'category_id' => 2)));
     $tf->search('category:"Feature request"');
     $tasks = $tf->findAll();
     $this->assertNotEmpty($tasks);
     $this->assertCount(1, $tasks);
     $this->assertEquals('task2', $tasks[0]['title']);
     $tf->search('category:"hé hé"');
     $tasks = $tf->findAll();
     $this->assertNotEmpty($tasks);
     $this->assertCount(1, $tasks);
     $this->assertEquals('task3', $tasks[0]['title']);
     $tf->search('category:"Feature request" category:"hé hé"');
     $tasks = $tf->findAll();
     $this->assertNotEmpty($tasks);
     $this->assertCount(2, $tasks);
     $this->assertEquals('task2', $tasks[0]['title']);
     $this->assertEquals('task3', $tasks[1]['title']);
     $tf->search('category:none');
     $tasks = $tf->findAll();
     $this->assertNotEmpty($tasks);
     $this->assertCount(1, $tasks);
     $this->assertEquals('task1', $tasks[0]['title']);
     $tf->search('category:"not found"');
     $tasks = $tf->findAll();
     $this->assertEmpty($tasks);
 }
示例#16
0
 /**
  * 生成对应的HTML表单内容
  * @param type $field 提交过来的字段
  */
 public function formList($field)
 {
     switch ($field['field_type']) {
         case 'text':
             require 'theme/text.php';
             break;
         case 'textarea':
             require 'theme/textarea.php';
             break;
         case 'editor':
             /**
              * 将属于必填项的表单名称写入数组
              * 在模板的底部进行一个JS的校验.
              */
             static $checkEditor, $checkEditorName;
             if ($field['field_required'] == '1') {
                 /* 表单名称 */
                 $checkEditor[] = $field['field_name'];
                 /* 显示名称 */
                 $checkEditorName[] = $field['field_display_name'];
             }
             require 'theme/editor.php';
             break;
         case 'date':
             require 'theme/date.php';
             break;
         case 'radio':
             require 'theme/radio.php';
             break;
         case 'checkbox':
             require 'theme/checkbox.php';
             break;
         case 'thumb':
             require 'theme/thumb.php';
             break;
         case 'category':
             \Model\Category::$where = 'm.model_name = "' . MODULE . '"';
             $tree = \Model\Category::getSelectCate($field['value'] ? array($field['value']) : array(), true);
             require 'theme/category.php';
             break;
         case 'select':
             require 'theme/select.php';
             break;
         case 'file':
             require 'theme/file.php';
             break;
         case 'img':
             require 'theme/img.php';
             break;
         case 'theme':
             $themeName = THEME . '/Home/' . \Core\Func\CoreFunc::getThemeName('Home') . '/' . MODULE;
             $themeList = scandir($themeName);
             $theme = ['默认模板' => ''];
             foreach ($themeList as $value) {
                 if ($value != '.' && $value != '..' && $value != '.DS_Store') {
                     $value = str_replace('.php', '', $value);
                     $theme[$value] = $value;
                 }
             }
             $field['field_option'] = json_encode($theme);
             require 'theme/select.php';
             break;
     }
 }
示例#17
0
 /**
  * 根据父类ID查找数据
  * @param type $parent_id 分类父类ID
  * @param type $is_nav 是否为导航
  * @return array 返回二维数组
  */
 public function getCate($category_parent = '0', $category_nav = '')
 {
     return \Model\Category::getCat($category_parent, $category_nav);
 }
 public function addCategory(\model\Category $c)
 {
     $smt = $this->conn->prepare("INSERT INTO " . self::$table . " (\n\t\t\t\t\t\t\t\t\t" . self::$c_name . ", \n\t\t\t\t\t\t\t\t\t" . self::$c_level . ") \n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $c->getCategoryName() . "', \n\t\t\t\t\t\t\t\t\t\t\t'" . $c->getLevel() . "')");
     $smt->execute();
 }
示例#19
0
 public function testCloneProjectWithActionTaskAssignColorCategory()
 {
     $p = new Project($this->container);
     $a = new Action($this->container);
     $c = new Category($this->container);
     $pd = new ProjectDuplication($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertEquals(1, $c->create(array('name' => 'C1', 'project_id' => 1)));
     $this->assertEquals(2, $c->create(array('name' => 'C2', 'project_id' => 1)));
     $this->assertEquals(3, $c->create(array('name' => 'C3', 'project_id' => 1)));
     $this->assertEquals(1, $a->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignColorCategory', 'params' => array('color_id' => 'blue', 'category_id' => 2))));
     $this->assertEquals(2, $pd->duplicate(1));
     $actions = $a->getAllByProject(2);
     $this->assertNotEmpty($actions);
     $this->assertEquals('TaskAssignColorCategory', $actions[0]['action_name']);
     $this->assertNotEmpty($actions[0]['params']);
     $this->assertEquals('blue', $actions[0]['params'][0]['value']);
     $this->assertEquals(5, $actions[0]['params'][1]['value']);
 }
示例#20
0
use Model\Project;
use Model\Task;
use Model\User;
use Model\Config;
use Model\Category;
use Model\Comment;
use Model\SubTask;
use Model\Board;
use Model\Action;
use Model\Webhook;
use Model\Notification;
$config = new Config($registry);
$project = new Project($registry);
$task = new Task($registry);
$user = new User($registry);
$category = new Category($registry);
$comment = new Comment($registry);
$subtask = new SubTask($registry);
$board = new Board($registry);
$action = new Action($registry);
$webhook = new Webhook($registry);
$notification = new Notification($registry);
$action->attachEvents();
$project->attachEvents();
$webhook->attachEvents();
$notification->attachEvents();
// Load translations
$language = $config->get('language', 'en_US');
if ($language !== 'en_US') {
    Translator::load($language);
}
示例#21
0
            <ul class="am-tabs-nav am-nav am-nav-tabs">
                <li class="am-active"><a href="#tab1">基本信息</a></li>
            </ul>

            <div class="am-tabs-bd">
                <div class="am-tab-panel am-fade am-in am-active">

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            所属分类
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                            <select name="category_parent" required>
                                <option value="0">顶层分类</option>
                                <?php 
echo \Model\Category::getCategorys(array($category_parent));
?>
                            </select>
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">*必填</div>
                    </div>

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            模型类型
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                            <select name="model_id" required>
                                <option value="">请选择</option>
                                <?php 
foreach ($model as $key => $value) {
 /**
  *	Method for creating a category
  *	@param \model\Category $c
  */
 public function createCategory(\model\Category $c)
 {
     if ($this->categoryDAL->checkCategoryExists($c->getCategoryName())) {
         throw new \PDOCategoryExistsException("Category name already exists in database.");
     }
     $this->categoryDAL->addCategory($c);
 }
示例#23
0
 public function testMoveAnotherProjectWithCategory()
 {
     $td = new TaskDuplication($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $c = new Category($this->container);
     // We create 2 projects
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     $this->assertEquals(2, $p->create(array('name' => 'test2')));
     $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1)));
     $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 2)));
     $this->assertTrue($c->exists(1, 1));
     $this->assertTrue($c->exists(2, 2));
     // We create a task
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'category_id' => 1)));
     // We move our task to the 2nd project
     $this->assertTrue($td->moveToProject(1, 2));
     // Check the values of the duplicated task
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(0, $task['owner_id']);
     $this->assertEquals(2, $task['category_id']);
     $this->assertEquals(0, $task['swimlane_id']);
     $this->assertEquals(5, $task['column_id']);
     $this->assertEquals(1, $task['position']);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals('test', $task['title']);
 }
示例#24
0
 public function testDuplicateToAnotherProject()
 {
     $t = new Task($this->registry);
     $p = new Project($this->registry);
     $c = new Category($this->registry);
     // We create 2 projects
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     $this->assertEquals(2, $p->create(array('name' => 'test2')));
     $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1)));
     $this->assertTrue($c->exists(1, 1));
     // We create a task
     $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1, 'category_id' => 1)));
     $task = $t->getById(1);
     // We duplicate our task to the 2nd project
     $this->assertEquals(2, $t->duplicateToAnotherProject(2, $task));
     $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_CREATE));
     // Check the values of the duplicated task
     $task = $t->getById(2);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['owner_id']);
     $this->assertEquals(0, $task['category_id']);
     $this->assertEquals(5, $task['column_id']);
     $this->assertEquals(1, $task['position']);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals('test', $task['title']);
 }
示例#25
0
 public function testRelationsInitCollections()
 {
     $category = new Category();
     $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $category->getArticles());
 }
示例#26
0
 public function testDuplicateMixedResults()
 {
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $a = new Action($this->container);
     $u = new User($this->container);
     $c = new Category($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertEquals(2, $p->create(array('name' => 'P2')));
     $this->assertEquals(1, $c->create(array('name' => 'C1', 'project_id' => 1)));
     $this->assertEquals(2, $c->create(array('name' => 'C2', 'project_id' => 2)));
     $this->assertEquals(3, $c->create(array('name' => 'C1', 'project_id' => 2)));
     $this->assertEquals(2, $u->create(array('username' => 'unittest1')));
     $this->assertTrue($pp->addMember(1, 2));
     $this->assertEquals(1, $a->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignSpecificUser', 'params' => array('column_id' => 1, 'user_id' => 2))));
     $action = $a->getById(1);
     $this->assertNotEmpty($action);
     $this->assertNotEmpty($action['params']);
     $this->assertEquals(2, $a->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignCategoryColor', 'params' => array('color_id' => 'blue', 'category_id' => 1))));
     $action = $a->getById(2);
     $this->assertNotEmpty($action);
     $this->assertNotEmpty($action['params']);
     $this->assertEquals('category_id', $action['params'][1]['name']);
     $this->assertEquals(1, $action['params'][1]['value']);
     $actions = $a->getAllByProject(1);
     $this->assertNotEmpty($actions);
     $this->assertCount(2, $actions);
     $this->assertTrue($a->duplicate(1, 2));
     $actions = $a->getAllByProject(2);
     $this->assertNotEmpty($actions);
     $this->assertCount(1, $actions);
     $actions = $a->getAll();
     $this->assertNotEmpty($actions);
     $this->assertCount(3, $actions);
     $action = $a->getById($actions[2]['id']);
     $this->assertNotEmpty($action);
     $this->assertNotEmpty($action['params']);
     $this->assertEquals('color_id', $action['params'][0]['name']);
     $this->assertEquals('blue', $action['params'][0]['value']);
     $this->assertEquals('category_id', $action['params'][1]['name']);
     $this->assertEquals(3, $action['params'][1]['value']);
 }