2013-01-12 01:34:20 +00:00
|
|
|
<?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
|
|
|
|
{
|
2013-01-12 01:48:19 +00:00
|
|
|
/**
|
|
|
|
* @param string $constant
|
|
|
|
* @param mixed $expected
|
|
|
|
*
|
|
|
|
* @return null
|
|
|
|
*/
|
2013-01-13 18:08:20 +00:00
|
|
|
static protected function ensureConstant($constant, $expected)
|
2013-01-12 01:48:19 +00:00
|
|
|
{
|
|
|
|
if (defined($constant))
|
|
|
|
{
|
|
|
|
$value = constant($constant);
|
2013-01-12 01:34:20 +00:00
|
|
|
|
2013-01-12 01:48:19 +00:00
|
|
|
if ($value !== $expected)
|
|
|
|
{
|
2013-01-12 02:03:29 +00:00
|
|
|
if (function_exists('runkit_constant_redefine'))
|
|
|
|
{
|
|
|
|
if (!runkit_constant_redefine($constant, $expected))
|
|
|
|
{
|
|
|
|
self::markTestSkipped(sprintf(
|
2013-01-13 18:08:20 +00:00
|
|
|
"Failed to redefine constant %s to %s",
|
2013-01-12 02:03:29 +00:00
|
|
|
$constant,
|
|
|
|
$expected
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self::markTestSkipped(sprintf(
|
2013-01-13 18:08:20 +00:00
|
|
|
"Skipping test because constant %s is %s instead of %s",
|
2013-01-12 02:03:29 +00:00
|
|
|
$constant,
|
|
|
|
$value,
|
|
|
|
$expected
|
|
|
|
));
|
|
|
|
}
|
2013-01-12 01:48:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
define($constant, $expected);
|
|
|
|
}
|
|
|
|
}
|
2013-01-12 20:22:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-12 01:34:20 +00:00
|
|
|
}
|