diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration.mysql.xml | 5 | ||||
-rw-r--r-- | tests/units/Model/ConfigTest.php | 60 | ||||
-rw-r--r-- | tests/units/Model/LanguageTest.php | 58 | ||||
-rw-r--r-- | tests/units/Model/ProjectTest.php | 4 | ||||
-rw-r--r-- | tests/units/Model/TimezoneTest.php | 32 |
5 files changed, 96 insertions, 63 deletions
diff --git a/tests/integration.mysql.xml b/tests/integration.mysql.xml index 30769371..9d87f77e 100644 --- a/tests/integration.mysql.xml +++ b/tests/integration.mysql.xml @@ -13,5 +13,8 @@ <const name="DB_USERNAME" value="root" /> <const name="DB_PASSWORD" value="" /> <const name="DB_PORT" value="" /> + <const name="DB_SSL_KEY" value="" /> + <const name="DB_SSL_CA" value="" /> + <const name="DB_SSL_CERT" value="" /> </php> -</phpunit>
\ No newline at end of file +</phpunit> diff --git a/tests/units/Model/ConfigTest.php b/tests/units/Model/ConfigTest.php index 6ccdbef9..ad74ad50 100644 --- a/tests/units/Model/ConfigTest.php +++ b/tests/units/Model/ConfigTest.php @@ -6,66 +6,6 @@ use Kanboard\Model\Config; class ConfigTest extends Base { - public function testGetTimezones() - { - $configModel = new Config($this->container); - $this->assertNotEmpty($configModel->getTimezones()); - $this->assertArrayHasKey('Europe/Paris', $configModel->getTimezones()); - $this->assertContains('Europe/Paris', $configModel->getTimezones()); - $this->assertArrayNotHasKey('', $configModel->getTimezones()); - - $this->assertArrayHasKey('', $configModel->getTimezones(true)); - $this->assertContains('Application default', $configModel->getTimezones(true)); - } - - public function testGetLanguages() - { - $configModel = new Config($this->container); - $this->assertNotEmpty($configModel->getLanguages()); - $this->assertArrayHasKey('fr_FR', $configModel->getLanguages()); - $this->assertContains('Français', $configModel->getLanguages()); - $this->assertArrayNotHasKey('', $configModel->getLanguages()); - - $this->assertArrayHasKey('', $configModel->getLanguages(true)); - $this->assertContains('Application default', $configModel->getLanguages(true)); - } - - public function testGetJsLanguage() - { - $configModel = new Config($this->container); - $this->assertEquals('en', $configModel->getJsLanguageCode()); - - $this->container['sessionStorage']->user = array('language' => 'fr_FR'); - $this->assertEquals('fr', $configModel->getJsLanguageCode()); - - $this->container['sessionStorage']->user = array('language' => 'xx_XX'); - $this->assertEquals('en', $configModel->getJsLanguageCode()); - } - - public function testGetCurrentLanguage() - { - $configModel = new Config($this->container); - $this->assertEquals('en_US', $configModel->getCurrentLanguage()); - - $this->container['sessionStorage']->user = array('language' => 'fr_FR'); - $this->assertEquals('fr_FR', $configModel->getCurrentLanguage()); - - $this->container['sessionStorage']->user = array('language' => 'xx_XX'); - $this->assertEquals('xx_XX', $configModel->getCurrentLanguage()); - } - - public function testGetCurrentTimezone() - { - $configModel = new Config($this->container); - $this->assertEquals('UTC', $configModel->getCurrentTimezone()); - - $this->container['sessionStorage']->user = array('timezone' => 'Europe/Paris'); - $this->assertEquals('Europe/Paris', $configModel->getCurrentTimezone()); - - $this->container['sessionStorage']->user = array('timezone' => 'Something'); - $this->assertEquals('Something', $configModel->getCurrentTimezone()); - } - public function testRegenerateToken() { $configModel = new Config($this->container); diff --git a/tests/units/Model/LanguageTest.php b/tests/units/Model/LanguageTest.php new file mode 100644 index 00000000..dff98a83 --- /dev/null +++ b/tests/units/Model/LanguageTest.php @@ -0,0 +1,58 @@ +<?php + +use Kanboard\Model\Language; + +require_once __DIR__.'/../Base.php'; + +class LanguageTest extends Base +{ + public function testGetCodes() + { + $codes = Language::getCodes(); + $this->assertContains('fr_FR', $codes); + $this->assertContains('en_US', $codes); + } + + public function testFindCode() + { + $this->assertSame('', Language::findCode('xx-XX')); + $this->assertSame('fr_FR', Language::findCode('fr-FR')); + $this->assertSame('en_US', Language::findCode('en-US')); + } + + public function testGetJsLanguage() + { + $languageModel = new Language($this->container); + $this->assertEquals('en', $languageModel->getJsLanguageCode()); + + $this->container['sessionStorage']->user = array('language' => 'fr_FR'); + $this->assertEquals('fr', $languageModel->getJsLanguageCode()); + + $this->container['sessionStorage']->user = array('language' => 'xx_XX'); + $this->assertEquals('en', $languageModel->getJsLanguageCode()); + } + + public function testGetCurrentLanguage() + { + $languageModel = new Language($this->container); + $this->assertEquals('en_US', $languageModel->getCurrentLanguage()); + + $this->container['sessionStorage']->user = array('language' => 'fr_FR'); + $this->assertEquals('fr_FR', $languageModel->getCurrentLanguage()); + + $this->container['sessionStorage']->user = array('language' => 'xx_XX'); + $this->assertEquals('xx_XX', $languageModel->getCurrentLanguage()); + } + + public function testGetLanguages() + { + $languageModel = new Language($this->container); + $this->assertNotEmpty($languageModel->getLanguages()); + $this->assertArrayHasKey('fr_FR', $languageModel->getLanguages()); + $this->assertContains('Français', $languageModel->getLanguages()); + $this->assertArrayNotHasKey('', $languageModel->getLanguages()); + + $this->assertArrayHasKey('', $languageModel->getLanguages(true)); + $this->assertContains('Application default', $languageModel->getLanguages(true)); + } +} diff --git a/tests/units/Model/ProjectTest.php b/tests/units/Model/ProjectTest.php index b3dcd2e5..6c50744b 100644 --- a/tests/units/Model/ProjectTest.php +++ b/tests/units/Model/ProjectTest.php @@ -15,10 +15,10 @@ class ProjectTest extends Base { public function testCreationForAllLanguages() { - $c = new Config($this->container); $p = new Project($this->container); - foreach ($c->getLanguages() as $locale => $language) { + foreach ($this->container['language']->getLanguages() as $locale => $language) { + Translator::unload(); Translator::load($locale); $this->assertNotFalse($p->create(array('name' => 'UnitTest '.$locale)), 'Unable to create project with '.$locale.':'.$language); } diff --git a/tests/units/Model/TimezoneTest.php b/tests/units/Model/TimezoneTest.php new file mode 100644 index 00000000..ac2cd6a1 --- /dev/null +++ b/tests/units/Model/TimezoneTest.php @@ -0,0 +1,32 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Kanboard\Model\Timezone; + +class TimezoneTest extends Base +{ + public function testGetTimezones() + { + $timezoneModel = new Timezone($this->container); + $this->assertNotEmpty($timezoneModel->getTimezones()); + $this->assertArrayHasKey('Europe/Paris', $timezoneModel->getTimezones()); + $this->assertContains('Europe/Paris', $timezoneModel->getTimezones()); + $this->assertArrayNotHasKey('', $timezoneModel->getTimezones()); + + $this->assertArrayHasKey('', $timezoneModel->getTimezones(true)); + $this->assertContains('Application default', $timezoneModel->getTimezones(true)); + } + + public function testGetCurrentTimezone() + { + $timezoneModel = new Timezone($this->container); + $this->assertEquals('UTC', $timezoneModel->getCurrentTimezone()); + + $this->container['sessionStorage']->user = array('timezone' => 'Europe/Paris'); + $this->assertEquals('Europe/Paris', $timezoneModel->getCurrentTimezone()); + + $this->container['sessionStorage']->user = array('timezone' => 'Something'); + $this->assertEquals('Something', $timezoneModel->getCurrentTimezone()); + } +} |