From 6d24b92b11ab40d3206f0b86598481d5fbacbfe5 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 13 Jan 2013 19:08:20 +0100 Subject: [PATCH 1/2] [constant-trickery] Better name for constant redefine method. --- tests/Math/BigInteger/BCMathTest.php | 2 +- tests/Math/BigInteger/GMPTest.php | 2 +- tests/Math/BigInteger/InternalTest.php | 2 +- tests/PhpseclibTestCase.php | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Math/BigInteger/BCMathTest.php b/tests/Math/BigInteger/BCMathTest.php index 08d4b3fe..f97fac93 100644 --- a/tests/Math/BigInteger/BCMathTest.php +++ b/tests/Math/BigInteger/BCMathTest.php @@ -16,6 +16,6 @@ class Math_BigInteger_BCMathTest extends Math_BigInteger_TestCase parent::setUpBeforeClass(); - self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH); + self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH); } } diff --git a/tests/Math/BigInteger/GMPTest.php b/tests/Math/BigInteger/GMPTest.php index fcd898d1..a0074db5 100644 --- a/tests/Math/BigInteger/GMPTest.php +++ b/tests/Math/BigInteger/GMPTest.php @@ -16,6 +16,6 @@ class Math_BigInteger_GMPTest extends Math_BigInteger_TestCase parent::setUpBeforeClass(); - self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP); + self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP); } } diff --git a/tests/Math/BigInteger/InternalTest.php b/tests/Math/BigInteger/InternalTest.php index 1ca2ef74..7b1c100a 100644 --- a/tests/Math/BigInteger/InternalTest.php +++ b/tests/Math/BigInteger/InternalTest.php @@ -11,6 +11,6 @@ class Math_BigInteger_InternalTest extends Math_BigInteger_TestCase { parent::setUpBeforeClass(); - self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL); + self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL); } } diff --git a/tests/PhpseclibTestCase.php b/tests/PhpseclibTestCase.php index e69aa25a..22cdb95e 100644 --- a/tests/PhpseclibTestCase.php +++ b/tests/PhpseclibTestCase.php @@ -13,7 +13,7 @@ abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase * * @return null */ - static protected function ensureModeConstant($constant, $expected) + static protected function ensureConstant($constant, $expected) { if (defined($constant)) { @@ -26,7 +26,7 @@ abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase if (!runkit_constant_redefine($constant, $expected)) { self::markTestSkipped(sprintf( - "Failed to redefine mode constant %s to %s", + "Failed to redefine constant %s to %s", $constant, $expected )); @@ -35,7 +35,7 @@ abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase else { self::markTestSkipped(sprintf( - "Skipping test because mode constant %s is %s instead of %s", + "Skipping test because constant %s is %s instead of %s", $constant, $value, $expected From 93d7bf4444aa6cb13e8e458cc19486e7d7d551c8 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 13 Jan 2013 19:14:06 +0100 Subject: [PATCH 2/2] [constant-trickery] Also test without OpenSSL. --- tests/Math/BigInteger/InternalOpenSSLTest.php | 21 +++++++++++++++++++ tests/Math/BigInteger/InternalTest.php | 1 + 2 files changed, 22 insertions(+) create mode 100644 tests/Math/BigInteger/InternalOpenSSLTest.php diff --git a/tests/Math/BigInteger/InternalOpenSSLTest.php b/tests/Math/BigInteger/InternalOpenSSLTest.php new file mode 100644 index 00000000..f235484d --- /dev/null +++ b/tests/Math/BigInteger/InternalOpenSSLTest.php @@ -0,0 +1,21 @@ + + * @copyright MMXIII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +class Math_BigInteger_InternalOpenSSLTest extends Math_BigInteger_TestCase +{ + static public function setUpBeforeClass() + { + if (!function_exists('openssl_public_encrypt')) + { + self::markTestSkipped('openssl_public_encrypt() function is not available.'); + } + + parent::setUpBeforeClass(); + + self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL); + } +} diff --git a/tests/Math/BigInteger/InternalTest.php b/tests/Math/BigInteger/InternalTest.php index 7b1c100a..7cbbc8f8 100644 --- a/tests/Math/BigInteger/InternalTest.php +++ b/tests/Math/BigInteger/InternalTest.php @@ -12,5 +12,6 @@ class Math_BigInteger_InternalTest extends Math_BigInteger_TestCase parent::setUpBeforeClass(); self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL); + self::ensureConstant('MATH_BIGINTEGER_OPENSSL_DISABLE', true); } }