Added local file link provider
This commit is contained in:
43
tests/units/ExternalLink/FileLinkProviderTest.php
Normal file
43
tests/units/ExternalLink/FileLinkProviderTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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('');
|
||||
$this->assertFalse($attachmentLinkProvider->match());
|
||||
}
|
||||
|
||||
public function testGetLink()
|
||||
{
|
||||
$attachmentLinkProvider = new FileLinkProvider($this->container);
|
||||
$this->assertInstanceOf('\Kanboard\ExternalLink\FileLink', $attachmentLinkProvider->getLink());
|
||||
}
|
||||
}
|
||||
28
tests/units/ExternalLink/FileLinkTest.php
Normal file
28
tests/units/ExternalLink/FileLinkTest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../Base.php';
|
||||
|
||||
use Kanboard\ExternalLink\FileLink;
|
||||
|
||||
class FileLinkTest extends Base
|
||||
{
|
||||
public function testGetTitleFromUrlWithUnixPath()
|
||||
{
|
||||
$url = 'file:///tmp/test.txt';
|
||||
|
||||
$link = new FileLink($this->container);
|
||||
$link->setUrl($url);
|
||||
$this->assertEquals($url, $link->getUrl());
|
||||
$this->assertEquals('test.txt', $link->getTitle());
|
||||
}
|
||||
|
||||
public function testGetTitleFromUrlWithWindowsPath()
|
||||
{
|
||||
$url = 'file:///c:\temp\test.txt';
|
||||
|
||||
$link = new FileLink($this->container);
|
||||
$link->setUrl($url);
|
||||
$this->assertEquals($url, $link->getUrl());
|
||||
$this->assertEquals('test.txt', $link->getTitle());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user