Merge remote-tracking branch 'upstream/master'

This commit is contained in:
terrafrost 2013-01-13 10:50:47 -06:00
commit db949bfc61
8 changed files with 148 additions and 3 deletions

View File

@ -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

View File

@ -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()
{ {

View File

@ -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()
{ {

View 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);
}
}

View 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);
}
}

View 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);
}
}

View File

@ -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);

View 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");
}
}
}
}