From 5245fb2264bfeadd46cce2509a16176ce8739d9c Mon Sep 17 00:00:00 2001 From: Hanne Moa <hanne.moa@uninett.no> Date: Fri, 30 Sep 2016 12:14:38 +0200 Subject: [PATCH] Add easy tests for SimpleSAML/Locale/Translate --- tests/lib/SimpleSAML/Locale/TranslateTest.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/lib/SimpleSAML/Locale/TranslateTest.php diff --git a/tests/lib/SimpleSAML/Locale/TranslateTest.php b/tests/lib/SimpleSAML/Locale/TranslateTest.php new file mode 100644 index 000000000..ee431d600 --- /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)); + } +} -- GitLab