summaryrefslogtreecommitdiff
path: root/tests/units/Core/ExternalTask/ExternalTaskManagerTest.php
blob: e6f4e0690a6921dbb7f37b019ae033c4c96dfb17 (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
<?php

use Kanboard\Core\ExternalTask\ExternalTaskManager;

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

class ExternalTaskManagerTest extends Base
{
    public function testProviderNotFound()
    {
        $this->setExpectedException('Kanboard\Core\ExternalTask\ProviderNotFoundException');

        $manager = new ExternalTaskManager();
        $manager->getProvider('foobar');
    }

    public function testRegister()
    {
        $provider = $this->getMock('Kanboard\Core\ExternalTask\ExternalTaskProviderInterface');
        $provider->expects($this->any())->method('getName')->willReturn('MyProvider');

        $manager = new ExternalTaskManager();
        $manager->register($provider);

        $this->assertInstanceOf('Kanboard\Core\ExternalTask\ExternalTaskProviderInterface', $manager->getProvider('MyProvider'));
    }

    public function testGetList()
    {
        $provider1 = $this->getMock('Kanboard\Core\ExternalTask\ExternalTaskProviderInterface');
        $provider1->expects($this->any())->method('getName')->willReturn('MyProvider1');

        $provider2 = $this->getMock('Kanboard\Core\ExternalTask\ExternalTaskProviderInterface');
        $provider2->expects($this->any())->method('getName')->willReturn('MyProvider2');

        $manager = new ExternalTaskManager();
        $manager->register($provider1);
        $manager->register($provider2);
        $providers = $manager->getProvidersList();

        $expected = array('MyProvider1' => 'MyProvider1', 'MyProvider2' => 'MyProvider2');
        $this->assertEquals($expected, $providers);
    }
}