summaryrefslogtreecommitdiff
path: root/tests/units/Filter/TaskPriorityFilterTest.php
blob: 4c95ddce10711804897f2f956b70bd2345f157ba (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
40
41
42
43
44
45
46
47
<?php

use Kanboard\Filter\TaskPriorityFilter;
use Kanboard\Model\ProjectModel;
use Kanboard\Model\TaskCreationModel;
use Kanboard\Model\TaskFinderModel;

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

class TaskPriorityFilterTest extends Base
{
    public function testWithDefinedPriority()
    {
        $taskFinder = new TaskFinderModel($this->container);
        $taskCreation = new TaskCreationModel($this->container);
        $projectModel = new ProjectModel($this->container);
        $query = $taskFinder->getExtendedQuery();

        $this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
        $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1, 'priority' => 2)));

        $filter = new TaskPriorityFilter();
        $filter->withQuery($query);
        $filter->withValue(2);
        $filter->apply();

        $this->assertCount(1, $query->findAll());
    }

    public function testWithNoPriority()
    {
        $taskFinder = new TaskFinderModel($this->container);
        $taskCreation = new TaskCreationModel($this->container);
        $projectModel = new ProjectModel($this->container);
        $query = $taskFinder->getExtendedQuery();

        $this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
        $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1)));

        $filter = new TaskPriorityFilter();
        $filter->withQuery($query);
        $filter->withValue(2);
        $filter->apply();

        $this->assertCount(0, $query->findAll());
    }
}