From: andy wharmby Date: Tue, 23 Jun 2009 22:39:42 +0000 (+0000) Subject: New basic parse_str() tests. Tested on Windows,Linux and Lnux 64 bit. Some tests... X-Git-Tag: php-5.4.0alpha1~191^2~3255 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0dfd8754a6697a545ee0ee3017acae16d301b6d9;p=php New basic parse_str() tests. Tested on Windows,Linux and Lnux 64 bit. Some tests fail on PHP 6 (tagged with XFAIL) due to bug 48658 --- diff --git a/ext/standard/tests/strings/parse_str_basic1.phpt b/ext/standard/tests/strings/parse_str_basic1.phpt new file mode 100644 index 0000000000..ea393b0668 --- /dev/null +++ b/ext/standard/tests/strings/parse_str_basic1.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test parse_str() function : basic functionality +--XFAIL-- +Bug 48658: Test currently fails as parse_str() api insists that the optional reult array +is pre-defined. +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing parse_str() : basic functionality *** +Basic test WITHOUT result arg +NULL +unicode(4) "val1" +unicode(4) "val2" +unicode(4) "val3" + +Basic test WITH undefined var for result arg +NULL +array(3) { + [u"first"]=> + unicode(4) "val1" + [u"second"]=> + unicode(4) "val2" + [u"third"]=> + unicode(4) "val3" +} + +Basic test WITH existing non-array var for result arg +NULL +array(3) { + [u"first"]=> + unicode(4) "val1" + [u"second"]=> + unicode(4) "val2" + [u"third"]=> + unicode(4) "val3" +} + +Basic test with an existing array as results array +NULL +array(3) { + [u"first"]=> + unicode(4) "val1" + [u"second"]=> + unicode(4) "val2" + [u"third"]=> + unicode(4) "val3" +} +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/parse_str_basic2.phpt b/ext/standard/tests/strings/parse_str_basic2.phpt new file mode 100644 index 0000000000..2c84305f77 --- /dev/null +++ b/ext/standard/tests/strings/parse_str_basic2.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test parse_str() function : non-default arg_separator.input specified +--INI-- +arg_separator.input = "/" +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing parse_str() : non-default arg_separator.input specified *** +NULL +unicode(4) "val1" +unicode(4) "val2" +unicode(4) "val3" +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/parse_str_basic3.phpt b/ext/standard/tests/strings/parse_str_basic3.phpt new file mode 100644 index 0000000000..a82f2eacda --- /dev/null +++ b/ext/standard/tests/strings/parse_str_basic3.phpt @@ -0,0 +1,276 @@ +--TEST-- +Test parse_str() function : Basic functionality +--XFAIL-- +Bug 48658: Test currently fails as parse_str() api insists that the optional reult array +is pre-defined. php.net bugzilla +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing parse_str() : basic functionality *** + +Test string with array values +NULL +unicode(3) "abc" +array(3) { + [0]=> + unicode(3) "123" + [1]=> + unicode(5) "false" + [2]=> + unicode(4) "last" +} +array(1) { + [0]=> + unicode(3) "str" +} +array(1) { + [0]=> + unicode(3) "3.5" +} + +Test string with array values and results array +NULL +array(4) { + [u"first"]=> + unicode(3) "abc" + [u"a"]=> + array(3) { + [0]=> + unicode(3) "123" + [1]=> + unicode(5) "false" + [2]=> + unicode(4) "last" + } + [u"b"]=> + array(1) { + [0]=> + unicode(3) "str" + } + [u"c"]=> + array(1) { + [0]=> + unicode(3) "3.5" + } +} + +Test string containing numerical array keys +NULL +array(1) { + [u"arr"]=> + array(2) { + [1]=> + unicode(3) "sid" + [4]=> + unicode(4) "bill" + } +} + +Test string containing associative keys +NULL +array(1) { + [u"arr"]=> + array(2) { + ["first"]=> + unicode(3) "sid" + ["forth"]=> + unicode(4) "bill" + } +} + +Test string with array values with same name as existing variable +NULL +array(3) { + [0]=> + unicode(3) "123" + [1]=> + unicode(5) "false" + [2]=> + unicode(4) "last" +} + +Test string with non-array value with same name as existing array variable +unicode(3) "999" + +Test string with encoded data +unicode(17) "<== foo bar ==>" +unicode(17) "###Hello World###" + +Test string with single quotes characters +NULL +unicode(4) "Bill" +unicode(9) "O\'Reilly" + +Test string with backslash characters +NULL +unicode(7) "10\\2=5" + +Test string with double quotes data +NULL +unicode(32) "A string with \"quoted\" strings" + +Test string with nulls +NULL +unicode(37) "A string with containing \0\0\0 nulls" + +Test string with 2-dim array with numeric keys +NULL +array(1) { + [u"arr"]=> + array(1) { + [3]=> + array(2) { + [4]=> + unicode(3) "sid" + [6]=> + unicode(4) "fred" + } + } +} + +Test string with 2-dim array with null keys +NULL +array(1) { + [u"arr"]=> + array(2) { + [0]=> + array(1) { + [0]=> + unicode(3) "sid" + } + [1]=> + array(1) { + [0]=> + unicode(4) "fred" + } + } +} + +Test string with 2-dim array with non-numeric keys +NULL +array(1) { + [u"arr"]=> + array(2) { + [u"one"]=> + array(1) { + ["four"]=> + unicode(3) "sid" + } + [u"three"]=> + array(1) { + [u"six"]=> + unicode(4) "fred" + } + } +} + +Test string with 3-dim array with numeric keys +NULL +array(1) { + [u"arr"]=> + array(1) { + [1]=> + array(1) { + [2]=> + array(2) { + [3]=> + unicode(3) "sid" + [6]=> + unicode(4) "fred" + } + } + } +} +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/parse_str_basic4.phpt b/ext/standard/tests/strings/parse_str_basic4.phpt new file mode 100644 index 0000000000..3aa33acf83 --- /dev/null +++ b/ext/standard/tests/strings/parse_str_basic4.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test parse_str() function : test with badly formed strings +--XFAIL-- +Bug 48658: Test currently fails as parse_str() api insists that the optional reult array +is pre-defined. php.net bugzilla +--FILE-- + +===DONE=== +--EXPECTF-- +Test string with badly formed strings +NULL +array(2) { + [u"arr_1"]=> + unicode(3) "sid" + [u"arr"]=> + array(1) { + [4]=> + unicode(4) "fred" + } +} +NULL +array(2) { + [u"arr1]"]=> + unicode(3) "sid" + [u"arr"]=> + array(1) { + [4]=> + unicode(4) "fred" + } +} +NULL +array(2) { + [u"arr_one"]=> + unicode(3) "sid" + [u"arr"]=> + array(1) { + [4]=> + unicode(4) "fred" + } +} + +Test string with non-binary safe name +NULL +array(1) { + [u"arr_test"]=> + array(2) { + [1]=> + unicode(3) "sid" + [4]=> + array(1) { + [u"two"]=> + unicode(4) "fred" + } + } +} +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/parse_str_error1.phpt b/ext/standard/tests/strings/parse_str_error1.phpt new file mode 100644 index 0000000000..a9c902e807 --- /dev/null +++ b/ext/standard/tests/strings/parse_str_error1.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test parse_str() function : non-default arg_separator.input specified +--INI-- +arg_separator.input = "/" +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing parse_str() : error conditions *** + +-- Testing htmlentities() function with less than expected no. of arguments -- + +Warning: parse_str() expects at least 1 parameter, 0 given in %s on line %d + +-- Testing htmlentities() function with more than expected no. of arguments -- + +Warning: parse_str() expects at most 2 parameters, 3 given in %s on line %d +===DONE=== \ No newline at end of file