2014-03-03 01:34:43 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @author Andreas Fischer <bantu@phpbb.com>
|
2014-12-10 00:02:44 +01:00
|
|
|
* @copyright 2014 Andreas Fischer
|
2014-03-03 01:34:43 +01:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
*/
|
|
|
|
|
2014-12-17 01:16:54 +01:00
|
|
|
use phpseclib\Crypt\Hash;
|
|
|
|
use phpseclib\Math\BigInteger;
|
|
|
|
|
2014-03-03 01:34:43 +01:00
|
|
|
abstract class PhpseclibFunctionalTestCase extends PhpseclibTestCase
|
|
|
|
{
|
2015-07-15 03:52:31 +02:00
|
|
|
public static function setUpBeforeClass()
|
2014-08-01 18:01:53 +02:00
|
|
|
{
|
2014-08-04 23:33:23 +02:00
|
|
|
if (extension_loaded('runkit')) {
|
2014-12-12 11:54:27 +01:00
|
|
|
if (extension_loaded('gmp')) {
|
|
|
|
self::ensureConstant(
|
|
|
|
'MATH_BIGINTEGER_MODE',
|
2014-12-17 01:16:54 +01:00
|
|
|
BigInteger::MODE_GMP
|
2014-12-12 11:54:27 +01:00
|
|
|
);
|
|
|
|
} elseif (extension_loaded('bcmath')) {
|
|
|
|
self::ensureConstant(
|
|
|
|
'MATH_BIGINTEGER_MODE',
|
2014-12-17 01:16:54 +01:00
|
|
|
BigInteger::MODE_BCMATH
|
2014-12-12 11:54:27 +01:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
self::markTestSkipped(
|
|
|
|
'Should have gmp or bcmath extension for functional test.'
|
|
|
|
);
|
|
|
|
}
|
2014-08-04 23:33:23 +02:00
|
|
|
self::reRequireFile('Math/BigInteger.php');
|
|
|
|
}
|
2014-08-01 18:01:53 +02:00
|
|
|
parent::setUpBeforeClass();
|
|
|
|
}
|
|
|
|
|
2014-03-03 01:34:43 +01:00
|
|
|
/**
|
2015-03-29 18:07:17 +02:00
|
|
|
* @param string $variable
|
|
|
|
* @param string|null $message
|
|
|
|
*
|
|
|
|
* @return null
|
|
|
|
*/
|
2014-03-03 01:34:43 +01:00
|
|
|
protected function requireEnv($variable, $message = null)
|
|
|
|
{
|
|
|
|
if ($this->_getEnv($variable) === false) {
|
|
|
|
$msg = $message ? $message : sprintf(
|
|
|
|
"This test requires the '%s' environment variable.",
|
|
|
|
$this->_prefixEnvVariable($variable)
|
|
|
|
);
|
|
|
|
$this->markTestSkipped($msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-03-29 18:07:17 +02:00
|
|
|
* @param string $variable
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2014-03-03 01:34:43 +01:00
|
|
|
protected function getEnv($variable)
|
|
|
|
{
|
|
|
|
$this->requireEnv($variable);
|
|
|
|
return $this->_getEnv($variable);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function _getEnv($variable)
|
|
|
|
{
|
|
|
|
return getenv($this->_prefixEnvVariable($variable));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function _prefixEnvVariable($variable)
|
|
|
|
{
|
|
|
|
return 'PHPSECLIB_' . $variable;
|
|
|
|
}
|
|
|
|
}
|