Skip to content

Commit 8ac0dbc

Browse files
committed
Add more tests to check we use the correct library versions
1 parent 566841e commit 8ac0dbc

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

tests/test_2_extensions.php

+15-4
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,18 @@
7575
}
7676

7777
$extensions = [
78-
'cURL' => function_exists('curl_init'),
78+
'curl' => function_exists('curl_init')
79+
// Make sure we are not using the default AL2 cURL version (7.79)
80+
&& version_compare(curl_version()['version'], '7.85.0', '>='),
81+
// https://github.com/brefphp/aws-lambda-layers/issues/42
82+
'curl-http2' => defined('CURL_HTTP_VERSION_2'),
83+
// Make sure we are not using the default AL2 OpenSSL version (7.79)
84+
'curl-openssl' => str_starts_with(curl_version()['ssl_version'], 'OpenSSL/1.1.1'),
85+
// Make sure we are using curl with our compiled libssh
86+
'curl-libssh' => version_compare(str_replace('libssh2/', '', curl_version()['libssh_version']), '1.10.0', '>='),
7987
'json' => function_exists('json_encode'),
8088
'bcmath' => function_exists('bcadd'),
8189
'ctype' => function_exists('ctype_digit'),
82-
// https://github.com/brefphp/aws-lambda-layers/issues/42
83-
'curl-with-http2' => defined('CURL_HTTP_VERSION_2'),
8490
'dom' => class_exists(\DOMDocument::class),
8591
'exif' => function_exists('exif_imagetype'),
8692
'fileinfo' => function_exists('finfo_file'),
@@ -102,17 +108,22 @@
102108
'spl' => class_exists(\SplQueue::class),
103109
'sqlite3' => class_exists(\SQLite3::class),
104110
'tokenizer' => function_exists('token_get_all'),
111+
'libxml' => function_exists('libxml_get_errors'),
105112
'xml' => function_exists('xml_parse'),
106113
'xmlreader' => class_exists(\XMLReader::class),
107114
'xmlwriter' => class_exists(\XMLWriter::class),
108115
'xsl' => class_exists(\XSLTProcessor::class),
109116
];
117+
$errors = [];
110118
foreach ($extensions as $extension => $test) {
111119
if (! $test) {
112-
error($extension . ' extension was not loaded');
120+
$errors[] = "[Extension] $extension extension was not loaded or failed the test";
113121
}
114122
success("[Extension] $extension");
115123
}
124+
if ($errors) {
125+
errors($errors);
126+
}
116127

117128
$extensionsDisabledByDefault = [
118129
'intl' => class_exists(\Collator::class),

tests/utils.php

+12
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ function success(string $message): void
1313
echo "\033[31m⨯ $message\033[0m" . PHP_EOL;
1414
exit(1);
1515
}
16+
17+
/**
18+
* @param string[] $messages
19+
* @return never-return
20+
*/
21+
#[NoReturn] function errors(array $messages): void
22+
{
23+
foreach ($messages as $message) {
24+
echo "\033[31m⨯ $message\033[0m" . PHP_EOL;
25+
}
26+
exit(1);
27+
}

0 commit comments

Comments
 (0)