1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<?php
require_once __DIR__.'/../Base.php';
use Kanboard\Event\GenericEvent;
use Kanboard\Model\TaskFinder;
use Kanboard\Model\Project;
use Kanboard\Action\TaskCreation as TaskCreationAction;
class TaskCreationActionTest extends Base
{
public function testSuccess()
{
$projectModel = new Project($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$event = new GenericEvent(array('project_id' => 1, 'task_id' => 1, 'title' => 'test123', 'reference' => 'ref123', 'description' => 'test'));
$action = new TaskCreationAction($this->container);
$action->setProjectId(1);
$action->addEvent('test.event', 'Test Event');
$this->assertTrue($action->execute($event, 'test.event'));
$task = $taskFinderModel->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals('test123', $task['title']);
$this->assertEquals('ref123', $task['reference']);
$this->assertEquals('test', $task['description']);
}
public function testWithNoTitle()
{
$projectModel = new Project($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$event = new GenericEvent(array('project_id' => 1, 'task_id' => 1, 'reference' => 'ref123', 'description' => 'test'));
$action = new TaskCreationAction($this->container);
$action->setProjectId(1);
$action->addEvent('test.event', 'Test Event');
$this->assertFalse($action->execute($event, 'test.event'));
}
}
|