summaryrefslogtreecommitdiff
path: root/tests/integration/TaskExternalLinkProcedureTest.php
diff options
context:
space:
mode:
authorJLGC @monolinux <monolinux@junglacode.org>2016-08-15 23:13:16 -0500
committerJLGC @monolinux <monolinux@junglacode.org>2016-08-15 23:13:16 -0500
commit683c0464093f6a7976236c68653c2a2cc5dae280 (patch)
treebf176ecd82415cc4952eea071b7d264dd5fd68b4 /tests/integration/TaskExternalLinkProcedureTest.php
parentb1e795fc5b45369f7b9b565b1e106d2673361977 (diff)
parent5f82a942c0011bf91947b2c1d627c0907bda0c92 (diff)
Merge https://github.com/kanboard/kanboard
Diffstat (limited to 'tests/integration/TaskExternalLinkProcedureTest.php')
-rw-r--r--tests/integration/TaskExternalLinkProcedureTest.php98
1 files changed, 98 insertions, 0 deletions
diff --git a/tests/integration/TaskExternalLinkProcedureTest.php b/tests/integration/TaskExternalLinkProcedureTest.php
new file mode 100644
index 00000000..47ff53ad
--- /dev/null
+++ b/tests/integration/TaskExternalLinkProcedureTest.php
@@ -0,0 +1,98 @@
+<?php
+
+require_once __DIR__.'/BaseProcedureTest.php';
+
+class TaskExternalLinkProcedureTest extends BaseProcedureTest
+{
+ protected $projectName = 'My project to test external links';
+ private $linkId = 0;
+
+ public function testAll()
+ {
+ $this->assertCreateTeamProject();
+ $this->assertCreateTask();
+ $this->assertGetExternalTaskLinkTypes();
+ $this->assertGetExternalTaskLinkProviderDependencies();
+ $this->assertGetExternalTaskLinkProviderDependenciesWithProviderNotFound();
+ $this->assertCreateExternalTaskLink();
+ $this->assertUpdateExternalTaskLink();
+ $this->assertGetAllExternalTaskLinks();
+ $this->assertRemoveExternalTaskLink();
+ }
+
+ public function assertGetExternalTaskLinkTypes()
+ {
+ $expected = array(
+ 'auto' => 'Auto',
+ 'attachment' => 'Attachment',
+ 'file' => 'Local File',
+ 'weblink' => 'Web Link',
+ );
+
+ $types = $this->app->getExternalTaskLinkTypes();
+ $this->assertEquals($expected, $types);
+ }
+
+ public function assertGetExternalTaskLinkProviderDependencies()
+ {
+ $expected = array(
+ 'related' => 'Related',
+ );
+
+ $dependencies = $this->app->getExternalTaskLinkProviderDependencies('weblink');
+
+ $this->assertEquals($expected, $dependencies);
+ }
+
+ public function assertGetExternalTaskLinkProviderDependenciesWithProviderNotFound()
+ {
+ $this->assertFalse($this->app->getExternalTaskLinkProviderDependencies('foobar'));
+ }
+
+ public function assertCreateExternalTaskLink()
+ {
+ $url = 'http://localhost/document.pdf';
+ $this->linkId = $this->app->createExternalTaskLink($this->taskId, $url, 'related', 'attachment');
+ $this->assertNotFalse($this->linkId);
+
+ $link = $this->app->getExternalTaskLinkById($this->taskId, $this->linkId);
+ $this->assertEquals($this->linkId, $link['id']);
+ $this->assertEquals($this->taskId, $link['task_id']);
+ $this->assertEquals('document.pdf', $link['title']);
+ $this->assertEquals($url, $link['url']);
+ $this->assertEquals('related', $link['dependency']);
+ $this->assertEquals(0, $link['creator_id']);
+ }
+
+ public function assertUpdateExternalTaskLink()
+ {
+ $this->assertTrue($this->app->updateExternalTaskLink(array(
+ 'task_id' => $this->taskId,
+ 'link_id' => $this->linkId,
+ 'title' => 'New title',
+ )));
+
+ $link = $this->app->getExternalTaskLinkById($this->taskId, $this->linkId);
+ $this->assertEquals($this->linkId, $link['id']);
+ $this->assertEquals($this->taskId, $link['task_id']);
+ $this->assertEquals('New title', $link['title']);
+ $this->assertEquals('related', $link['dependency']);
+ $this->assertEquals(0, $link['creator_id']);
+ }
+
+ public function assertGetAllExternalTaskLinks()
+ {
+ $links = $this->app->getAllExternalTaskLinks($this->taskId);
+ $this->assertCount(1, $links);
+ $this->assertEquals($this->linkId, $links[0]['id']);
+ $this->assertEquals($this->taskId, $links[0]['task_id']);
+ $this->assertEquals('New title', $links[0]['title']);
+ $this->assertEquals('related', $links[0]['dependency']);
+ $this->assertEquals(0, $links[0]['creator_id']);
+ }
+
+ public function assertRemoveExternalTaskLink()
+ {
+ $this->assertTrue($this->app->removeExternalTaskLink($this->taskId, $this->linkId));
+ }
+}