diff options
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/ApiTest.php | 212 | ||||
-rw-r--r-- | tests/integration/Base.php | 2 | ||||
-rw-r--r-- | tests/integration/BoardTest.php | 21 | ||||
-rw-r--r-- | tests/integration/ColumnTest.php | 65 | ||||
-rw-r--r-- | tests/integration/SwimlaneTest.php | 103 | ||||
-rw-r--r-- | tests/integration/UserTest.php | 18 |
6 files changed, 222 insertions, 199 deletions
diff --git a/tests/integration/ApiTest.php b/tests/integration/ApiTest.php index 798bde42..5fed0368 100644 --- a/tests/integration/ApiTest.php +++ b/tests/integration/ApiTest.php @@ -170,192 +170,6 @@ class Api extends PHPUnit_Framework_TestCase $this->assertCount(0, $activities); } - public function testGetBoard() - { - $board = $this->client->getBoard(1); - $this->assertTrue(is_array($board)); - $this->assertEquals(1, count($board)); - $this->assertEquals('Default swimlane', $board[0]['name']); - $this->assertEquals(4, count($board[0]['columns'])); - } - - public function testGetColumns() - { - $columns = $this->client->getColumns(1); - $this->assertTrue(is_array($columns)); - $this->assertEquals(4, count($columns)); - $this->assertEquals('Done', $columns[3]['title']); - } - - public function testMoveColumnUp() - { - $this->assertTrue($this->client->moveColumnUp(1, 4)); - - $columns = $this->client->getColumns(1); - $this->assertTrue(is_array($columns)); - $this->assertEquals('Done', $columns[2]['title']); - $this->assertEquals('Work in progress', $columns[3]['title']); - } - - public function testMoveColumnDown() - { - $this->assertTrue($this->client->moveColumnDown(1, 4)); - - $columns = $this->client->getColumns(1); - $this->assertTrue(is_array($columns)); - $this->assertEquals('Work in progress', $columns[2]['title']); - $this->assertEquals('Done', $columns[3]['title']); - } - - public function testUpdateColumn() - { - $this->assertTrue($this->client->updateColumn(4, 'Boo', 2)); - - $columns = $this->client->getColumns(1); - $this->assertTrue(is_array($columns)); - $this->assertEquals('Boo', $columns[3]['title']); - $this->assertEquals(2, $columns[3]['task_limit']); - } - - public function testAddColumn() - { - $column_id = $this->client->addColumn(1, 'New column'); - - $this->assertNotFalse($column_id); - $this->assertInternalType('int', $column_id); - $this->assertTrue($column_id > 0); - - $columns = $this->client->getColumns(1); - $this->assertTrue(is_array($columns)); - $this->assertEquals(5, count($columns)); - $this->assertEquals('New column', $columns[4]['title']); - } - - public function testRemoveColumn() - { - $this->assertTrue($this->client->removeColumn(5)); - - $columns = $this->client->getColumns(1); - $this->assertTrue(is_array($columns)); - $this->assertEquals(4, count($columns)); - } - - public function testGetDefaultSwimlane() - { - $swimlane = $this->client->getDefaultSwimlane(1); - $this->assertNotEmpty($swimlane); - $this->assertEquals('Default swimlane', $swimlane['default_swimlane']); - } - - public function testAddSwimlane() - { - $swimlane_id = $this->client->addSwimlane(1, 'Swimlane 1'); - $this->assertNotFalse($swimlane_id); - $this->assertInternalType('int', $swimlane_id); - - $swimlane = $this->client->getSwimlaneById($swimlane_id); - $this->assertNotEmpty($swimlane); - $this->assertInternalType('array', $swimlane); - $this->assertEquals('Swimlane 1', $swimlane['name']); - } - - public function testGetSwimlane() - { - $swimlane = $this->client->getSwimlane(1); - $this->assertNotEmpty($swimlane); - $this->assertInternalType('array', $swimlane); - $this->assertEquals('Swimlane 1', $swimlane['name']); - } - - public function testUpdateSwimlane() - { - $swimlane = $this->client->getSwimlaneByName(1, 'Swimlane 1'); - $this->assertNotEmpty($swimlane); - $this->assertInternalType('array', $swimlane); - $this->assertEquals(1, $swimlane['id']); - $this->assertEquals('Swimlane 1', $swimlane['name']); - - $this->assertTrue($this->client->updateSwimlane($swimlane['id'], 'Another swimlane')); - - $swimlane = $this->client->getSwimlaneById($swimlane['id']); - $this->assertNotEmpty($swimlane); - $this->assertEquals('Another swimlane', $swimlane['name']); - } - - public function testDisableSwimlane() - { - $this->assertTrue($this->client->disableSwimlane(1, 1)); - - $swimlane = $this->client->getSwimlaneById(1); - $this->assertNotEmpty($swimlane); - $this->assertEquals(0, $swimlane['is_active']); - } - - public function testEnableSwimlane() - { - $this->assertTrue($this->client->enableSwimlane(1, 1)); - - $swimlane = $this->client->getSwimlaneById(1); - $this->assertNotEmpty($swimlane); - $this->assertEquals(1, $swimlane['is_active']); - } - - public function testGetAllSwimlanes() - { - $this->assertNotFalse($this->client->addSwimlane(1, 'Swimlane A')); - - $swimlanes = $this->client->getAllSwimlanes(1); - $this->assertNotEmpty($swimlanes); - $this->assertCount(2, $swimlanes); - $this->assertEquals('Another swimlane', $swimlanes[0]['name']); - $this->assertEquals('Swimlane A', $swimlanes[1]['name']); - } - - public function testGetActiveSwimlane() - { - $this->assertTrue($this->client->disableSwimlane(1, 1)); - - $swimlanes = $this->client->getActiveSwimlanes(1); - $this->assertNotEmpty($swimlanes); - $this->assertCount(2, $swimlanes); - $this->assertEquals('Default swimlane', $swimlanes[0]['name']); - $this->assertEquals('Swimlane A', $swimlanes[1]['name']); - } - - public function testMoveSwimlaneUp() - { - $this->assertTrue($this->client->enableSwimlane(1, 1)); - $this->assertTrue($this->client->moveSwimlaneUp(1, 1)); - - $swimlanes = $this->client->getActiveSwimlanes(1); - $this->assertNotEmpty($swimlanes); - $this->assertCount(3, $swimlanes); - $this->assertEquals('Default swimlane', $swimlanes[0]['name']); - $this->assertEquals('Another swimlane', $swimlanes[1]['name']); - $this->assertEquals('Swimlane A', $swimlanes[2]['name']); - - $this->assertTrue($this->client->moveSwimlaneUp(1, 2)); - - $swimlanes = $this->client->getActiveSwimlanes(1); - $this->assertNotEmpty($swimlanes); - $this->assertCount(3, $swimlanes); - $this->assertEquals('Default swimlane', $swimlanes[0]['name']); - $this->assertEquals('Swimlane A', $swimlanes[1]['name']); - $this->assertEquals('Another swimlane', $swimlanes[2]['name']); - } - - public function testMoveSwimlaneDown() - { - $this->assertTrue($this->client->moveSwimlaneDown(1, 2)); - - $swimlanes = $this->client->getActiveSwimlanes(1); - $this->assertNotEmpty($swimlanes); - $this->assertCount(3, $swimlanes); - $this->assertEquals('Default swimlane', $swimlanes[0]['name']); - $this->assertEquals('Another swimlane', $swimlanes[1]['name']); - $this->assertEquals('Swimlane A', $swimlanes[2]['name']); - } - public function testCreateTaskWithWrongMember() { $task = array( @@ -464,18 +278,6 @@ class Api extends PHPUnit_Framework_TestCase $this->assertNotEquals($moved_timestamp, $task['date_moved']); } - public function testRemoveSwimlane() - { - $this->assertTrue($this->client->removeSwimlane(1, 2)); - - $task = $this->client->getTask($this->getTaskId()); - $this->assertNotFalse($task); - $this->assertTrue(is_array($task)); - $this->assertEquals(1, $task['position']); - $this->assertEquals(4, $task['column_id']); - $this->assertEquals(0, $task['swimlane_id']); - } - public function testUpdateTask() { $task = $this->client->getTask(1); @@ -563,6 +365,20 @@ class Api extends PHPUnit_Framework_TestCase $this->assertNull($this->client->getUser(2222)); } + public function testGetUserByName() + { + $user = $this->client->getUserByName('toto'); + $this->assertNotFalse($user); + $this->assertTrue(is_array($user)); + $this->assertEquals(2, $user['id']); + + $user = $this->client->getUserByName('manager'); + $this->assertNotEmpty($user); + $this->assertEquals('app-manager', $user['role']); + + $this->assertNull($this->client->getUserByName('nonexistantusername')); + } + public function testUpdateUser() { $user = array(); diff --git a/tests/integration/Base.php b/tests/integration/Base.php index 6facd9ce..983d0ed9 100644 --- a/tests/integration/Base.php +++ b/tests/integration/Base.php @@ -35,7 +35,7 @@ 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->debug = true; $this->admin = new JsonRPC\Client(API_URL); $this->admin->authentication('admin', 'admin'); diff --git a/tests/integration/BoardTest.php b/tests/integration/BoardTest.php new file mode 100644 index 00000000..bf8d50b9 --- /dev/null +++ b/tests/integration/BoardTest.php @@ -0,0 +1,21 @@ +<?php + +require_once __DIR__.'/Base.php'; + +class BoardTest extends Base +{ + public function testCreateProject() + { + $this->assertEquals(1, $this->app->createProject('A project')); + } + + public function testGetBoard() + { + $board = $this->app->getBoard(1); + $this->assertCount(1, $board); + $this->assertEquals('Default swimlane', $board[0]['name']); + + $this->assertCount(4, $board[0]['columns']); + $this->assertEquals('Ready', $board[0]['columns'][1]['title']); + } +} diff --git a/tests/integration/ColumnTest.php b/tests/integration/ColumnTest.php new file mode 100644 index 00000000..6d02afc0 --- /dev/null +++ b/tests/integration/ColumnTest.php @@ -0,0 +1,65 @@ +<?php + +require_once __DIR__.'/Base.php'; + +class ColumnTest extends Base +{ + public function testCreateProject() + { + $this->assertEquals(1, $this->app->createProject('A project')); + } + + public function testGetColumns() + { + $columns = $this->app->getColumns($this->getProjectId()); + $this->assertCount(4, $columns); + $this->assertEquals('Done', $columns[3]['title']); + } + + public function testUpdateColumn() + { + $this->assertTrue($this->app->updateColumn(4, 'Boo', 2)); + + $columns = $this->app->getColumns($this->getProjectId()); + $this->assertEquals('Boo', $columns[3]['title']); + $this->assertEquals(2, $columns[3]['task_limit']); + } + + public function testAddColumn() + { + $column_id = $this->app->addColumn($this->getProjectId(), 'New column'); + + $this->assertNotFalse($column_id); + $this->assertInternalType('int', $column_id); + $this->assertTrue($column_id > 0); + + $columns = $this->app->getColumns($this->getProjectId()); + $this->assertCount(5, $columns); + $this->assertEquals('New column', $columns[4]['title']); + } + + public function testRemoveColumn() + { + $this->assertTrue($this->app->removeColumn(5)); + + $columns = $this->app->getColumns($this->getProjectId()); + $this->assertCount(4, $columns); + } + + public function testChangeColumnPosition() + { + $this->assertTrue($this->app->changeColumnPosition($this->getProjectId(), 1, 3)); + + $columns = $this->app->getColumns($this->getProjectId()); + $this->assertCount(4, $columns); + + $this->assertEquals('Ready', $columns[0]['title']); + $this->assertEquals(1, $columns[0]['position']); + $this->assertEquals('Work in progress', $columns[1]['title']); + $this->assertEquals(2, $columns[1]['position']); + $this->assertEquals('Backlog', $columns[2]['title']); + $this->assertEquals(3, $columns[2]['position']); + $this->assertEquals('Boo', $columns[3]['title']); + $this->assertEquals(4, $columns[3]['position']); + } +} diff --git a/tests/integration/SwimlaneTest.php b/tests/integration/SwimlaneTest.php new file mode 100644 index 00000000..88747204 --- /dev/null +++ b/tests/integration/SwimlaneTest.php @@ -0,0 +1,103 @@ +<?php + +require_once __DIR__.'/Base.php'; + +class SwimlaneTest extends Base +{ + public function testCreateProject() + { + $this->assertEquals(1, $this->app->createProject('A project')); + } + + public function testGetDefaultSwimlane() + { + $swimlane = $this->app->getDefaultSwimlane(1); + $this->assertNotEmpty($swimlane); + $this->assertEquals('Default swimlane', $swimlane['default_swimlane']); + } + + public function testAddSwimlane() + { + $swimlane_id = $this->app->addSwimlane(1, 'Swimlane 1'); + $this->assertNotFalse($swimlane_id); + $this->assertInternalType('int', $swimlane_id); + + $swimlane = $this->app->getSwimlaneById($swimlane_id); + $this->assertNotEmpty($swimlane); + $this->assertInternalType('array', $swimlane); + $this->assertEquals('Swimlane 1', $swimlane['name']); + } + + public function testGetSwimlane() + { + $swimlane = $this->app->getSwimlane(1); + $this->assertInternalType('array', $swimlane); + $this->assertEquals('Swimlane 1', $swimlane['name']); + } + + public function testUpdateSwimlane() + { + $swimlane = $this->app->getSwimlaneByName(1, 'Swimlane 1'); + $this->assertInternalType('array', $swimlane); + $this->assertEquals(1, $swimlane['id']); + $this->assertEquals('Swimlane 1', $swimlane['name']); + + $this->assertTrue($this->app->updateSwimlane($swimlane['id'], 'Another swimlane')); + + $swimlane = $this->app->getSwimlaneById($swimlane['id']); + $this->assertEquals('Another swimlane', $swimlane['name']); + } + + public function testDisableSwimlane() + { + $this->assertTrue($this->app->disableSwimlane(1, 1)); + + $swimlane = $this->app->getSwimlaneById(1); + $this->assertEquals(0, $swimlane['is_active']); + } + + public function testEnableSwimlane() + { + $this->assertTrue($this->app->enableSwimlane(1, 1)); + + $swimlane = $this->app->getSwimlaneById(1); + $this->assertEquals(1, $swimlane['is_active']); + } + + public function testGetAllSwimlanes() + { + $this->assertNotFalse($this->app->addSwimlane(1, 'Swimlane A')); + + $swimlanes = $this->app->getAllSwimlanes(1); + $this->assertCount(2, $swimlanes); + $this->assertEquals('Another swimlane', $swimlanes[0]['name']); + $this->assertEquals('Swimlane A', $swimlanes[1]['name']); + } + + public function testGetActiveSwimlane() + { + $this->assertTrue($this->app->disableSwimlane(1, 1)); + + $swimlanes = $this->app->getActiveSwimlanes(1); + $this->assertCount(2, $swimlanes); + $this->assertEquals('Default swimlane', $swimlanes[0]['name']); + $this->assertEquals('Swimlane A', $swimlanes[1]['name']); + } + + public function testRemoveSwimlane() + { + $this->assertTrue($this->app->removeSwimlane(1, 2)); + } + + public function testChangePosition() + { + $this->assertNotFalse($this->app->addSwimlane(1, 'Swimlane 1')); + $this->assertNotFalse($this->app->addSwimlane(1, 'Swimlane 2')); + + $swimlanes = $this->app->getAllSwimlanes(1); + $this->assertCount(3, $swimlanes); + + $this->assertTrue($this->app->changeSwimlanePosition(1, 1, 3)); + $this->assertFalse($this->app->changeSwimlanePosition(1, 1, 6)); + } +} diff --git a/tests/integration/UserTest.php b/tests/integration/UserTest.php new file mode 100644 index 00000000..10da051c --- /dev/null +++ b/tests/integration/UserTest.php @@ -0,0 +1,18 @@ +<?php + +require_once __DIR__.'/Base.php'; + +class UserTest extends Base +{ + public function testDisableUser() + { + $this->assertEquals(2, $this->app->createUser(array('username' => 'someone', 'password' => 'test123'))); + $this->assertTrue($this->app->isActiveUser(2)); + + $this->assertTrue($this->app->disableUser(2)); + $this->assertFalse($this->app->isActiveUser(2)); + + $this->assertTrue($this->app->enableUser(2)); + $this->assertTrue($this->app->isActiveUser(2)); + } +} |