curl_version_variation1.phpt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. --TEST--
  2. Test curl_version() function : usage variations - test values for $ascii argument
  3. --SKIPIF--
  4. <?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
  5. --FILE--
  6. <?php
  7. /* Prototype : array curl_version ([ int $age ] )
  8. * Description: Returns information about the cURL version.
  9. * Source code: ext/curl/interface.c
  10. */
  11. echo "*** Testing curl_version() function: with unexpected inputs for 'age' argument ***\n";
  12. //get an unset variable
  13. $unset_var = 'string_val';
  14. unset($unset_var);
  15. //defining a class
  16. class sample {
  17. public function __toString() {
  18. return "sample object";
  19. }
  20. }
  21. //getting the resource
  22. $file_handle = fopen(__FILE__, "r");
  23. // array with different values for $input
  24. $inputs = array (
  25. // integer values
  26. 0,
  27. 1,
  28. 255,
  29. 256,
  30. PHP_INT_MAX,
  31. -PHP_INT_MAX,
  32. // float values
  33. 10.5,
  34. -20.5,
  35. 10.1234567e10,
  36. // array values
  37. array(),
  38. array(0),
  39. array(1, 2),
  40. //string values
  41. "ABC",
  42. 'abc',
  43. "2abc",
  44. // boolean values
  45. true,
  46. false,
  47. TRUE,
  48. FALSE,
  49. // null values
  50. NULL,
  51. null,
  52. // objects
  53. new sample(),
  54. // resource
  55. $file_handle,
  56. // undefined variable
  57. @$undefined_var,
  58. // unset variable
  59. @$unset_var
  60. );
  61. // loop through with each element of the $inputs array to test curl_version() function
  62. $count = 1;
  63. foreach($inputs as $input) {
  64. echo "-- Iteration $count --\n";
  65. var_dump( is_array(curl_version($input)) );
  66. $count ++;
  67. }
  68. fclose($file_handle); //closing the file handle
  69. ?>
  70. ===Done===
  71. --EXPECTF--
  72. *** Testing curl_version() function: with unexpected inputs for 'age' argument ***
  73. -- Iteration 1 --
  74. bool(true)
  75. -- Iteration 2 --
  76. bool(true)
  77. -- Iteration 3 --
  78. bool(true)
  79. -- Iteration 4 --
  80. bool(true)
  81. -- Iteration 5 --
  82. bool(true)
  83. -- Iteration 6 --
  84. bool(true)
  85. -- Iteration 7 --
  86. bool(true)
  87. -- Iteration 8 --
  88. bool(true)
  89. -- Iteration 9 --
  90. bool(true)
  91. -- Iteration 10 --
  92. Warning: curl_version() expects parameter 1 to be long, array given in %s on line %d
  93. bool(false)
  94. -- Iteration 11 --
  95. Warning: curl_version() expects parameter 1 to be long, array given in %s on line %d
  96. bool(false)
  97. -- Iteration 12 --
  98. Warning: curl_version() expects parameter 1 to be long, array given in %s on line %d
  99. bool(false)
  100. -- Iteration 13 --
  101. Warning: curl_version() expects parameter 1 to be long, string given in %s on line %d
  102. bool(false)
  103. -- Iteration 14 --
  104. Warning: curl_version() expects parameter 1 to be long, string given in %s on line %d
  105. bool(false)
  106. -- Iteration 15 --
  107. Notice: A non well formed numeric value encountered in %s on line %d
  108. bool(true)
  109. -- Iteration 16 --
  110. bool(true)
  111. -- Iteration 17 --
  112. bool(true)
  113. -- Iteration 18 --
  114. bool(true)
  115. -- Iteration 19 --
  116. bool(true)
  117. -- Iteration 20 --
  118. bool(true)
  119. -- Iteration 21 --
  120. bool(true)
  121. -- Iteration 22 --
  122. Warning: curl_version() expects parameter 1 to be long, object given in %s on line %d
  123. bool(false)
  124. -- Iteration 23 --
  125. Warning: curl_version() expects parameter 1 to be long, resource given in %s on line %d
  126. bool(false)
  127. -- Iteration 24 --
  128. bool(true)
  129. -- Iteration 25 --
  130. bool(true)
  131. ===Done===