summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-03-17 21:52:40 -0400
committerFrederic Guillot <fred@kanboard.net>2016-03-17 21:52:40 -0400
commite3e08d0e3436e3cf2f951321861e1a274cc2ebbd (patch)
tree1f9586d3fea3cb14a2ade8e5fc6da24df2f212f2 /tests
parent18d203225ba31e51155055d406a811a9cfba599a (diff)
Added local file link provider
Diffstat (limited to 'tests')
-rw-r--r--tests/units/ExternalLink/FileLinkProviderTest.php43
-rw-r--r--tests/units/ExternalLink/FileLinkTest.php28
2 files changed, 71 insertions, 0 deletions
diff --git a/tests/units/ExternalLink/FileLinkProviderTest.php b/tests/units/ExternalLink/FileLinkProviderTest.php
new file mode 100644
index 00000000..8cef82f8
--- /dev/null
+++ b/tests/units/ExternalLink/FileLinkProviderTest.php
@@ -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());
+ }
+}
diff --git a/tests/units/ExternalLink/FileLinkTest.php b/tests/units/ExternalLink/FileLinkTest.php
new file mode 100644
index 00000000..b83000cd
--- /dev/null
+++ b/tests/units/ExternalLink/FileLinkTest.php
@@ -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());
+ }
+}