summaryrefslogtreecommitdiff
path: root/tests/units/Formatter/TaskSuggestMenuFormatterTest.php
blob: d247d670e8a9cec66340b0df3af31fba25930da7 (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
35
36
37
38
39
<?php

use Kanboard\Formatter\TaskSuggestMenuFormatter;
use Kanboard\Model\ProjectModel;
use Kanboard\Model\TaskCreationModel;

require_once __DIR__.'/../Base.php';

class TaskSuggestMenuFormatterTest extends Base
{
    public function testFormat()
    {
        $projectModel = new ProjectModel($this->container);
        $taskCreationModel = new TaskCreationModel($this->container);
        $taskSuggestMenuFormatter = new TaskSuggestMenuFormatter($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)));

        $result = $taskSuggestMenuFormatter
            ->withQuery($this->container['taskFinderModel']->getExtendedQuery())
            ->format()
        ;

        $expected = array(
            array(
                'value' => '1',
                'html' => '#1 Task 1 <small>My Project</small>',
            ),
            array(
                'value' => '2',
                'html' => '#2 Task 2 <small>My Project</small>',
            ),
        );

        $this->assertSame($expected, $result);
    }
}