diff options
Diffstat (limited to 'tests/units/ExternalLink/AttachmentLinkProviderTest.php')
-rw-r--r-- | tests/units/ExternalLink/AttachmentLinkProviderTest.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/units/ExternalLink/AttachmentLinkProviderTest.php b/tests/units/ExternalLink/AttachmentLinkProviderTest.php new file mode 100644 index 00000000..fe374664 --- /dev/null +++ b/tests/units/ExternalLink/AttachmentLinkProviderTest.php @@ -0,0 +1,64 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Kanboard\ExternalLink\AttachmentLinkProvider; + +class AttachmentLinkProviderTest extends Base +{ + public function testGetName() + { + $attachmentLinkProvider = new AttachmentLinkProvider($this->container); + $this->assertEquals('Attachment', $attachmentLinkProvider->getName()); + } + + public function testGetType() + { + $attachmentLinkProvider = new AttachmentLinkProvider($this->container); + $this->assertEquals('attachment', $attachmentLinkProvider->getType()); + } + + public function testGetDependencies() + { + $attachmentLinkProvider = new AttachmentLinkProvider($this->container); + $this->assertEquals(array('related' => 'Related'), $attachmentLinkProvider->getDependencies()); + } + + public function testMatch() + { + $attachmentLinkProvider = new AttachmentLinkProvider($this->container); + + $attachmentLinkProvider->setUserTextInput('http://kanboard.net/FILE.DOC'); + $this->assertTrue($attachmentLinkProvider->match()); + + $attachmentLinkProvider->setUserTextInput('http://kanboard.net/folder/document.PDF'); + $this->assertTrue($attachmentLinkProvider->match()); + + $attachmentLinkProvider->setUserTextInput('http://kanboard.net/archive.zip'); + $this->assertTrue($attachmentLinkProvider->match()); + + $attachmentLinkProvider->setUserTextInput(' https://kanboard.net/folder/archive.tar '); + $this->assertTrue($attachmentLinkProvider->match()); + + $attachmentLinkProvider->setUserTextInput('http:// invalid url'); + $this->assertFalse($attachmentLinkProvider->match()); + + $attachmentLinkProvider->setUserTextInput(''); + $this->assertFalse($attachmentLinkProvider->match()); + + $attachmentLinkProvider->setUserTextInput('http://kanboard.net/folder/document.html'); + $this->assertFalse($attachmentLinkProvider->match()); + + $attachmentLinkProvider->setUserTextInput('http://kanboard.net/folder/DOC.HTML'); + $this->assertFalse($attachmentLinkProvider->match()); + + $attachmentLinkProvider->setUserTextInput('http://kanboard.net/folder/document.do'); + $this->assertFalse($attachmentLinkProvider->match()); + } + + public function testGetLink() + { + $attachmentLinkProvider = new AttachmentLinkProvider($this->container); + $this->assertInstanceOf('\Kanboard\ExternalLink\AttachmentLink', $attachmentLinkProvider->getLink()); + } +} |