diff options
author | Marc Alexander <admin@m-a-styles.de> | 2012-12-09 21:02:31 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2012-12-09 21:02:31 +0100 |
commit | 1aae72961a3205a8487218b6d69361c43a1297d6 (patch) | |
tree | 3096a599c14c88084f782022f002ed84224ccf8b /tests/functions | |
parent | 26bde05a30c7111b57621a37d86425aa69d74263 (diff) | |
parent | 3fe381eed561e724700b21789e28ea3efb1f7ef9 (diff) | |
download | forums-1aae72961a3205a8487218b6d69361c43a1297d6.tar forums-1aae72961a3205a8487218b6d69361c43a1297d6.tar.gz forums-1aae72961a3205a8487218b6d69361c43a1297d6.tar.bz2 forums-1aae72961a3205a8487218b6d69361c43a1297d6.tar.xz forums-1aae72961a3205a8487218b6d69361c43a1297d6.zip |
Merge branch 'develop' into feature/avatars
Conflicts:
phpBB/install/database_update.php
Diffstat (limited to 'tests/functions')
-rw-r--r-- | tests/functions/build_hidden_fields_for_query_params_test.php | 71 | ||||
-rw-r--r-- | tests/functions/get_formatted_filesize_test.php | 71 | ||||
-rw-r--r-- | tests/functions/quoteattr_test.php | 44 |
3 files changed, 186 insertions, 0 deletions
diff --git a/tests/functions/build_hidden_fields_for_query_params_test.php b/tests/functions/build_hidden_fields_for_query_params_test.php new file mode 100644 index 0000000000..ef2f5744d3 --- /dev/null +++ b/tests/functions/build_hidden_fields_for_query_params_test.php @@ -0,0 +1,71 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_build_hidden_fields_for_query_params_test extends phpbb_test_case +{ + public function build_hidden_fields_for_query_params_test_data() + { + return array( + // get + // post + // exclude + // expected + array( + array('foo' => 'bar'), + array(), + array(), + "<input type='hidden' name=\"foo\" value=\"bar\" />", + ), + array( + array('foo' => 'bar', 'a' => 'b'), + array(), + array(), + "<input type='hidden' name=\"foo\" value=\"bar\" /><input type='hidden' name=\"a\" value=\"b\" />", + ), + array( + array('a' => 'quote"', 'b' => '<less>'), + array(), + array(), + "<input type='hidden' name=\"a\" value='quote\"' /><input type='hidden' name=\"b\" value=\"<less>\" />", + ), + array( + array('a' => "quotes'\""), + array(), + array(), + "<input type='hidden' name=\"a\" value=\"quotes'"\" />", + ), + array( + array('foo' => 'bar', 'a' => 'b'), + array('a' => 'c'), + array(), + "<input type='hidden' name=\"foo\" value=\"bar\" />", + ), + // strict equality check + array( + array('foo' => 'bar', 'a' => '0'), + array('a' => ''), + array(), + "<input type='hidden' name=\"foo\" value=\"bar\" />", + ), + ); + } + + /** + * @dataProvider build_hidden_fields_for_query_params_test_data + */ + public function test_build_hidden_fields_for_query_params($get, $post, $exclude, $expected) + { + $request = new phpbb_mock_request($get, $post); + $result = phpbb_build_hidden_fields_for_query_params($request, $exclude); + + $this->assertEquals($expected, $result); + } +} diff --git a/tests/functions/get_formatted_filesize_test.php b/tests/functions/get_formatted_filesize_test.php new file mode 100644 index 0000000000..96ea2be132 --- /dev/null +++ b/tests/functions/get_formatted_filesize_test.php @@ -0,0 +1,71 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_get_formatted_filesize_test extends phpbb_test_case +{ + public function get_formatted_filesize_test_data() + { + return array( + // exact powers of 2 + array(1, '1 BYTES'), + array(1024, '1 KIB'), + array(1048576, '1 MIB'), + array(1073741824, '1 GIB'), + array(1099511627776, '1 TIB'), + + // exact powers of 10 + array(1000, '1000 BYTES'), + array(1000000, '976.56 KIB'), + array(1000000000, '953.67 MIB'), + array(1000000000000, '931.32 GIB'), + array(100000000000000, '90.95 TIB'), + + array(0, '0 BYTES'), + array(2, '2 BYTES'), + + array(1023, '1023 BYTES'), + array(1025, '1 KIB'), + array(1048575, '1024 KIB'), + + // String values + // exact powers of 2 + array('1', '1 BYTES'), + array('1024', '1 KIB'), + array('1048576', '1 MIB'), + array('1073741824', '1 GIB'), + array('1099511627776', '1 TIB'), + + // exact powers of 10 + array('1000', '1000 BYTES'), + array('1000000', '976.56 KIB'), + array('1000000000', '953.67 MIB'), + array('1000000000000', '931.32 GIB'), + array('100000000000000', '90.95 TIB'), + + array('0', '0 BYTES'), + array('2', '2 BYTES'), + + array('1023', '1023 BYTES'), + array('1025', '1 KIB'), + array('1048575', '1024 KIB'), + ); + } + + /** + * @dataProvider get_formatted_filesize_test_data + */ + public function test_get_formatted_filesize($input, $expected) + { + $output = get_formatted_filesize($input); + + $this->assertEquals($expected, $output); + } +} diff --git a/tests/functions/quoteattr_test.php b/tests/functions/quoteattr_test.php new file mode 100644 index 0000000000..9d2a7d470e --- /dev/null +++ b/tests/functions/quoteattr_test.php @@ -0,0 +1,44 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_quoteattr_test extends phpbb_test_case +{ + public function quoteattr_test_data() + { + return array( + array('foo', null, '"foo"'), + array('', null, '""'), + array(' ', null, '" "'), + array('<a>', null, '"<a>"'), + array('&', null, '"&amp;"'), + array('"hello"', null, "'\"hello\"'"), + array("'hello'", null, "\"'hello'\""), + array("\"'", null, "\""'\""), + array("a\nb", null, '"a b"'), + array("a\r\nb", null, '"a b"'), + array("a\tb", null, '"a	b"'), + array('a b', null, '"a b"'), + array('"a<b"', null, "'\"a<b\"'"), + array('foo', array('f' => 'z'), '"zoo"'), + array('<a>', array('a' => '&'), '"<&>"'), + ); + } + + /** + * @dataProvider quoteattr_test_data + */ + public function test_quoteattr($input, $entities, $expected) + { + $output = phpbb_quoteattr($input, $entities); + + $this->assertEquals($expected, $output); + } +} |