summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/TagProcedureTest.php58
-rw-r--r--tests/integration/TaskTagProcedureTest.php54
-rw-r--r--tests/units/Helper/TextHelperTest.php93
-rw-r--r--tests/units/Job/UserMentionJobTest.php10
4 files changed, 186 insertions, 29 deletions
diff --git a/tests/integration/TagProcedureTest.php b/tests/integration/TagProcedureTest.php
new file mode 100644
index 00000000..f15efa3c
--- /dev/null
+++ b/tests/integration/TagProcedureTest.php
@@ -0,0 +1,58 @@
+<?php
+
+require_once __DIR__.'/BaseProcedureTest.php';
+
+class TagProcedureTest extends BaseProcedureTest
+{
+ protected $projectName = 'My project with tags';
+
+ public function testAll()
+ {
+ $this->assertCreateTeamProject();
+ $this->assertCreateTag();
+ $this->assertGetProjectTags();
+ $this->assertGetAllTags();
+ $this->assertUpdateTag();
+ $this->assertRemoveTag();
+ }
+
+ public function assertCreateTag()
+ {
+ $this->assertNotFalse($this->app->createTag($this->projectId, 'some tag'));
+ }
+
+ public function assertGetProjectTags()
+ {
+ $tags = $this->app->getTagsByProject($this->projectId);
+ $this->assertCount(1, $tags);
+ $this->assertEquals('some tag', $tags[0]['name']);
+ }
+
+ public function assertGetAllTags()
+ {
+ $tags = $this->app->getAllTags();
+ $this->assertCount(1, $tags);
+ $this->assertEquals('some tag', $tags[0]['name']);
+ }
+
+ public function assertUpdateTag()
+ {
+ $tags = $this->app->getAllTags();
+ $this->assertCount(1, $tags);
+ $this->assertTrue($this->app->updateTag($tags[0]['id'], 'another tag'));
+
+ $tags = $this->app->getAllTags();
+ $this->assertCount(1, $tags);
+ $this->assertEquals('another tag', $tags[0]['name']);
+ }
+
+ public function assertRemoveTag()
+ {
+ $tags = $this->app->getAllTags();
+ $this->assertCount(1, $tags);
+ $this->assertTrue($this->app->removeTag($tags[0]['id']));
+
+ $tags = $this->app->getAllTags();
+ $this->assertCount(0, $tags);
+ }
+}
diff --git a/tests/integration/TaskTagProcedureTest.php b/tests/integration/TaskTagProcedureTest.php
new file mode 100644
index 00000000..4b820c9a
--- /dev/null
+++ b/tests/integration/TaskTagProcedureTest.php
@@ -0,0 +1,54 @@
+<?php
+
+require_once __DIR__.'/BaseProcedureTest.php';
+
+class TaskTagProcedureTest extends BaseProcedureTest
+{
+ protected $projectName = 'My project with tasks and tags';
+
+ public function testAll()
+ {
+ $this->assertCreateTeamProject();
+ $this->assertCreateTask();
+ $this->assertSetTaskTags();
+ $this->assertGetTaskTags();
+ $this->assertCreateTaskWithTags();
+ $this->assertUpdateTaskWithTags();
+ }
+
+ public function assertSetTaskTags()
+ {
+ $this->assertTrue($this->app->setTaskTags($this->projectId, $this->taskId, array('tag1', 'tag2')));
+ }
+
+ public function assertGetTaskTags()
+ {
+ $tags = $this->app->getTaskTags($this->taskId);
+ $this->assertEquals(array('tag1', 'tag2'), array_values($tags));
+ }
+
+ public function assertCreateTaskWithTags()
+ {
+ $this->taskId = $this->app->createTask(array(
+ 'title' => $this->taskTitle,
+ 'project_id' => $this->projectId,
+ 'tags' => array('tag A', 'tag B'),
+ ));
+
+ $this->assertNotFalse($this->taskId);
+
+ $tags = $this->app->getTaskTags($this->taskId);
+ $this->assertEquals(array('tag A', 'tag B'), array_values($tags));
+ }
+
+ public function assertUpdateTaskWithTags()
+ {
+ $this->assertTrue($this->app->updateTask(array(
+ 'id' => $this->taskId,
+ 'tags' => array('tag C'),
+ )));
+
+ $tags = $this->app->getTaskTags($this->taskId);
+ $this->assertEquals(array('tag C'), array_values($tags));
+ }
+}
diff --git a/tests/units/Helper/TextHelperTest.php b/tests/units/Helper/TextHelperTest.php
index a54c5780..5c8a10f6 100644
--- a/tests/units/Helper/TextHelperTest.php
+++ b/tests/units/Helper/TextHelperTest.php
@@ -5,12 +5,13 @@ require_once __DIR__.'/../Base.php';
use Kanboard\Helper\TextHelper;
use Kanboard\Model\ProjectModel;
use Kanboard\Model\TaskCreationModel;
+use Kanboard\Model\UserModel;
class TextHelperTest extends Base
{
public function testMarkdownTaskLink()
{
- $helper = new TextHelper($this->container);
+ $textHelper = new TextHelper($this->container);
$projectModel = new ProjectModel($this->container);
$taskCreationModel = new TaskCreationModel($this->container);
@@ -19,26 +20,26 @@ class TextHelperTest extends Base
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1)));
$project = $projectModel->getById(1);
- $this->assertEquals('<p>Test</p>', $helper->markdown('Test'));
+ $this->assertEquals('<p>Test</p>', $textHelper->markdown('Test'));
$this->assertEquals(
'<p>Task <a href="?controller=TaskViewController&amp;action=show&amp;task_id=123">#123</a></p>',
- $helper->markdown('Task #123')
+ $textHelper->markdown('Task #123')
);
$this->assertEquals(
'<p>Task #123</p>',
- $helper->markdown('Task #123', true)
+ $textHelper->markdown('Task #123', true)
);
$this->assertEquals(
'<p>Task <a href="http://localhost/?controller=TaskViewController&amp;action=readonly&amp;token='.$project['token'].'&amp;task_id=1">#1</a></p>',
- $helper->markdown('Task #1', true)
+ $textHelper->markdown('Task #1', true)
);
$this->assertEquals(
'<p>Check that: <a href="http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454">http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454</a></p>',
- $helper->markdown(
+ $textHelper->markdown(
'Check that: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454'
)
);
@@ -46,44 +47,82 @@ class TextHelperTest extends Base
public function testMarkdownUserLink()
{
- $h = new TextHelper($this->container);
- $this->assertEquals('<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link">@admin</a> @notfound</p>', $h->markdown('Text @admin @notfound'));
- $this->assertEquals('<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link">@admin</a>,</p>', $h->markdown('Text @admin,'));
- $this->assertEquals('<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link">@admin</a>!</p>', $h->markdown('Text @admin!'));
- $this->assertEquals('<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link">@admin</a>? </p>', $h->markdown('Text @admin? '));
- $this->assertEquals('<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link">@admin</a>.</p>', $h->markdown('Text @admin.'));
- $this->assertEquals('<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link">@admin</a>: test</p>', $h->markdown('Text @admin: test'));
- $this->assertEquals('<p>Text @admin @notfound</p>', $h->markdown('Text @admin @notfound', true));
+ $textHelper = new TextHelper($this->container);
+ $userModel = new UserModel($this->container);
+
+ $this->assertEquals(2, $userModel->create(array('username' => 'firstname.lastname', 'name' => 'Firstname Lastname')));
+
+ $this->assertEquals(
+ '<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link" title="admin">@admin</a> @notfound</p>',
+ $textHelper->markdown('Text @admin @notfound')
+ );
+
+ $this->assertEquals(
+ '<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link" title="admin">@admin</a>,</p>',
+ $textHelper->markdown('Text @admin,')
+ );
+
+ $this->assertEquals(
+ '<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link" title="admin">@admin</a>!</p>',
+ $textHelper->markdown('Text @admin!')
+ );
+
+ $this->assertEquals(
+ '<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link" title="admin">@admin</a>? </p>',
+ $textHelper->markdown('Text @admin? ')
+ );
+
+ $this->assertEquals(
+ '<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link" title="admin">@admin</a>.</p>',
+ $textHelper->markdown('Text @admin.')
+ );
+
+ $this->assertEquals(
+ '<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link" title="admin">@admin</a>: test</p>',
+ $textHelper->markdown('Text @admin: test')
+ );
+
+ $this->assertEquals(
+ '<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link" title="admin">@admin</a>: test</p>',
+ $textHelper->markdown('Text @admin: test')
+ );
+
+ $this->assertEquals(
+ '<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=2" class="user-mention-link" title="Firstname Lastname">@firstname.lastname</a>. test</p>',
+ $textHelper->markdown('Text @firstname.lastname. test')
+ );
+
+ $this->assertEquals('<p>Text @admin @notfound</p>', $textHelper->markdown('Text @admin @notfound', true));
}
public function testMarkdownAttribute()
{
- $helper = new TextHelper($this->container);
- $this->assertEquals('&lt;p&gt;&Ccedil;a marche&lt;/p&gt;', $helper->markdownAttribute('Ça marche'));
- $this->assertEquals('&lt;p&gt;Test with &amp;quot;double quotes&amp;quot;&lt;/p&gt;', $helper->markdownAttribute('Test with "double quotes"'));
- $this->assertEquals('&lt;p&gt;Test with &#039;single quotes&#039;&lt;/p&gt;', $helper->markdownAttribute("Test with 'single quotes'"));
+ $textHelper = new TextHelper($this->container);
+ $this->assertEquals('&lt;p&gt;&Ccedil;a marche&lt;/p&gt;', $textHelper->markdownAttribute('Ça marche'));
+ $this->assertEquals('&lt;p&gt;Test with &amp;quot;double quotes&amp;quot;&lt;/p&gt;', $textHelper->markdownAttribute('Test with "double quotes"'));
+ $this->assertEquals('&lt;p&gt;Test with &#039;single quotes&#039;&lt;/p&gt;', $textHelper->markdownAttribute("Test with 'single quotes'"));
}
public function testFormatBytes()
{
- $h = new TextHelper($this->container);
+ $textHelper = new TextHelper($this->container);
- $this->assertEquals('1k', $h->bytes(1024));
- $this->assertEquals('33.71k', $h->bytes(34520));
+ $this->assertEquals('1k', $textHelper->bytes(1024));
+ $this->assertEquals('33.71k', $textHelper->bytes(34520));
}
public function testContains()
{
- $h = new TextHelper($this->container);
+ $textHelper = new TextHelper($this->container);
- $this->assertTrue($h->contains('abc', 'b'));
- $this->assertFalse($h->contains('abc', 'd'));
+ $this->assertTrue($textHelper->contains('abc', 'b'));
+ $this->assertFalse($textHelper->contains('abc', 'd'));
}
public function testInList()
{
- $h = new TextHelper($this->container);
- $this->assertEquals('?', $h->in('a', array('b' => 'c')));
- $this->assertEquals('c', $h->in('b', array('b' => 'c')));
+ $textHelper = new TextHelper($this->container);
+ $this->assertEquals('?', $textHelper->in('a', array('b' => 'c')));
+ $this->assertEquals('c', $textHelper->in('b', array('b' => 'c')));
}
}
diff --git a/tests/units/Job/UserMentionJobTest.php b/tests/units/Job/UserMentionJobTest.php
index 4cd4ac9b..04ffa0d3 100644
--- a/tests/units/Job/UserMentionJobTest.php
+++ b/tests/units/Job/UserMentionJobTest.php
@@ -53,13 +53,19 @@ class UserMentionJobTest extends Base
$this->assertNotFalse($userModel->create(array('username' => 'user1')));
$this->assertNotFalse($userModel->create(array('username' => 'user2', 'name' => 'Foobar', 'notifications_enabled' => 1)));
+ $this->assertNotFalse($userModel->create(array('username' => 'user3.with.dot', 'notifications_enabled' => 1)));
- $users = $userMentionJob->getMentionedUsers('test @user2, test');
- $this->assertCount(1, $users);
+ $users = $userMentionJob->getMentionedUsers('test @user2, test, @user3.with.dot.');
+ $this->assertCount(2, $users);
$this->assertEquals('user2', $users[0]['username']);
$this->assertEquals('Foobar', $users[0]['name']);
$this->assertEquals('', $users[0]['email']);
$this->assertEquals('', $users[0]['language']);
+
+ $this->assertEquals('user3.with.dot', $users[1]['username']);
+ $this->assertEquals('', $users[1]['name']);
+ $this->assertEquals('', $users[1]['email']);
+ $this->assertEquals('', $users[1]['language']);
}
public function testGetMentionedUsersWithNotficationEnabledAndUserLoggedIn()