Improve board API calls
This commit is contained in:
@@ -38,6 +38,7 @@ class Api extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->client = new JsonRPC\Client(API_URL);
|
||||
$this->client->authentication('jsonrpc', API_KEY);
|
||||
//$this->client->debug = true;
|
||||
}
|
||||
|
||||
private function getTaskId()
|
||||
@@ -126,7 +127,7 @@ class Api extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testUpdateColumn()
|
||||
{
|
||||
$this->assertTrue($this->client->updateColumn(4, array('title' => 'Boo', 'task_limit' => 2)));
|
||||
$this->assertTrue($this->client->updateColumn(4, 'Boo', 2));
|
||||
|
||||
$columns = $this->client->getColumns(1);
|
||||
$this->assertTrue(is_array($columns));
|
||||
@@ -136,7 +137,7 @@ class Api extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testAddColumn()
|
||||
{
|
||||
$this->assertTrue($this->client->addColumn(1, array('title' => 'New column')));
|
||||
$this->assertTrue($this->client->addColumn(1, 'New column'));
|
||||
|
||||
$columns = $this->client->getColumns(1);
|
||||
$this->assertTrue(is_array($columns));
|
||||
@@ -164,14 +165,20 @@ class Api extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
|
||||
$this->assertTrue($this->client->execute('createTask', $task));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException BadFunctionCallException
|
||||
*/
|
||||
public function testCreateTaskWithBadParams()
|
||||
{
|
||||
$task = array(
|
||||
'title' => 'Task #1',
|
||||
'color_id' => 'blue',
|
||||
'owner_id' => 1,
|
||||
);
|
||||
|
||||
$this->assertNull($this->client->createTask($task));
|
||||
$this->client->createTask($task);
|
||||
}
|
||||
|
||||
public function testGetTask()
|
||||
@@ -236,7 +243,13 @@ class Api extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
|
||||
$this->assertTrue($this->client->execute('createUser', $user));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException BadFunctionCallException
|
||||
*/
|
||||
public function testCreateUserWithBadParams()
|
||||
{
|
||||
$user = array(
|
||||
'name' => 'Titi',
|
||||
'password' => '123456',
|
||||
@@ -481,9 +494,14 @@ class Api extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
|
||||
$this->assertFalse($this->client->execute('createCategory', $category));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException BadFunctionCallException
|
||||
*/
|
||||
public function testCategoryCreationWithBadParams()
|
||||
{
|
||||
// Missing project id
|
||||
|
||||
$category = array(
|
||||
'name' => 'Category',
|
||||
);
|
||||
|
||||
@@ -39,6 +39,92 @@ class BoardTest extends Base
|
||||
$this->assertEquals('column #2', $columns[6]);
|
||||
}
|
||||
|
||||
public function testGetBoard()
|
||||
{
|
||||
$p = new Project($this->registry);
|
||||
$b = new Board($this->registry);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
|
||||
|
||||
$board = $b->get(1);
|
||||
$this->assertNotEmpty($board);
|
||||
$this->assertEquals(4, count($board));
|
||||
$this->assertTrue(array_key_exists('tasks', $board[2]));
|
||||
$this->assertTrue(array_key_exists('title', $board[2]));
|
||||
}
|
||||
|
||||
public function testGetColumn()
|
||||
{
|
||||
$p = new Project($this->registry);
|
||||
$b = new Board($this->registry);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
|
||||
|
||||
$column = $b->getColumn(3);
|
||||
$this->assertNotEmpty($column);
|
||||
$this->assertEquals('Work in progress', $column['title']);
|
||||
|
||||
$column = $b->getColumn(33);
|
||||
$this->assertEmpty($column);
|
||||
}
|
||||
|
||||
public function testRemoveColumn()
|
||||
{
|
||||
$p = new Project($this->registry);
|
||||
$b = new Board($this->registry);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
|
||||
$this->assertTrue($b->removeColumn(3));
|
||||
$this->assertFalse($b->removeColumn(322));
|
||||
|
||||
$columns = $b->getColumns(1);
|
||||
$this->assertTrue(is_array($columns));
|
||||
$this->assertEquals(3, count($columns));
|
||||
}
|
||||
|
||||
public function testUpdateColumn()
|
||||
{
|
||||
$p = new Project($this->registry);
|
||||
$b = new Board($this->registry);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
|
||||
|
||||
$this->assertTrue($b->updateColumn(3, 'blah', 5));
|
||||
$this->assertTrue($b->updateColumn(2, 'boo'));
|
||||
|
||||
$column = $b->getColumn(3);
|
||||
$this->assertNotEmpty($column);
|
||||
$this->assertEquals('blah', $column['title']);
|
||||
$this->assertEquals(5, $column['task_limit']);
|
||||
|
||||
$column = $b->getColumn(2);
|
||||
$this->assertNotEmpty($column);
|
||||
$this->assertEquals('boo', $column['title']);
|
||||
$this->assertEquals(0, $column['task_limit']);
|
||||
}
|
||||
|
||||
public function testAddColumn()
|
||||
{
|
||||
$p = new Project($this->registry);
|
||||
$b = new Board($this->registry);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
|
||||
$this->assertTrue($b->addColumn(1, 'another column'));
|
||||
$this->assertTrue($b->addColumn(1, 'one more', 3));
|
||||
|
||||
$columns = $b->getColumns(1);
|
||||
$this->assertTrue(is_array($columns));
|
||||
$this->assertEquals(6, count($columns));
|
||||
|
||||
$this->assertEquals('another column', $columns[4]['title']);
|
||||
$this->assertEquals(0, $columns[4]['task_limit']);
|
||||
$this->assertEquals(5, $columns[4]['position']);
|
||||
|
||||
$this->assertEquals('one more', $columns[5]['title']);
|
||||
$this->assertEquals(3, $columns[5]['task_limit']);
|
||||
$this->assertEquals(6, $columns[5]['position']);
|
||||
}
|
||||
|
||||
public function testMoveColumns()
|
||||
{
|
||||
$p = new Project($this->registry);
|
||||
|
||||
Reference in New Issue
Block a user