--- /dev/null
+--TEST--
+Test curl_exec() function with basic functionality
+--CREDITS--
+Sebastian Deutsch <sebastian.deutsch@9elements.com>
+--SKIPIF--
+<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?>
+--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===
--- /dev/null
+--TEST--
+Test curl_opt() function with CURLOPT_RETURNTRANSFER paremter set to 1
+--CREDITS--
+Sebastian Deutsch <sebastian.deutsch@9elements.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_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===
--- /dev/null
+--TEST--
+Test curl_opt() function with POST parameters
+--CREDITS--
+Sebastian Deutsch <sebastian.deutsch@9elements.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 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===
--- /dev/null
+--TEST--
+Test curl_opt() function with setting referer
+--CREDITS--
+Sebastian Deutsch <sebastian.deutsch@9elements.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 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===
--- /dev/null
+--TEST--
+Test curl_opt() function with user agent
+--CREDITS--
+Sebastian Deutsch <sebastian.deutsch@9elements.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 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===
--- /dev/null
+<?php
+ switch($_GET['test']) {
+ case 'getpost':
+ var_dump($_GET);
+ var_dump($_POST);
+ break;
+ case 'referer':
+ echo $_SERVER['HTTP_REFERER'];
+ break;
+ case 'useragent':
+ echo $_SERVER['HTTP_USER_AGENT'];
+ break;
+ default:
+ echo "Hello World!\n";
+ echo "Hello World!";
+ break;
+ }
+?>
\ No newline at end of file