summaryrefslogtreecommitdiff
path: root/tests/units/ActionCommentCreationTest.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-06-21 12:19:06 -0400
committerFrederic Guillot <fred@kanboard.net>2015-06-21 12:19:06 -0400
commitd7a8160c2b422dcf950093d9d17d90f1e80201de (patch)
tree51ad4b6bd086e178406ec2b6c5b29699f7917cf7 /tests/units/ActionCommentCreationTest.php
parent98fd34bfe340fae6d0fd3b7333b6f9a6647cbae2 (diff)
Update Bitbucket webhooks to handle issues/commit/comments
Diffstat (limited to 'tests/units/ActionCommentCreationTest.php')
-rw-r--r--tests/units/ActionCommentCreationTest.php83
1 files changed, 82 insertions, 1 deletions
diff --git a/tests/units/ActionCommentCreationTest.php b/tests/units/ActionCommentCreationTest.php
index 03f45f28..cf9e1e0a 100644
--- a/tests/units/ActionCommentCreationTest.php
+++ b/tests/units/ActionCommentCreationTest.php
@@ -11,6 +11,59 @@ use Integration\GithubWebhook;
class ActionCommentCreationTest extends Base
{
+ public function testWithoutRequiredParams()
+ {
+ $action = new Action\CommentCreation($this->container, 1, GithubWebhook::EVENT_ISSUE_COMMENT);
+
+ // We create a task in the first column
+ $tc = new TaskCreation($this->container);
+ $p = new Project($this->container);
+ $c = new Comment($this->container);
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
+
+ // We create an event to move the task to the 2nd column
+ $event = array(
+ 'project_id' => 1,
+ 'task_id' => 1,
+ 'user_id' => 1,
+ );
+
+ // Our event should be executed
+ $this->assertFalse($action->execute(new GenericEvent($event)));
+
+ $comment = $c->getById(1);
+ $this->assertEmpty($comment);
+ }
+
+ public function testWithCommitMessage()
+ {
+ $action = new Action\CommentCreation($this->container, 1, GithubWebhook::EVENT_ISSUE_COMMENT);
+
+ // We create a task in the first column
+ $tc = new TaskCreation($this->container);
+ $p = new Project($this->container);
+ $c = new Comment($this->container);
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
+
+ // We create an event to move the task to the 2nd column
+ $event = array(
+ 'project_id' => 1,
+ 'task_id' => 1,
+ 'commit_comment' => 'plop',
+ );
+
+ // Our event should be executed
+ $this->assertTrue($action->execute(new GenericEvent($event)));
+
+ $comment = $c->getById(1);
+ $this->assertNotEmpty($comment);
+ $this->assertEquals(1, $comment['task_id']);
+ $this->assertEquals(0, $comment['user_id']);
+ $this->assertEquals('plop', $comment['comment']);
+ }
+
public function testWithUser()
{
$action = new Action\CommentCreation($this->container, 1, GithubWebhook::EVENT_ISSUE_COMMENT);
@@ -33,11 +86,39 @@ class ActionCommentCreationTest extends Base
// Our event should be executed
$this->assertTrue($action->execute(new GenericEvent($event)));
- // Our task should be updated
$comment = $c->getById(1);
$this->assertNotEmpty($comment);
$this->assertEquals(1, $comment['task_id']);
$this->assertEquals(1, $comment['user_id']);
$this->assertEquals('youpi', $comment['comment']);
}
+
+ public function testWithNoUser()
+ {
+ $action = new Action\CommentCreation($this->container, 1, GithubWebhook::EVENT_ISSUE_COMMENT);
+
+ // We create a task in the first column
+ $tc = new TaskCreation($this->container);
+ $p = new Project($this->container);
+ $c = new Comment($this->container);
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
+
+ // We create an event to move the task to the 2nd column
+ $event = array(
+ 'project_id' => 1,
+ 'task_id' => 1,
+ 'user_id' => 0,
+ 'comment' => 'youpi',
+ );
+
+ // Our event should be executed
+ $this->assertTrue($action->execute(new GenericEvent($event)));
+
+ $comment = $c->getById(1);
+ $this->assertNotEmpty($comment);
+ $this->assertEquals(1, $comment['task_id']);
+ $this->assertEquals(0, $comment['user_id']);
+ $this->assertEquals('youpi', $comment['comment']);
+ }
}