mirror of
https://github.com/php/php-src.git
synced 2024-09-24 03:17:26 +00:00
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:
commit
6bfea28ce3
30
ext/standard/tests/strings/http_build_query_variation1.phpt
Normal file
30
ext/standard/tests/strings/http_build_query_variation1.phpt
Normal 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
|
39
ext/standard/tests/strings/http_build_query_variation2.phpt
Normal file
39
ext/standard/tests/strings/http_build_query_variation2.phpt
Normal 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
|
27
ext/standard/tests/strings/http_build_query_variation3.phpt
Normal file
27
ext/standard/tests/strings/http_build_query_variation3.phpt
Normal 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
|
Loading…
Reference in New Issue
Block a user