Commit:    152f73f92ac87f3ab171c37b102decf78894c8fb
Author:    Adam Gegotek <a.gego...@ocom.com>         Sat, 23 Jun 2012 14:58:58 
+0200
Committer: Stanislav Malyshev <s...@php.net>      Sat, 14 Jul 2012 18:58:52 
-0700
Parents:   1916bb223ebdc92489f030a73f895f5d9a120812
Branches:  PHP-5.4 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=152f73f92ac87f3ab171c37b102decf78894c8fb

Log:
Testing variation on input parameters of http_build_query() function

Changed paths:
  A  ext/standard/tests/strings/http_build_query_variation1.phpt
  A  ext/standard/tests/strings/http_build_query_variation2.phpt
  A  ext/standard/tests/strings/http_build_query_variation3.phpt


Diff:
diff --git a/ext/standard/tests/strings/http_build_query_variation1.phpt 
b/ext/standard/tests/strings/http_build_query_variation1.phpt
new file mode 100644
index 0000000..56d81c9
--- /dev/null
+++ b/ext/standard/tests/strings/http_build_query_variation1.phpt
@@ -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
diff --git a/ext/standard/tests/strings/http_build_query_variation2.phpt 
b/ext/standard/tests/strings/http_build_query_variation2.phpt
new file mode 100644
index 0000000..ca1d8f4
--- /dev/null
+++ b/ext/standard/tests/strings/http_build_query_variation2.phpt
@@ -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
diff --git a/ext/standard/tests/strings/http_build_query_variation3.phpt 
b/ext/standard/tests/strings/http_build_query_variation3.phpt
new file mode 100644
index 0000000..8cd616b
--- /dev/null
+++ b/ext/standard/tests/strings/http_build_query_variation3.phpt
@@ -0,0 +1,26 @@
+--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


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to