diff options
author | Andreas Fischer <bantu@phpbb.com> | 2011-02-07 16:32:25 +0100 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2011-02-07 16:32:25 +0100 |
commit | f50d74506a2334a83e03ae50c65a237d766c7d7e (patch) | |
tree | 2fd7f24c3899818b282dd269a9019805738e6127 /tests | |
parent | ec143edaf1aa5957671712e12a6af196c8d9452b (diff) | |
parent | df78a3a62df1c8da5f3a9ff2cfef5815aaf4909c (diff) | |
download | forums-f50d74506a2334a83e03ae50c65a237d766c7d7e.tar forums-f50d74506a2334a83e03ae50c65a237d766c7d7e.tar.gz forums-f50d74506a2334a83e03ae50c65a237d766c7d7e.tar.bz2 forums-f50d74506a2334a83e03ae50c65a237d766c7d7e.tar.xz forums-f50d74506a2334a83e03ae50c65a237d766c7d7e.zip |
Merge branch 'develop-olympus' into develop
* develop-olympus:
[ticket/9949] Unit tests for user::lang()
[ticket/9949] $user->lang() uses last int-value to get the key not first
Diffstat (limited to 'tests')
-rw-r--r-- | tests/user/lang_test.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php new file mode 100644 index 0000000000..6c60583a7b --- /dev/null +++ b/tests/user/lang_test.php @@ -0,0 +1,58 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; + +class phpbb_user_lang_test extends phpbb_test_case +{ + public function test_user_lang_sprintf() + { + $user = new user; + $user->lang = array( + 'FOO' => 'BAR', + 'BARZ' => 'PENG', + 'EMPTY' => '', + 'ZERO' => '0', + 'STR' => '%d %s, %d topics', + 'STR2' => '%d foos', + 'ARRY' => array( + 0 => 'No posts', // 0 + 1 => '1 post', // 1 + 2 => '%d posts', // 2+ + ), + ); + + // No param + $this->assertEquals($user->lang('FOO'), 'BAR'); + $this->assertEquals($user->lang('EMPTY'), ''); + $this->assertEquals($user->lang('ZERO'), '0'); + + // Invalid index + $this->assertEquals($user->lang('VOID'), 'VOID'); + + // Unnecessary param + $this->assertEquals($user->lang('FOO', 2), 'BAR'); + $this->assertEquals($user->lang('FOO', 2, 3), 'BAR'); + $this->assertEquals($user->lang('FOO', 2, 3, 'BARZ'), 'BAR'); + + // String + $this->assertEquals($user->lang('STR', 24, 'x', 42), '24 x, 42 topics'); + $this->assertEquals($user->lang('STR2', 64), '64 foos'); + + // Array + $this->assertEquals($user->lang('ARRY', 0), 'No posts'); + $this->assertEquals($user->lang('ARRY', 1), '1 post'); + $this->assertEquals($user->lang('ARRY', 2), '2 posts'); + $this->assertEquals($user->lang('ARRY', 123), '123 posts'); + + // Bug PHPBB3-9949 + $this->assertEquals($user->lang('ARRY', 1, 2), '1 post'); + $this->assertEquals($user->lang('ARRY', 1, 's', 2), '1 post'); + } +} |