summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/functionals/ApiTest.php24
-rw-r--r--tests/units/AclTest.php2
-rw-r--r--tests/units/Base.php2
-rw-r--r--tests/units/DateParserTest.php6
-rw-r--r--tests/units/DatetimeHelperTest.php10
-rw-r--r--tests/units/GitlabWebhookTest.php131
-rw-r--r--tests/units/LexerTest.php125
-rw-r--r--tests/units/OAuth2Test.php43
-rw-r--r--tests/units/ProjectDailyColumnStatsTest.php (renamed from tests/units/ProjectDailySummaryTest.php)6
-rw-r--r--tests/units/RouterTest.php79
-rw-r--r--tests/units/TaskCreationTest.php76
-rw-r--r--tests/units/TaskDuplicationTest.php144
-rw-r--r--tests/units/TaskFilterTest.php231
-rw-r--r--tests/units/TaskModificationTest.php18
-rw-r--r--tests/units/TaskPositionTest.php107
-rw-r--r--tests/units/UrlHelperTest.php30
-rw-r--r--tests/units/UserHelperTest.php16
-rw-r--r--tests/units/fixtures/gitlab_comment_created.json46
-rw-r--r--tests/units/fixtures/gitlab_issue_closed.json25
-rw-r--r--tests/units/fixtures/gitlab_issue_opened.json25
-rw-r--r--tests/units/fixtures/gitlab_push.json44
21 files changed, 1093 insertions, 97 deletions
diff --git a/tests/functionals/ApiTest.php b/tests/functionals/ApiTest.php
index b7ae80f1..284c31b9 100644
--- a/tests/functionals/ApiTest.php
+++ b/tests/functionals/ApiTest.php
@@ -63,6 +63,9 @@ class Api extends PHPUnit_Framework_TestCase
if ($projects) {
foreach ($projects as $project) {
+ $this->assertEquals('http://127.0.0.1:8000/?controller=board&action=show&project_id='.$project['id'], $project['url']['board']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=calendar&action=show&project_id='.$project['id'], $project['url']['calendar']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=listing&action=show&project_id='.$project['id'], $project['url']['list']);
$this->assertTrue($this->client->removeProject($project['id']));
}
}
@@ -80,6 +83,9 @@ class Api extends PHPUnit_Framework_TestCase
$project = $this->client->getProjectById(1);
$this->assertNotEmpty($project);
$this->assertEquals(1, $project['id']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=board&action=show&project_id='.$project['id'], $project['url']['board']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=calendar&action=show&project_id='.$project['id'], $project['url']['calendar']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=listing&action=show&project_id='.$project['id'], $project['url']['list']);
}
public function testGetProjectByName()
@@ -87,6 +93,9 @@ class Api extends PHPUnit_Framework_TestCase
$project = $this->client->getProjectByName('API test');
$this->assertNotEmpty($project);
$this->assertEquals(1, $project['id']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=board&action=show&project_id='.$project['id'], $project['url']['board']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=calendar&action=show&project_id='.$project['id'], $project['url']['calendar']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=listing&action=show&project_id='.$project['id'], $project['url']['list']);
$project = $this->client->getProjectByName(array('name' => 'API test'));
$this->assertNotEmpty($project);
@@ -97,6 +106,18 @@ class Api extends PHPUnit_Framework_TestCase
$this->assertNull($project);
}
+ public function testGetAllProjects()
+ {
+ $projects = $this->client->getAllProjects();
+ $this->assertNotEmpty($projects);
+
+ foreach ($projects as $project) {
+ $this->assertEquals('http://127.0.0.1:8000/?controller=board&action=show&project_id='.$project['id'], $project['url']['board']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=calendar&action=show&project_id='.$project['id'], $project['url']['calendar']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=listing&action=show&project_id='.$project['id'], $project['url']['list']);
+ }
+ }
+
public function testUpdateProject()
{
$project = $this->client->getProjectById(1);
@@ -385,6 +406,7 @@ class Api extends PHPUnit_Framework_TestCase
$this->assertNotFalse($task);
$this->assertTrue(is_array($task));
$this->assertEquals('Task #1', $task['title']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'], $task['url']);
}
public function testGetAllTasks()
@@ -394,6 +416,7 @@ class Api extends PHPUnit_Framework_TestCase
$this->assertNotFalse($tasks);
$this->assertTrue(is_array($tasks));
$this->assertEquals('Task #1', $tasks[0]['title']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=task&action=show&task_id='.$tasks[0]['id'].'&project_id='.$tasks[0]['project_id'], $tasks[0]['url']);
$tasks = $this->client->getAllTasks(2, 0);
@@ -1030,5 +1053,6 @@ class Api extends PHPUnit_Framework_TestCase
$this->assertNotEmpty($task);
$this->assertEquals('Task with external ticket number', $task['title']);
$this->assertEquals('TICKET-1234', $task['reference']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'], $task['url']);
}
} \ No newline at end of file
diff --git a/tests/units/AclTest.php b/tests/units/AclTest.php
index 72c897c0..05e8561e 100644
--- a/tests/units/AclTest.php
+++ b/tests/units/AclTest.php
@@ -39,6 +39,8 @@ class AclTest extends Base
$this->assertFalse($acl->isPublicAction('board', 'show'));
$this->assertTrue($acl->isPublicAction('feed', 'project'));
$this->assertTrue($acl->isPublicAction('feed', 'user'));
+ $this->assertTrue($acl->isPublicAction('oauth', 'github'));
+ $this->assertTrue($acl->isPublicAction('oauth', 'google'));
}
public function testAdminActions()
diff --git a/tests/units/Base.php b/tests/units/Base.php
index 7ad4e626..0a045a09 100644
--- a/tests/units/Base.php
+++ b/tests/units/Base.php
@@ -58,6 +58,8 @@ abstract class Base extends PHPUnit_Framework_TestCase
public function setUp()
{
+ date_default_timezone_set('UTC');
+
if (DB_DRIVER === 'mysql') {
$pdo = new PDO('mysql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
$pdo->exec('DROP DATABASE '.DB_NAME);
diff --git a/tests/units/DateParserTest.php b/tests/units/DateParserTest.php
index 9403063b..4b3e93c8 100644
--- a/tests/units/DateParserTest.php
+++ b/tests/units/DateParserTest.php
@@ -56,6 +56,12 @@ class DateParserTest extends Base
$this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('2014-03-05')));
$this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('2014_03_05')));
$this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('03/05/2014')));
+ $this->assertEquals('2014-03-25 17:18', date('Y-m-d H:i', $d->getTimestamp('03/25/2014 5:18 pm')));
+ $this->assertEquals('2014-03-25 05:18', date('Y-m-d H:i', $d->getTimestamp('03/25/2014 5:18 am')));
+ $this->assertEquals('2014-03-25 05:18', date('Y-m-d H:i', $d->getTimestamp('03/25/2014 5:18am')));
+ $this->assertEquals('2014-03-25 23:14', date('Y-m-d H:i', $d->getTimestamp('03/25/2014 23:14')));
+ $this->assertEquals('2014-03-29 23:14', date('Y-m-d H:i', $d->getTimestamp('2014_03_29 23:14')));
+ $this->assertEquals('2014-03-29 23:14', date('Y-m-d H:i', $d->getTimestamp('2014-03-29 23:14')));
}
public function testConvert()
diff --git a/tests/units/DatetimeHelperTest.php b/tests/units/DatetimeHelperTest.php
index 216cf34c..21d452dd 100644
--- a/tests/units/DatetimeHelperTest.php
+++ b/tests/units/DatetimeHelperTest.php
@@ -2,13 +2,13 @@
require_once __DIR__.'/Base.php';
-use Helper\Datetime;
+use Helper\Dt;
class DatetimeHelperTest extends Base
{
public function testAge()
{
- $h = new Datetime($this->container);
+ $h = new Dt($this->container);
$this->assertEquals('<15m', $h->age(0, 30));
$this->assertEquals('<30m', $h->age(0, 1000));
@@ -20,7 +20,7 @@ class DatetimeHelperTest extends Base
public function testGetDayHours()
{
- $h = new Datetime($this->container);
+ $h = new Dt($this->container);
$slots = $h->getDayHours();
@@ -36,7 +36,7 @@ class DatetimeHelperTest extends Base
public function testGetWeekDays()
{
- $h = new Datetime($this->container);
+ $h = new Dt($this->container);
$slots = $h->getWeekDays();
@@ -48,7 +48,7 @@ class DatetimeHelperTest extends Base
public function testGetWeekDay()
{
- $h = new Datetime($this->container);
+ $h = new Dt($this->container);
$this->assertEquals('Monday', $h->getWeekDay(1));
$this->assertEquals('Sunday', $h->getWeekDay(7));
diff --git a/tests/units/GitlabWebhookTest.php b/tests/units/GitlabWebhookTest.php
index b69f7431..a2dc0d3a 100644
--- a/tests/units/GitlabWebhookTest.php
+++ b/tests/units/GitlabWebhookTest.php
@@ -6,20 +6,18 @@ use Integration\GitlabWebhook;
use Model\TaskCreation;
use Model\TaskFinder;
use Model\Project;
+use Model\ProjectPermission;
+use Model\User;
class GitlabWebhookTest extends Base
{
- private $push_payload = '{"before":"9187f41ba34a2b40d41c50ed4b624ce374c5e583","after":"b3caaee62ad27dc31497946065ac18299784aee4","ref":"refs/heads/master","user_id":74067,"user_name":"Fred","project_id":124474,"repository":{"name":"kanboard","url":"git@gitlab.com:minicoders/kanboard.git","description":"Test repo","homepage":"https://gitlab.com/minicoders/kanboard"},"commits":[{"id":"b3caaee62ad27dc31497946065ac18299784aee4","message":"Fix bug #2\n","timestamp":"2014-12-28T20:31:48-05:00","url":"https://gitlab.com/minicoders/kanboard/commit/b3caaee62ad27dc31497946065ac18299784aee4","author":{"name":"Frédéric Guillot","email":"git@localhost"}}],"total_commits_count":1}';
- private $issue_open_payload = '{"object_kind":"issue","user":{"name":"Fred","username":"minicoders","avatar_url":"https://secure.gravatar.com/avatar/3c44936e5a56f80711bff14987d2733f?s=40\u0026d=identicon"},"object_attributes":{"id":103356,"title":"Test Webhook","assignee_id":null,"author_id":74067,"project_id":124474,"created_at":"2014-12-29 01:24:24 UTC","updated_at":"2014-12-29 01:24:24 UTC","position":0,"branch_name":null,"description":"- test1\r\n- test2","milestone_id":null,"state":"opened","iid":1,"url":"https://gitlab.com/minicoders/kanboard/issues/1","action":"open"}}';
- private $issue_closed_payload = '{"object_kind":"issue","user":{"name":"Fred","username":"minicoders","avatar_url":"https://secure.gravatar.com/avatar/3c44936e5a56f80711bff14987d2733f?s=40\u0026d=identicon"},"object_attributes":{"id":103361,"title":"uu","assignee_id":null,"author_id":74067,"project_id":124474,"created_at":"2014-12-29 01:28:44 UTC","updated_at":"2014-12-29 01:34:47 UTC","position":0,"branch_name":null,"description":"","milestone_id":null,"state":"closed","iid":4,"url":"https://gitlab.com/minicoders/kanboard/issues/4","action":"update"}}';
-
public function testGetEventType()
{
$g = new GitlabWebhook($this->container);
- $this->assertEquals(GitlabWebhook::TYPE_PUSH, $g->getType(json_decode($this->push_payload, true)));
- $this->assertEquals(GitlabWebhook::TYPE_ISSUE, $g->getType(json_decode($this->issue_open_payload, true)));
- $this->assertEquals(GitlabWebhook::TYPE_ISSUE, $g->getType(json_decode($this->issue_closed_payload, true)));
+ $this->assertEquals(GitlabWebhook::TYPE_PUSH, $g->getType(json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_push.json'), true)));
+ $this->assertEquals(GitlabWebhook::TYPE_ISSUE, $g->getType(json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_issue_opened.json'), true)));
+ $this->assertEquals(GitlabWebhook::TYPE_COMMENT, $g->getType(json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_comment_created.json'), true)));
$this->assertEquals('', $g->getType(array()));
}
@@ -35,7 +33,7 @@ class GitlabWebhookTest extends Base
$this->container['dispatcher']->addListener(GitlabWebhook::EVENT_COMMIT, array($this, 'onCommit'));
- $event = json_decode($this->push_payload, true);
+ $event = json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_push.json'), true);
// No task
$this->assertFalse($g->handleCommit($event['commits'][0]));
@@ -59,7 +57,7 @@ class GitlabWebhookTest extends Base
$this->container['dispatcher']->addListener(GitlabWebhook::EVENT_ISSUE_OPENED, array($this, 'onOpen'));
- $event = json_decode($this->issue_open_payload, true);
+ $event = json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_issue_opened.json'), true);
$this->assertTrue($g->handleIssueOpened($event['object_attributes']));
$called = $this->container['dispatcher']->getCalledListeners();
@@ -78,7 +76,7 @@ class GitlabWebhookTest extends Base
$this->container['dispatcher']->addListener(GitlabWebhook::EVENT_ISSUE_CLOSED, array($this, 'onClose'));
- $event = json_decode($this->issue_closed_payload, true);
+ $event = json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_issue_closed.json'), true);
// Issue not there
$this->assertFalse($g->handleIssueClosed($event['object_attributes']));
@@ -87,11 +85,11 @@ class GitlabWebhookTest extends Base
$this->assertEmpty($called);
// Create a task with the issue reference
- $this->assertEquals(1, $tc->create(array('title' => 'A', 'project_id' => 1, 'reference' => 103361)));
- $task = $tf->getByReference(1, 103361);
+ $this->assertEquals(1, $tc->create(array('title' => 'A', 'project_id' => 1, 'reference' => 355691)));
+ $task = $tf->getByReference(1, 355691);
$this->assertNotEmpty($task);
- $task = $tf->getByReference(2, 103361);
+ $task = $tf->getByReference(2, 355691);
$this->assertEmpty($task);
$this->assertTrue($g->handleIssueClosed($event['object_attributes']));
@@ -100,13 +98,76 @@ class GitlabWebhookTest extends Base
$this->assertArrayHasKey(GitlabWebhook::EVENT_ISSUE_CLOSED.'.GitlabWebhookTest::onClose', $called);
}
+ public function testCommentCreatedWithNoUser()
+ {
+ $this->container['dispatcher']->addListener(GitlabWebhook::EVENT_ISSUE_COMMENT, array($this, 'onCommentCreatedWithNoUser'));
+
+ $p = new Project($this->container);
+ $this->assertEquals(1, $p->create(array('name' => 'foobar')));
+
+ $tc = new TaskCreation($this->container);
+ $this->assertEquals(1, $tc->create(array('title' => 'boo', 'reference' => 355691, 'project_id' => 1)));
+
+ $g = new GitlabWebhook($this->container);
+ $g->setProjectId(1);
+
+ $this->assertNotFalse($g->parsePayload(
+ json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_comment_created.json'), true)
+ ));
+ }
+
+ public function testCommentCreatedWithNotMember()
+ {
+ $this->container['dispatcher']->addListener(GitlabWebhook::EVENT_ISSUE_COMMENT, array($this, 'onCommentCreatedWithNotMember'));
+
+ $p = new Project($this->container);
+ $this->assertEquals(1, $p->create(array('name' => 'foobar')));
+
+ $tc = new TaskCreation($this->container);
+ $this->assertEquals(1, $tc->create(array('title' => 'boo', 'reference' => 355691, 'project_id' => 1)));
+
+ $u = new User($this->container);
+ $this->assertEquals(2, $u->create(array('username' => 'minicoders')));
+
+ $g = new GitlabWebhook($this->container);
+ $g->setProjectId(1);
+
+ $this->assertNotFalse($g->parsePayload(
+ json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_comment_created.json'), true)
+ ));
+ }
+
+ public function testCommentCreatedWithUser()
+ {
+ $this->container['dispatcher']->addListener(GitlabWebhook::EVENT_ISSUE_COMMENT, array($this, 'onCommentCreatedWithUser'));
+
+ $p = new Project($this->container);
+ $this->assertEquals(1, $p->create(array('name' => 'foobar')));
+
+ $tc = new TaskCreation($this->container);
+ $this->assertEquals(1, $tc->create(array('title' => 'boo', 'reference' => 355691, 'project_id' => 1)));
+
+ $u = new User($this->container);
+ $this->assertEquals(2, $u->create(array('username' => 'minicoders')));
+
+ $pp = new ProjectPermission($this->container);
+ $this->assertTrue($pp->addMember(1, 2));
+
+ $g = new GitlabWebhook($this->container);
+ $g->setProjectId(1);
+
+ $this->assertNotFalse($g->parsePayload(
+ json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_comment_created.json'), true)
+ ));
+ }
+
public function onOpen($event)
{
$data = $event->getAll();
$this->assertEquals(1, $data['project_id']);
- $this->assertEquals(103356, $data['reference']);
- $this->assertEquals('Test Webhook', $data['title']);
- $this->assertEquals("- test1\r\n- test2\n\n[Gitlab Issue](https://gitlab.com/minicoders/kanboard/issues/1)", $data['description']);
+ $this->assertEquals(355691, $data['reference']);
+ $this->assertEquals('Bug', $data['title']);
+ $this->assertEquals("There is a bug somewhere.\r\n\r\nBye\n\n[Gitlab Issue](https://gitlab.com/minicoders/test-webhook/issues/1)", $data['description']);
}
public function onClose($event)
@@ -114,7 +175,7 @@ class GitlabWebhookTest extends Base
$data = $event->getAll();
$this->assertEquals(1, $data['project_id']);
$this->assertEquals(1, $data['task_id']);
- $this->assertEquals(103361, $data['reference']);
+ $this->assertEquals(355691, $data['reference']);
}
public function onCommit($event)
@@ -123,8 +184,38 @@ class GitlabWebhookTest extends Base
$this->assertEquals(1, $data['project_id']);
$this->assertEquals(2, $data['task_id']);
$this->assertEquals('test2', $data['title']);
- $this->assertEquals("Fix bug #2\n\n\n[Commit made by @Frédéric Guillot on Gitlab](https://gitlab.com/minicoders/kanboard/commit/b3caaee62ad27dc31497946065ac18299784aee4)", $data['commit_comment']);
- $this->assertEquals("Fix bug #2\n", $data['commit_message']);
- $this->assertEquals('https://gitlab.com/minicoders/kanboard/commit/b3caaee62ad27dc31497946065ac18299784aee4', $data['commit_url']);
+ $this->assertEquals("Fix bug #2\n\n[Commit made by @Fred on Gitlab](https://gitlab.com/minicoders/test-webhook/commit/48aafa75eef9ad253aa254b0c82c987a52ebea78)", $data['commit_comment']);
+ $this->assertEquals("Fix bug #2", $data['commit_message']);
+ $this->assertEquals('https://gitlab.com/minicoders/test-webhook/commit/48aafa75eef9ad253aa254b0c82c987a52ebea78', $data['commit_url']);
+ }
+
+ public function onCommentCreatedWithNoUser($event)
+ {
+ $data = $event->getAll();
+ $this->assertEquals(1, $data['project_id']);
+ $this->assertEquals(1, $data['task_id']);
+ $this->assertEquals(0, $data['user_id']);
+ $this->assertEquals(1642761, $data['reference']);
+ $this->assertEquals("Super comment!\n\n[By @minicoders on Gitlab](https://gitlab.com/minicoders/test-webhook/issues/1#note_1642761)", $data['comment']);
+ }
+
+ public function onCommentCreatedWithNotMember($event)
+ {
+ $data = $event->getAll();
+ $this->assertEquals(1, $data['project_id']);
+ $this->assertEquals(1, $data['task_id']);
+ $this->assertEquals(0, $data['user_id']);
+ $this->assertEquals(1642761, $data['reference']);
+ $this->assertEquals("Super comment!\n\n[By @minicoders on Gitlab](https://gitlab.com/minicoders/test-webhook/issues/1#note_1642761)", $data['comment']);
+ }
+
+ public function onCommentCreatedWithUser($event)
+ {
+ $data = $event->getAll();
+ $this->assertEquals(1, $data['project_id']);
+ $this->assertEquals(1, $data['task_id']);
+ $this->assertEquals(2, $data['user_id']);
+ $this->assertEquals(1642761, $data['reference']);
+ $this->assertEquals("Super comment!\n\n[By @minicoders on Gitlab](https://gitlab.com/minicoders/test-webhook/issues/1#note_1642761)", $data['comment']);
}
}
diff --git a/tests/units/LexerTest.php b/tests/units/LexerTest.php
index 38974357..3b15810e 100644
--- a/tests/units/LexerTest.php
+++ b/tests/units/LexerTest.php
@@ -6,6 +6,31 @@ use Core\Lexer;
class LexerTest extends Base
{
+ public function testSwimlaneQuery()
+ {
+ $lexer = new Lexer;
+
+ $this->assertEquals(
+ array(array('match' => 'swimlane:', 'token' => 'T_SWIMLANE'), array('match' => 'Version 42', 'token' => 'T_STRING')),
+ $lexer->tokenize('swimlane:"Version 42"')
+ );
+
+ $this->assertEquals(
+ array(array('match' => 'swimlane:', 'token' => 'T_SWIMLANE'), array('match' => 'v3', 'token' => 'T_STRING')),
+ $lexer->tokenize('swimlane:v3')
+ );
+
+ $this->assertEquals(
+ array('T_SWIMLANE' => array('v3')),
+ $lexer->map($lexer->tokenize('swimlane:v3'))
+ );
+
+ $this->assertEquals(
+ array('T_SWIMLANE' => array('Version 42', 'v3')),
+ $lexer->map($lexer->tokenize('swimlane:"Version 42" swimlane:v3'))
+ );
+ }
+
public function testAssigneeQuery()
{
$lexer = new Lexer;
@@ -171,6 +196,36 @@ class LexerTest extends Base
);
}
+ public function testReferenceQuery()
+ {
+ $lexer = new Lexer;
+
+ $this->assertEquals(
+ array(array('match' => 'ref:', 'token' => 'T_REFERENCE'), array('match' => '123', 'token' => 'T_STRING')),
+ $lexer->tokenize('ref:123')
+ );
+
+ $this->assertEquals(
+ array(array('match' => 'reference:', 'token' => 'T_REFERENCE'), array('match' => '456', 'token' => 'T_STRING')),
+ $lexer->tokenize('reference:456')
+ );
+
+ $this->assertEquals(
+ array('T_REFERENCE' => '123'),
+ $lexer->map($lexer->tokenize('reference:123'))
+ );
+
+ $this->assertEquals(
+ array('T_REFERENCE' => '456'),
+ $lexer->map($lexer->tokenize('ref:456'))
+ );
+
+ $this->assertEquals(
+ array(),
+ $lexer->map($lexer->tokenize('ref: '))
+ );
+ }
+
public function testDescriptionQuery()
{
$lexer = new Lexer;
@@ -256,6 +311,71 @@ class LexerTest extends Base
);
}
+ public function testModifiedQuery()
+ {
+ $lexer = new Lexer;
+
+ $this->assertEquals(
+ array(array('match' => 'modified:', 'token' => 'T_UPDATED'), array('match' => '2015-05-01', 'token' => 'T_DATE')),
+ $lexer->tokenize('modified:2015-05-01')
+ );
+
+ $this->assertEquals(
+ array(array('match' => 'modified:', 'token' => 'T_UPDATED'), array('match' => '<2015-05-01', 'token' => 'T_DATE')),
+ $lexer->tokenize('modified:<2015-05-01')
+ );
+
+ $this->assertEquals(
+ array(array('match' => 'modified:', 'token' => 'T_UPDATED'), array('match' => '>2015-05-01', 'token' => 'T_DATE')),
+ $lexer->tokenize('modified:>2015-05-01')
+ );
+
+ $this->assertEquals(
+ array(array('match' => 'updated:', 'token' => 'T_UPDATED'), array('match' => '<=2015-05-01', 'token' => 'T_DATE')),
+ $lexer->tokenize('updated:<=2015-05-01')
+ );
+
+ $this->assertEquals(
+ array(array('match' => 'updated:', 'token' => 'T_UPDATED'), array('match' => '>=2015-05-01', 'token' => 'T_DATE')),
+ $lexer->tokenize('updated:>=2015-05-01')
+ );
+
+ $this->assertEquals(
+ array(array('match' => 'updated:', 'token' => 'T_UPDATED'), array('match' => 'yesterday', 'token' => 'T_DATE')),
+ $lexer->tokenize('updated:yesterday')
+ );
+
+ $this->assertEquals(
+ array(array('match' => 'updated:', 'token' => 'T_UPDATED'), array('match' => 'tomorrow', 'token' => 'T_DATE')),
+ $lexer->tokenize('updated:tomorrow')
+ );
+
+ $this->assertEquals(
+ array(),
+ $lexer->tokenize('updated:#2015-05-01')
+ );
+
+ $this->assertEquals(
+ array(),
+ $lexer->tokenize('modified:01-05-1024')
+ );
+
+ $this->assertEquals(
+ array('T_UPDATED' => '2015-05-01'),
+ $lexer->map($lexer->tokenize('modified:2015-05-01'))
+ );
+
+ $this->assertEquals(
+ array('T_UPDATED' => '<2015-05-01'),
+ $lexer->map($lexer->tokenize('modified:<2015-05-01'))
+ );
+
+ $this->assertEquals(
+ array('T_UPDATED' => 'today'),
+ $lexer->map($lexer->tokenize('modified:today'))
+ );
+ }
+
public function testMultipleCriterias()
{
$lexer = new Lexer;
@@ -311,6 +431,11 @@ class LexerTest extends Base
);
$this->assertEquals(
+ array('T_TITLE' => '#123'),
+ $lexer->map($lexer->tokenize('#123'))
+ );
+
+ $this->assertEquals(
array(),
$lexer->map($lexer->tokenize('color:assignee:'))
);
diff --git a/tests/units/OAuth2Test.php b/tests/units/OAuth2Test.php
new file mode 100644
index 00000000..0275f426
--- /dev/null
+++ b/tests/units/OAuth2Test.php
@@ -0,0 +1,43 @@
+<?php
+
+require_once __DIR__.'/Base.php';
+
+use Core\OAuth2;
+
+class OAuth2Test extends Base
+{
+ public function testAuthUrl()
+ {
+ $oauth = new OAuth2($this->container);
+ $oauth->createService('A', 'B', 'C', 'D', 'E', array('f', 'g'));
+ $this->assertEquals('D?response_type=code&client_id=A&redirect_uri=C&scope=f+g', $oauth->getAuthorizationUrl());
+ }
+
+ public function testAuthHeader()
+ {
+ $oauth = new OAuth2($this->container);
+ $oauth->createService('A', 'B', 'C', 'D', 'E', array('f', 'g'));
+
+ $oauth->setAccessToken('foobar', 'BeaRer');
+ $this->assertEquals('Authorization: Bearer foobar', $oauth->getAuthorizationHeader());
+
+ $oauth->setAccessToken('foobar', 'unknown');
+ $this->assertEquals('', $oauth->getAuthorizationHeader());
+ }
+
+ public function testAccessToken()
+ {
+ $oauth = new OAuth2($this->container);
+ $oauth->createService('A', 'B', 'C', 'D', 'E', array('f', 'g'));
+ $oauth->getAccessToken('something');
+
+ $data = $this->container['httpClient']->getData();
+ $this->assertEquals('something', $data['code']);
+ $this->assertEquals('A', $data['client_id']);
+ $this->assertEquals('B', $data['client_secret']);
+ $this->assertEquals('C', $data['redirect_uri']);
+ $this->assertEquals('authorization_code', $data['grant_type']);
+
+ $this->assertEquals('E', $this->container['httpClient']->getUrl());
+ }
+}
diff --git a/tests/units/ProjectDailySummaryTest.php b/tests/units/ProjectDailyColumnStatsTest.php
index ed806361..d314ac93 100644
--- a/tests/units/ProjectDailySummaryTest.php
+++ b/tests/units/ProjectDailyColumnStatsTest.php
@@ -3,17 +3,17 @@
require_once __DIR__.'/Base.php';
use Model\Project;
-use Model\ProjectDailySummary;
+use Model\ProjectDailyColumnStats;
use Model\Task;
use Model\TaskCreation;
use Model\TaskStatus;
-class ProjectDailySummaryTest extends Base
+class ProjectDailyColumnStatsTest extends Base
{
public function testUpdateTotals()
{
$p = new Project($this->container);
- $pds = new ProjectDailySummary($this->container);
+ $pds = new ProjectDailyColumnStats($this->container);
$tc = new TaskCreation($this->container);
$ts = new TaskStatus($this->container);
diff --git a/tests/units/RouterTest.php b/tests/units/RouterTest.php
new file mode 100644
index 00000000..e4582121
--- /dev/null
+++ b/tests/units/RouterTest.php
@@ -0,0 +1,79 @@
+<?php
+
+require_once __DIR__.'/Base.php';
+
+use Core\Router;
+
+class RouterTest extends Base
+{
+ public function testSanitize()
+ {
+ $r = new Router($this->container);
+
+ $this->assertEquals('plop', $r->sanitize('PloP', 'default'));
+ $this->assertEquals('default', $r->sanitize('', 'default'));
+ $this->assertEquals('default', $r->sanitize('123-AB', 'default'));
+ $this->assertEquals('default', $r->sanitize('R&D', 'default'));
+ $this->assertEquals('default', $r->sanitize('Test123', 'default'));
+ }
+
+ public function testPath()
+ {
+ $r = new Router($this->container);
+
+ $this->assertEquals('a/b/c', $r->getPath('/a/b/c'));
+ $this->assertEquals('a/b/something', $r->getPath('/a/b/something?test=a', 'test=a'));
+
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $_SERVER['PHP_SELF'] = '/a/index.php';
+
+ $this->assertEquals('b/c', $r->getPath('/a/b/c'));
+ $this->assertEquals('b/c', $r->getPath('/a/b/c?e=f', 'e=f'));
+ }
+
+ public function testFindRouteWithEmptyTable()
+ {
+ $r = new Router($this->container);
+ $this->assertEquals(array('app', 'index'), $r->findRoute(''));
+ $this->assertEquals(array('app', 'index'), $r->findRoute('/'));
+ }
+
+ public function testFindRouteWithoutPlaceholders()
+ {
+ $r = new Router($this->container);
+ $r->addRoute('a/b', 'controller', 'action');
+ $this->assertEquals(array('app', 'index'), $r->findRoute('a/b/c'));
+ $this->assertEquals(array('controller', 'action'), $r->findRoute('a/b'));
+ }
+
+ public function testFindRouteWithPlaceholders()
+ {
+ $r = new Router($this->container);
+ $r->addRoute('a/:myvar1/b/:myvar2', 'controller', 'action');
+ $this->assertEquals(array('app', 'index'), $r->findRoute('a/123/b'));
+ $this->assertEquals(array('controller', 'action'), $r->findRoute('a/456/b/789'));
+ $this->assertEquals(array('myvar1' => 456, 'myvar2' => 789), $_GET);
+ }
+
+ public function testFindMultipleRoutes()
+ {
+ $r = new Router($this->container);
+ $r->addRoute('a/b', 'controller1', 'action1');
+ $r->addRoute('a/b', 'duplicate', 'duplicate');
+ $r->addRoute('a', 'controller2', 'action2');
+ $this->assertEquals(array('controller1', 'action1'), $r->findRoute('a/b'));
+ $this->assertEquals(array('controller2', 'action2'), $r->findRoute('a'));
+ }
+
+ public function testFindUrl()
+ {
+ $r = new Router($this->container);
+ $r->addRoute('a/b', 'controller1', 'action1');
+ $r->addRoute('a/:myvar1/b/:myvar2', 'controller2', 'action2', array('myvar1', 'myvar2'));
+
+ $this->assertEquals('a/1/b/2', $r->findUrl('controller2', 'action2', array('myvar1' => 1, 'myvar2' => 2)));
+ $this->assertEquals('', $r->findUrl('controller2', 'action2', array('myvar1' => 1)));
+ $this->assertEquals('a/b', $r->findUrl('controller1', 'action1'));
+ $this->assertEquals('', $r->findUrl('controller1', 'action2'));
+ }
+}
diff --git a/tests/units/TaskCreationTest.php b/tests/units/TaskCreationTest.php
index b3f001c7..2dc67ad4 100644
--- a/tests/units/TaskCreationTest.php
+++ b/tests/units/TaskCreationTest.php
@@ -2,6 +2,7 @@
require_once __DIR__.'/Base.php';
+use Model\Config;
use Model\Task;
use Model\TaskCreation;
use Model\TaskFinder;
@@ -175,6 +176,28 @@ class TaskCreationTest extends Base
$this->assertEquals(1, $task['creator_id']);
}
+ public function testThatCreatorIsDefined()
+ {
+ $p = new Project($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+
+ $_SESSION = array();
+ $_SESSION['user']['id'] = 1;
+
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test')));
+
+ $task = $tf->getById(1);
+ $this->assertNotEmpty($task);
+ $this->assertNotFalse($task);
+
+ $this->assertEquals(1, $task['id']);
+ $this->assertEquals(1, $task['creator_id']);
+
+ $_SESSION = array();
+ }
+
public function testColumnId()
{
$p = new Project($this->container);
@@ -284,29 +307,35 @@ class TaskCreationTest extends Base
public function testDateStarted()
{
- $date = '2014-11-23';
- $timestamp = strtotime('+2days');
$p = new Project($this->container);
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
- $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => $date)));
- $this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => $timestamp)));
+
+ // Set only a date
+ $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => '2014-11-24')));
$task = $tf->getById(1);
- $this->assertNotEmpty($task);
- $this->assertNotFalse($task);
+ $this->assertEquals('2014-11-24 '.date('H:i'), date('Y-m-d H:i', $task['date_started']));
- $this->assertEquals(1, $task['id']);
- $this->assertEquals($date, date('Y-m-d', $task['date_started']));
+ // Set a datetime
+ $this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => '2014-11-24 16:25')));
$task = $tf->getById(2);
- $this->assertNotEmpty($task);
- $this->assertNotFalse($task);
+ $this->assertEquals('2014-11-24 16:25', date('Y-m-d H:i', $task['date_started']));
- $this->assertEquals(2, $task['id']);
- $this->assertEquals($timestamp, $task['date_started']);
+ // Set a datetime
+ $this->assertEquals(3, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => '2014-11-24 6:25pm')));
+
+ $task = $tf->getById(3);
+ $this->assertEquals('2014-11-24 18:25', date('Y-m-d H:i', $task['date_started']));
+
+ // Set a timestamp
+ $this->assertEquals(4, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => time())));
+
+ $task = $tf->getById(4);
+ $this->assertEquals(time(), $task['date_started'], '', 1);
}
public function testTime()
@@ -355,4 +384,27 @@ class TaskCreationTest extends Base
$this->assertNotFalse($task);
$this->assertEquals(3, $task['score']);
}
+
+ public function testDefaultColor()
+ {
+ $p = new Project($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+ $c = new Config($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test1')));
+
+ $task = $tf->getById(1);
+ $this->assertNotEmpty($task);
+ $this->assertEquals('yellow', $task['color_id']);
+
+ $this->assertTrue($c->save(array('default_color' => 'orange')));
+
+ $this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'test2')));
+
+ $task = $tf->getById(2);
+ $this->assertNotEmpty($task);
+ $this->assertEquals('orange', $task['color_id']);
+ }
}
diff --git a/tests/units/TaskDuplicationTest.php b/tests/units/TaskDuplicationTest.php
index cd791312..e87fe9cc 100644
--- a/tests/units/TaskDuplicationTest.php
+++ b/tests/units/TaskDuplicationTest.php
@@ -15,6 +15,36 @@ use Model\Swimlane;
class TaskDuplicationTest extends Base
{
+ public function testThatDuplicateDefineCreator()
+ {
+ $td = new TaskDuplication($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+ $p = new Project($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'test1')));
+ $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
+
+ $task = $tf->getById(1);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(1, $task['position']);
+ $this->assertEquals(1, $task['project_id']);
+ $this->assertEquals(0, $task['creator_id']);
+
+ $_SESSION = array();
+ $_SESSION['user']['id'] = 1;
+
+ // We duplicate our task
+ $this->assertEquals(2, $td->duplicate(1));
+
+ // Check the values of the duplicated task
+ $task = $tf->getById(2);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(1, $task['creator_id']);
+
+ $_SESSION = array();
+ }
+
public function testDuplicateSameProject()
{
$td = new TaskDuplication($this->container);
@@ -144,6 +174,45 @@ class TaskDuplicationTest extends Base
$this->assertEquals('test', $task['title']);
}
+ public function testDuplicateAnotherProjectWithPredefinedCategory()
+ {
+ $td = new TaskDuplication($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+ $p = new Project($this->container);
+ $c = new Category($this->container);
+
+ // We create 2 projects
+ $this->assertEquals(1, $p->create(array('name' => 'test1')));
+ $this->assertEquals(2, $p->create(array('name' => 'test2')));
+
+ $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1)));
+ $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 2)));
+ $this->assertNotFalse($c->create(array('name' => 'Category #2', 'project_id' => 2)));
+ $this->assertTrue($c->exists(1, 1));
+ $this->assertTrue($c->exists(2, 2));
+ $this->assertTrue($c->exists(3, 2));
+
+ // We create a task
+ $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'category_id' => 1)));
+
+ // We duplicate our task to the 2nd project with no category
+ $this->assertEquals(2, $td->duplicateToProject(1, 2, null, null, 0));
+
+ // Check the values of the duplicated task
+ $task = $tf->getById(2);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(0, $task['category_id']);
+
+ // We duplicate our task to the 2nd project with a different category
+ $this->assertEquals(3, $td->duplicateToProject(1, 2, null, null, 3));
+
+ // Check the values of the duplicated task
+ $task = $tf->getById(3);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(3, $task['category_id']);
+ }
+
public function testDuplicateAnotherProjectWithSwimlane()
{
$td = new TaskDuplication($this->container);
@@ -210,6 +279,57 @@ class TaskDuplicationTest extends Base
$this->assertEquals('test', $task['title']);
}
+ public function testDuplicateAnotherProjectWithPredefinedSwimlane()
+ {
+ $td = new TaskDuplication($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+ $p = new Project($this->container);
+ $s = new Swimlane($this->container);
+
+ // We create 2 projects
+ $this->assertEquals(1, $p->create(array('name' => 'test1')));
+ $this->assertEquals(2, $p->create(array('name' => 'test2')));
+
+ $this->assertNotFalse($s->create(1, 'Swimlane #1'));
+ $this->assertNotFalse($s->create(2, 'Swimlane #1'));
+ $this->assertNotFalse($s->create(2, 'Swimlane #2'));
+
+ // We create a task
+ $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1)));
+
+ // We duplicate our task to the 2nd project
+ $this->assertEquals(2, $td->duplicateToProject(1, 2, 3));
+
+ // Check the values of the duplicated task
+ $task = $tf->getById(2);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(3, $task['swimlane_id']);
+ }
+
+ public function testDuplicateAnotherProjectWithPredefinedColumn()
+ {
+ $td = new TaskDuplication($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+ $p = new Project($this->container);
+
+ // We create 2 projects
+ $this->assertEquals(1, $p->create(array('name' => 'test1')));
+ $this->assertEquals(2, $p->create(array('name' => 'test2')));
+
+ // We create a task
+ $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2)));
+
+ // We duplicate our task to the 2nd project with a different column
+ $this->assertEquals(2, $td->duplicateToProject(1, 2, null, 7));
+
+ // Check the values of the duplicated task
+ $task = $tf->getById(2);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(7, $task['column_id']);
+ }
+
public function testDuplicateAnotherProjectWithUser()
{
$td = new TaskDuplication($this->container);
@@ -267,6 +387,30 @@ class TaskDuplicationTest extends Base
$this->assertEquals(5, $task['column_id']);
}
+ public function testDuplicateAnotherProjectWithPredefinedUser()
+ {
+ $td = new TaskDuplication($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+ $p = new Project($this->container);
+ $pp = new ProjectPermission($this->container);
+
+ // We create 2 projects
+ $this->assertEquals(1, $p->create(array('name' => 'test1')));
+ $this->assertEquals(2, $p->create(array('name' => 'test2')));
+
+ // We create a task
+ $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 2)));
+
+ // We duplicate our task to the 2nd project
+ $this->assertEquals(2, $td->duplicateToProject(1, 2, null, null, null, 1));
+
+ // Check the values of the duplicated task
+ $task = $tf->getById(2);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(1, $task['owner_id']);
+ }
+
public function onMoveProject($event)
{
$this->assertInstanceOf('Event\TaskEvent', $event);
diff --git a/tests/units/TaskFilterTest.php b/tests/units/TaskFilterTest.php
index c68e8880..47fe4e35 100644
--- a/tests/units/TaskFilterTest.php
+++ b/tests/units/TaskFilterTest.php
@@ -8,9 +8,62 @@ use Model\TaskFilter;
use Model\TaskCreation;
use Model\DateParser;
use Model\Category;
+use Model\Subtask;
+use Model\Config;
+use Model\Swimlane;
class TaskFilterTest extends Base
{
+ public function testIcalEventsWithCreatorAndDueDate()
+ {
+ $dp = new DateParser($this->container);
+ $p = new Project($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFilter($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1', 'creator_id' => 1, 'date_due' => $dp->getTimestampFromIsoFormat('-2 days'))));
+
+ $events = $tf->create()->filterByDueDateRange(strtotime('-1 month'), strtotime('+1 month'))->addAllDayIcalEvents();
+ $ics = $events->render();
+
+ $this->assertContains('UID:task-#1-date_due', $ics);
+ $this->assertContains('DTSTART;TZID=UTC;VALUE=DATE:'.date('Ymd', strtotime('-2 days')), $ics);
+ $this->assertContains('DTEND;TZID=UTC;VALUE=DATE:'.date('Ymd', strtotime('-2 days')), $ics);
+ $this->assertContains('URL:http://localhost/?controller=task&action=show&task_id=1&project_id=1', $ics);
+ $this->assertContains('SUMMARY:#1 task1', $ics);
+ $this->assertContains('ATTENDEE:MAILTO:admin@kanboard.local', $ics);
+ $this->assertContains('X-MICROSOFT-CDO-ALLDAYEVENT:TRUE', $ics);
+ }
+
+ public function testIcalEventsWithAssigneeAndDueDate()
+ {
+ $dp = new DateParser($this->container);
+ $p = new Project($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFilter($this->container);
+ $u = new User($this->container);
+ $c = new Config($this->container);
+
+ $this->assertNotFalse($c->save(array('application_url' => 'http://kb/')));
+ $this->assertEquals('http://kb/', $c->get('application_url'));
+
+ $this->assertNotFalse($u->update(array('id' => 1, 'email' => 'bob@localhost')));
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1', 'owner_id' => 1, 'date_due' => $dp->getTimestampFromIsoFormat('+5 days'))));
+
+ $events = $tf->create()->filterByDueDateRange(strtotime('-1 month'), strtotime('+1 month'))->addAllDayIcalEvents();
+ $ics = $events->render();
+
+ $this->assertContains('UID:task-#1-date_due', $ics);
+ $this->assertContains('DTSTART;TZID=UTC;VALUE=DATE:'.date('Ymd', strtotime('+5 days')), $ics);
+ $this->assertContains('DTEND;TZID=UTC;VALUE=DATE:'.date('Ymd', strtotime('+5 days')), $ics);
+ $this->assertContains('URL:http://kb/?controller=task&action=show&task_id=1&project_id=1', $ics);
+ $this->assertContains('SUMMARY:#1 task1', $ics);
+ $this->assertContains('ORGANIZER:MAILTO:bob@localhost', $ics);
+ $this->assertContains('X-MICROSOFT-CDO-ALLDAYEVENT:TRUE', $ics);
+ }
+
public function testSearchWithEmptyResult()
{
$dp = new DateParser($this->container);
@@ -27,6 +80,78 @@ class TaskFilterTest extends Base
$this->assertEmpty($tf->search('search something')->findAll());
}
+ public function testSearchById()
+ {
+ $p = new Project($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFilter($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1')));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task2')));
+
+ $tf->search('#2');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task2', $tasks[0]['title']);
+
+ $tf->search('1');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task1', $tasks[0]['title']);
+
+ $tf->search('something');
+ $tasks = $tf->findAll();
+ $this->assertEmpty($tasks);
+
+ $tf->search('#');
+ $tasks = $tf->findAll();
+ $this->assertEmpty($tasks);
+
+ $tf->search('#abcd');
+ $tasks = $tf->findAll();
+ $this->assertEmpty($tasks);
+
+ $tf->search('task1');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task1', $tasks[0]['title']);
+ }
+
+ public function testSearchWithReference()
+ {
+ $p = new Project($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFilter($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1')));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task2', 'reference' => 123)));
+
+ $tf->search('ref:123');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task2', $tasks[0]['title']);
+
+ $tf->search('reference:123');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task2', $tasks[0]['title']);
+
+ $tf->search('ref:plop');
+ $tasks = $tf->findAll();
+ $this->assertEmpty($tasks);
+
+ $tf->search('ref:');
+ $tasks = $tf->findAll();
+ $this->assertEmpty($tasks);
+ }
+
public function testSearchWithStatus()
{
$p = new Project($this->container);
@@ -163,6 +288,64 @@ class TaskFilterTest extends Base
$this->assertEmpty($tasks);
}
+ public function testSearchWithSwimlane()
+ {
+ $p = new Project($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFilter($this->container);
+ $s = new Swimlane($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'My project A')));
+ $this->assertEquals(1, $s->create(1, 'Version 1.1'));
+ $this->assertEquals(2, $s->create(1, 'Version 1.2'));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1', 'swimlane_id' => 1)));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task2', 'swimlane_id' => 2)));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task3', 'swimlane_id' => 0)));
+
+ $tf->search('swimlane:"Version 1.1"');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task1', $tasks[0]['title']);
+ $this->assertEquals('Version 1.1', $tasks[0]['swimlane_name']);
+
+ $tf->search('swimlane:"versioN 1.2"');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task2', $tasks[0]['title']);
+ $this->assertEquals('Version 1.2', $tasks[0]['swimlane_name']);
+
+ $tf->search('swimlane:"Default swimlane"');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task3', $tasks[0]['title']);
+ $this->assertEquals('Default swimlane', $tasks[0]['default_swimlane']);
+ $this->assertEquals('', $tasks[0]['swimlane_name']);
+
+ $tf->search('swimlane:default');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task3', $tasks[0]['title']);
+ $this->assertEquals('Default swimlane', $tasks[0]['default_swimlane']);
+ $this->assertEquals('', $tasks[0]['swimlane_name']);
+
+ $tf->search('swimlane:"Version 1.1" swimlane:"Version 1.2"');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(2, $tasks);
+ $this->assertEquals('task1', $tasks[0]['title']);
+ $this->assertEquals('Version 1.1', $tasks[0]['swimlane_name']);
+ $this->assertEquals('task2', $tasks[1]['title']);
+ $this->assertEquals('Version 1.2', $tasks[1]['swimlane_name']);
+
+ $tf->search('swimlane:"not found"');
+ $tasks = $tf->findAll();
+ $this->assertEmpty($tasks);
+ }
+
public function testSearchWithColumn()
{
$p = new Project($this->container);
@@ -346,6 +529,54 @@ class TaskFilterTest extends Base
$this->assertEquals('Bob at work', $tasks[1]['title']);
}
+ public function testSearchWithAssigneeIncludingSubtasks()
+ {
+ $p = new Project($this->container);
+ $u = new User($this->container);
+ $tc = new TaskCreation($this->container);
+ $s = new Subtask($this->container);
+ $tf = new TaskFilter($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertEquals(2, $u->create(array('username' => 'bob', 'name' => 'Paul Ryan')));
+
+ $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'task1', 'owner_id' => 2)));
+ $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1, 'status' => 1, 'user_id' => 0)));
+
+ $this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'task2', 'owner_id' => 0)));
+ $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 2, 'status' => 1, 'user_id' => 2)));
+
+ $this->assertEquals(3, $tc->create(array('project_id' => 1, 'title' => 'task3', 'owner_id' => 0)));
+ $this->assertEquals(3, $s->create(array('title' => 'subtask #3', 'task_id' => 3, 'user_id' => 1)));
+
+ $tf->search('assignee:bob');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(2, $tasks);
+ $this->assertEquals('task1', $tasks[0]['title']);
+ $this->assertEquals('task2', $tasks[1]['title']);
+
+ $tf->search('assignee:"Paul Ryan"');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(2, $tasks);
+ $this->assertEquals('task1', $tasks[0]['title']);
+ $this->assertEquals('task2', $tasks[1]['title']);
+
+ $tf->search('assignee:nobody');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(2, $tasks);
+ $this->assertEquals('task2', $tasks[0]['title']);
+ $this->assertEquals('task3', $tasks[1]['title']);
+
+ $tf->search('assignee:admin');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task3', $tasks[0]['title']);
+ }
+
public function testCopy()
{
$tf = new TaskFilter($this->container);
diff --git a/tests/units/TaskModificationTest.php b/tests/units/TaskModificationTest.php
index e6d8f8dc..4dd89c5e 100644
--- a/tests/units/TaskModificationTest.php
+++ b/tests/units/TaskModificationTest.php
@@ -202,15 +202,29 @@ class TaskModificationTest extends Base
$task = $tf->getById(1);
$this->assertEquals(0, $task['date_started']);
+ // Set only a date
$this->assertTrue($tm->update(array('id' => 1, 'date_started' => '2014-11-24')));
$task = $tf->getById(1);
- $this->assertEquals('2014-11-24', date('Y-m-d', $task['date_started']));
+ $this->assertEquals('2014-11-24 '.date('H:i'), date('Y-m-d H:i', $task['date_started']));
+ // Set a datetime
+ $this->assertTrue($tm->update(array('id' => 1, 'date_started' => '2014-11-24 16:25')));
+
+ $task = $tf->getById(1);
+ $this->assertEquals('2014-11-24 16:25', date('Y-m-d H:i', $task['date_started']));
+
+ // Set a datetime
+ $this->assertTrue($tm->update(array('id' => 1, 'date_started' => '2014-11-24 6:25pm')));
+
+ $task = $tf->getById(1);
+ $this->assertEquals('2014-11-24 18:25', date('Y-m-d H:i', $task['date_started']));
+
+ // Set a timestamp
$this->assertTrue($tm->update(array('id' => 1, 'date_started' => time())));
$task = $tf->getById(1);
- $this->assertEquals(date('Y-m-d'), date('Y-m-d', $task['date_started']));
+ $this->assertEquals(time(), $task['date_started'], '', 1);
}
public function testChangeTimeEstimated()
diff --git a/tests/units/TaskPositionTest.php b/tests/units/TaskPositionTest.php
index ca7b3bf2..f3be325b 100644
--- a/tests/units/TaskPositionTest.php
+++ b/tests/units/TaskPositionTest.php
@@ -11,49 +11,88 @@ use Model\Swimlane;
class TaskPositionTest extends Base
{
- public function testCalculatePositionBadPosition()
+ public function testMoveTaskToWrongPosition()
{
$tp = new TaskPosition($this->container);
$tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
- $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
- $this->assertFalse($tp->calculatePositions(1, 1, 2, 0));
+ $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
+ $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
+
+ // We move the task 2 to the position 0
+ $this->assertFalse($tp->movePosition(1, 1, 3, 0));
+
+ // Check tasks position
+ $task = $tf->getById(1);
+ $this->assertEquals(1, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
+
+ $task = $tf->getById(2);
+ $this->assertEquals(2, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(2, $task['position']);
}
- public function testCalculatePositionBadColumn()
+ public function testMoveTaskToGreaterPosition()
{
$tp = new TaskPosition($this->container);
$tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
- $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
- $this->assertFalse($tp->calculatePositions(1, 1, 10, 1));
+ $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
+ $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
+
+ // We move the task 2 to the position 42
+ $this->assertTrue($tp->movePosition(1, 1, 1, 42));
+
+ // Check tasks position
+ $task = $tf->getById(1);
+ $this->assertEquals(1, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(2, $task['position']);
+
+ $task = $tf->getById(2);
+ $this->assertEquals(2, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
}
- public function testCalculatePositions()
+ public function testMoveTaskToEmptyColumn()
{
$tp = new TaskPosition($this->container);
$tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
- $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
-
- $positions = $tp->calculatePositions(1, 1, 2, 1);
- $this->assertNotFalse($positions);
- $this->assertNotEmpty($positions);
- $this->assertEmpty($positions[1]);
- $this->assertEmpty($positions[3]);
- $this->assertEmpty($positions[4]);
- $this->assertEquals(array(1), $positions[2]);
+
+ $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
+ $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
+
+ // We move the task 2 to the column 3
+ $this->assertTrue($tp->movePosition(1, 1, 3, 1));
+
+ // Check tasks position
+ $task = $tf->getById(1);
+ $this->assertEquals(1, $task['id']);
+ $this->assertEquals(3, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
+
+ $task = $tf->getById(2);
+ $this->assertEquals(2, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
}
- public function testMoveTaskWithColumnThatNotChange()
+ public function testMoveTaskToAnotherColumn()
{
$tp = new TaskPosition($this->container);
$tc = new TaskCreation($this->container);
@@ -116,40 +155,6 @@ class TaskPositionTest extends Base
$this->assertEquals(3, $task['position']);
}
- public function testMoveTaskWithBadPreviousPosition()
- {
- $tp = new TaskPosition($this->container);
- $tc = new TaskCreation($this->container);
- $tf = new TaskFinder($this->container);
- $p = new Project($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
- $this->assertEquals(1, $this->container['db']->table('tasks')->insert(array('title' => 'A', 'column_id' => 1, 'project_id' => 1, 'position' => 1)));
-
- // Both tasks have the same position
- $this->assertEquals(2, $this->container['db']->table('tasks')->insert(array('title' => 'B', 'column_id' => 2, 'project_id' => 1, 'position' => 1)));
- $this->assertEquals(3, $this->container['db']->table('tasks')->insert(array('title' => 'C', 'column_id' => 2, 'project_id' => 1, 'position' => 1)));
-
- // Move the first column to the last position of the 2nd column
- $this->assertTrue($tp->movePosition(1, 1, 2, 3));
-
- // Check tasks position
- $task = $tf->getById(2);
- $this->assertEquals(2, $task['id']);
- $this->assertEquals(2, $task['column_id']);
- $this->assertEquals(1, $task['position']);
-
- $task = $tf->getById(3);
- $this->assertEquals(3, $task['id']);
- $this->assertEquals(2, $task['column_id']);
- $this->assertEquals(2, $task['position']);
-
- $task = $tf->getById(1);
- $this->assertEquals(1, $task['id']);
- $this->assertEquals(2, $task['column_id']);
- $this->assertEquals(3, $task['position']);
- }
-
public function testMoveTaskTop()
{
$tp = new TaskPosition($this->container);
diff --git a/tests/units/UrlHelperTest.php b/tests/units/UrlHelperTest.php
index d70842aa..ebfe9c99 100644
--- a/tests/units/UrlHelperTest.php
+++ b/tests/units/UrlHelperTest.php
@@ -34,30 +34,52 @@ class UrlHelperTest extends Base
);
}
+ public function testDir()
+ {
+ $h = new Url($this->container);
+ $this->assertEquals('', $h->dir());
+
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $_SERVER['PHP_SELF'] = '/plop/index.php';
+ $h = new Url($this->container);
+ $this->assertEquals('/plop/', $h->dir());
+
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $_SERVER['PHP_SELF'] = '';
+ $h = new Url($this->container);
+ $this->assertEquals('/', $h->dir());
+ }
+
public function testServer()
{
$h = new Url($this->container);
+ $this->assertEquals('http://localhost/', $h->server());
+
$_SERVER['PHP_SELF'] = '/';
- $_SERVER['SERVER_NAME'] = 'localhost';
+ $_SERVER['SERVER_NAME'] = 'kb';
$_SERVER['SERVER_PORT'] = 1234;
- $this->assertEquals('http://localhost:1234/', $h->server());
+ $this->assertEquals('http://kb:1234/', $h->server());
}
public function testBase()
{
$h = new Url($this->container);
+ $this->assertEquals('http://localhost/', $h->base());
+
$_SERVER['PHP_SELF'] = '/';
- $_SERVER['SERVER_NAME'] = 'localhost';
+ $_SERVER['SERVER_NAME'] = 'kb';
$_SERVER['SERVER_PORT'] = 1234;
- $this->assertEquals('http://localhost:1234/', $h->base());
+ $h = new Url($this->container);
+ $this->assertEquals('http://kb:1234/', $h->base());
$c = new Config($this->container);
$c->save(array('application_url' => 'https://mykanboard/'));
+ $h = new Url($this->container);
$this->assertEquals('https://mykanboard/', $c->get('application_url'));
$this->assertEquals('https://mykanboard/', $h->base());
}
diff --git a/tests/units/UserHelperTest.php b/tests/units/UserHelperTest.php
new file mode 100644
index 00000000..9129edd9
--- /dev/null
+++ b/tests/units/UserHelperTest.php
@@ -0,0 +1,16 @@
+<?php
+
+require_once __DIR__.'/Base.php';
+
+use Helper\User;
+
+class UserHelperTest extends Base
+{
+ public function testInitials()
+ {
+ $h = new User($this->container);
+
+ $this->assertEquals('CN', $h->getInitials('chuck norris'));
+ $this->assertEquals('A', $h->getInitials('admin'));
+ }
+}
diff --git a/tests/units/fixtures/gitlab_comment_created.json b/tests/units/fixtures/gitlab_comment_created.json
new file mode 100644
index 00000000..b6599419
--- /dev/null
+++ b/tests/units/fixtures/gitlab_comment_created.json
@@ -0,0 +1,46 @@
+{
+ "object_kind": "note",
+ "user": {
+ "name": "Fred",
+ "username": "minicoders",
+ "avatar_url": "https://secure.gravatar.com/avatar/3c44936e5a56f80711bff14987d2733f?s=40&d=identicon"
+ },
+ "project_id": 320820,
+ "repository": {
+ "name": "test-webhook",
+ "url": "git@gitlab.com:minicoders/test-webhook.git",
+ "description": "",
+ "homepage": "https://gitlab.com/minicoders/test-webhook"
+ },
+ "object_attributes": {
+ "id": 1642761,
+ "note": "Super comment!",
+ "noteable_type": "Issue",
+ "author_id": 74067,
+ "created_at": "2015-07-17 21:37:48 UTC",
+ "updated_at": "2015-07-17 21:37:48 UTC",
+ "project_id": 320820,
+ "attachment": null,
+ "line_code": null,
+ "commit_id": "",
+ "noteable_id": 355691,
+ "st_diff": null,
+ "system": false,
+ "url": "https://gitlab.com/minicoders/test-webhook/issues/1#note_1642761"
+ },
+ "issue": {
+ "id": 355691,
+ "title": "Bug",
+ "assignee_id": null,
+ "author_id": 74067,
+ "project_id": 320820,
+ "created_at": "2015-07-17 21:31:47 UTC",
+ "updated_at": "2015-07-17 21:37:48 UTC",
+ "position": 0,
+ "branch_name": null,
+ "description": "There is a bug somewhere.\r\n\r\nBye",
+ "milestone_id": null,
+ "state": "opened",
+ "iid": 1
+ }
+} \ No newline at end of file
diff --git a/tests/units/fixtures/gitlab_issue_closed.json b/tests/units/fixtures/gitlab_issue_closed.json
new file mode 100644
index 00000000..82500b3c
--- /dev/null
+++ b/tests/units/fixtures/gitlab_issue_closed.json
@@ -0,0 +1,25 @@
+{
+ "object_kind": "issue",
+ "user": {
+ "name": "Fred",
+ "username": "minicoders",
+ "avatar_url": "https://secure.gravatar.com/avatar/3c44936e5a56f80711bff14987d2733f?s=40&d=identicon"
+ },
+ "object_attributes": {
+ "id": 355691,
+ "title": "Bug",
+ "assignee_id": null,
+ "author_id": 74067,
+ "project_id": 320820,
+ "created_at": "2015-07-17 21:31:47 UTC",
+ "updated_at": "2015-07-17 22:10:17 UTC",
+ "position": 0,
+ "branch_name": null,
+ "description": "There is a bug somewhere.\r\n\r\nBye",
+ "milestone_id": null,
+ "state": "closed",
+ "iid": 1,
+ "url": "https://gitlab.com/minicoders/test-webhook/issues/1",
+ "action": "close"
+ }
+} \ No newline at end of file
diff --git a/tests/units/fixtures/gitlab_issue_opened.json b/tests/units/fixtures/gitlab_issue_opened.json
new file mode 100644
index 00000000..3e75c138
--- /dev/null
+++ b/tests/units/fixtures/gitlab_issue_opened.json
@@ -0,0 +1,25 @@
+{
+ "object_kind": "issue",
+ "user": {
+ "name": "Fred",
+ "username": "minicoders",
+ "avatar_url": "https://secure.gravatar.com/avatar/3c44936e5a56f80711bff14987d2733f?s=40&d=identicon"
+ },
+ "object_attributes": {
+ "id": 355691,
+ "title": "Bug",
+ "assignee_id": null,
+ "author_id": 74067,
+ "project_id": 320820,
+ "created_at": "2015-07-17 21:31:47 UTC",
+ "updated_at": "2015-07-17 21:31:47 UTC",
+ "position": 0,
+ "branch_name": null,
+ "description": "There is a bug somewhere.\r\n\r\nBye",
+ "milestone_id": null,
+ "state": "opened",
+ "iid": 1,
+ "url": "https://gitlab.com/minicoders/test-webhook/issues/1",
+ "action": "open"
+ }
+} \ No newline at end of file
diff --git a/tests/units/fixtures/gitlab_push.json b/tests/units/fixtures/gitlab_push.json
new file mode 100644
index 00000000..ed77f041
--- /dev/null
+++ b/tests/units/fixtures/gitlab_push.json
@@ -0,0 +1,44 @@
+{
+ "object_kind": "push",
+ "before": "e4ec6156d208a45fc546fae73c28300b5af1692a",
+ "after": "48aafa75eef9ad253aa254b0c82c987a52ebea78",
+ "ref": "refs/heads/master",
+ "checkout_sha": "48aafa75eef9ad253aa254b0c82c987a52ebea78",
+ "message": null,
+ "user_id": 74067,
+ "user_name": "Fred",
+ "user_email": "f+gitlab@minicoders.com",
+ "project_id": 320820,
+ "repository": {
+ "name": "test-webhook",
+ "url": "git@gitlab.com:minicoders/test-webhook.git",
+ "description": "",
+ "homepage": "https://gitlab.com/minicoders/test-webhook",
+ "git_http_url": "https://gitlab.com/minicoders/test-webhook.git",
+ "git_ssh_url": "git@gitlab.com:minicoders/test-webhook.git",
+ "visibility_level": 0
+ },
+ "commits": [
+ {
+ "id": "48aafa75eef9ad253aa254b0c82c987a52ebea78",
+ "message": "Fix bug #2",
+ "timestamp": "2015-06-21T00:41:41+00:00",
+ "url": "https://gitlab.com/minicoders/test-webhook/commit/48aafa75eef9ad253aa254b0c82c987a52ebea78",
+ "author": {
+ "name": "Fred",
+ "email": "me@localhost"
+ }
+ },
+ {
+ "id": "e4ec6156d208a45fc546fae73c28300b5af1692a",
+ "message": "test",
+ "timestamp": "2015-06-21T00:35:55+00:00",
+ "url": "https://gitlab.com/localhost/test-webhook/commit/e4ec6156d208a45fc546fae73c28300b5af1692a",
+ "author": {
+ "name": "Fred",
+ "email": "me@localhost"
+ }
+ }
+ ],
+ "total_commits_count": 2
+} \ No newline at end of file