Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/curl/tests/bug48207.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ $ch = curl_init($url);
try {
curl_setopt($ch, CURLOPT_FILE, $fp);
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
echo $exception::class, ': ', $exception->getMessage(), "\n";
}

curl_exec($ch);
is_file($tempfile) and @unlink($tempfile);
isset($tempname) and is_file($tempname) and @unlink($tempname);
?>
--EXPECT--
curl_setopt(): The provided file handle must be writable
ValueError: curl_setopt(): The provided file handle must be writable
Hello World!
Hello World!
4 changes: 2 additions & 2 deletions ext/curl/tests/bug68089.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ $ch = curl_init();
try {
curl_setopt($ch, CURLOPT_URL, $url);
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
echo $exception::class, ': ', $exception->getMessage(), "\n";
}

?>
Done
--EXPECT--
curl_setopt(): cURL option must not contain any null bytes
ValueError: curl_setopt(): cURL option must not contain any null bytes
Done
4 changes: 2 additions & 2 deletions ext/curl/tests/bug73147.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ $poc = 'a:1:{i:0;O:8:"CURLFile":1:{s:4:"name";R:1;}}';
try {
var_dump(unserialize($poc));
} catch(Exception $e) {
echo $e->getMessage();
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Unserialization of 'CURLFile' is not allowed
Exception: Unserialization of 'CURLFile' is not allowed
12 changes: 6 additions & 6 deletions ext/curl/tests/bug80121.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ curl
try {
new CurlHandle;
} catch (Error $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
new CurlMultiHandle;
} catch (Error $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
new CurlShareHandle;
} catch (Error $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
Cannot directly construct CurlHandle, use curl_init() instead
Cannot directly construct CurlMultiHandle, use curl_multi_init() instead
Cannot directly construct CurlShareHandle, use curl_share_init() instead
Error: Cannot directly construct CurlHandle, use curl_init() instead
Error: Cannot directly construct CurlMultiHandle, use curl_multi_init() instead
Error: Cannot directly construct CurlShareHandle, use curl_share_init() instead
4 changes: 2 additions & 2 deletions ext/curl/tests/curl_file_upload.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var_dump(curl_exec($ch));
try {
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 0);
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
echo $exception::class, ': ', $exception->getMessage(), "\n";
}

$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt');
Expand All @@ -72,7 +72,7 @@ string(%d) "%s/curl_testdata1.txt"
string(%d) "curl_testdata1.txt|text/plain|6"
string(%d) "foo.txt"
string(%d) "foo.txt|application/octet-stream|6"
curl_setopt(): Disabling safe uploads is no longer supported
ValueError: curl_setopt(): Disabling safe uploads is no longer supported
string(0) ""
string(0) ""
string(%d) "array(1) {
Expand Down
1 change: 0 additions & 1 deletion ext/curl/tests/curl_getinfo_CURLINFO_CONN_ID.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,3 @@ bool(true)
bool(true)
bool(true)
bool(true)

4 changes: 2 additions & 2 deletions ext/curl/tests/curl_multi_errno_strerror_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo curl_multi_strerror($errno) . PHP_EOL;
try {
curl_multi_setopt($mh, -1, -1);
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
echo $exception::class, ': ', $exception->getMessage(), "\n";
}

$errno = curl_multi_errno($mh);
Expand All @@ -23,6 +23,6 @@ echo curl_multi_strerror($errno) . PHP_EOL;
--EXPECT--
0
No error
curl_multi_setopt(): Argument #2 ($option) is not a valid cURL multi option
ValueError: curl_multi_setopt(): Argument #2 ($option) is not a valid cURL multi option
6
Unknown option
4 changes: 2 additions & 2 deletions ext/curl/tests/curl_multi_setopt_basic001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ var_dump(curl_multi_setopt($mh, CURLMOPT_PIPELINING, 0));
try {
curl_multi_setopt($mh, -1, 0);
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
echo $exception::class, ': ', $exception->getMessage(), "\n";
}

?>
--EXPECT--
bool(true)
curl_multi_setopt(): Argument #2 ($option) is not a valid cURL multi option
ValueError: curl_multi_setopt(): Argument #2 ($option) is not a valid cURL multi option
4 changes: 2 additions & 2 deletions ext/curl/tests/curl_persistent_share_003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ curl
try {
$sh = curl_share_init_persistent([CURL_LOCK_DATA_DNS, CURL_LOCK_DATA_CONNECT, 30]);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
curl_share_init_persistent(): Argument #1 ($share_options) must contain only CURL_LOCK_DATA_* constants
ValueError: curl_share_init_persistent(): Argument #1 ($share_options) must contain only CURL_LOCK_DATA_* constants
4 changes: 2 additions & 2 deletions ext/curl/tests/curl_persistent_share_004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ curl
try {
$sh = curl_share_init_persistent([CURL_LOCK_DATA_COOKIE]);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
curl_share_init_persistent(): Argument #1 ($share_options) must not contain CURL_LOCK_DATA_COOKIE because sharing cookies across PHP requests is unsafe
ValueError: curl_share_init_persistent(): Argument #1 ($share_options) must not contain CURL_LOCK_DATA_COOKIE because sharing cookies across PHP requests is unsafe
4 changes: 2 additions & 2 deletions ext/curl/tests/curl_persistent_share_005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ $sh = curl_share_init_persistent([CURL_LOCK_DATA_DNS]);
try {
curl_share_setopt($sh, CURLOPT_SHARE, CURL_LOCK_DATA_CONNECT);
} catch (\TypeError $e) {
echo $e->getMessage() . PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
curl_share_setopt(): Argument #1 ($share_handle) must be of type CurlShareHandle, CurlSharePersistentHandle given
TypeError: curl_share_setopt(): Argument #1 ($share_handle) must be of type CurlShareHandle, CurlSharePersistentHandle given
4 changes: 2 additions & 2 deletions ext/curl/tests/curl_persistent_share_006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ curl
try {
$sh = curl_share_init_persistent([]);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
curl_share_init_persistent(): Argument #1 ($share_options) must not be empty
ValueError: curl_share_init_persistent(): Argument #1 ($share_options) must not be empty
16 changes: 8 additions & 8 deletions ext/curl/tests/curl_seekfunction_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ echo "Returning a non-int:\n";
try {
run_upload($host, fn($ch, $offset, $origin) => 'not an int');
} catch (\TypeError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "\nReturning an out-of-range int:\n";
try {
run_upload($host, fn($ch, $offset, $origin) => 42);
} catch (\ValueError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "\nThrowing from the callback:\n";
Expand All @@ -47,7 +47,7 @@ try {
throw new \RuntimeException('boom from seek');
});
} catch (\RuntimeException $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "\nSetting the callback to null:\n";
Expand All @@ -57,21 +57,21 @@ echo "\nSetting a non-callable scalar:\n";
try {
curl_setopt(curl_init(), CURLOPT_SEEKFUNCTION, 42);
} catch (\TypeError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
Returning a non-int:
The CURLOPT_SEEKFUNCTION callback must return one of CURL_SEEKFUNC_OK, CURL_SEEKFUNC_FAIL or CURL_SEEKFUNC_CANTSEEK
TypeError: The CURLOPT_SEEKFUNCTION callback must return one of CURL_SEEKFUNC_OK, CURL_SEEKFUNC_FAIL or CURL_SEEKFUNC_CANTSEEK

Returning an out-of-range int:
The CURLOPT_SEEKFUNCTION callback must return one of CURL_SEEKFUNC_OK, CURL_SEEKFUNC_FAIL or CURL_SEEKFUNC_CANTSEEK
ValueError: The CURLOPT_SEEKFUNCTION callback must return one of CURL_SEEKFUNC_OK, CURL_SEEKFUNC_FAIL or CURL_SEEKFUNC_CANTSEEK

Throwing from the callback:
boom from seek
RuntimeException: boom from seek

Setting the callback to null:
bool(true)

Setting a non-callable scalar:
curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_SEEKFUNCTION, no array or string given
TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_SEEKFUNCTION, no array or string given
12 changes: 6 additions & 6 deletions ext/curl/tests/curl_setopt_CURLOPT_DEBUGFUNCTION.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ try {
var_dump(curl_setopt($ch, CURLINFO_HEADER_OUT, true));
}
catch (\ValueError $e) {
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), "\n";
}
$chCopy = curl_copy_handle($ch);
try {
var_dump(curl_setopt($chCopy, CURLINFO_HEADER_OUT, true));
}
catch (\ValueError $e) {
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), "\n";
}
var_dump(curl_setopt($chCopy, CURLOPT_DEBUGFUNCTION, null));
var_dump(curl_setopt($chCopy, CURLINFO_HEADER_OUT, true));
Expand Down Expand Up @@ -138,7 +138,7 @@ try {
var_dump($result = curl_exec($ch));
}
catch (\RuntimeException $e) {
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), "\n";
}
var_dump(curl_getinfo($ch, CURLINFO_HEADER_OUT));

Expand Down Expand Up @@ -183,8 +183,8 @@ bool(true)
bool(true)
bool(true)
bool(true)
string(87) "CURLINFO_HEADER_OUT option must not be set when the CURLOPT_DEBUGFUNCTION option is set"
string(87) "CURLINFO_HEADER_OUT option must not be set when the CURLOPT_DEBUGFUNCTION option is set"
ValueError: CURLINFO_HEADER_OUT option must not be set when the CURLOPT_DEBUGFUNCTION option is set
ValueError: CURLINFO_HEADER_OUT option must not be set when the CURLOPT_DEBUGFUNCTION option is set
bool(true)
bool(true)

Expand Down Expand Up @@ -216,7 +216,7 @@ Accept: */*

===Test CURLOPT_DEBUGFUNCTION can throw within callback===
bool(true)
string(41) "This should get caught after verbose=true"
RuntimeException: This should get caught after verbose=true
string(%d) "GET /get.inc?test=file HTTP/%s
Host: %s:%d
Accept: */*
Expand Down
20 changes: 10 additions & 10 deletions ext/curl/tests/curl_setopt_CURLOPT_PREREQFUNCTION.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ curl_setopt($ch, CURLOPT_PREREQFUNCTION, function() use ($port) {
try {
curl_exec($ch);
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

echo "\nTesting with invalid type\n";
Expand All @@ -83,7 +83,7 @@ curl_setopt($ch, CURLOPT_PREREQFUNCTION, function() use ($port) {
try {
curl_exec($ch);
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

echo "\nTesting with invalid value\n";
Expand All @@ -93,21 +93,21 @@ curl_setopt($ch, CURLOPT_PREREQFUNCTION, function() use ($port) {
try {
curl_exec($ch);
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

echo "\nTesting with invalid option value\n";
try {
curl_setopt($ch, CURLOPT_PREREQFUNCTION, 42);
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

echo "\nTesting with invalid option callback\n";
try {
curl_setopt($ch, CURLOPT_PREREQFUNCTION, 'function_does_not_exist');
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

echo "\nTesting with null as the callback\n";
Expand Down Expand Up @@ -161,19 +161,19 @@ string(0) ""
int(0)

Testing with no return type
The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT
TypeError: The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT

Testing with invalid type
The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT
TypeError: The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT

Testing with invalid value
The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT
ValueError: The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT

Testing with invalid option value
curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_PREREQFUNCTION, no array or string given
TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_PREREQFUNCTION, no array or string given

Testing with invalid option callback
curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_PREREQFUNCTION, function "function_does_not_exist" not found or invalid function name
TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_PREREQFUNCTION, function "function_does_not_exist" not found or invalid function name

Testing with null as the callback
bool(true)
Expand Down
4 changes: 2 additions & 2 deletions ext/curl/tests/curl_setopt_basic003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ch = curl_init();
try {
curl_setopt($ch, CURLOPT_HTTPHEADER, 1);
} catch (TypeError $exception) {
echo $exception->getMessage() . "\n";
echo $exception::class, ': ', $exception->getMessage(), "\n";
}

$curl_content = curl_exec($ch);
Expand All @@ -42,6 +42,6 @@ var_dump( $curl_content );
?>
--EXPECT--
*** curl_setopt() call with CURLOPT_HTTPHEADER
curl_setopt(): The CURLOPT_HTTPHEADER option must have an array value
TypeError: curl_setopt(): The CURLOPT_HTTPHEADER option must have an array value
bool(false)
bool(true)
12 changes: 6 additions & 6 deletions ext/curl/tests/curl_setopt_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ $ch = curl_init();
try {
curl_setopt($ch, '', false);
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
curl_setopt($ch, -10, 0);
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
curl_setopt($ch, 1000, 0);
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
*** curl_setopt() call with incorrect parameters
curl_setopt(): Argument #2 ($option) must be of type int, string given
curl_setopt(): Argument #2 ($option) is not a valid cURL option
curl_setopt(): Argument #2 ($option) is not a valid cURL option
TypeError: curl_setopt(): Argument #2 ($option) must be of type int, string given
ValueError: curl_setopt(): Argument #2 ($option) is not a valid cURL option
ValueError: curl_setopt(): Argument #2 ($option) is not a valid cURL option
Loading
Loading