summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/random.php42
-rwxr-xr-xtests/phpunit.sh4
2 files changed, 31 insertions, 15 deletions
diff --git a/lib/random.php b/lib/random.php
index d9ebe98..7e11152 100644
--- a/lib/random.php
+++ b/lib/random.php
@@ -59,7 +59,12 @@ if (PHP_VERSION_ID < 70000) {
if (extension_loaded('libsodium')) {
// See random_bytes_libsodium.php
require_once "$__DIR__/random_bytes_libsodium.php";
- } elseif (DIRECTORY_SEPARATOR === '/' && @is_readable('/dev/urandom')) {
+ }
+ if (
+ !function_exists('random_bytes') &&
+ DIRECTORY_SEPARATOR === '/' &&
+ @is_readable('/dev/urandom')
+ ) {
// DIRECTORY_SEPARATOR === '/' on Unix-like OSes -- this is a fast
// way to exclude Windows.
//
@@ -71,24 +76,35 @@ if (PHP_VERSION_ID < 70000) {
// See random_bytes_dev_urandom.php
require_once "$__DIR__/random_bytes_dev_urandom.php";
- } elseif (PHP_VERSION_ID >= 50307 && extension_loaded('mcrypt')) {
+ }
+ if (!function_exists('random_bytes') && PHP_VERSION_ID >= 50307 && extension_loaded('mcrypt')) {
// See random_bytes_mcrypt.php
require_once "$__DIR__/random_bytes_mcrypt.php";
- } elseif (
+ }
+ if (
+ !function_exists('random_bytes') &&
extension_loaded('com_dotnet') &&
- class_exists('COM') &&
- (
- $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1') &&
- method_exists($RandomCompatCOMtest, 'GetRandom')
- )
+ class_exists('COM')
+ ) {
+ try {
+ $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
+ if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
+ // See random_bytes_com_dotnet.php
+ require_once "$__DIR__/random_bytes_com_dotnet.php";
+ }
+ } catch (com_exception $e) {
+ // Don't try to use it.
+ }
+ }
+ if (
+ !function_exists('random_bytes') &&
+ extension_loaded('openssl') &&
+ PHP_VERSION_ID >= 50300
) {
- unset($RandomCompatCOMtest);
- // See random_bytes_com_dotnet.php
- require_once "$__DIR__/random_bytes_com_dotnet.php";
- } elseif (extension_loaded('openssl') && PHP_VERSION_ID >= 50300) {
// See random_bytes_openssl.php
require_once "$__DIR__/random_bytes_openssl.php";
- } else {
+ }
+ if (!function_exists('random_bytes')) {
/**
* We don't have any more options, so let's throw an exception right now
* and hope the developer won't let it fail silently.
diff --git a/tests/phpunit.sh b/tests/phpunit.sh
index 2e8e57f..66d8997 100755
--- a/tests/phpunit.sh
+++ b/tests/phpunit.sh
@@ -85,7 +85,7 @@ if [ $? -eq 0 ]; then
exit 1
fi
# Should we perform full statistical analyses?
- if [ $fulltest -eq 1 ]; then
+ if [[ "$fulltest" == "1" ]]; then
php phpunit.phar --bootstrap "$parentdir/vendor/autoload.php" "$parentdir/tests/full"
if [ $? -ne 0 ]; then
# Test failure
@@ -93,7 +93,7 @@ if [ $? -eq 0 ]; then
fi
fi
# Cleanup
- if [ "$clean" -eq 1 ]; then
+ if [[ "$clean" == "1" ]]; then
echo -e "\033[32mCleaning Up!\033[0m"
rm -f phpunit.phar
rm -f phpunit.phar.asc