summaryrefslogtreecommitdiff
path: root/tests/units/ActionCommentCreationTest.php
blob: 03f45f28df4b6ab5eaa7d12a507d10f87bf7d3d2 (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
<?php

require_once __DIR__.'/Base.php';

use Event\GenericEvent;
use Model\Task;
use Model\TaskCreation;
use Model\Comment;
use Model\Project;
use Integration\GithubWebhook;

class ActionCommentCreationTest extends Base
{
    public function testWithUser()
    {
        $action = new Action\CommentCreation($this->container, 1, GithubWebhook::EVENT_ISSUE_COMMENT);

        // We create a task in the first column
        $tc = new TaskCreation($this->container);
        $p = new Project($this->container);
        $c = new Comment($this->container);
        $this->assertEquals(1, $p->create(array('name' => 'test')));
        $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));

        // We create an event to move the task to the 2nd column
        $event = array(
            'project_id' => 1,
            'task_id' => 1,
            'user_id' => 1,
            'comment' => 'youpi',
        );

        // Our event should be executed
        $this->assertTrue($action->execute(new GenericEvent($event)));

        // Our task should be updated
        $comment = $c->getById(1);
        $this->assertNotEmpty($comment);
        $this->assertEquals(1, $comment['task_id']);
        $this->assertEquals(1, $comment['user_id']);
        $this->assertEquals('youpi', $comment['comment']);
    }
}