Merge pull request #50 from bantu/constant-trickery

Also test Math_BigInteger without OpenSSL.
This commit is contained in:
terrafrost 2013-01-13 14:43:37 -08:00
commit f1ccbd4ee1
5 changed files with 28 additions and 6 deletions

View File

@ -16,6 +16,6 @@ class Math_BigInteger_BCMathTest extends Math_BigInteger_TestCase
parent::setUpBeforeClass(); parent::setUpBeforeClass();
self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH); self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH);
} }
} }

View File

@ -16,6 +16,6 @@ class Math_BigInteger_GMPTest extends Math_BigInteger_TestCase
parent::setUpBeforeClass(); parent::setUpBeforeClass();
self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP); self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP);
} }
} }

View File

@ -0,0 +1,21 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @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);
}
}

View File

@ -11,6 +11,7 @@ class Math_BigInteger_InternalTest extends Math_BigInteger_TestCase
{ {
parent::setUpBeforeClass(); parent::setUpBeforeClass();
self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL); self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
self::ensureConstant('MATH_BIGINTEGER_OPENSSL_DISABLE', true);
} }
} }

View File

@ -13,7 +13,7 @@ abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase
* *
* @return null * @return null
*/ */
static protected function ensureModeConstant($constant, $expected) static protected function ensureConstant($constant, $expected)
{ {
if (defined($constant)) if (defined($constant))
{ {
@ -26,7 +26,7 @@ abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase
if (!runkit_constant_redefine($constant, $expected)) if (!runkit_constant_redefine($constant, $expected))
{ {
self::markTestSkipped(sprintf( self::markTestSkipped(sprintf(
"Failed to redefine mode constant %s to %s", "Failed to redefine constant %s to %s",
$constant, $constant,
$expected $expected
)); ));
@ -35,7 +35,7 @@ abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase
else else
{ {
self::markTestSkipped(sprintf( 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, $constant,
$value, $value,
$expected $expected