Skip to content

Commit 281231c

Browse files
committed
Fix test due to unavailable SSH_HOSTKEY option
1 parent a951d49 commit 281231c

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
Test curl_setopt(_array)() with CURLOPT_SSH_HOSTKEYFUNCTION option
3+
--EXTENSIONS--
4+
curl
5+
--SKIPIF--
6+
<?php
7+
$curl_version = curl_version();
8+
if ($curl_version['version_number'] < 0x075400) {
9+
die("skip: blob options not supported for curl < 7.84.0");
10+
}
11+
?>
12+
--FILE--
13+
<?php
14+
15+
function testOption(CurlHandle $handle, int $option) {
16+
try {
17+
var_dump(curl_setopt($handle, $option, 'undefined'));
18+
} catch (Throwable $e) {
19+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
20+
}
21+
22+
try {
23+
var_dump(curl_setopt_array($handle, [$option => 'undefined']));
24+
} catch (Throwable $e) {
25+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
26+
}
27+
}
28+
29+
$url = "https://example.com";
30+
$ch = curl_init($url);
31+
testOption($ch, CURLOPT_SSH_HOSTKEYFUNCTION);
32+
33+
?>
34+
--EXPECT--
35+
TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_SSH_HOSTKEYFUNCTION, function "undefined" not found or invalid function name
36+
TypeError: curl_setopt_array(): Argument #2 ($options) must be a valid callback for option CURLOPT_SSH_HOSTKEYFUNCTION, function "undefined" not found or invalid function name

ext/curl/tests/curl_setopt_callables.phpt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ Test curl_setopt(_array)() with options that take callabes
44
curl
55
--FILE--
66
<?php
7-
include 'server.inc';
8-
$host = curl_cli_server_start();
97

108
function testOption(CurlHandle $handle, int $option) {
119
try {
@@ -21,10 +19,9 @@ function testOption(CurlHandle $handle, int $option) {
2119
}
2220
}
2321

24-
$url = "{$host}/get.inc";
22+
$url = "https://example.com";
2523
$ch = curl_init($url);
2624
testOption($ch, CURLOPT_PROGRESSFUNCTION);
27-
testOption($ch, CURLOPT_SSH_HOSTKEYFUNCTION);
2825
testOption($ch, CURLOPT_XFERINFOFUNCTION);
2926
testOption($ch, CURLOPT_FNMATCH_FUNCTION);
3027
testOption($ch, CURLOPT_WRITEFUNCTION);
@@ -35,8 +32,6 @@ testOption($ch, CURLOPT_READFUNCTION);
3532
--EXPECT--
3633
TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_PROGRESSFUNCTION, function "undefined" not found or invalid function name
3734
TypeError: curl_setopt_array(): Argument #2 ($options) must be a valid callback for option CURLOPT_PROGRESSFUNCTION, function "undefined" not found or invalid function name
38-
TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_SSH_HOSTKEYFUNCTION, function "undefined" not found or invalid function name
39-
TypeError: curl_setopt_array(): Argument #2 ($options) must be a valid callback for option CURLOPT_SSH_HOSTKEYFUNCTION, function "undefined" not found or invalid function name
4035
TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_XFERINFOFUNCTION, function "undefined" not found or invalid function name
4136
TypeError: curl_setopt_array(): Argument #2 ($options) must be a valid callback for option CURLOPT_XFERINFOFUNCTION, function "undefined" not found or invalid function name
4237
TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_FNMATCH_FUNCTION, function "undefined" not found or invalid function name

0 commit comments

Comments
 (0)