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
|
|
|
|
*/
|
|
|
|
|
|
|
|
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',
|
|
|
|
MATH_BIGINTEGER_MODE_GMP
|
|
|
|
);
|
|
|
|
} elseif (extension_loaded('bcmath')) {
|
|
|
|
self::ensureConstant(
|
|
|
|
'MATH_BIGINTEGER_MODE',
|
|
|
|
MATH_BIGINTEGER_MODE_BCMATH
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
self::markTestSkipped(
|
|
|
|
'Should have gmp or bcmath extension for functional test.'
|
|
|
|
);
|
|
|
|
}
|
2014-08-04 23:33:23 +02:00
|
|
|
self::ensureConstant('CRYPT_HASH_MODE', CRYPT_HASH_MODE_HASH);
|
|
|
|
self::reRequireFile('Math/BigInteger.php');
|
|
|
|
self::reRequireFile('Crypt/Hash.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;
|
|
|
|
}
|
|
|
|
}
|