diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-12-28 15:39:39 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-12-28 15:39:39 -0500 |
commit | e59be3dc021e81babaacf70661737cbba42c80cc (patch) | |
tree | 76fd26ca5ce17261927917699b6fb4e689df054e /tests/units | |
parent | bcbc1b78c67860a1037e77a97c260899611adcdc (diff) |
Add default project categories in settings
Diffstat (limited to 'tests/units')
-rw-r--r-- | tests/units/ConfigTest.php | 3 | ||||
-rw-r--r-- | tests/units/ProjectTest.php | 60 |
2 files changed, 63 insertions, 0 deletions
diff --git a/tests/units/ConfigTest.php b/tests/units/ConfigTest.php index 950d4a09..b630f284 100644 --- a/tests/units/ConfigTest.php +++ b/tests/units/ConfigTest.php @@ -51,5 +51,8 @@ class ConfigTest extends Base $this->assertEquals('foo', $c->get('board_columns')); $this->assertEquals('foo', $c->get('board_columns', 'test')); $this->assertEquals('test', $c->get('empty_value', 'test')); + + session_id(''); + unset($this->container['session']); } } diff --git a/tests/units/ProjectTest.php b/tests/units/ProjectTest.php index 31481d96..38b742b3 100644 --- a/tests/units/ProjectTest.php +++ b/tests/units/ProjectTest.php @@ -10,6 +10,8 @@ use Model\Task; use Model\TaskCreation; use Model\Acl; use Model\Board; +use Model\Config; +use Model\Category; class ProjectTest extends Base { @@ -28,6 +30,64 @@ class ProjectTest extends Base $this->assertEmpty($project['token']); } + public function testCreationWithDefaultCategories() + { + $p = new Project($this->container); + $c = new Config($this->container); + $cat = new Category($this->container); + + // Multiple categories correctly formatted + + $this->assertTrue($c->save(array('project_categories' => 'Test1, Test2'))); + $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); + + $project = $p->getById(1); + $this->assertNotEmpty($project); + + $categories = $cat->getAll(1); + $this->assertNotEmpty($categories); + $this->assertEquals(2, count($categories)); + $this->assertEquals('Test1', $categories[0]['name']); + $this->assertEquals('Test2', $categories[1]['name']); + + // Single category + + $this->assertTrue($c->save(array('project_categories' => 'Test1'))); + $this->assertEquals(2, $p->create(array('name' => 'UnitTest2'))); + + $project = $p->getById(2); + $this->assertNotEmpty($project); + + $categories = $cat->getAll(2); + $this->assertNotEmpty($categories); + $this->assertEquals(1, count($categories)); + $this->assertEquals('Test1', $categories[0]['name']); + + // Multiple categories badly formatted + + $this->assertTrue($c->save(array('project_categories' => 'ABC, , DEF 3, '))); + $this->assertEquals(3, $p->create(array('name' => 'UnitTest3'))); + + $project = $p->getById(3); + $this->assertNotEmpty($project); + + $categories = $cat->getAll(3); + $this->assertNotEmpty($categories); + $this->assertEquals(2, count($categories)); + $this->assertEquals('ABC', $categories[0]['name']); + $this->assertEquals('DEF 3', $categories[1]['name']); + + // No default categories + $this->assertTrue($c->save(array('project_categories' => ' '))); + $this->assertEquals(4, $p->create(array('name' => 'UnitTest4'))); + + $project = $p->getById(4); + $this->assertNotEmpty($project); + + $categories = $cat->getAll(4); + $this->assertEmpty($categories); + } + public function testUpdateLastModifiedDate() { $p = new Project($this->container); |