Add some tests
This commit is contained in:
@@ -1055,4 +1055,31 @@ class Api extends PHPUnit_Framework_TestCase
|
||||
$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']);
|
||||
}
|
||||
|
||||
public function testCreateOverdueTask()
|
||||
{
|
||||
$this->assertNotFalse($this->client->createTask(array(
|
||||
'title' => 'overdue task',
|
||||
'project_id' => 1,
|
||||
'date_due' => date('Y-m-d', strtotime('-2days')),
|
||||
)));
|
||||
}
|
||||
|
||||
public function testGetOverdueTasksByProject()
|
||||
{
|
||||
$tasks = $this->client->getOverdueTasksByProject(1);
|
||||
$this->assertNotEmpty($tasks);
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertEquals('overdue task', $tasks[0]['title']);
|
||||
$this->assertEquals('API test', $tasks[0]['project_name']);
|
||||
}
|
||||
|
||||
public function testGetOverdueTasks()
|
||||
{
|
||||
$tasks = $this->client->getOverdueTasks();
|
||||
$this->assertNotEmpty($tasks);
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertEquals('overdue task', $tasks[0]['title']);
|
||||
$this->assertEquals('API test', $tasks[0]['project_name']);
|
||||
}
|
||||
}
|
||||
@@ -121,6 +121,7 @@ class UserApi extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$profile = $this->user->getMe();
|
||||
$this->assertNotEmpty($profile);
|
||||
$this->assertEquals(2, $profile['id']);
|
||||
$this->assertEquals('user', $profile['username']);
|
||||
}
|
||||
|
||||
@@ -138,6 +139,18 @@ class UserApi extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('my project', $projects[2]);
|
||||
}
|
||||
|
||||
public function testGetMyProjects()
|
||||
{
|
||||
$projects = $this->user->getMyProjects();
|
||||
$this->assertNotEmpty($projects);
|
||||
$this->assertCount(1, $projects);
|
||||
$this->assertEquals(2, $projects[0]['id']);
|
||||
$this->assertEquals('my project', $projects[0]['name']);
|
||||
$this->assertNotEmpty($projects[0]['url']['calendar']);
|
||||
$this->assertNotEmpty($projects[0]['url']['board']);
|
||||
$this->assertNotEmpty($projects[0]['url']['list']);
|
||||
}
|
||||
|
||||
public function testGetProjectById()
|
||||
{
|
||||
$project = $this->user->getProjectById(2);
|
||||
@@ -172,6 +185,20 @@ class UserApi extends PHPUnit_Framework_TestCase
|
||||
$this->user->getTask(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException JsonRPC\AccessDeniedException
|
||||
*/
|
||||
public function testGetProjectActivityDenied()
|
||||
{
|
||||
$this->user->getProjectActivity(1);
|
||||
}
|
||||
|
||||
public function testGetProjectActivityAllowed()
|
||||
{
|
||||
$activity = $this->user->getProjectActivity(2);
|
||||
$this->assertNotEmpty($activity);
|
||||
}
|
||||
|
||||
public function testGetMyActivityStream()
|
||||
{
|
||||
$activity = $this->user->getMyActivityStream();
|
||||
@@ -222,4 +249,32 @@ class UserApi extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->assertNotEmpty($this->user->getBoard(2));
|
||||
}
|
||||
|
||||
public function testCreateOverdueTask()
|
||||
{
|
||||
$this->assertNotFalse($this->user->createTask(array(
|
||||
'title' => 'overdue task',
|
||||
'project_id' => 2,
|
||||
'date_due' => date('Y-m-d', strtotime('-2days')),
|
||||
'owner_id' => 2,
|
||||
)));
|
||||
}
|
||||
|
||||
public function testGetMyOverdueTasks()
|
||||
{
|
||||
$tasks = $this->user->getMyOverdueTasks();
|
||||
$this->assertNotEmpty($tasks);
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertEquals('overdue task', $tasks[0]['title']);
|
||||
$this->assertEquals('my project', $tasks[0]['project_name']);
|
||||
}
|
||||
|
||||
public function testGetOverdueTasksByProject()
|
||||
{
|
||||
$tasks = $this->user->getOverdueTasksByProject(2);
|
||||
$this->assertNotEmpty($tasks);
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertEquals('overdue task', $tasks[0]['title']);
|
||||
$this->assertEquals('my project', $tasks[0]['project_name']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,17 @@ class ProjectTest extends Base
|
||||
$this->assertGreaterThan($now, $project['last_modified']);
|
||||
}
|
||||
|
||||
public function testGetAllIds()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
|
||||
|
||||
$this->assertEmpty($p->getAllByIds(array()));
|
||||
$this->assertNotEmpty($p->getAllByIds(array(1, 2)));
|
||||
$this->assertCount(1, $p->getAllByIds(array(1)));
|
||||
}
|
||||
|
||||
public function testIsLastModified()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
|
||||
@@ -30,4 +30,55 @@ class TaskFinderTest extends Base
|
||||
$this->assertEquals(1, count($tasks));
|
||||
$this->assertEquals('Task #1', $tasks[0]['title']);
|
||||
}
|
||||
|
||||
public function testGetOverdueTasksByProject()
|
||||
{
|
||||
$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(2, $p->create(array('name' => 'Project #2')));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 2, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
|
||||
$this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1, 'date_due' => 0)));
|
||||
$this->assertEquals(5, $tc->create(array('title' => 'Task #5', 'project_id' => 1)));
|
||||
|
||||
$tasks = $tf->getOverdueTasksByProject(1);
|
||||
$this->assertNotEmpty($tasks);
|
||||
$this->assertTrue(is_array($tasks));
|
||||
$this->assertEquals(1, count($tasks));
|
||||
$this->assertEquals('Task #1', $tasks[0]['title']);
|
||||
}
|
||||
|
||||
public function testGetOverdueTasksByUser()
|
||||
{
|
||||
$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(2, $p->create(array('name' => 'Project #2')));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 1, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 2, 'owner_id' => 1, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
|
||||
$this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1, 'date_due' => 0)));
|
||||
$this->assertEquals(5, $tc->create(array('title' => 'Task #5', 'project_id' => 1)));
|
||||
|
||||
$tasks = $tf->getOverdueTasksByUser(1);
|
||||
$this->assertNotEmpty($tasks);
|
||||
$this->assertTrue(is_array($tasks));
|
||||
$this->assertEquals(2, count($tasks));
|
||||
|
||||
$this->assertEquals(1, $tasks[0]['id']);
|
||||
$this->assertEquals('Task #1', $tasks[0]['title']);
|
||||
$this->assertEquals(1, $tasks[0]['owner_id']);
|
||||
$this->assertEquals(1, $tasks[0]['project_id']);
|
||||
$this->assertEquals('Project #1', $tasks[0]['project_name']);
|
||||
$this->assertEquals('admin', $tasks[0]['assignee_username']);
|
||||
$this->assertEquals('', $tasks[0]['assignee_name']);
|
||||
|
||||
$this->assertEquals('Task #2', $tasks[1]['title']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user