aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functions/build_hidden_fields_for_query_params_test.php
blob: aee7a569d4e2c9838c6ca6c6e84091c3f6350f42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/

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);
	}
}