summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/units/Model/ProjectNotificationTypeTest.php41
-rw-r--r--tests/units/Model/UserNotificationTypeTest.php2
-rw-r--r--tests/units/Notification/WebhookTest.php (renamed from tests/units/Model/WebhookTest.php)58
3 files changed, 71 insertions, 30 deletions
diff --git a/tests/units/Model/ProjectNotificationTypeTest.php b/tests/units/Model/ProjectNotificationTypeTest.php
new file mode 100644
index 00000000..d03bffe0
--- /dev/null
+++ b/tests/units/Model/ProjectNotificationTypeTest.php
@@ -0,0 +1,41 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Kanboard\Model\Project;
+use Kanboard\Model\ProjectNotificationType;
+
+class ProjectNotificationTypeTest extends Base
+{
+ public function testGetTypes()
+ {
+ $nt = new ProjectNotificationType($this->container);
+ $this->assertEmpty($nt->getTypes());
+
+ $nt->setType('foo', 'Foo', 'Something1');
+ $nt->setType('bar', 'Bar', 'Something2');
+ $nt->setType('baz', 'Baz', 'Something3', true);
+
+ $this->assertEquals(array('bar' => 'Bar', 'foo' => 'Foo'), $nt->getTypes());
+ $this->assertEquals(array('baz'), $nt->getHiddenTypes());
+ }
+
+ public function testGetSelectedTypes()
+ {
+ $nt = new ProjectNotificationType($this->container);
+ $p = new Project($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
+
+ // No type defined
+ $this->assertEmpty($nt->getSelectedTypes(1));
+
+ // Hidden type
+ $nt->setType('baz', 'Baz', 'Something3', true);
+ $this->assertEquals(array('baz'), $nt->getSelectedTypes(1));
+
+ // User defined types
+ $this->assertTrue($nt->saveSelectedTypes(1, array('foo', 'bar')));
+ $this->assertEquals(array('baz', 'bar', 'foo'), $nt->getSelectedTypes(1));
+ }
+}
diff --git a/tests/units/Model/UserNotificationTypeTest.php b/tests/units/Model/UserNotificationTypeTest.php
index a0a1491d..6982e890 100644
--- a/tests/units/Model/UserNotificationTypeTest.php
+++ b/tests/units/Model/UserNotificationTypeTest.php
@@ -16,7 +16,7 @@ class UserNotificationTypeTest extends Base
$this->assertEquals(array('email' => 'Email', 'web' => 'Web'), $nt->getTypes());
}
- public function testGetUserNotificationTypes()
+ public function testGetSelectedTypes()
{
$nt = new UserNotificationType($this->container);
$types = $nt->getSelectedTypes(1);
diff --git a/tests/units/Model/WebhookTest.php b/tests/units/Notification/WebhookTest.php
index 39819ba7..b55cd6e2 100644
--- a/tests/units/Model/WebhookTest.php
+++ b/tests/units/Notification/WebhookTest.php
@@ -8,7 +8,7 @@ use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskModification;
use Kanboard\Model\Project;
use Kanboard\Model\Comment;
-use Kanboard\Subscriber\WebhookSubscriber;
+use Kanboard\Subscriber\NotificationSubscriber;
class WebhookTest extends Base
{
@@ -17,7 +17,7 @@ class WebhookTest extends Base
$c = new Config($this->container);
$p = new Project($this->container);
$tc = new TaskCreation($this->container);
- $this->container['dispatcher']->addSubscriber(new WebhookSubscriber($this->container));
+ $this->container['dispatcher']->addSubscriber(new NotificationSubscriber($this->container));
$c->save(array('webhook_url' => 'http://localhost/?task-creation'));
@@ -33,16 +33,16 @@ class WebhookTest extends Base
$this->assertEquals('task.create', $event['event_name']);
$this->assertNotEmpty($event['event_data']);
- $this->assertArrayHasKey('project_id', $event['event_data']);
- $this->assertArrayHasKey('task_id', $event['event_data']);
- $this->assertArrayHasKey('title', $event['event_data']);
- $this->assertArrayHasKey('column_id', $event['event_data']);
- $this->assertArrayHasKey('color_id', $event['event_data']);
- $this->assertArrayHasKey('swimlane_id', $event['event_data']);
- $this->assertArrayHasKey('date_creation', $event['event_data']);
- $this->assertArrayHasKey('date_modification', $event['event_data']);
- $this->assertArrayHasKey('date_moved', $event['event_data']);
- $this->assertArrayHasKey('position', $event['event_data']);
+ $this->assertArrayHasKey('project_id', $event['event_data']['task']);
+ $this->assertArrayHasKey('id', $event['event_data']['task']);
+ $this->assertArrayHasKey('title', $event['event_data']['task']);
+ $this->assertArrayHasKey('column_id', $event['event_data']['task']);
+ $this->assertArrayHasKey('color_id', $event['event_data']['task']);
+ $this->assertArrayHasKey('swimlane_id', $event['event_data']['task']);
+ $this->assertArrayHasKey('date_creation', $event['event_data']['task']);
+ $this->assertArrayHasKey('date_modification', $event['event_data']['task']);
+ $this->assertArrayHasKey('date_moved', $event['event_data']['task']);
+ $this->assertArrayHasKey('position', $event['event_data']['task']);
}
public function testTaskModification()
@@ -51,7 +51,7 @@ class WebhookTest extends Base
$p = new Project($this->container);
$tc = new TaskCreation($this->container);
$tm = new TaskModification($this->container);
- $this->container['dispatcher']->addSubscriber(new WebhookSubscriber($this->container));
+ $this->container['dispatcher']->addSubscriber(new NotificationSubscriber($this->container));
$c->save(array('webhook_url' => 'http://localhost/modif/'));
@@ -68,16 +68,16 @@ class WebhookTest extends Base
$this->assertEquals('task.update', $event['event_name']);
$this->assertNotEmpty($event['event_data']);
- $this->assertArrayHasKey('project_id', $event['event_data']);
- $this->assertArrayHasKey('task_id', $event['event_data']);
- $this->assertArrayHasKey('title', $event['event_data']);
- $this->assertArrayHasKey('column_id', $event['event_data']);
- $this->assertArrayHasKey('color_id', $event['event_data']);
- $this->assertArrayHasKey('swimlane_id', $event['event_data']);
- $this->assertArrayHasKey('date_creation', $event['event_data']);
- $this->assertArrayHasKey('date_modification', $event['event_data']);
- $this->assertArrayHasKey('date_moved', $event['event_data']);
- $this->assertArrayHasKey('position', $event['event_data']);
+ $this->assertArrayHasKey('project_id', $event['event_data']['task']);
+ $this->assertArrayHasKey('id', $event['event_data']['task']);
+ $this->assertArrayHasKey('title', $event['event_data']['task']);
+ $this->assertArrayHasKey('column_id', $event['event_data']['task']);
+ $this->assertArrayHasKey('color_id', $event['event_data']['task']);
+ $this->assertArrayHasKey('swimlane_id', $event['event_data']['task']);
+ $this->assertArrayHasKey('date_creation', $event['event_data']['task']);
+ $this->assertArrayHasKey('date_modification', $event['event_data']['task']);
+ $this->assertArrayHasKey('date_moved', $event['event_data']['task']);
+ $this->assertArrayHasKey('position', $event['event_data']['task']);
}
public function testCommentCreation()
@@ -86,7 +86,7 @@ class WebhookTest extends Base
$p = new Project($this->container);
$tc = new TaskCreation($this->container);
$cm = new Comment($this->container);
- $this->container['dispatcher']->addSubscriber(new WebhookSubscriber($this->container));
+ $this->container['dispatcher']->addSubscriber(new NotificationSubscriber($this->container));
$c->save(array('webhook_url' => 'http://localhost/comment'));
@@ -103,10 +103,10 @@ class WebhookTest extends Base
$this->assertEquals('comment.create', $event['event_name']);
$this->assertNotEmpty($event['event_data']);
- $this->assertArrayHasKey('task_id', $event['event_data']);
- $this->assertArrayHasKey('user_id', $event['event_data']);
- $this->assertArrayHasKey('comment', $event['event_data']);
- $this->assertArrayHasKey('id', $event['event_data']);
- $this->assertEquals('test comment', $event['event_data']['comment']);
+ $this->assertArrayHasKey('task_id', $event['event_data']['comment']);
+ $this->assertArrayHasKey('user_id', $event['event_data']['comment']);
+ $this->assertArrayHasKey('comment', $event['event_data']['comment']);
+ $this->assertArrayHasKey('id', $event['event_data']['comment']);
+ $this->assertEquals('test comment', $event['event_data']['comment']['comment']);
}
}