diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-09-05 23:30:56 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-09-05 23:30:56 -0400 |
commit | 710f2c7bb046b43ec9878ae795a181101f6d7515 (patch) | |
tree | b62723b6b49c3b6bf2b3ca41a772f552464a9031 /tests/units/Model/ConfigTest.php | |
parent | 94b38dd94bd819168163003beec8ef693f9d9839 (diff) |
Improve unit tests
Diffstat (limited to 'tests/units/Model/ConfigTest.php')
-rw-r--r-- | tests/units/Model/ConfigTest.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/units/Model/ConfigTest.php b/tests/units/Model/ConfigTest.php new file mode 100644 index 00000000..c0ed0313 --- /dev/null +++ b/tests/units/Model/ConfigTest.php @@ -0,0 +1,66 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Model\Config; +use Core\Session; + +class ConfigTest extends Base +{ + public function testDefaultValues() + { + $c = new Config($this->container); + + $this->assertEquals('en_US', $c->get('application_language')); + $this->assertEquals('UTC', $c->get('application_timezone')); + + $this->assertEmpty($c->get('webhook_url_task_modification')); + $this->assertEmpty($c->get('webhook_url_task_creation')); + $this->assertEmpty($c->get('board_columns')); + $this->assertEmpty($c->get('application_url')); + + $this->assertNotEmpty($c->get('webhook_token')); + $this->assertNotEmpty($c->get('api_token')); + } + + public function testGet() + { + $c = new Config($this->container); + + $this->assertEquals('', $c->get('board_columns')); + $this->assertEquals('test', $c->get('board_columns', 'test')); + $this->assertEquals(0, $c->get('board_columns', 0)); + } + + public function testGetWithSession() + { + $this->container['session'] = new Session; + $c = new Config($this->container); + + session_id('test'); + + $this->assertTrue(Session::isOpen()); + + $this->assertEquals('', $c->get('board_columns')); + $this->assertEquals('test', $c->get('board_columns', 'test')); + + $this->container['session']['config'] = array( + 'board_columns' => 'foo', + 'empty_value' => 0 + ); + + $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']); + } + + public function testSave() + { + $c = new Config($this->container); + $this->assertTrue($c->save(array('application_url' => 'http://localhost/'))); + $this->assertEquals('http://localhost/', $c->get('application_url')); + } +} |