diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functionals/ApiTest.php | 10 | ||||
-rw-r--r-- | tests/units/ActionTest.php | 8 | ||||
-rw-r--r-- | tests/units/ProjectDuplicationTest.php | 4 | ||||
-rw-r--r-- | tests/units/SubtaskTest.php | 75 |
4 files changed, 88 insertions, 9 deletions
diff --git a/tests/functionals/ApiTest.php b/tests/functionals/ApiTest.php index f778d1ca..9fdfd1ba 100644 --- a/tests/functionals/ApiTest.php +++ b/tests/functionals/ApiTest.php @@ -39,7 +39,7 @@ class Api extends PHPUnit_Framework_TestCase { $this->client = new JsonRPC\Client(API_URL); $this->client->authentication('jsonrpc', API_KEY); - //$this->client->debug = true; + // $this->client->debug = true; } private function getTaskId() @@ -53,8 +53,12 @@ class Api extends PHPUnit_Framework_TestCase public function testGetTimezone() { - $timezone = $this->client->getTimezone(); - $this->assertEquals('Europe/Paris', $timezone); + $this->assertEquals('Europe/Paris', $this->client->getTimezone()); + } + + public function testGetVersion() + { + $this->assertEquals('master', $this->client->getVersion()); } public function testRemoveAll() diff --git a/tests/units/ActionTest.php b/tests/units/ActionTest.php index 429a181a..67957a26 100644 --- a/tests/units/ActionTest.php +++ b/tests/units/ActionTest.php @@ -27,7 +27,7 @@ class ActionTest extends Base $this->assertEquals(1, $project->create(array('name' => 'unit_test'))); // We create a new action - $this->assertTrue($action->create(array( + $this->assertEquals(1, $action->create(array( 'project_id' => 1, 'event_name' => Task::EVENT_MOVE_COLUMN, 'action_name' => 'TaskClose', @@ -78,14 +78,14 @@ class ActionTest extends Base $this->assertEquals(1, $c->create(array('name' => 'unit_test'))); // We create a new action - $this->assertTrue($a->create(array( + $this->assertEquals(1, $a->create(array( 'project_id' => 1, 'event_name' => GithubWebhook::EVENT_ISSUE_OPENED, 'action_name' => 'TaskCreation', 'params' => array() ))); - $this->assertTrue($a->create(array( + $this->assertEquals(2, $a->create(array( 'project_id' => 1, 'event_name' => GithubWebhook::EVENT_ISSUE_LABEL_CHANGE, 'action_name' => 'TaskAssignCategoryLabel', @@ -95,7 +95,7 @@ class ActionTest extends Base ) ))); - $this->assertTrue($a->create(array( + $this->assertEquals(3, $a->create(array( 'project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignColorCategory', diff --git a/tests/units/ProjectDuplicationTest.php b/tests/units/ProjectDuplicationTest.php index b35575aa..311ecc4a 100644 --- a/tests/units/ProjectDuplicationTest.php +++ b/tests/units/ProjectDuplicationTest.php @@ -156,7 +156,7 @@ class ProjectDuplicationTest extends Base $this->assertEquals(1, $p->create(array('name' => 'P1'))); - $this->assertTrue($a->create(array( + $this->assertEquals(1, $a->create(array( 'project_id' => 1, 'event_name' => Task::EVENT_MOVE_COLUMN, 'action_name' => 'TaskAssignCurrentUser', @@ -186,7 +186,7 @@ class ProjectDuplicationTest extends Base $this->assertEquals(2, $c->create(array('name' => 'C2', 'project_id' => 1))); $this->assertEquals(3, $c->create(array('name' => 'C3', 'project_id' => 1))); - $this->assertTrue($a->create(array( + $this->assertEquals(1, $a->create(array( 'project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignColorCategory', diff --git a/tests/units/SubtaskTest.php b/tests/units/SubtaskTest.php index 62475186..eb1a3fd3 100644 --- a/tests/units/SubtaskTest.php +++ b/tests/units/SubtaskTest.php @@ -11,6 +11,78 @@ use Model\User; class SubTaskTest extends Base { + public function testMoveUp() + { + $tc = new TaskCreation($this->container); + $s = new Subtask($this->container); + $p = new Project($this->container); + + $this->assertEquals(1, $p->create(array('name' => 'test1'))); + $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); + + $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1))); + $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1))); + $this->assertEquals(3, $s->create(array('title' => 'subtask #3', 'task_id' => 1))); + + $subtask = $s->getById(1); + $this->assertNotEmpty($subtask); + $this->assertEquals(1, $subtask['position']); + + $subtask = $s->getById(2); + $this->assertNotEmpty($subtask); + $this->assertEquals(2, $subtask['position']); + + $subtask = $s->getById(3); + $this->assertNotEmpty($subtask); + $this->assertEquals(3, $subtask['position']); + + $this->assertTrue($s->moveUp(1, 2)); + + $subtask = $s->getById(1); + $this->assertNotEmpty($subtask); + $this->assertEquals(2, $subtask['position']); + + $subtask = $s->getById(2); + $this->assertNotEmpty($subtask); + $this->assertEquals(1, $subtask['position']); + + $subtask = $s->getById(3); + $this->assertNotEmpty($subtask); + $this->assertEquals(3, $subtask['position']); + + $this->assertFalse($s->moveUp(1, 2)); + } + + public function testMoveDown() + { + $tc = new TaskCreation($this->container); + $s = new Subtask($this->container); + $p = new Project($this->container); + + $this->assertEquals(1, $p->create(array('name' => 'test1'))); + $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); + + $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1))); + $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1))); + $this->assertEquals(3, $s->create(array('title' => 'subtask #3', 'task_id' => 1))); + + $this->assertTrue($s->moveDown(1, 1)); + + $subtask = $s->getById(1); + $this->assertNotEmpty($subtask); + $this->assertEquals(2, $subtask['position']); + + $subtask = $s->getById(2); + $this->assertNotEmpty($subtask); + $this->assertEquals(1, $subtask['position']); + + $subtask = $s->getById(3); + $this->assertNotEmpty($subtask); + $this->assertEquals(3, $subtask['position']); + + $this->assertFalse($s->moveDown(1, 3)); + } + public function testDuplicate() { $tc = new TaskCreation($this->container); @@ -53,5 +125,8 @@ class SubTaskTest extends Base $this->assertEquals(0, $subtasks[0]['user_id']); $this->assertEquals(0, $subtasks[1]['user_id']); + + $this->assertEquals(1, $subtasks[0]['position']); + $this->assertEquals(2, $subtasks[1]['position']); } } |