mirror of
https://github.com/danog/phpseclib.git
synced 2024-12-03 10:08:04 +01:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
db949bfc61
@ -5,5 +5,9 @@ php:
|
|||||||
- 5.3
|
- 5.3
|
||||||
- 5.4
|
- 5.4
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- git clone git://github.com/zenovich/runkit.git && cd runkit && phpize && ./configure && make && make install && cd ..
|
||||||
|
- echo "extension=runkit.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- phpunit --verbose
|
- phpunit --verbose
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
abstract class Crypt_AES_TestCase extends PHPUnit_Framework_TestCase
|
abstract class Crypt_AES_TestCase extends PhpseclibTestCase
|
||||||
{
|
{
|
||||||
static public function setUpBeforeClass()
|
static public function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
abstract class Crypt_Hash_TestCase extends PHPUnit_Framework_TestCase
|
abstract class Crypt_Hash_TestCase extends PhpseclibTestCase
|
||||||
{
|
{
|
||||||
static public function setUpBeforeClass()
|
static public function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
|
21
tests/Math/BigInteger/BCMathTest.php
Normal file
21
tests/Math/BigInteger/BCMathTest.php
Normal 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_BCMathTest extends Math_BigInteger_TestCase
|
||||||
|
{
|
||||||
|
static public function setUpBeforeClass()
|
||||||
|
{
|
||||||
|
if (!extension_loaded('bcmath'))
|
||||||
|
{
|
||||||
|
self::markTestSkipped('BCMath extension is not available.');
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::setUpBeforeClass();
|
||||||
|
|
||||||
|
self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH);
|
||||||
|
}
|
||||||
|
}
|
21
tests/Math/BigInteger/GMPTest.php
Normal file
21
tests/Math/BigInteger/GMPTest.php
Normal 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_GMPTest extends Math_BigInteger_TestCase
|
||||||
|
{
|
||||||
|
static public function setUpBeforeClass()
|
||||||
|
{
|
||||||
|
if (!extension_loaded('gmp'))
|
||||||
|
{
|
||||||
|
self::markTestSkipped('GNU Multiple Precision (GMP) extension is not available.');
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::setUpBeforeClass();
|
||||||
|
|
||||||
|
self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP);
|
||||||
|
}
|
||||||
|
}
|
16
tests/Math/BigInteger/InternalTest.php
Normal file
16
tests/Math/BigInteger/InternalTest.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?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_InternalTest extends Math_BigInteger_TestCase
|
||||||
|
{
|
||||||
|
static public function setUpBeforeClass()
|
||||||
|
{
|
||||||
|
parent::setUpBeforeClass();
|
||||||
|
|
||||||
|
self::ensureModeConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
|
||||||
|
}
|
||||||
|
}
|
@ -5,8 +5,17 @@
|
|||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Math_BigIntegerTest extends PHPUnit_Framework_TestCase
|
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)
|
public function getInstance($x = 0, $base = 10)
|
||||||
{
|
{
|
||||||
return new Math_BigInteger($x, $base);
|
return new Math_BigInteger($x, $base);
|
74
tests/PhpseclibTestCase.php
Normal file
74
tests/PhpseclibTestCase.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Andreas Fischer <bantu@phpbb.com>
|
||||||
|
* @copyright MMXIII Andreas Fischer
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
|
*/
|
||||||
|
|
||||||
|
abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param string $constant
|
||||||
|
* @param mixed $expected
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
static protected function ensureModeConstant($constant, $expected)
|
||||||
|
{
|
||||||
|
if (defined($constant))
|
||||||
|
{
|
||||||
|
$value = constant($constant);
|
||||||
|
|
||||||
|
if ($value !== $expected)
|
||||||
|
{
|
||||||
|
if (function_exists('runkit_constant_redefine'))
|
||||||
|
{
|
||||||
|
if (!runkit_constant_redefine($constant, $expected))
|
||||||
|
{
|
||||||
|
self::markTestSkipped(sprintf(
|
||||||
|
"Failed to redefine mode constant %s to %s",
|
||||||
|
$constant,
|
||||||
|
$expected
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self::markTestSkipped(sprintf(
|
||||||
|
"Skipping test because mode constant %s is %s instead of %s",
|
||||||
|
$constant,
|
||||||
|
$value,
|
||||||
|
$expected
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user