diff --git a/tests/lib/SimpleSAML/Locale/TranslateTest.php b/tests/lib/SimpleSAML/Locale/TranslateTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ee431d6005e4c2f50cb0240a5a452616d3b4a3a7 --- /dev/null +++ b/tests/lib/SimpleSAML/Locale/TranslateTest.php @@ -0,0 +1,38 @@ +<?php + +namespace SimpleSAML\Test\Locale; + +use SimpleSAML\Locale\Translate; + +class TranslateTest extends \PHPUnit_Framework_TestCase +{ + + /** + * Test SimpleSAML\Locale\Translate::noop(). + */ + public function testNoop() + { + // test default + $c = \SimpleSAML_Configuration::loadFromArray(array()); + $t = new Translate($c); + $testString = 'Blablabla'; + $this->assertEquals($testString, $t->noop($testString)); + } + + /** + * Test SimpleSAML\Locale\Translate::t(). + */ + public function testTFallback() + { + $c = \SimpleSAML_Configuration::loadFromArray(array()); + $t = new Translate($c); + $testString = 'Blablabla'; + + // $fallbackdefault = true + $result = 'not translated ('.$testString.')'; + $this->assertEquals($result, $t->t($testString)); + + // $fallbackdefault = false, should be a noop + $this->assertEquals($testString, $t->t($testString, array(), false)); + } +}