summaryrefslogtreecommitdiff
path: root/tests/integration/MeTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/MeTest.php')
-rw-r--r--tests/integration/MeTest.php228
1 files changed, 27 insertions, 201 deletions
diff --git a/tests/integration/MeTest.php b/tests/integration/MeTest.php
index 1b028b84..047ebf85 100644
--- a/tests/integration/MeTest.php
+++ b/tests/integration/MeTest.php
@@ -1,207 +1,60 @@
<?php
-require_once __DIR__.'/Base.php';
+require_once __DIR__.'/BaseIntegrationTest.php';
-class MeTest extends Base
+class MeTest extends BaseIntegrationTest
{
- public function testCreateProject()
- {
- $this->assertEquals(1, $this->app->createProject('team project'));
- }
-
- public function testCreateUser()
- {
- $this->assertEquals(2, $this->app->createUser('user', 'password'));
- }
-
- /**
- * @expectedException JsonRPC\Exception\AccessDeniedException
- */
- public function testNotAllowedAppProcedure()
- {
- $this->app->getMe();
- }
-
- /**
- * @expectedException JsonRPC\Exception\AccessDeniedException
- */
- public function testNotAllowedUserProcedure()
- {
- $this->user->getAllProjects();
- }
+ protected $projectName = 'My private project';
- /**
- * @expectedException JsonRPC\Exception\AccessDeniedException
- */
- public function testNotAllowedProjectForUser()
+ public function testAll()
{
- $this->user->getProjectById(1);
+ $this->assertGetMe();
+ $this->assertCreateMyPrivateProject();
+ $this->assertGetMyProjectsList();
+ $this->assertGetMyProjects();
+ $this->assertCreateTask();
+ $this->assertGetMyDashboard();
+ $this->assertGetMyActivityStream();
}
- public function testAllowedProjectForAdmin()
- {
- $this->assertNotEmpty($this->admin->getProjectById(1));
- }
-
- public function testGetTimezone()
- {
- $this->assertEquals('UTC', $this->user->getTimezone());
- }
-
- public function testGetVersion()
- {
- $this->assertEquals('master', $this->user->getVersion());
- }
-
- public function testGetDefaultColor()
- {
- $this->assertEquals('yellow', $this->user->getDefaultTaskColor());
- }
-
- public function testGetDefaultColors()
- {
- $colors = $this->user->getDefaultTaskColors();
- $this->assertNotEmpty($colors);
- $this->assertArrayHasKey('red', $colors);
- }
-
- public function testGetColorList()
- {
- $colors = $this->user->getColorList();
- $this->assertNotEmpty($colors);
- $this->assertArrayHasKey('red', $colors);
- $this->assertEquals('Red', $colors['red']);
- }
-
- public function testGetMe()
+ public function assertGetMe()
{
$profile = $this->user->getMe();
- $this->assertNotEmpty($profile);
- $this->assertEquals(2, $profile['id']);
$this->assertEquals('user', $profile['username']);
+ $this->assertEquals('app-user', $profile['role']);
}
- public function testCreateMyPrivateProject()
+ public function assertCreateMyPrivateProject()
{
- $this->assertEquals(2, $this->user->createMyPrivateProject('my project'));
+ $this->projectId = $this->user->createMyPrivateProject($this->projectName);
+ $this->assertNotFalse($this->projectId);
}
- public function testGetMyProjectsList()
+ public function assertGetMyProjectsList()
{
$projects = $this->user->getMyProjectsList();
$this->assertNotEmpty($projects);
- $this->assertArrayNotHasKey(1, $projects);
- $this->assertArrayHasKey(2, $projects);
- $this->assertEquals('my project', $projects[2]);
+ $this->assertEquals($this->projectName, $projects[$this->projectId]);
}
- public function testGetMyProjects()
+ public function assertGetMyProjects()
{
$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->assertEquals($this->projectName, $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);
- $this->assertNotEmpty($project);
- $this->assertEquals('my project', $project['name']);
- $this->assertEquals(1, $project['is_private']);
- }
-
- public function testCreateTask()
- {
- $this->assertEquals(1, $this->user->createTask('my user title', 2));
- $this->assertEquals(2, $this->admin->createTask('my admin title', 1));
- }
-
- public function testCreateTaskWithWrongMember()
- {
- $this->assertFalse($this->user->createTask(array('title' => 'something', 'project_id' => 2, 'owner_id' => 1)));
- $this->assertFalse($this->app->createTask(array('title' => 'something', 'project_id' => 1, 'owner_id' => 2)));
- }
-
- public function testGetTask()
- {
- $task = $this->user->getTask(1);
- $this->assertNotEmpty($task);
- $this->assertEquals('my user title', $task['title']);
- $this->assertEquals('yellow', $task['color_id']);
- $this->assertArrayHasKey('color', $task);
- $this->assertArrayHasKey('name', $task['color']);
- $this->assertArrayHasKey('border', $task['color']);
- $this->assertArrayHasKey('background', $task['color']);
- }
-
- /**
- * @expectedException JsonRPC\Exception\AccessDeniedException
- */
- public function testGetAdminTask()
+ public function assertCreateTask()
{
- $this->user->getTask(2);
+ $taskId = $this->user->createTask(array('title' => 'My task', 'project_id' => $this->projectId, 'owner_id' => $this->userUserId));
+ $this->assertNotFalse($taskId);
}
- /**
- * @expectedException JsonRPC\Exception\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();
- $this->assertNotEmpty($activity);
- }
-
- public function testCloseTask()
- {
- $this->assertTrue($this->user->closeTask(1));
- }
-
- public function testOpenTask()
- {
- $this->assertTrue($this->user->openTask(1));
- }
-
- public function testMoveTaskPosition()
- {
- $this->assertTrue($this->user->moveTaskPosition(2, 1, 2, 1));
- }
-
- public function testUpdateTaskWithWrongMember()
- {
- $this->assertFalse($this->user->updateTask(array('id' => 1, 'title' => 'new title', 'reference' => 'test', 'owner_id' => 1)));
- }
-
- public function testUpdateTask()
- {
- $this->assertTrue($this->user->updateTask(array('id' => 1, 'title' => 'new title', 'reference' => 'test', 'owner_id' => 2)));
- }
-
- public function testGetbyReference()
- {
- $task = $this->user->getTaskByReference(2, 'test');
- $this->assertNotEmpty($task);
- $this->assertEquals('new title', $task['title']);
- $this->assertEquals(2, $task['column_id']);
- $this->assertEquals(1, $task['position']);
- }
-
- public function testGetMyDashboard()
+ public function assertGetMyDashboard()
{
$dashboard = $this->user->getMyDashboard();
$this->assertNotEmpty($dashboard);
@@ -212,36 +65,9 @@ class MeTest extends Base
$this->assertNotEmpty($dashboard['tasks']);
}
- public function testGetBoard()
- {
- $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()
+ public function assertGetMyActivityStream()
{
- $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']);
+ $activity = $this->user->getMyActivityStream();
+ $this->assertNotEmpty($activity);
}
}