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