]> granicus.if.org Git - php/commitdiff
Fix test parse_url_variation_002.phpt for 64bit platforms.
authorRobin Fernandes <robinf@php.net>
Fri, 11 Apr 2008 14:35:04 +0000 (14:35 +0000)
committerRobin Fernandes <robinf@php.net>
Fri, 11 Apr 2008 14:35:04 +0000 (14:35 +0000)
ext/standard/tests/url/parse_url_variation_001.phpt
ext/standard/tests/url/parse_url_variation_002_32bit.phpt [moved from ext/standard/tests/url/parse_url_variation_002.phpt with 95% similarity]
ext/standard/tests/url/parse_url_variation_002_64bit.phpt [new file with mode: 0644]

index 2cf80ff5a7c3f90f7c001329e8b3f1268458e141..18ef0a547b56a02428e44cce36e529068fe0a657 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Test parse_url() function : usage variations  - <type here specifics of this variation>
+Test parse_url() function : usage variations  - unexpected type for arg 1.
 --FILE--
 <?php
 /* Prototype  : proto mixed parse_url(string url, [int url_component])
similarity index 95%
rename from ext/standard/tests/url/parse_url_variation_002.phpt
rename to ext/standard/tests/url/parse_url_variation_002_32bit.phpt
index bdc00598ae11224cf37fbc2f73c26b12f1876aa4..88971e9642788252037fbd32cda57733d70d8298 100644 (file)
@@ -1,5 +1,7 @@
 --TEST--
-Test parse_url() function : usage variations  - <type here specifics of this variation>
+Test parse_url() function : usage variations  - unexpected type for arg 2.
+--SKIPIF--
+<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only"); ?>
 --FILE--
 <?php
 /* Prototype  : proto mixed parse_url(string url, [int url_component])
diff --git a/ext/standard/tests/url/parse_url_variation_002_64bit.phpt b/ext/standard/tests/url/parse_url_variation_002_64bit.phpt
new file mode 100644 (file)
index 0000000..561a433
--- /dev/null
@@ -0,0 +1,184 @@
+--TEST--
+Test parse_url() function : usage variations  - unexpected type for arg 2.
+--SKIPIF--
+<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); ?>
+--FILE--
+<?php
+/* Prototype  : proto mixed parse_url(string url, [int url_component])
+ * Description: Parse a URL and return its components 
+ * Source code: ext/standard/url.c
+ * Alias to functions: 
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing parse_url() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$url = 'http://secret:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+      // float data
+      10.5,
+      -10.5,
+      10.1234567e10,
+      10.7654321E-10,
+      .5,
+
+      // array data
+      array(),
+      array(0),
+      array(1),
+      array(1, 2),
+      array('color' => 'red', 'item' => 'pen'),
+
+      // null data
+      NULL,
+      null,
+
+      // boolean data
+      true,
+      false,
+      TRUE,
+      FALSE,
+
+      // empty data
+      "",
+      '',
+
+      // string data
+      "string",
+      'string',
+
+      // object data
+      new stdclass(),
+
+      // undefined data
+      $undefined_var,
+
+      // unset data
+      $unset_var,
+);
+
+// loop through each element of the array for url_component
+
+foreach($values as $value) {
+      echo "\nArg value $value \n";
+      var_dump( parse_url($url, $value) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing parse_url() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(61)
+Error: 8 - Undefined variable: unset_var, %s(64)
+
+Arg value 10.5 
+Error: 2 - parse_url(): Invalid URL component identifier 10, %s(71)
+bool(false)
+
+Arg value -10.5 
+array(8) {
+  ["scheme"]=>
+  string(4) "http"
+  ["host"]=>
+  string(11) "www.php.net"
+  ["port"]=>
+  int(80)
+  ["user"]=>
+  string(6) "secret"
+  ["pass"]=>
+  string(7) "hideout"
+  ["path"]=>
+  string(10) "/index.php"
+  ["query"]=>
+  string(31) "test=1&test2=char&test3=mixesCI"
+  ["fragment"]=>
+  string(16) "some_page_ref123"
+}
+
+Arg value 101234567000 
+Error: 2 - parse_url(): Invalid URL component identifier 101234567000, %s(71)
+bool(false)
+
+Arg value 1.07654321E-9 
+string(4) "http"
+
+Arg value 0.5 
+string(4) "http"
+
+Arg value Array 
+Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71)
+NULL
+
+Arg value Array 
+Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71)
+NULL
+
+Arg value Array 
+Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71)
+NULL
+
+Arg value Array 
+Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71)
+NULL
+
+Arg value Array 
+Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71)
+NULL
+
+Arg value  
+string(4) "http"
+
+Arg value  
+string(4) "http"
+
+Arg value 1 
+string(11) "www.php.net"
+
+Arg value  
+string(4) "http"
+
+Arg value 1 
+string(11) "www.php.net"
+
+Arg value  
+string(4) "http"
+
+Arg value  
+Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71)
+NULL
+
+Arg value  
+Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71)
+NULL
+
+Arg value string 
+Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71)
+NULL
+
+Arg value string 
+Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71)
+NULL
+Error: 4096 - Object of class stdClass could not be converted to string, %s(70)
+
+Arg value  
+Error: 2 - parse_url() expects parameter 2 to be long, object given, %s(71)
+NULL
+
+Arg value  
+string(4) "http"
+
+Arg value  
+string(4) "http"
+Done
\ No newline at end of file