From 70179659dbccb611bcf0ccc6af488f5c91d29409 Mon Sep 17 00:00:00 2001 From: Vladimir Kolesnikov Date: Wed, 11 Dec 2013 05:35:49 +0200 Subject: [PATCH] Unit test --- unit-tests/TranslateTest.php | 42 ++++++++++++++++++++++++++++++++++++ unit-tests/phpunit.xml | 1 + 2 files changed, 43 insertions(+) create mode 100644 unit-tests/TranslateTest.php diff --git a/unit-tests/TranslateTest.php b/unit-tests/TranslateTest.php new file mode 100644 index 0000000000..e0dfff77f7 --- /dev/null +++ b/unit-tests/TranslateTest.php @@ -0,0 +1,42 @@ + | + | Eduar Carvajal | + | Vladimir Kolesnikov | + +------------------------------------------------------------------------+ +*/ + +class TranslateTest extends PHPUnit_Framework_TestCase +{ + public function testBasic() + { + $options = array( + 'content' => array( + 'Hello!' => 'Привет!', + 'Hello %fname% %lname%!' => 'Привет, %fname% %lname%!', + ), + ); + + $t = new \Phalcon\Translate\Adapter\NativeArray($options); + $this->assertEquals($options['content']['Hello!'], $t['Hello!']); + $this->assertTrue(isset($t['Hello!'])); + $this->assertFalse(isset($t['Hi there!'])); + + $actual = $t->_('Hello %fname% %lname%!', array('fname' => 'John', 'lname' => 'Doe')); + $expected = 'Привет, John Doe!'; + $this->assertEquals($expected, $actual); + } +} diff --git a/unit-tests/phpunit.xml b/unit-tests/phpunit.xml index 6c07c9c95c..90ed9f362b 100644 --- a/unit-tests/phpunit.xml +++ b/unit-tests/phpunit.xml @@ -93,6 +93,7 @@ unit-tests/CryptTest.php unit-tests/SecurityTest.php unit-tests/BeanstalkTest.php + unit-tests/TranslateTest.php unit-tests/ModelsResultsetCacheTest.php