summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Core/Csv.php2
-rw-r--r--app/Model/NotificationType.php36
-rw-r--r--app/Model/OverdueNotification.php2
-rw-r--r--app/Model/ProjectNotification.php29
-rw-r--r--app/Model/ProjectNotificationType.php57
-rw-r--r--app/Model/Webhook.php34
-rw-r--r--app/Notification/Webhook.php55
-rw-r--r--app/Schema/Mysql.php16
-rw-r--r--app/Schema/Postgres.php15
-rw-r--r--app/Schema/Sqlite.php15
-rw-r--r--app/ServiceProvider/ClassProvider.php15
-rw-r--r--app/ServiceProvider/EventDispatcherProvider.php2
-rw-r--r--app/Subscriber/NotificationSubscriber.php12
-rw-r--r--app/Subscriber/ProjectActivitySubscriber.php4
-rw-r--r--app/Subscriber/WebhookSubscriber.php45
-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
18 files changed, 311 insertions, 129 deletions
diff --git a/app/Core/Csv.php b/app/Core/Csv.php
index 7c6a4620..bec400ed 100644
--- a/app/Core/Csv.php
+++ b/app/Core/Csv.php
@@ -131,7 +131,7 @@ class Csv
*
* @access public
* @param string $filename
- * @param \Closure $callback Example: function(array $row, $line_number)
+ * @param callable $callback Example: function(array $row, $line_number)
* @return Csv
*/
public function read($filename, $callback)
diff --git a/app/Model/NotificationType.php b/app/Model/NotificationType.php
index 50d6080f..e05cc686 100644
--- a/app/Model/NotificationType.php
+++ b/app/Model/NotificationType.php
@@ -13,7 +13,7 @@ use Pimple\Container;
abstract class NotificationType extends Base
{
/**
- * Mail transport instances
+ * Container
*
* @access private
* @var \Pimple\Container
@@ -21,7 +21,7 @@ abstract class NotificationType extends Base
private $classes;
/**
- * Mail transport instances
+ * Notification type labels
*
* @access private
* @var array
@@ -29,6 +29,14 @@ abstract class NotificationType extends Base
private $labels = array();
/**
+ * Hidden notification types
+ *
+ * @access private
+ * @var array
+ */
+ private $hiddens = array();
+
+ /**
* Constructor
*
* @access public
@@ -47,15 +55,24 @@ abstract class NotificationType extends Base
* @param string $type
* @param string $label
* @param string $class
+ * @param boolean $hidden
+ * @return NotificationType
*/
- public function setType($type, $label, $class)
+ public function setType($type, $label, $class, $hidden = false)
{
$container = $this->container;
- $this->labels[$type] = $label;
+
+ if ($hidden) {
+ $this->hiddens[] = $type;
+ } else {
+ $this->labels[$type] = $label;
+ }
$this->classes[$type] = function () use ($class, $container) {
return new $class($container);
};
+
+ return $this;
}
/**
@@ -80,4 +97,15 @@ abstract class NotificationType extends Base
{
return $this->labels;
}
+
+ /**
+ * Get all hidden notification types
+ *
+ * @access public
+ * @return array
+ */
+ public function getHiddenTypes()
+ {
+ return $this->hiddens;
+ }
}
diff --git a/app/Model/OverdueNotification.php b/app/Model/OverdueNotification.php
index d8c2fef4..84565548 100644
--- a/app/Model/OverdueNotification.php
+++ b/app/Model/OverdueNotification.php
@@ -20,8 +20,6 @@ class OverdueNotification extends Base
$tasks = $this->taskFinder->getOverdueTasks();
foreach ($this->groupByColumn($tasks, 'project_id') as $project_id => $project_tasks) {
-
- // Get the list of users that should receive notifications for each projects
$users = $this->userNotification->getUsersWithNotificationEnabled($project_id);
foreach ($users as $user) {
diff --git a/app/Model/ProjectNotification.php b/app/Model/ProjectNotification.php
new file mode 100644
index 00000000..49fcc61d
--- /dev/null
+++ b/app/Model/ProjectNotification.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Kanboard\Model;
+
+/**
+ * Project Notification
+ *
+ * @package model
+ * @author Frederic Guillot
+ */
+class ProjectNotification extends Base
+{
+ /**
+ * Send notifications
+ *
+ * @access public
+ * @param integer $project_id
+ * @param string $event_name
+ * @param array $event_data
+ */
+ public function sendNotifications($project_id, $event_name, array $event_data)
+ {
+ $project = $this->project->getById($project_id);
+
+ foreach ($this->projectNotificationType->getSelectedTypes($project_id) as $type) {
+ $this->projectNotificationType->getType($type)->notifyProject($project, $event_name, $event_data);
+ }
+ }
+}
diff --git a/app/Model/ProjectNotificationType.php b/app/Model/ProjectNotificationType.php
new file mode 100644
index 00000000..d8568589
--- /dev/null
+++ b/app/Model/ProjectNotificationType.php
@@ -0,0 +1,57 @@
+<?php
+
+namespace Kanboard\Model;
+
+/**
+ * Project Notification Type
+ *
+ * @package model
+ * @author Frederic Guillot
+ */
+class ProjectNotificationType extends NotificationType
+{
+ /**
+ * SQL table name
+ *
+ * @var string
+ */
+ const TABLE = 'project_has_notification_types';
+
+ /**
+ * Get selected notification types for a given project
+ *
+ * @access public
+ * @param integer $project_id
+ * @return array
+ */
+ public function getSelectedTypes($project_id)
+ {
+ $selectedTypes = $this->db
+ ->table(self::TABLE)
+ ->eq('project_id', $project_id)
+ ->asc('notification_type')
+ ->findAllByColumn('notification_type');
+
+ return array_merge($this->getHiddenTypes(), $selectedTypes);
+ }
+
+ /**
+ * Save notification types for a given project
+ *
+ * @access public
+ * @param integer $project_id
+ * @param string[] $types
+ * @return boolean
+ */
+ public function saveSelectedTypes($project_id, array $types)
+ {
+ $results = array();
+ $this->db->table(self::TABLE)->eq('project_id', $project_id)->remove();
+
+ foreach ($types as $type) {
+ $results[] = $this->db->table(self::TABLE)->insert(array('project_id' => $project_id, 'notification_type' => $type));
+ }
+
+ return ! in_array(false, $results);
+ }
+}
diff --git a/app/Model/Webhook.php b/app/Model/Webhook.php
deleted file mode 100644
index 7c17e61e..00000000
--- a/app/Model/Webhook.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-namespace Kanboard\Model;
-
-/**
- * Webhook model
- *
- * @package model
- * @author Frederic Guillot
- */
-class Webhook extends Base
-{
- /**
- * Call the external URL
- *
- * @access public
- * @param array $values Event payload
- */
- public function notify(array $values)
- {
- $url = $this->config->get('webhook_url');
- $token = $this->config->get('webhook_token');
-
- if (! empty($url)) {
- if (strpos($url, '?') !== false) {
- $url .= '&token='.$token;
- } else {
- $url .= '?token='.$token;
- }
-
- return $this->httpClient->postJson($url, $values);
- }
- }
-}
diff --git a/app/Notification/Webhook.php b/app/Notification/Webhook.php
new file mode 100644
index 00000000..feeee5d6
--- /dev/null
+++ b/app/Notification/Webhook.php
@@ -0,0 +1,55 @@
+<?php
+
+namespace Kanboard\Notification;
+
+use Kanboard\Core\Base;
+
+/**
+ * Webhook Notification
+ *
+ * @package notification
+ * @author Frederic Guillot
+ */
+class Webhook extends Base implements NotificationInterface
+{
+ /**
+ * Send notification to a user
+ *
+ * @access public
+ * @param array $user
+ * @param string $event_name
+ * @param array $event_data
+ */
+ public function notifyUser(array $user, $event_name, array $event_data)
+ {
+ }
+
+ /**
+ * Send notification to a project
+ *
+ * @access public
+ * @param array $project
+ * @param string $event_name
+ * @param array $event_data
+ */
+ public function notifyProject(array $project, $event_name, array $event_data)
+ {
+ $url = $this->config->get('webhook_url');
+ $token = $this->config->get('webhook_token');
+
+ if (! empty($url)) {
+ if (strpos($url, '?') !== false) {
+ $url .= '&token='.$token;
+ } else {
+ $url .= '?token='.$token;
+ }
+
+ $payload = array(
+ 'event_name' => $event_name,
+ 'event_data' => $event_data,
+ );
+
+ return $this->httpClient->postJson($url, $payload);
+ }
+ }
+}
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index edf63919..852dca92 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -6,7 +6,21 @@ use PDO;
use Kanboard\Core\Security;
use Kanboard\Model\Link;
-const VERSION = 91;
+const VERSION = 92;
+
+function version_92($pdo)
+{
+ $pdo->exec("
+ CREATE TABLE project_has_notification_types (
+ id INT NOT NULL AUTO_INCREMENT,
+ project_id INT NOT NULL,
+ notification_type VARCHAR(50),
+ PRIMARY KEY(id),
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE
+ UNIQUE(project_id, notification_type),
+ ) ENGINE=InnoDB CHARSET=utf8
+ ");
+}
function version_91($pdo)
{
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index 0cc31616..ac8b15ee 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -6,7 +6,20 @@ use PDO;
use Kanboard\Core\Security;
use Kanboard\Model\Link;
-const VERSION = 71;
+const VERSION = 72;
+
+function version_72($pdo)
+{
+ $pdo->exec("
+ CREATE TABLE project_has_notification_types (
+ id SERIAL PRIMARY KEY,
+ project_id INTEGER NOT NULL,
+ notification_type VARCHAR(50),
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ UNIQUE(project_id, notification_type)
+ )
+ ");
+}
function version_71($pdo)
{
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index 70b9d160..a1d5ee86 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -6,7 +6,20 @@ use Kanboard\Core\Security;
use PDO;
use Kanboard\Model\Link;
-const VERSION = 86;
+const VERSION = 87;
+
+function version_87($pdo)
+{
+ $pdo->exec("
+ CREATE TABLE project_has_notification_types (
+ id INTEGER PRIMARY KEY,
+ project_id INTEGER NOT NULL,
+ notification_type TEXT,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ UNIQUE(project_id, notification_type)
+ )
+ ");
+}
function version_86($pdo)
{
diff --git a/app/ServiceProvider/ClassProvider.php b/app/ServiceProvider/ClassProvider.php
index dde3cf10..182ecf26 100644
--- a/app/ServiceProvider/ClassProvider.php
+++ b/app/ServiceProvider/ClassProvider.php
@@ -2,6 +2,9 @@
namespace Kanboard\ServiceProvider;
+use Pimple\Container;
+use Pimple\ServiceProviderInterface;
+use League\HTMLToMarkdown\HtmlConverter;
use Kanboard\Core\Plugin\Loader;
use Kanboard\Core\Mail\Client as EmailClient;
use Kanboard\Core\ObjectStorage\FileStorage;
@@ -9,9 +12,7 @@ use Kanboard\Core\Paginator;
use Kanboard\Core\OAuth2;
use Kanboard\Core\Tool;
use Kanboard\Model\UserNotificationType;
-use Pimple\Container;
-use Pimple\ServiceProviderInterface;
-use League\HTMLToMarkdown\HtmlConverter;
+use Kanboard\Model\ProjectNotificationType;
class ClassProvider implements ServiceProviderInterface
{
@@ -39,6 +40,7 @@ class ClassProvider implements ServiceProviderInterface
'ProjectDailyStats',
'ProjectIntegration',
'ProjectPermission',
+ 'ProjectNotification',
'Subtask',
'SubtaskExport',
'SubtaskTimeTracking',
@@ -65,7 +67,6 @@ class ClassProvider implements ServiceProviderInterface
'UserNotificationType',
'UserNotificationFilter',
'UserUnreadNotification',
- 'Webhook',
),
'Formatter' => array(
'TaskFilterGanttFormatter',
@@ -135,6 +136,12 @@ class ClassProvider implements ServiceProviderInterface
return $type;
};
+ $container['projectNotificationType'] = function ($container) {
+ $type = new ProjectNotificationType($container);
+ $type->setType('webhook', t('Webhook'), '\Kanboard\Notification\Webhook', true);
+ return $type;
+ };
+
$container['pluginLoader'] = new Loader($container);
$container['cspRules'] = array('style-src' => "'self' 'unsafe-inline'", 'img-src' => '* data:');
diff --git a/app/ServiceProvider/EventDispatcherProvider.php b/app/ServiceProvider/EventDispatcherProvider.php
index 353d607b..3c9404d0 100644
--- a/app/ServiceProvider/EventDispatcherProvider.php
+++ b/app/ServiceProvider/EventDispatcherProvider.php
@@ -11,7 +11,6 @@ use Kanboard\Subscriber\NotificationSubscriber;
use Kanboard\Subscriber\ProjectActivitySubscriber;
use Kanboard\Subscriber\ProjectDailySummarySubscriber;
use Kanboard\Subscriber\ProjectModificationDateSubscriber;
-use Kanboard\Subscriber\WebhookSubscriber;
use Kanboard\Subscriber\SubtaskTimeTrackingSubscriber;
use Kanboard\Subscriber\TaskMovedDateSubscriber;
use Kanboard\Subscriber\TransitionSubscriber;
@@ -27,7 +26,6 @@ class EventDispatcherProvider implements ServiceProviderInterface
$container['dispatcher']->addSubscriber(new ProjectActivitySubscriber($container));
$container['dispatcher']->addSubscriber(new ProjectDailySummarySubscriber($container));
$container['dispatcher']->addSubscriber(new ProjectModificationDateSubscriber($container));
- $container['dispatcher']->addSubscriber(new WebhookSubscriber($container));
$container['dispatcher']->addSubscriber(new NotificationSubscriber($container));
$container['dispatcher']->addSubscriber(new SubtaskTimeTrackingSubscriber($container));
$container['dispatcher']->addSubscriber(new TaskMovedDateSubscriber($container));
diff --git a/app/Subscriber/NotificationSubscriber.php b/app/Subscriber/NotificationSubscriber.php
index 07ce00a1..394573e4 100644
--- a/app/Subscriber/NotificationSubscriber.php
+++ b/app/Subscriber/NotificationSubscriber.php
@@ -32,17 +32,25 @@ class NotificationSubscriber extends \Kanboard\Core\Base implements EventSubscri
public function execute(GenericEvent $event, $event_name)
{
- $this->userNotification->sendNotifications($event_name, $this->getEventData($event));
+ $event_data = $this->getEventData($event);
+
+ if (! empty($event_data)) {
+ $this->userNotification->sendNotifications($event_name, $event_data);
+ $this->projectNotification->sendNotifications($event_data['task']['project_id'], $event_name, $event_data);
+ }
}
public function getEventData(GenericEvent $event)
{
$values = array();
+ if (! empty($event['changes'])) {
+ $values['changes'] = $event['changes'];
+ }
+
switch (get_class($event)) {
case 'Kanboard\Event\TaskEvent':
$values['task'] = $this->taskFinder->getDetails($event['task_id']);
- $values['changes'] = isset($event['changes']) ? $event['changes'] : array();
break;
case 'Kanboard\Event\SubtaskEvent':
$values['subtask'] = $this->subtask->getById($event['id'], true);
diff --git a/app/Subscriber/ProjectActivitySubscriber.php b/app/Subscriber/ProjectActivitySubscriber.php
index a66bbc5a..a49a00ed 100644
--- a/app/Subscriber/ProjectActivitySubscriber.php
+++ b/app/Subscriber/ProjectActivitySubscriber.php
@@ -61,10 +61,10 @@ class ProjectActivitySubscriber extends \Kanboard\Core\Base implements EventSubs
$values['changes'] = isset($event['changes']) ? $event['changes'] : array();
switch (get_class($event)) {
- case 'Event\SubtaskEvent':
+ case 'Kanboard\Event\SubtaskEvent':
$values['subtask'] = $this->subtask->getById($event['id'], true);
break;
- case 'Event\CommentEvent':
+ case 'Kanboard\Event\CommentEvent':
$values['comment'] = $this->comment->getById($event['id']);
break;
}
diff --git a/app/Subscriber/WebhookSubscriber.php b/app/Subscriber/WebhookSubscriber.php
deleted file mode 100644
index 8a2bd080..00000000
--- a/app/Subscriber/WebhookSubscriber.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-namespace Kanboard\Subscriber;
-
-use Kanboard\Event\CommentEvent;
-use Kanboard\Event\GenericEvent;
-use Kanboard\Event\TaskEvent;
-use Kanboard\Model\Comment;
-use Kanboard\Model\Task;
-use Kanboard\Model\File;
-use Kanboard\Model\Subtask;
-use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-
-class WebhookSubscriber extends \Kanboard\Core\Base implements EventSubscriberInterface
-{
- public static function getSubscribedEvents()
- {
- return array(
- Task::EVENT_CREATE => array('execute', 0),
- Task::EVENT_UPDATE => array('execute', 0),
- Task::EVENT_CLOSE => array('execute', 0),
- Task::EVENT_OPEN => array('execute', 0),
- Task::EVENT_MOVE_COLUMN => array('execute', 0),
- Task::EVENT_MOVE_POSITION => array('execute', 0),
- Task::EVENT_ASSIGNEE_CHANGE => array('execute', 0),
- Task::EVENT_MOVE_PROJECT => array('execute', 0),
- Task::EVENT_MOVE_SWIMLANE => array('execute', 0),
- Comment::EVENT_CREATE => array('execute', 0),
- Comment::EVENT_UPDATE => array('execute', 0),
- File::EVENT_CREATE => array('execute', 0),
- Subtask::EVENT_CREATE => array('execute', 0),
- Subtask::EVENT_UPDATE => array('execute', 0),
- );
- }
-
- public function execute(GenericEvent $event, $event_name)
- {
- $payload = array(
- 'event_name' => $event_name,
- 'event_data' => $event->getAll(),
- );
-
- $this->webhook->notify($payload);
- }
-}
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']);
}
}