Merge branch 'PHP-5.4'

* PHP-5.4:
  Fixing up closing tag
  Testing variation on input parameters of http_build_query() function
This commit is contained in:
Stanislav Malyshev 2012-07-14 19:00:35 -07:00
commit 6bfea28ce3
3 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,30 @@
--TEST--
Test http_build_query() function: usage variations - first arguments as object
--CREDITS--
Adam Gegotek <adam [dot] gegotek [at] gmail [dot] com>
--FILE--
<?php
/* Prototype : string http_build_query ( mixed $query_data [, string $numeric_prefix [, string $arg_separator [, int $enc_type = PHP_QUERY_RFC1738 ]]] )
* Description: Generates a URL-encoded query string from the associative (or indexed) array provided.
* Source code: ext/standard/http.c
*/
class UrlBuilder
{
public $name = 'homepage';
public $page = 1;
protected $sort = 'desc,name';
private $access = 'admin';
}
$obj = new stdClass;
$obj->name = 'homepage';
$obj->page = 1;
$obj->sort = 'desc,name';
echo http_build_query($obj) . PHP_EOL;
echo http_build_query(new UrlBuilder());
?>
--EXPECTF--
name=homepage&page=1&sort=desc%2Cname
name=homepage&page=1

View File

@ -0,0 +1,39 @@
--TEST--
Test http_build_query() function: usage variations - first arguments as multidimensional array and second argument present/not present
--CREDITS--
Adam Gegotek <adam [dot] gegotek [at] gmail [dot] com>
--FILE--
<?php
/* Prototype : string http_build_query ( mixed $query_data [, string $numeric_prefix [, string $arg_separator [, int $enc_type = PHP_QUERY_RFC1738 ]]] )
* Description: Generates a URL-encoded query string from the associative (or indexed) array provided.
* Source code: ext/standard/http.c
*/
$mDimensional = array(
20,
5 => 13,
"9" => array(
1 => "val1",
3 => "val2",
"string" => "string"
),
"name" => "homepage",
"page" => 10,
"sort" => array(
"desc",
"admin" => array(
"admin1",
"admin2" => array(
"who" => "admin2",
2 => "test"
)
)
)
);
echo http_build_query($mDimensional) . PHP_EOL;
echo http_build_query($mDimensional, 'prefix_');
?>
--EXPECTF--
0=20&5=13&9%5B1%5D=val1&9%5B3%5D=val2&9%5Bstring%5D=string&name=homepage&page=10&sort%5B0%5D=desc&sort%5Badmin%5D%5B0%5D=admin1&sort%5Badmin%5D%5Badmin2%5D%5Bwho%5D=admin2&sort%5Badmin%5D%5Badmin2%5D%5B2%5D=test
prefix_0=20&prefix_5=13&prefix_9%5B1%5D=val1&prefix_9%5B3%5D=val2&prefix_9%5Bstring%5D=string&name=homepage&page=10&sort%5B0%5D=desc&sort%5Badmin%5D%5B0%5D=admin1&sort%5Badmin%5D%5Badmin2%5D%5Bwho%5D=admin2&sort%5Badmin%5D%5Badmin2%5D%5B2%5D=test

View File

@ -0,0 +1,27 @@
--TEST--
Test http_build_query() function: usage variations - testing four parameter added in PHP 5.4.0
--CREDITS--
Adam Gegotek <adam [dot] gegotek [at] gmail [dot] com>
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.4.0', '<')) die("skip this test if PHP_VERSION is less than 5.4.0");
?>
--FILE--
<?php
/* Prototype : string http_build_query ( mixed $query_data [, string $numeric_prefix [, string $arg_separator [, int $enc_type = PHP_QUERY_RFC1738 ]]] )
* Description: Generates a URL-encoded query string from the associative (or indexed) array provided.
* Source code: ext/standard/http.c
*/
$oDimensional = array(
"name" => "main page",
"sort" => "desc,admin",
"equation" => "10 + 10 - 5"
);
echo http_build_query($oDimensional, '', ini_get('arg_separator.output'), PHP_QUERY_RFC1738) . PHP_EOL;
echo http_build_query($oDimensional, '', ini_get('arg_separator.output'), PHP_QUERY_RFC3986);
?>
--EXPECTF--
name=main+page&sort=desc%2Cadmin&equation=10+%2B+10+-+5
name=main%20page&sort=desc%2Cadmin&equation=10%20%2B%2010%20-%205