summaryrefslogtreecommitdiff
path: root/tests/units/Formatter
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-12-03 12:56:12 -0500
committerFrederic Guillot <fred@kanboard.net>2016-12-03 12:56:12 -0500
commit23d862aef8891130bc7eaeaa25513a9895b44c95 (patch)
tree85331881d6d36e3e358e3b6eb02ec32cf451648e /tests/units/Formatter
parent4b22db5400cc5b30696560cd4fc5e44ec845168c (diff)
Add suggest menu for task ID
Diffstat (limited to 'tests/units/Formatter')
-rw-r--r--tests/units/Formatter/TaskSuggestMenuFormatterTest.php39
-rw-r--r--tests/units/Formatter/UserMentionFormatterTest.php42
2 files changed, 81 insertions, 0 deletions
diff --git a/tests/units/Formatter/TaskSuggestMenuFormatterTest.php b/tests/units/Formatter/TaskSuggestMenuFormatterTest.php
new file mode 100644
index 00000000..d247d670
--- /dev/null
+++ b/tests/units/Formatter/TaskSuggestMenuFormatterTest.php
@@ -0,0 +1,39 @@
+<?php
+
+use Kanboard\Formatter\TaskSuggestMenuFormatter;
+use Kanboard\Model\ProjectModel;
+use Kanboard\Model\TaskCreationModel;
+
+require_once __DIR__.'/../Base.php';
+
+class TaskSuggestMenuFormatterTest extends Base
+{
+ public function testFormat()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $taskCreationModel = new TaskCreationModel($this->container);
+ $taskSuggestMenuFormatter = new TaskSuggestMenuFormatter($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'My Project')));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task 1', 'project_id' => 1)));
+ $this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task 2', 'project_id' => 1)));
+
+ $result = $taskSuggestMenuFormatter
+ ->withQuery($this->container['taskFinderModel']->getExtendedQuery())
+ ->format()
+ ;
+
+ $expected = array(
+ array(
+ 'value' => '1',
+ 'html' => '#1 Task 1 <small>My Project</small>',
+ ),
+ array(
+ 'value' => '2',
+ 'html' => '#2 Task 2 <small>My Project</small>',
+ ),
+ );
+
+ $this->assertSame($expected, $result);
+ }
+}
diff --git a/tests/units/Formatter/UserMentionFormatterTest.php b/tests/units/Formatter/UserMentionFormatterTest.php
new file mode 100644
index 00000000..6338e80f
--- /dev/null
+++ b/tests/units/Formatter/UserMentionFormatterTest.php
@@ -0,0 +1,42 @@
+<?php
+
+use Kanboard\Formatter\UserMentionFormatter;
+
+require_once __DIR__.'/../Base.php';
+
+class UserMentionFormatterTest extends Base
+{
+ public function testFormat()
+ {
+ $userMentionFormatter = new UserMentionFormatter($this->container);
+ $users = array(
+ array(
+ 'id' => 1,
+ 'username' => 'someone',
+ 'name' => 'Someone',
+ 'email' => 'test@localhost',
+ 'avatar_path' => 'avatar_image',
+ ),
+ array(
+ 'id' => 2,
+ 'username' => 'somebody',
+ 'name' => '',
+ 'email' => '',
+ 'avatar_path' => '',
+ )
+ );
+
+ $expected = array(
+ array(
+ 'value' => 'someone',
+ 'html' => '<div class="avatar avatar-20 avatar-inline"><img src="?controller=AvatarFileController&amp;action=image&amp;user_id=1&amp;size=20" alt="Someone" title="Someone"></div> someone <small>Someone</small>',
+ ),
+ array(
+ 'value' => 'somebody',
+ 'html' => '<div class="avatar avatar-20 avatar-inline"><div class="avatar-letter" style="background-color: rgb(191, 210, 121)" title="somebody">S</div></div> somebody',
+ ),
+ );
+
+ $this->assertSame($expected, $userMentionFormatter->withUsers($users)->format());
+ }
+}