curl_copy_handle_variation2.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --TEST--
  2. Test curl_copy_handle() add options to the handles
  3. --CREDITS--
  4. Francesco Fullone ff@ideato.it
  5. #PHPTestFest Cesena Italia on 2009-06-20
  6. --SKIPIF--
  7. <?php
  8. if (!extension_loaded("curl")) exit("skip curl extension not loaded");
  9. ?>
  10. --COMMENT--
  11. the only way to test if a option is setten on a curl handle is using the curl_getinfo() function.
  12. but this can only check on a limited amount of options...
  13. --FILE--
  14. <?php
  15. echo "*** Testing curl_copy_handle(): add options after copy ***\n";
  16. // create a new cURL resource
  17. $ch = curl_init();
  18. // copy the handle
  19. $ch2 = curl_copy_handle($ch);
  20. var_dump(curl_getinfo($ch) === curl_getinfo($ch2));
  21. // add some CURLOPT to the second handle
  22. curl_setopt($ch2, CURLOPT_URL, 'http://www.example.com/');
  23. var_dump(curl_getinfo($ch) === curl_getinfo($ch2));
  24. // add same CURLOPT to the first handle
  25. curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/');
  26. var_dump(curl_getinfo($ch) === curl_getinfo($ch2));
  27. // change a CURLOPT in the second handle
  28. curl_setopt($ch2, CURLOPT_URL, 'http://www.bar.com/');
  29. var_dump(curl_getinfo($ch) === curl_getinfo($ch2));
  30. ?>
  31. ===DONE===
  32. --EXPECTF--
  33. *** Testing curl_copy_handle(): add options after copy ***
  34. bool(true)
  35. bool(false)
  36. bool(true)
  37. bool(false)
  38. ===DONE===