blob: 20baf549dc3ef6734508a4f3f45b150c7d374db2 (
plain)
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
|
<?php
use Kanboard\Formatter\TaskAutoCompleteFormatter;
use Kanboard\Model\ProjectModel;
use Kanboard\Model\TaskCreationModel;
use Kanboard\Model\TaskFinderModel;
require_once __DIR__.'/../Base.php';
class TaskAutoCompleteFormatterTest extends Base
{
public function testFormat()
{
$projectModel = new ProjectModel($this->container);
$taskCreationModel = new TaskCreationModel($this->container);
$taskFinderModel = new TaskFinderModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'My Project')));
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task 1', 'project_id' => 1)));
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task 2', 'project_id' => 1)));
$tasks = TaskAutoCompleteFormatter::getInstance($this->container)
->withQuery($taskFinderModel->getExtendedQuery())
->format();
$this->assertCount(2, $tasks);
$this->assertEquals('My Project > #1 Task 1', $tasks[0]['label']);
$this->assertEquals('Task 1', $tasks[0]['value']);
$this->assertEquals(1, $tasks[0]['id']);
$this->assertEquals('My Project > #2 Task 2', $tasks[1]['label']);
$this->assertEquals('Task 2', $tasks[1]['value']);
$this->assertEquals(2, $tasks[1]['id']);
}
}
|