diff options
author | Cesar G <prototech91@gmail.com> | 2014-03-19 03:05:36 -0700 |
---|---|---|
committer | Cesar G <prototech91@gmail.com> | 2014-03-19 03:08:34 -0700 |
commit | 2a822931c6d95fe9e6066752ec59ab614189837e (patch) | |
tree | f7b9bd07131073dc3c2f990b5515deda412ed43e /tests/functions | |
parent | 7c1ab5f79d621f210fa1bdea0e9b217a10c20fa9 (diff) | |
download | forums-2a822931c6d95fe9e6066752ec59ab614189837e.tar forums-2a822931c6d95fe9e6066752ec59ab614189837e.tar.gz forums-2a822931c6d95fe9e6066752ec59ab614189837e.tar.bz2 forums-2a822931c6d95fe9e6066752ec59ab614189837e.tar.xz forums-2a822931c6d95fe9e6066752ec59ab614189837e.zip |
[ticket/11959] Add unit tests.
PHPBB3-11959
Diffstat (limited to 'tests/functions')
-rw-r--r-- | tests/functions/generate_string_list.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/functions/generate_string_list.php b/tests/functions/generate_string_list.php new file mode 100644 index 0000000000..60269b5656 --- /dev/null +++ b/tests/functions/generate_string_list.php @@ -0,0 +1,60 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_display.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_generate_string_list_test extends phpbb_test_case +{ + public $user; + + public function setUp() + { + parent::setUp(); + + $this->user = new \phpbb\user(); + $this->user->data = array('user_lang' => 'en'); + $this->user->add_lang('common'); + } + + public function generate_string_list_data() + { + return array( + array( + array(), + '', + ), + array( + array('A'), + 'A', + ), + array( + array(2 => 'A', 3 => 'B'), + 'A and B', + ), + array( + array('A' => 'A', 'B' => 'B', 'C' => 'C'), + 'A, B, and C', + ), + array( + array('A', 'B', 'C', 'D'), + 'A, B, C, and D', + ) + ); + } + + /** + * @dataProvider generate_string_list_data + */ + public function test_generate_string_list($items, $expected_result) + { + $result = phpbb_generate_string_list($items, $this->user); + $this->assertEquals($expected_result, $result); + } +} |