1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-09 10:16:36 +02:00

Merge remote-tracking branch 'p/ticket/11095-develop' into develop

* p/ticket/11095-develop:
  [ticket/11095] Restore brace on previous line.
  [ticket/11095] Docs and tests for phpbb_build_hidden_fields_for_query_params.
  [ticket/11095] Forward GET parameters into hidden fields for jumpbox.
  [ticket/11095] Python quoteattr port.
  [ticket/11095] Use get method in jumpboxes.
This commit is contained in:
Andreas Fischer
2012-12-08 16:14:42 +01:00
6 changed files with 220 additions and 5 deletions

View File

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

View File

@@ -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, '"&lt;a&gt;"'),
array('&amp;', null, '"&amp;amp;"'),
array('"hello"', null, "'\"hello\"'"),
array("'hello'", null, "\"'hello'\""),
array("\"'", null, "\"&quot;'\""),
array("a\nb", null, '"a&#10;b"'),
array("a\r\nb", null, '"a&#13;&#10;b"'),
array("a\tb", null, '"a&#9;b"'),
array('a b', null, '"a b"'),
array('"a<b"', null, "'\"a&lt;b\"'"),
array('foo', array('f' => 'z'), '"zoo"'),
array('<a>', array('a' => '&amp;'), '"&lt;&amp;&gt;"'),
);
}
/**
* @dataProvider quoteattr_test_data
*/
public function test_quoteattr($input, $entities, $expected)
{
$output = phpbb_quoteattr($input, $entities);
$this->assertEquals($expected, $output);
}
}