From 2de7153afd428f44d1c4c012ffe0bf072e449c64 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 Sep 2011 01:39:21 +0200 Subject: [ticket/10345] Allow float as array key and add some tests Added tests for the fallback when a key is missing and the float-feature. PHPBB3-10345 --- tests/user/lang_test.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/user') diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php index 90b0cdfb0f..971a9475f0 100644 --- a/tests/user/lang_test.php +++ b/tests/user/lang_test.php @@ -26,6 +26,14 @@ class phpbb_user_lang_test extends phpbb_test_case 1 => '1 post', // 1 2 => '%d posts', // 2+ ), + 'ARRY_NO_ZERO' => array( + 1 => '1 post', // 1 + 2 => '%d posts', // 0, 2+ + ), + 'ARRY_FLOAT' => array( + 1 => '1 post', // 1.x + 2 => '%1$.1f posts', // 0.x, 2+.x + ), ); // No param @@ -51,6 +59,16 @@ class phpbb_user_lang_test extends phpbb_test_case $this->assertEquals($user->lang('ARRY', 2), '2 posts'); $this->assertEquals($user->lang('ARRY', 123), '123 posts'); + // Array with missing keys + $this->assertEquals($user->lang('ARRY_NO_ZERO', 0), '0 posts'); + $this->assertEquals($user->lang('ARRY_NO_ZERO', 1), '1 post'); + $this->assertEquals($user->lang('ARRY_NO_ZERO', 2), '2 posts'); + + // Floats as array key + $this->assertEquals($user->lang('ARRY_FLOAT', 1.3), '1 post'); + $this->assertEquals($user->lang('ARRY_FLOAT', 2.0), '2.0 posts'); + $this->assertEquals($user->lang('ARRY_FLOAT', 2.51), '2.5 posts'); + // ticket PHPBB3-9949 $this->assertEquals($user->lang('ARRY', 1, 2), '1 post'); $this->assertEquals($user->lang('ARRY', 1, 's', 2), '1 post'); -- cgit v1.2.1