getMessage()); } } /** * Skips the test if the server version satisfies a comparison. * * @see http://php.net/version_compare * @param string $operator Comparison operator * @param string $version Version to compare against */ function skip_if_server_version($operator, $version) { $serverVersion = get_server_version(URI); if (version_compare($serverVersion, $version, $operator)) { exit("skip Server version '$serverVersion' $operator '$version'"); } } /** * Skips the test if the server not using a particular storage engine. * * @param string $storageEngine Storage engine name */ function skip_if_not_server_storage_engine($storageEngine) { $serverStorageEngine = get_server_storage_engine(URI); if ($serverStorageEngine !== $storageEngine) { exit("skip Server storage engine is '$serverStorageEngine' (needed '$storageEngine')"); } } /** * Skips the test if the server does not support test commands. */ function skip_if_test_commands_disabled() { if (!get_server_parameter(URI, 'enableTestCommands')) { exit('skip test commands are disabled'); } } /** * Skips the test if libmongoc does not support crypto. * * If one or more libaries are provided, additionally check that the reported * library is in that array. Possible values are "libcrypto", "Common Crypto", * and "CNG". * * @param array $libs Optional list of crypto libraries to require */ function skip_if_not_libmongoc_crypto(array $libs = []) { $lib = get_module_info('libmongoc crypto library'); if ($lib === null) { exit('skip libmongoc crypto is not enabled'); } if (!empty($libs) && !in_array($lib, $libs)) { exit('skip Needs libmongoc crypto library ' . implode(', ', $libs) . ', but found ' . $lib); } } /** * Skips the test if libmongoc does not support SSL. * * If one or more libaries are provided, additionally check that the reported * library is in that array. Possible values are "OpenSSL", "LibreSSL", * "Secure Transport", and "Secure Channel". * * @param array $libs Optional list of SSL libraries to require */ function skip_if_not_libmongoc_ssl(array $libs = []) { $lib = get_module_info('libmongoc SSL library'); if ($lib === null) { exit('skip libmongoc SSL is not enabled'); } if (!empty($libs) && !in_array($lib, $libs)) { exit('skip Needs libmongoc SSL library ' . implode(', ', $libs) . ', but found ' . $lib); } } /** * Skips the test if the collection cannot be dropped. * * @param string $databaseName Database name * @param string $collectionName Collection name */ function skip_if_not_clean($databaseName = DATABASE_NAME, $collectionName = COLLECTION_NAME) { try { drop_collection(URI, $databaseName, $collectionName); } catch (RuntimeException $e) { exit("skip Could not drop '$databaseName.$collectionName': " . $e->getMessage()); } }