aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functions/build_hidden_fields_for_query_params_test.php
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2012-11-29 14:41:48 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2012-11-29 14:42:06 -0500
commit3e907265d5782c535d43e503c32390cfde8dc4a8 (patch)
tree554524b1888e3ef6642f727ab37fbc87adbba915 /tests/functions/build_hidden_fields_for_query_params_test.php
parent2a39df1a53ae4d9798bcba9ceee610190702cc4b (diff)
downloadforums-3e907265d5782c535d43e503c32390cfde8dc4a8.tar
forums-3e907265d5782c535d43e503c32390cfde8dc4a8.tar.gz
forums-3e907265d5782c535d43e503c32390cfde8dc4a8.tar.bz2
forums-3e907265d5782c535d43e503c32390cfde8dc4a8.tar.xz
forums-3e907265d5782c535d43e503c32390cfde8dc4a8.zip
[ticket/11095] Docs and tests for phpbb_build_hidden_fields_for_query_params.
PHPBB3-11095
Diffstat (limited to 'tests/functions/build_hidden_fields_for_query_params_test.php')
-rw-r--r--tests/functions/build_hidden_fields_for_query_params_test.php71
1 files changed, 71 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=\"&lt;less&gt;\" />",
+ ),
+ array(
+ array('a' => "quotes'\""),
+ array(),
+ array(),
+ "<input type='hidden' name=\"a\" value=\"quotes'&quot;\" />",
+ ),
+ 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);
+ }
+}