diff --git a/tests/lib/SimpleSAML/Locale/LanguageTest.php b/tests/lib/SimpleSAML/Locale/LanguageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6921ba91744b712a281e9e57d54233ac19ce911f --- /dev/null +++ b/tests/lib/SimpleSAML/Locale/LanguageTest.php @@ -0,0 +1,33 @@ +<?php + +namespace SimpleSAML\Test\Locale; + +use SimpleSAML\Locale\Language; + +class LanguageTest extends \PHPUnit_Framework_TestCase +{ + + + /** + * Test SimpleSAML\Locale\Language::getLanguageCookie(). + */ + public function testGetLanguageCookie() + { + // test it works when no cookie is set + \SimpleSAML_Configuration::loadFromArray(array(), '', 'simplesaml'); + $this->assertNull(Language::getLanguageCookie()); + + // test that it works fine with defaults + \SimpleSAML_Configuration::loadFromArray(array(), '', 'simplesaml'); + $_COOKIE['language'] = 'en'; + $this->assertEquals('en', Language::getLanguageCookie()); + + // test that it works with non-defaults + \SimpleSAML_Configuration::loadFromArray(array( + 'language.available' => array('xx', 'yy', 'zz'), + 'language.cookie.name' => 'xyz' + ), '', 'simplesaml'); + $_COOKIE['xyz'] = 'yy'; + $this->assertEquals('yy', Language::getLanguageCookie()); + } +}