[constant-trickery] Reimport class definition to clear static variables.

This commit is contained in:
Andreas Fischer 2013-01-12 21:22:01 +01:00
parent 3c75fa1ad4
commit f62a9114b3
5 changed files with 36 additions and 3 deletions

View File

@ -14,7 +14,8 @@ class Math_BigInteger_BCMathTest extends Math_BigInteger_TestCase
self::markTestSkipped('BCMath extension is not available.');
}
self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH);
parent::setUpBeforeClass();
self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH);
}
}

View File

@ -14,7 +14,8 @@ class Math_BigInteger_GMPTest extends Math_BigInteger_TestCase
self::markTestSkipped('GNU Multiple Precision (GMP) extension is not available.');
}
self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP);
parent::setUpBeforeClass();
self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP);
}
}

View File

@ -9,7 +9,8 @@ class Math_BigInteger_InternalTest extends Math_BigInteger_TestCase
{
static public function setUpBeforeClass()
{
self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
parent::setUpBeforeClass();
self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
}
}

View File

@ -9,6 +9,13 @@ require_once 'Math/BigInteger.php';
abstract class Math_BigInteger_TestCase extends PhpseclibTestCase
{
static public function setUpBeforeClass()
{
parent::setUpBeforeClass();
self::reRequireFile('Math/BigInteger.php');
}
public function getInstance($x = 0, $base = 10)
{
return new Math_BigInteger($x, $base);

View File

@ -48,4 +48,27 @@ abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase
define($constant, $expected);
}
}
/**
* @param string $filename
*
* @return null
*/
static protected function reRequireFile($filename)
{
if (function_exists('runkit_import'))
{
$result = runkit_import(
$filename,
RUNKIT_IMPORT_FUNCTIONS |
RUNKIT_IMPORT_CLASS_METHODS |
RUNKIT_IMPORT_OVERRIDE
);
if (!$result)
{
self::markTestSkipped("Failed to reimport file $filename");
}
}
}
}