only mock mcrypt if it isn't installed
This commit is contained in:
parent
67133ec090
commit
1158c81259
|
@ -37,21 +37,24 @@ class serversaltTest extends PHPUnit_Framework_TestCase
|
||||||
$salt = serversalt::get();
|
$salt = serversalt::get();
|
||||||
|
|
||||||
// mcrypt mock
|
// mcrypt mock
|
||||||
if (!defined('MCRYPT_DEV_URANDOM')) define('MCRYPT_DEV_URANDOM', 1);
|
if (!function_exists('mcrypt_create_iv'))
|
||||||
function mcrypt_create_iv($int, $flag)
|
|
||||||
{
|
{
|
||||||
$randomSalt = '';
|
if (!defined('MCRYPT_DEV_URANDOM')) define('MCRYPT_DEV_URANDOM', 1);
|
||||||
for($i = 0; $i < 256; ++$i) {
|
function mcrypt_create_iv($int, $flag)
|
||||||
$randomSalt .= base_convert(mt_rand(), 10, 16);
|
|
||||||
}
|
|
||||||
// hex2bin requires an even length, pad if necessary
|
|
||||||
if (strlen($randomSalt) % 2)
|
|
||||||
{
|
{
|
||||||
$randomSalt = '0' . $randomSalt;
|
$randomSalt = '';
|
||||||
|
for($i = 0; $i < 256; ++$i) {
|
||||||
|
$randomSalt .= base_convert(mt_rand(), 10, 16);
|
||||||
|
}
|
||||||
|
// hex2bin requires an even length, pad if necessary
|
||||||
|
if (strlen($randomSalt) % 2)
|
||||||
|
{
|
||||||
|
$randomSalt = '0' . $randomSalt;
|
||||||
|
}
|
||||||
|
return hex2bin($randomSalt);
|
||||||
}
|
}
|
||||||
return hex2bin($randomSalt);
|
$this->assertNotEquals($salt, serversalt::generate());
|
||||||
}
|
}
|
||||||
$this->assertNotEquals($salt, serversalt::generate());
|
|
||||||
|
|
||||||
// try setting a different path and resetting it
|
// try setting a different path and resetting it
|
||||||
serversalt::setPath($this->_otherPath);
|
serversalt::setPath($this->_otherPath);
|
||||||
|
|
Loading…
Reference in New Issue