diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-04-18 14:28:55 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-04-18 14:28:55 -0400 |
commit | 7b7ea56460f755e77194b969c40a38c557ed08f6 (patch) | |
tree | fc309f628da34bf9ed817c01b24a1f2949506de5 /tests/units | |
parent | 94865a7c0343f352e862f7aea232545827922942 (diff) |
Fix issue move column up/down with non consecutive positions
Diffstat (limited to 'tests/units')
-rw-r--r-- | tests/units/BoardTest.php | 80 | ||||
-rw-r--r-- | tests/units/ProjectActivityTest.php | 2 |
2 files changed, 81 insertions, 1 deletions
diff --git a/tests/units/BoardTest.php b/tests/units/BoardTest.php index 23276718..ebd4f655 100644 --- a/tests/units/BoardTest.php +++ b/tests/units/BoardTest.php @@ -289,4 +289,84 @@ class BoardTest extends Base $this->assertEquals(4, $columns[3]['position']); $this->assertEquals($columns_id[3], $columns[3]['id']); } + + public function testMoveUpAndRemoveColumn() + { + $p = new Project($this->container); + $b = new Board($this->container); + + // We create a project + $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); + + // We remove the second column + $this->assertTrue($b->removeColumn(2)); + + $columns = $b->getColumns(1); + $this->assertNotEmpty($columns); + $this->assertCount(3, $columns); + + $this->assertEquals(1, $columns[0]['position']); + $this->assertEquals(3, $columns[1]['position']); + $this->assertEquals(4, $columns[2]['position']); + + $this->assertEquals(1, $columns[0]['id']); + $this->assertEquals(3, $columns[1]['id']); + $this->assertEquals(4, $columns[2]['id']); + + // We move up the second column + $this->assertTrue($b->moveUp(1, $columns[1]['id'])); + + // Check the new positions + $columns = $b->getColumns(1); + $this->assertNotEmpty($columns); + $this->assertCount(3, $columns); + + $this->assertEquals(1, $columns[0]['position']); + $this->assertEquals(2, $columns[1]['position']); + $this->assertEquals(3, $columns[2]['position']); + + $this->assertEquals(3, $columns[0]['id']); + $this->assertEquals(1, $columns[1]['id']); + $this->assertEquals(4, $columns[2]['id']); + } + + public function testMoveDownAndRemoveColumn() + { + $p = new Project($this->container); + $b = new Board($this->container); + + // We create a project + $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); + + // We remove the second column + $this->assertTrue($b->removeColumn(2)); + + $columns = $b->getColumns(1); + $this->assertNotEmpty($columns); + $this->assertCount(3, $columns); + + $this->assertEquals(1, $columns[0]['position']); + $this->assertEquals(3, $columns[1]['position']); + $this->assertEquals(4, $columns[2]['position']); + + $this->assertEquals(1, $columns[0]['id']); + $this->assertEquals(3, $columns[1]['id']); + $this->assertEquals(4, $columns[2]['id']); + + // We move up the second column + $this->assertTrue($b->moveDown(1, $columns[0]['id'])); + + // Check the new positions + $columns = $b->getColumns(1); + $this->assertNotEmpty($columns); + $this->assertCount(3, $columns); + + $this->assertEquals(1, $columns[0]['position']); + $this->assertEquals(2, $columns[1]['position']); + $this->assertEquals(3, $columns[2]['position']); + + $this->assertEquals(3, $columns[0]['id']); + $this->assertEquals(1, $columns[1]['id']); + $this->assertEquals(4, $columns[2]['id']); + } } diff --git a/tests/units/ProjectActivityTest.php b/tests/units/ProjectActivityTest.php index e70dfb0e..f0b27649 100644 --- a/tests/units/ProjectActivityTest.php +++ b/tests/units/ProjectActivityTest.php @@ -41,7 +41,7 @@ class ProjectActivityTest extends Base $this->assertNotEmpty($events); $this->assertTrue(is_array($events)); $this->assertEquals(2, count($events)); - $this->assertEquals(time(), $events[0]['date_creation']); + $this->assertEquals(time(), $events[0]['date_creation'], '', 1); $this->assertEquals(Task::EVENT_UPDATE, $events[0]['event_name']); $this->assertEquals(Task::EVENT_CLOSE, $events[1]['event_name']); } |