summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/Base.php6
-rw-r--r--tests/integration/GroupMemberTest.php8
-rw-r--r--tests/integration/MeTest.php10
-rw-r--r--tests/integration/TaskTest.php36
-rw-r--r--tests/units/Core/TemplateTest.php4
-rw-r--r--tests/units/Model/GroupMemberTest.php30
6 files changed, 84 insertions, 10 deletions
diff --git a/tests/integration/Base.php b/tests/integration/Base.php
index 983d0ed9..6f3ae076 100644
--- a/tests/integration/Base.php
+++ b/tests/integration/Base.php
@@ -35,15 +35,15 @@ abstract class Base extends PHPUnit_Framework_TestCase
{
$this->app = new JsonRPC\Client(API_URL);
$this->app->authentication('jsonrpc', API_KEY);
- // $this->app->debug = true;
+ $this->app->getHttpClient()->withDebug();
$this->admin = new JsonRPC\Client(API_URL);
$this->admin->authentication('admin', 'admin');
- // $this->admin->debug = true;
+ $this->admin->getHttpClient()->withDebug();
$this->user = new JsonRPC\Client(API_URL);
$this->user->authentication('user', 'password');
- // $this->user->debug = true;
+ $this->user->getHttpClient()->withDebug();
}
protected function getProjectId()
diff --git a/tests/integration/GroupMemberTest.php b/tests/integration/GroupMemberTest.php
index e84c0734..d49945b5 100644
--- a/tests/integration/GroupMemberTest.php
+++ b/tests/integration/GroupMemberTest.php
@@ -30,6 +30,14 @@ class GroupMemberTest extends Base
$this->assertFalse($this->app->isGroupMember($groupId, 2));
}
+ public function testGetGroups()
+ {
+ $groups = $this->app->getMemberGroups(1);
+ $this->assertCount(1, $groups);
+ $this->assertEquals(1, $groups[0]['id']);
+ $this->assertEquals('My Group A', $groups[0]['name']);
+ }
+
public function testRemove()
{
$groupId = $this->getGroupId();
diff --git a/tests/integration/MeTest.php b/tests/integration/MeTest.php
index 21f61756..1b028b84 100644
--- a/tests/integration/MeTest.php
+++ b/tests/integration/MeTest.php
@@ -15,7 +15,7 @@ class MeTest extends Base
}
/**
- * @expectedException JsonRPC\AccessDeniedException
+ * @expectedException JsonRPC\Exception\AccessDeniedException
*/
public function testNotAllowedAppProcedure()
{
@@ -23,7 +23,7 @@ class MeTest extends Base
}
/**
- * @expectedException JsonRPC\AccessDeniedException
+ * @expectedException JsonRPC\Exception\AccessDeniedException
*/
public function testNotAllowedUserProcedure()
{
@@ -31,7 +31,7 @@ class MeTest extends Base
}
/**
- * @expectedException JsonRPC\AccessDeniedException
+ * @expectedException JsonRPC\Exception\AccessDeniedException
*/
public function testNotAllowedProjectForUser()
{
@@ -140,7 +140,7 @@ class MeTest extends Base
}
/**
- * @expectedException JsonRPC\AccessDeniedException
+ * @expectedException JsonRPC\Exception\AccessDeniedException
*/
public function testGetAdminTask()
{
@@ -148,7 +148,7 @@ class MeTest extends Base
}
/**
- * @expectedException JsonRPC\AccessDeniedException
+ * @expectedException JsonRPC\Exception\AccessDeniedException
*/
public function testGetProjectActivityDenied()
{
diff --git a/tests/integration/TaskTest.php b/tests/integration/TaskTest.php
index 6d500da4..0c398761 100644
--- a/tests/integration/TaskTest.php
+++ b/tests/integration/TaskTest.php
@@ -4,6 +4,42 @@ require_once __DIR__.'/Base.php';
class TaskTest extends Base
{
+ public function testSearchTasks()
+ {
+ $project_id1 = $this->app->createProject('My project');
+ $project_id2 = $this->app->createProject('My project');
+ $this->assertNotFalse($project_id1);
+ $this->assertNotFalse($project_id2);
+
+ $this->assertNotFalse($this->app->createTask(array('project_id' => $project_id1, 'title' => 'T1')));
+ $this->assertNotFalse($this->app->createTask(array('project_id' => $project_id1, 'title' => 'T2')));
+ $this->assertNotFalse($this->app->createTask(array('project_id' => $project_id2, 'title' => 'T3')));
+
+ $tasks = $this->app->searchTasks($project_id1, 't2');
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('T2', $tasks[0]['title']);
+
+ $tasks = $this->app->searchTasks(array('project_id' => $project_id2, 'query' => 'assignee:nobody'));
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('T3', $tasks[0]['title']);
+ }
+
+ public function testPriorityAttribute()
+ {
+ $project_id = $this->app->createProject('My project');
+ $this->assertNotFalse($project_id);
+
+ $task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task', 'priority' => 2));
+
+ $task = $this->app->getTask($task_id);
+ $this->assertEquals(2, $task['priority']);
+
+ $this->assertTrue($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'priority' => 3)));
+
+ $task = $this->app->getTask($task_id);
+ $this->assertEquals(3, $task['priority']);
+ }
+
public function testChangeAssigneeToAssignableUser()
{
$project_id = $this->app->createProject('My project');
diff --git a/tests/units/Core/TemplateTest.php b/tests/units/Core/TemplateTest.php
index 9584c831..453f0b14 100644
--- a/tests/units/Core/TemplateTest.php
+++ b/tests/units/Core/TemplateTest.php
@@ -25,7 +25,7 @@ class TemplateTest extends Base
{
$template = new Template($this->container['helper']);
$this->assertStringEndsWith(
- implode(DIRECTORY_SEPARATOR, array('app', 'Core', '..', '..', 'plugins', 'Myplugin', 'Template', 'a', 'b.php')),
+ implode(DIRECTORY_SEPARATOR, array(PLUGINS_DIR, 'Myplugin', 'Template', 'a', 'b.php')),
$template->getTemplateFile('myplugin:a'.DIRECTORY_SEPARATOR.'b')
);
}
@@ -36,7 +36,7 @@ class TemplateTest extends Base
$template->setTemplateOverride('a'.DIRECTORY_SEPARATOR.'b', 'myplugin:c');
$this->assertStringEndsWith(
- implode(DIRECTORY_SEPARATOR, array('app', 'Core', '..', '..', 'plugins', 'Myplugin', 'Template', 'c.php')),
+ implode(DIRECTORY_SEPARATOR, array(PLUGINS_DIR, 'Myplugin', 'Template', 'c.php')),
$template->getTemplateFile('a'.DIRECTORY_SEPARATOR.'b')
);
diff --git a/tests/units/Model/GroupMemberTest.php b/tests/units/Model/GroupMemberTest.php
index 16f769e8..0ff9fdf6 100644
--- a/tests/units/Model/GroupMemberTest.php
+++ b/tests/units/Model/GroupMemberTest.php
@@ -72,5 +72,35 @@ class GroupMemberTest extends Base
$this->assertCount(2, $users);
$this->assertEquals('admin', $users[0]['username']);
$this->assertEquals('user1', $users[1]['username']);
+
+ $groups = $groupMemberModel->getGroups(1);
+ $this->assertCount(1, $groups);
+ $this->assertEquals(1, $groups[0]['id']);
+ $this->assertEquals('Group A', $groups[0]['name']);
+
+ $groups = $groupMemberModel->getGroups(2);
+ $this->assertCount(1, $groups);
+ $this->assertEquals(1, $groups[0]['id']);
+ $this->assertEquals('Group A', $groups[0]['name']);
+
+ $groups = $groupMemberModel->getGroups(3);
+ $this->assertCount(1, $groups);
+ $this->assertEquals(2, $groups[0]['id']);
+ $this->assertEquals('Group B', $groups[0]['name']);
+
+ $groups = $groupMemberModel->getGroups(4);
+ $this->assertCount(1, $groups);
+ $this->assertEquals(2, $groups[0]['id']);
+ $this->assertEquals('Group B', $groups[0]['name']);
+
+ $groups = $groupMemberModel->getGroups(5);
+ $this->assertCount(2, $groups);
+ $this->assertEquals(1, $groups[0]['id']);
+ $this->assertEquals('Group A', $groups[0]['name']);
+ $this->assertEquals(2, $groups[1]['id']);
+ $this->assertEquals('Group B', $groups[1]['name']);
+
+ $groups = $groupMemberModel->getGroups(6);
+ $this->assertCount(0, $groups);
}
}