summaryrefslogtreecommitdiff
path: root/tests/units/EventBuilder/ProjectFileEventBuilderTest.php
blob: 8f5eb87ec1bd3fb054c9129bb4b9472b7cf5d24e (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
<?php

use Kanboard\EventBuilder\ProjectFileEventBuilder;
use Kanboard\Model\ProjectFileModel;
use Kanboard\Model\ProjectModel;

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

class ProjectFileEventBuilderTest extends Base
{
    public function testWithMissingFile()
    {
        $projectFileEventBuilder = new ProjectFileEventBuilder($this->container);
        $projectFileEventBuilder->withFileId(42);
        $this->assertNull($projectFileEventBuilder->buildEvent());
    }

    public function testBuild()
    {
        $projectModel = new ProjectModel($this->container);
        $projectFileModel = new ProjectFileModel($this->container);
        $projectFileEventBuilder = new ProjectFileEventBuilder($this->container);

        $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
        $this->assertEquals(1, $projectFileModel->create(1, 'Test', '/tmp/test', 123));

        $event = $projectFileEventBuilder->withFileId(1)->buildEvent();

        $this->assertInstanceOf('Kanboard\Event\ProjectFileEvent', $event);
        $this->assertNotEmpty($event['file']);
        $this->assertNotEmpty($event['project']);
    }
}