summaryrefslogtreecommitdiff
path: root/tests/units/EventBuilder
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-07-17 17:15:14 -0400
committerFrederic Guillot <fred@kanboard.net>2016-07-17 17:15:14 -0400
commitec0ecc5b0387924f061865f4ec12dbfc5b7018fe (patch)
tree146fe907e300fa88587b621aaf53a9ca05e8c2d8 /tests/units/EventBuilder
parent3aa0f8574898876518dddf29ced43dd32efa2375 (diff)
Added event for removed comments with some refactoring
Diffstat (limited to 'tests/units/EventBuilder')
-rw-r--r--tests/units/EventBuilder/CommentEventBuilderTest.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/units/EventBuilder/CommentEventBuilderTest.php b/tests/units/EventBuilder/CommentEventBuilderTest.php
new file mode 100644
index 00000000..a490799e
--- /dev/null
+++ b/tests/units/EventBuilder/CommentEventBuilderTest.php
@@ -0,0 +1,37 @@
+<?php
+
+use Kanboard\EventBuilder\CommentEventBuilder;
+use Kanboard\Model\CommentModel;
+use Kanboard\Model\ProjectModel;
+use Kanboard\Model\TaskCreationModel;
+
+require_once __DIR__.'/../Base.php';
+
+class CommentEventBuilderTest extends Base
+{
+ public function testWithMissingComment()
+ {
+ $commentEventBuilder = new CommentEventBuilder($this->container);
+ $commentEventBuilder->withCommentId(42);
+ $this->assertNull($commentEventBuilder->build());
+ }
+
+ public function testBuild()
+ {
+ $commentModel = new CommentModel($this->container);
+ $taskCreationModel = new TaskCreationModel($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $commentEventBuilder = new CommentEventBuilder($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1)));
+ $this->assertEquals(1, $commentModel->create(array('task_id' => 1, 'comment' => 'bla bla', 'user_id' => 1)));
+
+ $commentEventBuilder->withCommentId(1);
+ $event = $commentEventBuilder->build();
+
+ $this->assertInstanceOf('Kanboard\Event\CommentEvent', $event);
+ $this->assertNotEmpty($event['comment']);
+ $this->assertNotEmpty($event['task']);
+ }
+}