Skip to content

Commit

Permalink
Unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks committed Dec 11, 2013
1 parent 9241407 commit 7017965
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions unit-tests/TranslateTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/*
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2012 Phalcon Team (http://www.phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to license@phalconphp.com so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Andres Gutierrez <andres@phalconphp.com> |
| Eduar Carvajal <eduar@phalconphp.com> |
| Vladimir Kolesnikov <vladimir@extrememember.com> |
+------------------------------------------------------------------------+
*/

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);
}
}
1 change: 1 addition & 0 deletions unit-tests/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<file>unit-tests/CryptTest.php</file>
<file>unit-tests/SecurityTest.php</file>
<file>unit-tests/BeanstalkTest.php</file>
<file>unit-tests/TranslateTest.php</file>

<!-- Complex components/Integral tests -->
<file>unit-tests/ModelsResultsetCacheTest.php</file>
Expand Down

0 comments on commit 7017965

Please sign in to comment.