summaryrefslogtreecommitdiff
path: root/tests/units/Notification/WebhookTest.php
blob: 7215baeb12bf4d1a4ee5f14bbc9e181f6ac5f282 (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
<?php

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

use Kanboard\Model\Config;
use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskModification;
use Kanboard\Model\Project;
use Kanboard\Model\Comment;
use Kanboard\Subscriber\NotificationSubscriber;

class WebhookTest extends Base
{
    public function testTaskCreation()
    {
        $c = new Config($this->container);
        $p = new Project($this->container);
        $tc = new TaskCreation($this->container);
        $this->container['dispatcher']->addSubscriber(new NotificationSubscriber($this->container));

        $c->save(array('webhook_url' => 'http://localhost/?task-creation'));

        $this->container['httpClient']
            ->expects($this->once())
            ->method('postJson')
            ->with($this->stringContains('http://localhost/?task-creation&token='), $this->anything());

        $this->assertEquals(1, $p->create(array('name' => 'test')));
        $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test')));
    }
}