]> granicus.if.org Git - php/commitdiff
- New tests (testfest ParisUG)
authorFelipe Pena <felipe@php.net>
Sat, 16 May 2009 16:38:17 +0000 (16:38 +0000)
committerFelipe Pena <felipe@php.net>
Sat, 16 May 2009 16:38:17 +0000 (16:38 +0000)
20 files changed:
ext/curl/tests/curl_basic_001.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_002.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_003.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_004.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_005.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_007.phpt [new file with mode: 0755]
ext/curl/tests/curl_basic_008.phpt [new file with mode: 0755]
ext/curl/tests/curl_basic_009.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_010.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_011.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_012.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_013.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_014.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_015.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_016.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_017.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_018.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_019.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_020.phpt [new file with mode: 0644]
ext/curl/tests/curl_basic_021.phpt [new file with mode: 0644]

diff --git a/ext/curl/tests/curl_basic_001.phpt b/ext/curl/tests/curl_basic_001.phpt
new file mode 100644 (file)
index 0000000..fa362b3
--- /dev/null
@@ -0,0 +1,45 @@
+--TEST--
+Test curl_exec() function with basic functionality 
+--CREDITS--
+Sebastian Deutsch <sebastian.deutsch@9elements.com>
+TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net>
+--SKIPIF--
+<?php 
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
+?>
+--FILE--
+<?php
+/* Prototype  : bool curl_exec(resource ch)
+ * Description: Perform a cURL session 
+ * Source code: ext/curl/interface.c
+ * Alias to functions: 
+ */
+       
+  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+
+  // start testing
+  echo "*** Testing curl_exec() : basic functionality ***\n";
+
+  $url = "{$host}/get.php?test=get";
+  $ch = curl_init();
+
+  ob_start(); // start output buffering
+  curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
+  $ok = curl_exec($ch);
+  curl_close($ch);
+  $curl_content = ob_get_contents();
+  ob_end_clean();
+
+  if($ok) {
+    var_dump( $curl_content );
+  } else {
+    echo "curl_exec returned false";
+  }
+?>
+===DONE===
+--EXPECTF--
+*** Testing curl_exec() : basic functionality ***
+string(25) "Hello World!
+Hello World!"
+===DONE===
diff --git a/ext/curl/tests/curl_basic_002.phpt b/ext/curl/tests/curl_basic_002.phpt
new file mode 100644 (file)
index 0000000..e46f323
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+Test curl_opt() function with CURLOPT_RETURNTRANSFER parameter set to 1
+--CREDITS--
+Sebastian Deutsch <sebastian.deutsch@9elements.com>
+TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net>
+--SKIPIF--
+<?php 
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
+?>
+--FILE--
+<?php
+/* Prototype  : bool curl_setopt(resource ch, int option, mixed value)
+ * Description: Set an option for a cURL transfer
+ * Source code: ext/curl/interface.c
+ * Alias to functions:
+ */
+
+  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+
+  // start testing
+  echo '*** Testing curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ***' . "\n";
+
+  $url = "{$host}/get.php?test=get";
+  $ch = curl_init();
+
+  ob_start(); // start output buffering
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
+  
+  $curl_content = curl_exec($ch);
+  curl_close($ch);
+
+  var_dump( $curl_content );
+?>
+===DONE===
+--EXPECTF--
+*** Testing curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ***
+string(25) "Hello World!
+Hello World!"
+===DONE===
diff --git a/ext/curl/tests/curl_basic_003.phpt b/ext/curl/tests/curl_basic_003.phpt
new file mode 100644 (file)
index 0000000..eb2aecd
--- /dev/null
@@ -0,0 +1,56 @@
+--TEST--
+Test curl_opt() function with POST parameters
+--CREDITS--
+Sebastian Deutsch <sebastian.deutsch@9elements.com>
+TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net>
+--SKIPIF--
+<?php 
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
+?>
+--FILE--
+<?php
+/* Prototype  : bool curl_setopt(resource ch, int option, mixed value)
+ * Description: Set an option for a cURL transfer
+ * Source code: ext/curl/interface.c
+ * Alias to functions:
+ */
+
+  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+
+  // start testing
+  echo '*** Testing curl sending through GET an POST ***' . "\n";
+
+  $url = "{$host}/get.php?test=getpost&get_param=Hello%20World";
+  $ch = curl_init();
+
+  ob_start(); // start output buffering
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_POST, 1);
+  curl_setopt($ch, CURLOPT_POSTFIELDS, "Hello=World&Foo=Bar&Person=John%20Doe");
+  curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
+  
+  $curl_content = curl_exec($ch);
+  curl_close($ch);
+
+  var_dump( $curl_content );
+?>
+===DONE===
+--EXPECTF--
+*** Testing curl sending through GET an POST ***
+string(208) "array(2) {
+  ["test"]=>
+  string(7) "getpost"
+  ["get_param"]=>
+  string(11) "Hello World"
+}
+array(3) {
+  ["Hello"]=>
+  string(5) "World"
+  ["Foo"]=>
+  string(3) "Bar"
+  ["Person"]=>
+  string(8) "John Doe"
+}
+"
+===DONE===
diff --git a/ext/curl/tests/curl_basic_004.phpt b/ext/curl/tests/curl_basic_004.phpt
new file mode 100644 (file)
index 0000000..ea2eeca
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+Test curl_opt() function with setting referer
+--CREDITS--
+Sebastian Deutsch <sebastian.deutsch@9elements.com>
+TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net>
+--SKIPIF--
+<?php 
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
+?>
+--FILE--
+<?php
+/* Prototype  : bool curl_setopt(resource ch, int option, mixed value)
+ * Description: Set an option for a cURL transfer
+ * Source code: ext/curl/interface.c
+ * Alias to functions:
+ */
+
+  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+
+  // start testing
+  echo '*** Testing curl setting referer ***' . "\n";
+
+  $url = "{$host}/get.php?test=referer";
+  $ch = curl_init();
+
+  ob_start(); // start output buffering
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_REFERER, 'http://www.refer.er');
+  curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
+  
+  $curl_content = curl_exec($ch);
+  curl_close($ch);
+
+  var_dump( $curl_content );
+?>
+===DONE===
+--EXPECTF--
+*** Testing curl setting referer ***
+string(19) "http://www.refer.er"
+===DONE===
diff --git a/ext/curl/tests/curl_basic_005.phpt b/ext/curl/tests/curl_basic_005.phpt
new file mode 100644 (file)
index 0000000..9285c10
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+Test curl_opt() function with user agent
+--CREDITS--
+Sebastian Deutsch <sebastian.deutsch@9elements.com>
+TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net>
+--SKIPIF--
+<?php 
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
+?>
+--FILE--
+<?php
+/* Prototype  : bool curl_setopt(resource ch, int option, mixed value)
+ * Description: Set an option for a cURL transfer
+ * Source code: ext/curl/interface.c
+ * Alias to functions:
+ */
+
+  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+
+  // start testing
+  echo '*** Testing curl with user agent ***' . "\n";
+
+  $url = "{$host}/get.php?test=useragent";
+  $ch = curl_init();
+
+  ob_start(); // start output buffering
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_USERAGENT, 'cURL phpt');
+  curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
+  
+  $curl_content = curl_exec($ch);
+  curl_close($ch);
+
+  var_dump( $curl_content );
+?>
+===DONE===
+--EXPECTF--
+*** Testing curl with user agent ***
+string(9) "cURL phpt"
+===DONE===
diff --git a/ext/curl/tests/curl_basic_007.phpt b/ext/curl/tests/curl_basic_007.phpt
new file mode 100755 (executable)
index 0000000..593cf6a
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+Test curl_error() & curl_errno() function without url
+--CREDITS--
+TestFest 2009 - AFUP - Perrick Penet <perrick@noparking.net>
+--SKIPIF--
+<?php if (!extension_loaded("curl")) print "skip"; ?>
+--FILE--
+<?php
+
+$ch = curl_init();
+
+curl_exec($ch);
+var_dump(curl_error($ch));
+var_dump(curl_errno($ch));
+curl_close($ch);
+
+
+?>
+--EXPECTF--
+%string|unicode%(11) "No URL set!"
+int(3)
diff --git a/ext/curl/tests/curl_basic_008.phpt b/ext/curl/tests/curl_basic_008.phpt
new file mode 100755 (executable)
index 0000000..4545699
--- /dev/null
@@ -0,0 +1,23 @@
+--TEST--
+Test curl_error() & curl_errno() function with problematic host
+--CREDITS--
+TestFest 2009 - AFUP - Perrick Penet <perrick@noparking.net>
+--SKIPIF--
+<?php if (!extension_loaded("curl")) print "skip"; ?>
+--FILE--
+<?php
+
+$url = "http://www.".uniqid().".".uniqid();
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_URL, $url);
+
+curl_exec($ch);
+var_dump(curl_error($ch));
+var_dump(curl_errno($ch));
+curl_close($ch);
+
+
+?>
+--EXPECTF--
+%unicode|string%(55) "Couldn't resolve host 'www.%s.%s'"
+int(6)
diff --git a/ext/curl/tests/curl_basic_009.phpt b/ext/curl/tests/curl_basic_009.phpt
new file mode 100644 (file)
index 0000000..529e590
--- /dev/null
@@ -0,0 +1,23 @@
+--TEST--
+Test curl_error() & curl_errno() function with problematic protocol
+--CREDITS--
+TestFest 2009 - AFUP - Perrick Penet <perrick@noparking.net>
+--SKIPIF--
+<?php if (!extension_loaded("curl")) print "skip"; ?>
+--FILE--
+<?php
+
+$url = uniqid()."://www.".uniqid().".".uniqid();
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_URL, $url);
+
+curl_exec($ch);
+var_dump(curl_error($ch));
+var_dump(curl_errno($ch));
+curl_close($ch);
+
+
+?>
+--EXPECTF--
+%unicode|string%(%d) "%Srotocol%s"
+int(1)
diff --git a/ext/curl/tests/curl_basic_010.phpt b/ext/curl/tests/curl_basic_010.phpt
new file mode 100644 (file)
index 0000000..a8ce19f
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Test curl_error() & curl_errno() function with problematic proxy
+--CREDITS--
+TestFest 2009 - AFUP - Perrick Penet <perrick@noparking.net>
+--SKIPIF--
+<?php if (!extension_loaded("curl")) print "skip"; ?>
+--FILE--
+<?php
+
+$url = "http://www.example.org";
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_PROXY, uniqid().":".uniqid());
+curl_setopt($ch, CURLOPT_URL, $url);
+
+curl_exec($ch);
+var_dump(curl_error($ch));
+var_dump(curl_errno($ch));
+curl_close($ch);
+
+
+?>
+--EXPECTF--
+%unicode|string%(38) "Couldn't resolve proxy '%s'"
+int(5)
diff --git a/ext/curl/tests/curl_basic_011.phpt b/ext/curl/tests/curl_basic_011.phpt
new file mode 100644 (file)
index 0000000..dfdc8f9
--- /dev/null
@@ -0,0 +1,38 @@
+--TEST--
+Test curl_opt() function with COOKIE 
+--CREDITS--
+TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com>      
+--SKIPIF--
+<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?>
+--FILE--
+<?php
+/* Prototype  : bool curl_setopt(resource ch, int option, mixed value)
+ * Description: Set an option for a cURL transfer
+ * Source code: ext/curl/interface.c
+ * Alias to functions:
+ */
+
+  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+
+  // start testing
+  echo '*** Testing curl with cookie ***' . "\n";
+
+  $url = "{$host}/get.php?test=cookie";
+  $ch = curl_init();
+
+  ob_start(); // start output buffering
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_COOKIE, 'foo=bar');    
+  curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
+  
+  $curl_content = curl_exec($ch);
+  curl_close($ch);
+
+  var_dump( $curl_content );
+?>
+===DONE===
+--EXPECTF--
+*** Testing curl with cookie ***
+string(3) "bar"
+===DONE===
+                     
\ No newline at end of file
diff --git a/ext/curl/tests/curl_basic_012.phpt b/ext/curl/tests/curl_basic_012.phpt
new file mode 100644 (file)
index 0000000..e4706fa
--- /dev/null
@@ -0,0 +1,38 @@
+--TEST--
+Test curl_opt() function with CURLOPT_HTTP_VERSION/CURL_HTTP_VERSION_1_0    
+--CREDITS--
+TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com>   
+--SKIPIF--
+<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?>
+--FILE--
+<?php
+/* Prototype  : bool curl_setopt(resource ch, int option, mixed value)
+ * Description: Set an option for a cURL transfer
+ * Source code: ext/curl/interface.c
+ * Alias to functions:
+ */
+
+  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+
+  // start testing
+  echo '*** Testing curl with HTTP/1.0 ***' . "\n";
+
+  $url = "{$host}/get.php?test=httpversion";
+  $ch = curl_init();
+
+  ob_start(); // start output buffering
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
+  curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
+  
+  $curl_content = curl_exec($ch);
+  curl_close($ch);
+
+  var_dump( $curl_content );
+?>
+===DONE===
+--EXPECTF--
+*** Testing curl with HTTP/1.0 ***
+string(8) "HTTP/1.0"
+===DONE===
+                     
\ No newline at end of file
diff --git a/ext/curl/tests/curl_basic_013.phpt b/ext/curl/tests/curl_basic_013.phpt
new file mode 100644 (file)
index 0000000..c49d187
--- /dev/null
@@ -0,0 +1,38 @@
+--TEST--
+Test curl_opt() function with CURLOPT_HTTP_VERSION/CURL_HTTP_VERSION_1_1 
+--CREDITS--
+TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com>      
+--SKIPIF--
+<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?>
+--FILE--
+<?php
+/* Prototype  : bool curl_setopt(resource ch, int option, mixed value)
+ * Description: Set an option for a cURL transfer
+ * Source code: ext/curl/interface.c
+ * Alias to functions:
+ */
+
+  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+
+  // start testing
+  echo '*** Testing curl with HTTP/1.1 ***' . "\n";
+
+  $url = "{$host}/get.php?test=httpversion";
+  $ch = curl_init();
+
+  ob_start(); // start output buffering
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
+  curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
+  
+  $curl_content = curl_exec($ch);
+  curl_close($ch);
+
+  var_dump( $curl_content );
+?>
+===DONE===
+--EXPECTF--
+*** Testing curl with HTTP/1.1 ***
+string(8) "HTTP/1.1"
+===DONE===
+                     
\ No newline at end of file
diff --git a/ext/curl/tests/curl_basic_014.phpt b/ext/curl/tests/curl_basic_014.phpt
new file mode 100644 (file)
index 0000000..4037970
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Test curl_init() function with basic functionality
+--CREDITS--
+Jean-Marc Fontaine <jmf@durcommefaire.net>
+--SKIPIF--
+<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
+--FILE--
+<?php
+  $ch = curl_init();
+  var_dump($ch);
+?>
+===DONE===
+--EXPECTF--
+resource(%d) of type (curl)
+===DONE===
diff --git a/ext/curl/tests/curl_basic_015.phpt b/ext/curl/tests/curl_basic_015.phpt
new file mode 100644 (file)
index 0000000..e8e43e5
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Test curl_init() function with $url parameter defined
+--CREDITS--
+Jean-Marc Fontaine <jmf@durcommefaire.net>
+--SKIPIF--
+<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
+--FILE--
+<?php
+  $url = 'http://www.example.com/'; 
+  $ch  = curl_init($url);
+  var_dump($url == curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
+?>
+===DONE===
+--EXPECTF--
+bool(true)
+===DONE===
diff --git a/ext/curl/tests/curl_basic_016.phpt b/ext/curl/tests/curl_basic_016.phpt
new file mode 100644 (file)
index 0000000..8b9f7ca
--- /dev/null
@@ -0,0 +1,57 @@
+--TEST--
+Test curl_getinfo() function with basic functionality
+--CREDITS--
+Jean-Marc Fontaine <jmf@durcommefaire.net>
+--SKIPIF--
+<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
+--FILE--
+<?php
+  $ch   = curl_init();
+  $info = curl_getinfo($ch);
+  var_dump($info);
+?>
+===DONE===
+--EXPECTF--
+array(20) {
+  [%u|b%"url"]=>
+  string(0) ""
+  ["content_type"]=>
+  NULL
+  ["http_code"]=>
+  int(0)
+  ["header_size"]=>
+  int(0)
+  ["request_size"]=>
+  int(0)
+  ["filetime"]=>
+  int(0)
+  ["ssl_verify_result"]=>
+  int(0)
+  ["redirect_count"]=>
+  int(0)
+  ["total_time"]=>
+  float(0)
+  ["namelookup_time"]=>
+  float(0)
+  ["connect_time"]=>
+  float(0)
+  ["pretransfer_time"]=>
+  float(0)
+  ["size_upload"]=>
+  float(0)
+  ["size_download"]=>
+  float(0)
+  ["speed_download"]=>
+  float(0)
+  ["speed_upload"]=>
+  float(0)
+  ["download_content_length"]=>
+  float(0)
+  ["upload_content_length"]=>
+  float(0)
+  ["starttransfer_time"]=>
+  float(0)
+  ["redirect_time"]=>
+  float(0)
+}
+===DONE===
diff --git a/ext/curl/tests/curl_basic_017.phpt b/ext/curl/tests/curl_basic_017.phpt
new file mode 100644 (file)
index 0000000..09247b2
--- /dev/null
@@ -0,0 +1,69 @@
+--TEST--
+Test curl_multi_exec() function with basic functionality 
+--CREDITS--
+TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com>
+--SKIPIF--
+<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?>
+--FILE--
+<?php
+/* Prototype  : bool curl_multi_exec(resource ch)
+ * Description: Perform a cURL session 
+ * Source code: ext/curl/multi.c
+ * Alias to functions: 
+ */
+       
+  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+
+  // start testing
+  echo "*** Testing curl_exec() : basic functionality ***\n";
+
+  $url = "{$host}/get.php?test=get";
+  $chs = array(
+    0 => curl_init(),
+    1 => curl_init(),
+    2 => curl_init(),
+  );
+  
+  ob_start(); // start output buffering
+  
+  curl_setopt($chs[0], CURLOPT_URL, $url); //set the url we want to use
+  curl_setopt($chs[1], CURLOPT_URL, $url); //set the url we want to use
+  curl_setopt($chs[2], CURLOPT_URL, $url); //set the url we want to use
+  
+  $mh = curl_multi_init();
+  
+  // add handlers
+  curl_multi_add_handle($mh, $chs[0]);
+  curl_multi_add_handle($mh, $chs[1]);
+  curl_multi_add_handle($mh, $chs[2]);
+  
+  $running=null;
+  //execute the handles
+  $state = null;
+  do {
+    $state = curl_multi_exec($mh, $running);
+  } while ($running > 0);
+  
+  //close the handles
+  curl_multi_remove_handle($mh, $chs[0]);
+  curl_multi_remove_handle($mh, $chs[1]);
+  curl_multi_remove_handle($mh, $chs[2]);
+  curl_multi_close($mh);
+  
+  $curl_content = ob_get_contents();
+  ob_end_clean();
+
+  if($state === CURLM_OK) {
+    var_dump( $curl_content );
+  } else {
+    echo "curl_exec returned false";
+  }
+?>
+===DONE===
+--EXPECTF--
+*** Testing curl_exec() : basic functionality ***
+string(75) "Hello World!
+Hello World!Hello World!
+Hello World!Hello World!
+Hello World!"
+===DONE===
diff --git a/ext/curl/tests/curl_basic_018.phpt b/ext/curl/tests/curl_basic_018.phpt
new file mode 100644 (file)
index 0000000..7cffb89
--- /dev/null
@@ -0,0 +1,72 @@
+--TEST--
+Test curl_setopt() with curl_multi function with basic functionality 
+--CREDITS--
+TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com>
+--SKIPIF--
+<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?>
+--FILE--
+<?php
+/* Prototype  : bool curl_setopt(resource ch, int option, mixed value)
+ * Description: Set an option for a cURL transfer
+ * Source code: ext/curl/interface.c
+ * Alias to functions:
+ */
+       
+  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+
+  // start testing
+  echo "*** Testing curl_exec() : basic functionality ***\n";
+
+  $url = "{$host}/get.php?test=get";
+  $chs = array(
+    0 => curl_init(),
+    1 => curl_init(),
+    2 => curl_init(),
+  );
+  
+  ob_start(); // start output buffering
+  
+  $options = array(
+    CURLOPT_RETURNTRANSFER => 1,
+    CURLOPT_URL => $url,
+  );
+  
+  curl_setopt_array($chs[0], $options); //set the options
+  curl_setopt_array($chs[1], $options); //set the options
+  curl_setopt_array($chs[2], $options); //set the options
+  
+  $mh = curl_multi_init();
+  
+  // add handlers
+  curl_multi_add_handle($mh, $chs[0]);
+  curl_multi_add_handle($mh, $chs[1]);
+  curl_multi_add_handle($mh, $chs[2]);
+  
+  $running=null;
+  //execute the handles
+  do {
+    curl_multi_exec($mh, $running);
+  } while ($running > 0);
+
+  $curl_content = '';
+  $curl_content .= curl_multi_getcontent($chs[0]);
+  $curl_content .= curl_multi_getcontent($chs[1]);
+  $curl_content .= curl_multi_getcontent($chs[2]);
+  
+  //close the handles
+  curl_multi_remove_handle($mh, $chs[0]);
+  curl_multi_remove_handle($mh, $chs[1]);
+  curl_multi_remove_handle($mh, $chs[2]);
+  curl_multi_close($mh);
+  
+  var_dump( $curl_content );
+  
+?>
+===DONE===
+--EXPECTF--
+*** Testing curl_exec() : basic functionality ***
+%unicode|string%(75) "Hello World!
+Hello World!Hello World!
+Hello World!Hello World!
+Hello World!"
+===DONE===
diff --git a/ext/curl/tests/curl_basic_019.phpt b/ext/curl/tests/curl_basic_019.phpt
new file mode 100644 (file)
index 0000000..ab605a8
--- /dev/null
@@ -0,0 +1,28 @@
+--TEST--
+Test curl_getinfo() function with CURLINFO_EFFECTIVE_URL parameter
+--CREDITS--
+Jean-Marc Fontaine <jmf@durcommefaire.net>
+--SKIPIF--
+<?php
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
+?>
+--FILE--
+<?php
+  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+
+  $url = "{$host}/get.php?test=";
+  $ch  = curl_init();
+
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_exec($ch);
+  $info = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
+  var_dump($url == $info);
+  
+  curl_close($ch);
+?>
+===DONE===
+--EXPECTF--
+Hello World!
+Hello World!bool(true)
+===DONE===
diff --git a/ext/curl/tests/curl_basic_020.phpt b/ext/curl/tests/curl_basic_020.phpt
new file mode 100644 (file)
index 0000000..d622053
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+Test curl_getinfo() function with CURLINFO_HTTP_CODE parameter
+--CREDITS--
+Jean-Marc Fontaine <jmf@durcommefaire.net>
+--SKIPIF--
+<?php
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
+?>
+--FILE--
+<?php
+  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+
+  $url = "{$host}/get.php?test=";
+  $ch  = curl_init();
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_exec($ch);
+  var_dump(curl_getinfo($ch, CURLINFO_HTTP_CODE));
+  curl_close($ch);
+?>
+===DONE===
+--EXPECTF--
+Hello World!
+Hello World!int(200)
+===DONE===
diff --git a/ext/curl/tests/curl_basic_021.phpt b/ext/curl/tests/curl_basic_021.phpt
new file mode 100644 (file)
index 0000000..3b4798d
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Test curl_getinfo() function with CURLINFO_CONTENT_TYPE parameter
+--CREDITS--
+Jean-Marc Fontaine <jmf@durcommefaire.net>
+--SKIPIF--
+<?php
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
+?>
+--FILE--
+<?php
+  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+  $url  = "{$host}/get.php?test=contenttype";
+
+  $ch = curl_init();
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_exec($ch);
+  var_dump(curl_getinfo($ch, CURLINFO_CONTENT_TYPE));
+  curl_close($ch);
+?>
+===DONE===
+--EXPECTF--
+%unicode|string%(24) "text/plain;charset=utf-8"
+===DONE===