summaryrefslogtreecommitdiff
path: root/tests/units/ExternalLink/FileLinkProviderTest.php
blob: 8698e174f0eea690e98739ca9f4e615c4bce0c56 (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
48
49
50
51
52
53
54
55
56
57
58
<?php

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

use Kanboard\ExternalLink\FileLinkProvider;

class FileLinkProviderTest extends Base
{
    public function testGetName()
    {
        $attachmentLinkProvider = new FileLinkProvider($this->container);
        $this->assertEquals('Local File', $attachmentLinkProvider->getName());
    }

    public function testGetType()
    {
        $attachmentLinkProvider = new FileLinkProvider($this->container);
        $this->assertEquals('file', $attachmentLinkProvider->getType());
    }

    public function testGetDependencies()
    {
        $attachmentLinkProvider = new FileLinkProvider($this->container);
        $this->assertEquals(array('related' => 'Related'), $attachmentLinkProvider->getDependencies());
    }

    public function testMatch()
    {
        $attachmentLinkProvider = new FileLinkProvider($this->container);

        $attachmentLinkProvider->setUserTextInput('file:///tmp/test.txt');
        $this->assertTrue($attachmentLinkProvider->match());

        $attachmentLinkProvider->setUserTextInput('owncloud:///tmp/test.txt');
        $this->assertTrue($attachmentLinkProvider->match());

        $attachmentLinkProvider->setUserTextInput('notebooks:///tmp/test.txt');
        $this->assertTrue($attachmentLinkProvider->match());

        $attachmentLinkProvider->setUserTextInput('http://google.com/');
        $this->assertFalse($attachmentLinkProvider->match());

        $attachmentLinkProvider->setUserTextInput('https://google.com/');
        $this->assertFalse($attachmentLinkProvider->match());

        $attachmentLinkProvider->setUserTextInput('ftp://google.com/');
        $this->assertFalse($attachmentLinkProvider->match());

        $attachmentLinkProvider->setUserTextInput('');
        $this->assertFalse($attachmentLinkProvider->match());
    }

    public function testGetLink()
    {
        $attachmentLinkProvider = new FileLinkProvider($this->container);
        $this->assertInstanceOf('\Kanboard\ExternalLink\FileLink', $attachmentLinkProvider->getLink());
    }
}