Refactoring of internal task events

This commit is contained in:
Frederic Guillot
2016-07-19 22:38:30 -04:00
parent d9d3788222
commit 390082aa41
58 changed files with 1210 additions and 468 deletions

View File

@@ -14,19 +14,19 @@ class TaskAssignCategoryLinkTest extends Base
{
public function testAssignCategory()
{
$tc = new TaskCreationModel($this->container);
$tf = new TaskFinderModel($this->container);
$p = new ProjectModel($this->container);
$c = new CategoryModel($this->container);
$taskCreationModel = new TaskCreationModel($this->container);
$taskFinderModel = new TaskFinderModel($this->container);
$projectModel = new ProjectModel($this->container);
$categoryModel = new CategoryModel($this->container);
$action = new TaskAssignCategoryLink($this->container);
$action->setProjectId(1);
$action->setParam('category_id', 1);
$action->setParam('link_id', 2);
$this->assertEquals(1, $p->create(array('name' => 'P1')));
$this->assertEquals(1, $c->create(array('name' => 'C1', 'project_id' => 1)));
$this->assertEquals(1, $tc->create(array('title' => 'T1', 'project_id' => 1)));
$this->assertEquals(1, $projectModel->create(array('name' => 'P1')));
$this->assertEquals(1, $categoryModel->create(array('name' => 'C1', 'project_id' => 1)));
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'T1', 'project_id' => 1)));
$event = new TaskLinkEvent(array(
'project_id' => 1,
@@ -37,25 +37,24 @@ class TaskAssignCategoryLinkTest extends Base
$this->assertTrue($action->execute($event, TaskLinkModel::EVENT_CREATE_UPDATE));
$task = $tf->getById(1);
$task = $taskFinderModel->getById(1);
$this->assertEquals(1, $task['category_id']);
}
public function testWhenLinkDontMatch()
{
$tc = new TaskCreationModel($this->container);
$tf = new TaskFinderModel($this->container);
$p = new ProjectModel($this->container);
$c = new CategoryModel($this->container);
$taskCreationModel = new TaskCreationModel($this->container);
$projectModel = new ProjectModel($this->container);
$categoryModel = new CategoryModel($this->container);
$action = new TaskAssignCategoryLink($this->container);
$action->setProjectId(1);
$action->setParam('category_id', 1);
$action->setParam('link_id', 1);
$this->assertEquals(1, $p->create(array('name' => 'P1')));
$this->assertEquals(1, $c->create(array('name' => 'C1', 'project_id' => 1)));
$this->assertEquals(1, $tc->create(array('title' => 'T1', 'project_id' => 1)));
$this->assertEquals(1, $projectModel->create(array('name' => 'P1')));
$this->assertEquals(1, $categoryModel->create(array('name' => 'C1', 'project_id' => 1)));
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'T1', 'project_id' => 1)));
$event = new TaskLinkEvent(array(
'project_id' => 1,
@@ -69,19 +68,19 @@ class TaskAssignCategoryLinkTest extends Base
public function testThatExistingCategoryWillNotChange()
{
$tc = new TaskCreationModel($this->container);
$p = new ProjectModel($this->container);
$c = new CategoryModel($this->container);
$taskCreationModel = new TaskCreationModel($this->container);
$projectModel = new ProjectModel($this->container);
$categoryModel = new CategoryModel($this->container);
$action = new TaskAssignCategoryLink($this->container);
$action->setProjectId(1);
$action->setParam('category_id', 2);
$action->setParam('link_id', 2);
$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(1, $tc->create(array('title' => 'T1', 'project_id' => 1, 'category_id' => 1)));
$this->assertEquals(1, $projectModel->create(array('name' => 'P1')));
$this->assertEquals(1, $categoryModel->create(array('name' => 'C1', 'project_id' => 1)));
$this->assertEquals(2, $categoryModel->create(array('name' => 'C2', 'project_id' => 1)));
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'T1', 'project_id' => 1, 'category_id' => 1)));
$event = new TaskLinkEvent(array(
'project_id' => 1,