Initial Commit
This commit is contained in:
121
database/php/tests/AllTests.php
Normal file
121
database/php/tests/AllTests.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* Test suite for PHP_CompatInfo
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CompatInfo
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD
|
||||
* @version CVS: $Id: AllTests.php,v 1.4 2008/07/22 20:27:11 farell Exp $
|
||||
* @link http://pear.php.net/package/PHP_CompatInfo
|
||||
* @since File available since Release 1.6.0
|
||||
*/
|
||||
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'PHP_CompatInfo_AllTests::main');
|
||||
}
|
||||
|
||||
require_once 'PHPUnit/Framework/TestSuite.php';
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
|
||||
chdir(dirname(__FILE__));
|
||||
|
||||
require_once 'PEAR/Config.php';
|
||||
require_once 'PHP_CompatInfo_TestSuite_Standard.php';
|
||||
require_once 'PHP_CompatInfo_TestSuite_Bugs.php';
|
||||
|
||||
/**
|
||||
* Class for running all test suites for PHP_CompatInfo package.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CompatInfo
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD
|
||||
* @version Release: @package_version@
|
||||
* @link http://pear.php.net/package/PHP_CompatInfo
|
||||
* @since File available since Release 1.6.0
|
||||
*/
|
||||
|
||||
class PHP_CompatInfo_AllTests
|
||||
{
|
||||
/**
|
||||
* Runs the test suite.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
PHPUnit_TextUI_TestRunner::run(self::suite());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the PHP_CompatInfo test suite.
|
||||
*
|
||||
* @return object the PHPUnit_Framework_TestSuite object
|
||||
*/
|
||||
public static function suite()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite('PHP_CompatInfo Test Suite');
|
||||
$suite->addTestSuite('PHP_CompatInfo_TestSuite_Standard');
|
||||
$suite->addTestSuite('PHP_CompatInfo_TestSuite_Bugs');
|
||||
|
||||
if (PHP_CompatInfo_AllTests::packageInstalled('Console_GetArgs', '1.3.3')
|
||||
&& PHP_CompatInfo_AllTests::packageInstalled('Console_Table', '1.0.5')) {
|
||||
/* Add CLI test suite, only
|
||||
if packages below are installed on your system :
|
||||
- Console_GetArgs 1.3.3 or better
|
||||
- Console_Table 1.0.5 or better
|
||||
*/
|
||||
include_once 'PHP_CompatInfo_TestSuite_Cli.php';
|
||||
|
||||
$suite->addTestSuite('PHP_CompatInfo_TestSuite_Cli');
|
||||
}
|
||||
return $suite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a package is installed
|
||||
*
|
||||
* Simple function to check if a package is installed under user
|
||||
* or system PEAR installation. Minimal version and channel info are supported.
|
||||
*
|
||||
* @param string $name Package name
|
||||
* @param string $version (optional) The minimal version
|
||||
* that should be installed
|
||||
* @param string $channel (optional) The package channel distribution
|
||||
* @param string $user_file (optional) file to read PEAR user-defined
|
||||
* options from
|
||||
* @param string $system_file (optional) file to read PEAR system-wide
|
||||
* defaults from
|
||||
*
|
||||
* @static
|
||||
* @return bool
|
||||
* @since PEAR_Info version 1.6.0 (2005-01-03)
|
||||
* @see PEAR_Info::packageInstalled()
|
||||
*/
|
||||
public static function packageInstalled($name, $version = null, $channel = null,
|
||||
$user_file = '', $system_file = '')
|
||||
{
|
||||
$config =& PEAR_Config::singleton($user_file, $system_file);
|
||||
$reg =& $config->getRegistry();
|
||||
|
||||
if (is_null($version)) {
|
||||
return $reg->packageExists($name, $channel);
|
||||
} else {
|
||||
$info = &$reg->getPackage($name, $channel);
|
||||
if (is_object($info)) {
|
||||
$installed['version'] = $info->getVersion();
|
||||
} else {
|
||||
$installed = $info;
|
||||
}
|
||||
return version_compare($version, $installed['version'], '<=');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'PHP_CompatInfo_AllTests::main') {
|
||||
PHP_CompatInfo_AllTests::main();
|
||||
}
|
||||
?>
|
||||
63
database/php/tests/Console_Getopt/tests/001-getopt.phpt
Normal file
63
database/php/tests/Console_Getopt/tests/001-getopt.phpt
Normal file
@@ -0,0 +1,63 @@
|
||||
--TEST--
|
||||
Console_Getopt
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'Console/Getopt.php';
|
||||
PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s\n\n");
|
||||
|
||||
function test($argstr, $optstr) {
|
||||
$argv = preg_split('/[[:space:]]+/', $argstr);
|
||||
if (PEAR::isError($options = Console_Getopt::getopt($argv, $optstr))) {
|
||||
return;
|
||||
}
|
||||
$opts = $options[0];
|
||||
$non_opts = $options[1];
|
||||
$i = 0;
|
||||
print "options: ";
|
||||
foreach ($opts as $o => $d) {
|
||||
if ($i++ > 0) {
|
||||
print ", ";
|
||||
}
|
||||
print $d[0] . '=' . $d[1];
|
||||
}
|
||||
print "\n";
|
||||
print "params: " . implode(", ", $non_opts) . "\n";
|
||||
print "\n";
|
||||
}
|
||||
|
||||
test("-abc", "abc");
|
||||
test("-abc foo", "abc");
|
||||
test("-abc foo", "abc:");
|
||||
test("-abc foo bar gazonk", "abc");
|
||||
test("-abc foo bar gazonk", "abc:");
|
||||
test("-a -b -c", "abc");
|
||||
test("-a -b -c", "abc:");
|
||||
test("-abc", "ab:c");
|
||||
test("-abc foo -bar gazonk", "abc");
|
||||
?>
|
||||
--EXPECT--
|
||||
options: a=, b=, c=
|
||||
params:
|
||||
|
||||
options: a=, b=, c=
|
||||
params: foo
|
||||
|
||||
options: a=, b=, c=foo
|
||||
params:
|
||||
|
||||
options: a=, b=, c=
|
||||
params: foo, bar, gazonk
|
||||
|
||||
options: a=, b=, c=foo
|
||||
params: bar, gazonk
|
||||
|
||||
options: a=, b=, c=
|
||||
params:
|
||||
|
||||
Console_Getopt: option requires an argument --c
|
||||
|
||||
options: a=, b=c
|
||||
params:
|
||||
|
||||
options: a=, b=, c=
|
||||
params: foo, -bar, gazonk
|
||||
22
database/php/tests/Console_Getopt/tests/bug10557.phpt
Normal file
22
database/php/tests/Console_Getopt/tests/bug10557.phpt
Normal file
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
Console_Getopt [bug 10557]
|
||||
--SKIPIF--
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'] =
|
||||
$argv = array('hi', '-fjjohnston@mail.com', '--to', '--mailpack', '--debug');
|
||||
require_once 'Console/Getopt.php';
|
||||
$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'f:t:',
|
||||
array('from=','to=','mailpack=','direction=','verbose','debug'));
|
||||
if(PEAR::isError($ret))
|
||||
{
|
||||
echo $ret->getMessage()."\n";
|
||||
echo 'FATAL';
|
||||
exit;
|
||||
}
|
||||
|
||||
print_r($ret);
|
||||
?>
|
||||
--EXPECT--
|
||||
Console_Getopt: option requires an argument --to
|
||||
FATAL
|
||||
44
database/php/tests/Console_Getopt/tests/bug11068.phpt
Normal file
44
database/php/tests/Console_Getopt/tests/bug11068.phpt
Normal file
@@ -0,0 +1,44 @@
|
||||
--TEST--
|
||||
Console_Getopt [bug 11068]
|
||||
--SKIPIF--
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'] =
|
||||
$argv = array('hi', '-fjjohnston@mail.com', '--to', 'hi', '-');
|
||||
require_once 'Console/Getopt.php';
|
||||
$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'f:t:',
|
||||
array('from=','to=','mailpack=','direction=','verbose','debug'));
|
||||
if(PEAR::isError($ret))
|
||||
{
|
||||
echo $ret->getMessage()."\n";
|
||||
echo 'FATAL';
|
||||
exit;
|
||||
}
|
||||
|
||||
print_r($ret);
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => f
|
||||
[1] => jjohnston@mail.com
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => --to
|
||||
[1] => hi
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => -
|
||||
)
|
||||
|
||||
)
|
||||
75
database/php/tests/Console_Getopt/tests/bug13140.phpt
Normal file
75
database/php/tests/Console_Getopt/tests/bug13140.phpt
Normal file
@@ -0,0 +1,75 @@
|
||||
--TEST--
|
||||
Console_Getopt [bug 13140]
|
||||
--SKIPIF--
|
||||
--FILE--
|
||||
<?php
|
||||
$_SERVER['argv'] = $argv =
|
||||
array('--bob', '--foo' , '-bar', '--test', '-rq', 'thisshouldbehere');
|
||||
|
||||
require_once 'Console/Getopt.php';
|
||||
$cg = new Console_GetOpt();
|
||||
|
||||
print_r($cg->getopt2($cg->readPHPArgv(), 't', array('test'), true));
|
||||
print_r($cg->getopt2($cg->readPHPArgv(), 'bar', array('foo'), true));
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => --test
|
||||
[1] =>
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => thisshouldbehere
|
||||
)
|
||||
|
||||
)
|
||||
Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => --foo
|
||||
[1] =>
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => b
|
||||
[1] =>
|
||||
)
|
||||
|
||||
[2] => Array
|
||||
(
|
||||
[0] => a
|
||||
[1] =>
|
||||
)
|
||||
|
||||
[3] => Array
|
||||
(
|
||||
[0] => r
|
||||
[1] =>
|
||||
)
|
||||
|
||||
[4] => Array
|
||||
(
|
||||
[0] => r
|
||||
[1] =>
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => thisshouldbehere
|
||||
)
|
||||
|
||||
)
|
||||
674
database/php/tests/PHP_CompatInfo_TestSuite_Bugs.php
Normal file
674
database/php/tests/PHP_CompatInfo_TestSuite_Bugs.php
Normal file
@@ -0,0 +1,674 @@
|
||||
<?php
|
||||
/**
|
||||
* Test suite for bugs declared in the PHP_CompatInfo class
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CompatInfo
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD
|
||||
* @version CVS: $Id: PHP_CompatInfo_TestSuite_Bugs.php,v 1.23 2008/12/18 23:06:45 farell Exp $
|
||||
* @link http://pear.php.net/package/PHP_CompatInfo
|
||||
* @since File available since Release 1.6.0
|
||||
*/
|
||||
if (!defined("PHPUnit_MAIN_METHOD")) {
|
||||
define("PHPUnit_MAIN_METHOD", "PHP_CompatInfo_TestSuite_Bugs::main");
|
||||
}
|
||||
|
||||
require_once "PHPUnit/Framework/TestCase.php";
|
||||
require_once "PHPUnit/Framework/TestSuite.php";
|
||||
|
||||
require_once 'PHP/CompatInfo.php';
|
||||
|
||||
/**
|
||||
* Test suite class to test standard PHP_CompatInfo API.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CompatInfo
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD
|
||||
* @version Release: 1.9.0
|
||||
* @link http://pear.php.net/package/PHP_CompatInfo
|
||||
* @since File available since Release 1.6.0
|
||||
*/
|
||||
class PHP_CompatInfo_TestSuite_Bugs extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* A PCI object
|
||||
* @var object
|
||||
*/
|
||||
protected $pci;
|
||||
|
||||
/**
|
||||
* Filename where to write results of debug pci events notification
|
||||
* @var string
|
||||
* @since 1.8.0RC1
|
||||
*/
|
||||
private $destLogFile;
|
||||
|
||||
/**
|
||||
* Runs the test methods of this class.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
include_once "PHPUnit/TextUI/TestRunner.php";
|
||||
|
||||
$suite = new PHPUnit_Framework_TestSuite('PHP_CompatInfo Bugs Tests');
|
||||
PHPUnit_TextUI_TestRunner::run($suite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the fixture.
|
||||
* This method is called before a test is executed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->destLogFile = dirname(__FILE__) . DIRECTORY_SEPARATOR .
|
||||
__CLASS__ . '.log';
|
||||
|
||||
$this->pci = new PHP_CompatInfo('null');
|
||||
$this->pci->addListener(array(&$this, 'debugNotify'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture.
|
||||
* This method is called after a test is executed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
unset($this->pci);
|
||||
}
|
||||
|
||||
/**
|
||||
* PCI Events notification observer for debug purpose only
|
||||
*
|
||||
* @param object &$auditEvent Instance of Event_Notification object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function debugNotify(&$auditEvent)
|
||||
{
|
||||
$notifyName = $auditEvent->getNotificationName();
|
||||
$notifyInfo = $auditEvent->getNotificationInfo();
|
||||
|
||||
if ($notifyName == PHP_COMPATINFO_EVENT_AUDITSTARTED) {
|
||||
$dbt = debug_backtrace();
|
||||
error_log('backtrace: '. $dbt[7]['function'] . PHP_EOL,
|
||||
3, $this->destLogFile);
|
||||
error_log($notifyName.':'. PHP_EOL .
|
||||
var_export($notifyInfo, true) . PHP_EOL,
|
||||
3, $this->destLogFile);
|
||||
|
||||
} elseif ($notifyName == PHP_COMPATINFO_EVENT_AUDITFINISHED) {
|
||||
error_log($notifyName.':'. PHP_EOL .
|
||||
var_export($notifyInfo, true) . PHP_EOL,
|
||||
3, $this->destLogFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve files list to be ignore by parsing process
|
||||
*
|
||||
* @param string $dir Directory to parse
|
||||
* @param array $options Parser options
|
||||
*
|
||||
* @return array
|
||||
* @since version 1.8.0RC1
|
||||
*/
|
||||
private function getIgnoredFileList($dir, $options)
|
||||
{
|
||||
$files = $this->pci->parser->getFileList($dir, $options);
|
||||
|
||||
$ff = new File_Find();
|
||||
$ff->dirsep = DIRECTORY_SEPARATOR;
|
||||
list(, $allfiles) = $ff->maptree($dir);
|
||||
|
||||
$ignored_files = PHP_CompatInfo_Parser::_arrayDiff($allfiles, $files);
|
||||
return $ignored_files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a dictionary for an Extension is available or not
|
||||
*
|
||||
* @param array $resources List of Extension dictionaries
|
||||
* that should be present to perform a unit test
|
||||
* @param array &$testSkipped Reasons of tests skipped
|
||||
*
|
||||
* @return bool
|
||||
* @since version 1.9.0b2
|
||||
*/
|
||||
private function isResourceAvailable($resources, &$testSkipped)
|
||||
{
|
||||
$dict = array();
|
||||
foreach ($resources as $ext) {
|
||||
if (!isset($GLOBALS['_PHP_COMPATINFO_FUNC_'.strtoupper($ext)])) {
|
||||
$dict[] = $ext;
|
||||
}
|
||||
}
|
||||
if (count($dict) == 1) {
|
||||
$testSkipped[] = 'The '. $dict[0] .
|
||||
' function dictionary is not available.';
|
||||
} elseif (count($dict) > 1) {
|
||||
$testSkipped[] = 'The '. implode(',', $dict) .
|
||||
' function dictionaries are not available.';
|
||||
}
|
||||
return (count($testSkipped) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for bug #1626
|
||||
*
|
||||
* @return void
|
||||
* @link http://pear.php.net/bugs/bug.php?id=1626
|
||||
* Class calls are seen wrong
|
||||
* @covers PHP_CompatInfo::parseString
|
||||
* @group parseString
|
||||
*/
|
||||
public function testBug1626()
|
||||
{
|
||||
$str = '<?php
|
||||
include("File.php");
|
||||
File::write("test", "test");
|
||||
?>';
|
||||
$r = $this->pci->parseString($str);
|
||||
$exp = array('ignored_files' => array(),
|
||||
'ignored_functions' => array(),
|
||||
'ignored_extensions' => array(),
|
||||
'ignored_constants' => array(),
|
||||
'max_version' => '',
|
||||
'version' => '4.0.0',
|
||||
'classes' => array(),
|
||||
'functions' => array(),
|
||||
'extensions' => array(),
|
||||
'constants' => array(),
|
||||
'tokens' => array(),
|
||||
'cond_code' => array(0));
|
||||
$this->assertSame($exp, $r);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for bug #2771
|
||||
*
|
||||
* @return void
|
||||
* @link http://pear.php.net/bugs/bug.php?id=2771
|
||||
* Substr($var,4) not working for SAPI_ extensions
|
||||
* @covers PHP_CompatInfo::parseString
|
||||
* @group parseString
|
||||
*/
|
||||
public function testBug2771()
|
||||
{
|
||||
$str = '<?php
|
||||
apache_request_headers();
|
||||
apache_response_headers();
|
||||
?>';
|
||||
$r = $this->pci->parseString($str);
|
||||
$exp = array('ignored_files' => array(),
|
||||
'ignored_functions' => array(),
|
||||
'ignored_extensions' => array(),
|
||||
'ignored_constants' => array(),
|
||||
'max_version' => '',
|
||||
'version' => '4.3.0',
|
||||
'classes' => array(),
|
||||
'functions' => array('apache_request_headers',
|
||||
'apache_response_headers'),
|
||||
'extensions' => array(),
|
||||
'constants' => array(),
|
||||
'tokens' => array(),
|
||||
'cond_code' => array(0));
|
||||
$this->assertSame($exp, $r);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for bug #7813
|
||||
*
|
||||
* Parse source file of PEAR_PackageUpdate 0.5.0
|
||||
*
|
||||
* @return void
|
||||
* @link http://pear.php.net/bugs/bug.php?id=7813
|
||||
* wrong PHP minimum version detection
|
||||
* @covers PHP_CompatInfo::parseFile
|
||||
* @group parseFile
|
||||
*/
|
||||
public function testBug7813()
|
||||
{
|
||||
$ds = DIRECTORY_SEPARATOR;
|
||||
$fn = dirname(__FILE__) . $ds . 'parseFile' . $ds . 'PackageUpdate.php';
|
||||
$opt = array('debug' => true,
|
||||
'ignore_functions' => array('debug_backtrace'));
|
||||
$r = $this->pci->parseFile($fn, $opt);
|
||||
$exp = array('ignored_files' => array(),
|
||||
'ignored_functions' => array('debug_backtrace'),
|
||||
'ignored_extensions' => array(),
|
||||
'ignored_constants' => array(),
|
||||
'max_version' => '',
|
||||
'version' => '4.3.0',
|
||||
'classes' => array('PEAR_Config'),
|
||||
'functions' => array('array_keys',
|
||||
'array_shift',
|
||||
'class_exists',
|
||||
'count',
|
||||
'debug_backtrace',
|
||||
'define',
|
||||
'explode',
|
||||
'factory',
|
||||
'fclose',
|
||||
'file_exists',
|
||||
'file_get_contents',
|
||||
'fopen',
|
||||
'function_exists',
|
||||
'fwrite',
|
||||
'get_class',
|
||||
'get_include_path',
|
||||
'getenv',
|
||||
'is_array',
|
||||
'is_int',
|
||||
'is_readable',
|
||||
'reset',
|
||||
'serialize',
|
||||
'settype',
|
||||
'strlen',
|
||||
'unserialize',
|
||||
'version_compare'),
|
||||
'extensions' => array(),
|
||||
'constants' => array('DIRECTORY_SEPARATOR',
|
||||
'E_COMPILE_ERROR',
|
||||
'E_COMPILE_WARNING',
|
||||
'E_CORE_ERROR',
|
||||
'E_CORE_WARNING',
|
||||
'E_ERROR',
|
||||
'E_NOTICE',
|
||||
'E_PARSE',
|
||||
'E_USER_ERROR',
|
||||
'E_USER_NOTICE',
|
||||
'E_USER_WARNING',
|
||||
'E_WARNING',
|
||||
'FALSE',
|
||||
'NULL',
|
||||
'PATH_SEPARATOR',
|
||||
'TRUE'),
|
||||
'tokens' => array(),
|
||||
'cond_code' => array(1, array(array('debug_backtrace'),
|
||||
array(),
|
||||
array())),
|
||||
'4.0.0' =>
|
||||
array(
|
||||
0 =>
|
||||
array(
|
||||
'function' => 'define',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'function' => 'get_class',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'function' => 'function_exists',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'function' => 'count',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
4 =>
|
||||
array (
|
||||
'function' => 'class_exists',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
5 =>
|
||||
array (
|
||||
'function' => 'explode',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
6 =>
|
||||
array (
|
||||
'function' => 'file_exists',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
7 =>
|
||||
array (
|
||||
'function' => 'is_readable',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
8 =>
|
||||
array (
|
||||
'function' => 'unserialize',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
9 =>
|
||||
array (
|
||||
'function' => 'strlen',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
10 =>
|
||||
array (
|
||||
'function' => 'getenv',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
11 =>
|
||||
array (
|
||||
'function' => 'reset',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
12 =>
|
||||
array (
|
||||
'function' => 'array_keys',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
13 =>
|
||||
array (
|
||||
'function' => 'fopen',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
14 =>
|
||||
array (
|
||||
'function' => 'serialize',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
15 =>
|
||||
array (
|
||||
'function' => 'fwrite',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
16 =>
|
||||
array (
|
||||
'function' => 'fclose',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
17 =>
|
||||
array (
|
||||
'function' => 'settype',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
18 =>
|
||||
array (
|
||||
'function' => 'is_int',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
),
|
||||
19 =>
|
||||
array (
|
||||
'function' => 'is_array',
|
||||
'extension' => false,
|
||||
'pecl' => false,
|
||||
),
|
||||
20 =>
|
||||
array (
|
||||
'function' => 'array_shift',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
)
|
||||
),
|
||||
'4.0.7' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'function' => 'version_compare',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
)
|
||||
),
|
||||
'4.3.0' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'function' => 'get_include_path',
|
||||
'extension' => false,
|
||||
'pecl' => false,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'function' => 'file_get_contents',
|
||||
'extension' => false,
|
||||
'pecl' => false
|
||||
)
|
||||
));
|
||||
|
||||
$this->assertSame($exp, $r);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for bug #8559
|
||||
*
|
||||
* @return void
|
||||
* @link http://pear.php.net/bugs/bug.php?id=8559
|
||||
* PHP_CompatInfo fails to scan if it finds empty file in path
|
||||
* @covers PHP_CompatInfo::parseDir
|
||||
* @group parseDir
|
||||
*/
|
||||
public function testBug8559()
|
||||
{
|
||||
$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'emptyDir';
|
||||
$r = $this->pci->parseDir($dir);
|
||||
$this->assertFalse($r);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for bug #10100
|
||||
*
|
||||
* @return void
|
||||
* @link http://pear.php.net/bugs/bug.php?id=10100
|
||||
* Wrong parsing of possible attributes in strings
|
||||
* @covers PHP_CompatInfo::parseString
|
||||
* @group parseString
|
||||
* @group bugs
|
||||
*/
|
||||
public function testBug10100()
|
||||
{
|
||||
$str = '<?php
|
||||
$test = "public$link";
|
||||
?>';
|
||||
$r = $this->pci->parseString($str);
|
||||
$exp = array('ignored_files' => array(),
|
||||
'ignored_functions' => array(),
|
||||
'ignored_extensions' => array(),
|
||||
'ignored_constants' => array(),
|
||||
'max_version' => '',
|
||||
'version' => '4.0.0',
|
||||
'classes' => array(),
|
||||
'functions' => array(),
|
||||
'extensions' => array(),
|
||||
'constants' => array(),
|
||||
'tokens' => array(),
|
||||
'cond_code' => array(0));
|
||||
$this->assertSame($exp, $r);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for bug #13873
|
||||
*
|
||||
* @return void
|
||||
* @link http://pear.php.net/bugs/bug.php?id=13873
|
||||
* PHP_CompatInfo fails to scan conditional code
|
||||
* if it finds other than encapsed string
|
||||
* @covers PHP_CompatInfo::parseFolder
|
||||
* @group parseDir
|
||||
* @group bugs
|
||||
*/
|
||||
public function testBug13873()
|
||||
{
|
||||
$resources = array('date', 'pcre');
|
||||
$testSkipped = array();
|
||||
if (!$this->isResourceAvailable($resources, $testSkipped)) {
|
||||
foreach ($testSkipped as $reason) {
|
||||
$this->markTestSkipped($reason);
|
||||
}
|
||||
}
|
||||
|
||||
$ds = DIRECTORY_SEPARATOR;
|
||||
$dir = dirname(__FILE__) . $ds . 'beehiveforum082' . $ds . 'forum';
|
||||
$opt = array();
|
||||
$r = $this->pci->parseFolder($dir, $opt);
|
||||
$exp = array('ignored_files' => $this->getIgnoredFileList($dir, $opt),
|
||||
'ignored_functions' => array(),
|
||||
'ignored_extensions' => array(),
|
||||
'ignored_constants' => array(),
|
||||
'max_version' => '',
|
||||
'version' => '4.0.6',
|
||||
'classes' => array(),
|
||||
'functions' => array('_htmlentities',
|
||||
'_stripslashes',
|
||||
'array_map',
|
||||
'array_merge',
|
||||
'basename',
|
||||
'bh_session_check_perm',
|
||||
'bh_session_get_value',
|
||||
'bh_setcookie',
|
||||
'db_affected_rows',
|
||||
'db_connect',
|
||||
'db_escape_string',
|
||||
'db_fetch_array',
|
||||
'db_insert_id',
|
||||
'db_num_rows',
|
||||
'db_query',
|
||||
'db_trigger_error',
|
||||
'defined',
|
||||
'delete_attachment_by_aid',
|
||||
'explode',
|
||||
'fclose',
|
||||
'file_exists',
|
||||
'filesize',
|
||||
'fix_html',
|
||||
'floor',
|
||||
'folder_get_available_by_forum',
|
||||
'fopen',
|
||||
'form_checkbox',
|
||||
'form_input_hidden',
|
||||
'form_input_password',
|
||||
'form_submit',
|
||||
'forum_apply_user_permissions',
|
||||
'forum_check_global_setting_name',
|
||||
'forum_check_password',
|
||||
'forum_check_setting_name',
|
||||
'forum_closed_message',
|
||||
'forum_delete',
|
||||
'forum_delete_tables',
|
||||
'forum_get_all_prefixes',
|
||||
'forum_get_global_settings',
|
||||
'forum_get_password',
|
||||
'forum_get_saved_password',
|
||||
'forum_get_setting',
|
||||
'forum_get_settings_by_fid',
|
||||
'forum_process_unread_cutoff',
|
||||
'forum_restricted_message',
|
||||
'forum_search',
|
||||
'forum_start_page_get_html',
|
||||
'fread',
|
||||
'function_exists',
|
||||
'fwrite',
|
||||
'get_forum_data',
|
||||
'get_request_uri',
|
||||
'get_table_prefix',
|
||||
'get_webtag',
|
||||
'header',
|
||||
'html_display_error_msg',
|
||||
'html_display_warning_msg',
|
||||
'html_draw_bottom',
|
||||
'html_draw_top',
|
||||
'html_get_top_frame_name',
|
||||
'implode',
|
||||
'in_array',
|
||||
'install_get_table_conflicts',
|
||||
'intval',
|
||||
'is_array',
|
||||
'is_dir',
|
||||
'is_md5',
|
||||
'is_null',
|
||||
'is_numeric',
|
||||
'load_language_file',
|
||||
'md5',
|
||||
'mkdir',
|
||||
'mt_rand',
|
||||
'ob_end_clean',
|
||||
'ob_get_contents',
|
||||
'ob_start',
|
||||
'perm_group_get_users',
|
||||
'preg_match',
|
||||
'sizeof',
|
||||
'sprintf',
|
||||
'str_replace',
|
||||
'stristr',
|
||||
'strlen',
|
||||
'strtoupper',
|
||||
'time',
|
||||
'trim',
|
||||
'user_get_logon',
|
||||
'word_filter_rem_ob_tags'),
|
||||
'extensions' => array('date', 'pcre'),
|
||||
'constants' => array('FALSE',
|
||||
'TRUE',
|
||||
'__FILE__'),
|
||||
'tokens' => array(),
|
||||
'cond_code' => array(4)
|
||||
);
|
||||
$this->assertSame($exp, $r);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for bug #14696
|
||||
*
|
||||
* @return void
|
||||
* @link http://pear.php.net/bugs/bug.php?id=14696
|
||||
* PHP_CompatInfo fails to scan code line when not ended with ;
|
||||
* @covers PHP_CompatInfo::parseFile
|
||||
* @group parseFile
|
||||
* @group bugs
|
||||
*/
|
||||
public function testBug14696()
|
||||
{
|
||||
$ds = DIRECTORY_SEPARATOR;
|
||||
$fn = dirname(__FILE__) . $ds . 'kohana22'
|
||||
. $ds . 'modules' . $ds . 'gmaps'
|
||||
. $ds . 'javascript.php';
|
||||
|
||||
$r = $this->pci->parseFile($fn);
|
||||
$exp = array('ignored_files' => array(),
|
||||
'ignored_functions' => array(),
|
||||
'ignored_extensions' => array(),
|
||||
'ignored_constants' => array(),
|
||||
'max_version' => '',
|
||||
'version' => '4.0.0',
|
||||
'classes' => array(),
|
||||
'functions' => array('substr'),
|
||||
'extensions' => array(),
|
||||
'constants' => array(),
|
||||
'tokens' => array(),
|
||||
'cond_code' => array(0)
|
||||
);
|
||||
|
||||
$this->assertSame($exp, $r);
|
||||
}
|
||||
}
|
||||
|
||||
// Call PHP_CompatInfo_TestSuite_Bugs::main() if file is executed directly.
|
||||
if (PHPUnit_MAIN_METHOD == "PHP_CompatInfo_TestSuite_Bugs::main") {
|
||||
PHP_CompatInfo_TestSuite_Bugs::main();
|
||||
}
|
||||
?>
|
||||
494
database/php/tests/PHP_CompatInfo_TestSuite_Cli.php
Normal file
494
database/php/tests/PHP_CompatInfo_TestSuite_Cli.php
Normal file
@@ -0,0 +1,494 @@
|
||||
<?php
|
||||
/**
|
||||
* Test suite for the PHP_CompatInfo_Cli class
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CompatInfo
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD
|
||||
* @version CVS: $Id: PHP_CompatInfo_TestSuite_Cli.php,v 1.26 2008/12/18 23:06:45 farell Exp $
|
||||
* @link http://pear.php.net/package/PHP_CompatInfo
|
||||
* @since File available since Release 1.6.0
|
||||
*/
|
||||
if (!defined("PHPUnit_MAIN_METHOD")) {
|
||||
define("PHPUnit_MAIN_METHOD", "PHP_CompatInfo_TestSuite_Cli::main");
|
||||
}
|
||||
|
||||
require_once "PHPUnit/Framework/TestCase.php";
|
||||
require_once "PHPUnit/Framework/TestSuite.php";
|
||||
|
||||
require_once 'PHP/CompatInfo/Cli.php';
|
||||
|
||||
/**
|
||||
* Test suite class to test standard PHP_CompatInfo API.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CompatInfo
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD
|
||||
* @version Release: @package_version@
|
||||
* @link http://pear.php.net/package/PHP_CompatInfo
|
||||
* @since File available since Release 1.6.0
|
||||
*/
|
||||
class PHP_CompatInfo_TestSuite_Cli extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* A PCI object
|
||||
* @var object
|
||||
*/
|
||||
protected $pci;
|
||||
|
||||
/**
|
||||
* Runs the test methods of this class.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
include_once "PHPUnit/TextUI/TestRunner.php";
|
||||
|
||||
$suite = new PHPUnit_Framework_TestSuite('PHP_CompatInfo CLI Tests');
|
||||
PHPUnit_TextUI_TestRunner::run($suite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the fixture.
|
||||
* This method is called before a test is executed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->pci = new PHP_CompatInfo_Cli();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture.
|
||||
* This method is called after a test is executed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
unset($this->pci);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a dictionary for an Extension is available or not
|
||||
*
|
||||
* @param array $resources List of Extension dictionaries
|
||||
* that should be present to perform a unit test
|
||||
* @param array &$testSkipped Reasons of tests skipped
|
||||
*
|
||||
* @return bool
|
||||
* @since version 1.9.0b2
|
||||
*/
|
||||
private function isResourceAvailable($resources, &$testSkipped)
|
||||
{
|
||||
$dict = array();
|
||||
foreach ($resources as $ext) {
|
||||
if (!isset($GLOBALS['_PHP_COMPATINFO_FUNC_'.strtoupper($ext)])) {
|
||||
$dict[] = $ext;
|
||||
}
|
||||
}
|
||||
if (count($dict) == 1) {
|
||||
$testSkipped[] = 'The '. $dict[0] .
|
||||
' function dictionary is not available.';
|
||||
} elseif (count($dict) > 1) {
|
||||
$testSkipped[] = 'The '. implode(',', $dict) .
|
||||
' function dictionaries are not available.';
|
||||
}
|
||||
return (count($testSkipped) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert results of php exec returns
|
||||
*
|
||||
* @param string $args Arguments list that will be pass to the 'pci' command
|
||||
* @param array $exp PCI output results expected
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function assertPhpExec($args, $exp)
|
||||
{
|
||||
$command = '@php_bin@ '
|
||||
. '-f @bin_dir@' . DIRECTORY_SEPARATOR . 'pci -- ';
|
||||
|
||||
$output = array();
|
||||
$return = 0;
|
||||
exec("$command $args", $output, $return);
|
||||
if ($return == 0) {
|
||||
$this->assertEquals($exp, $output);
|
||||
} else {
|
||||
$this->assertTrue($return);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for bug #3657
|
||||
*
|
||||
* @return void
|
||||
* @link http://pear.php.net/bugs/bug.php?id=3657
|
||||
* php5 clone constant/token in all sources
|
||||
* @covers PHP_CompatInfo::parseFile
|
||||
* @group parseFile
|
||||
*/
|
||||
public function testBug3657()
|
||||
{
|
||||
$ds = DIRECTORY_SEPARATOR;
|
||||
$exp = array('+-----------------------------+---------+------------+--------------------+',
|
||||
'| File | Version | Extensions | Constants/Tokens |',
|
||||
'+-----------------------------+---------+------------+--------------------+',
|
||||
'| ...File'.$ds.'phpweb-entities.php | 4.0.0 | | FALSE |',
|
||||
'| | | | __FILE__ |',
|
||||
'+-----------------------------+---------+------------+--------------------+');
|
||||
|
||||
$fn = dirname(__FILE__) . $ds . 'parseFile' . $ds . 'phpweb-entities.php';
|
||||
|
||||
$args = '-o 30 -f ' . $fn;
|
||||
$this->assertPhpExec($args, $exp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for bug #6581
|
||||
*
|
||||
* @return void
|
||||
* @link http://pear.php.net/bugs/bug.php?id=6581
|
||||
* Functions missing in func_array.php
|
||||
* @covers PHP_CompatInfo::parseFile
|
||||
* @group parseFile
|
||||
*/
|
||||
public function testBug6581()
|
||||
{
|
||||
$resources = array('bcmath', 'pcre');
|
||||
$testSkipped = array();
|
||||
if (!$this->isResourceAvailable($resources, $testSkipped)) {
|
||||
foreach ($testSkipped as $reason) {
|
||||
$this->markTestSkipped($reason);
|
||||
}
|
||||
}
|
||||
|
||||
$ds = DIRECTORY_SEPARATOR;
|
||||
$exp = array('+-----------------------------+---------+------------+--------------------+',
|
||||
'| File | Version | Extensions | Constants/Tokens |',
|
||||
'+-----------------------------+---------+------------+--------------------+',
|
||||
'| ...tests'.$ds.'parseFile'.$ds.'math.php | 4.0.0 | bcmath | |',
|
||||
'| | | pcre | |',
|
||||
'+-----------------------------+---------+------------+--------------------+');
|
||||
|
||||
$fn = dirname(__FILE__) . $ds . 'parseFile' . $ds . 'math.php';
|
||||
|
||||
$args = '-o 30 -f ' . $fn;
|
||||
$this->assertPhpExec($args, $exp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests parsing an empty directory
|
||||
*
|
||||
* Regression test for bug #8559
|
||||
*
|
||||
* @return void
|
||||
* @link http://pear.php.net/bugs/bug.php?id=8559
|
||||
* PHP_CompatInfo fails to scan if it finds empty file in path
|
||||
* @see PHP_CompatInfo_TestSuite_Bugs::testBug8559()
|
||||
* @covers PHP_CompatInfo::parseDir
|
||||
* @group parseDir
|
||||
*/
|
||||
public function testBug8559()
|
||||
{
|
||||
$ds = DIRECTORY_SEPARATOR;
|
||||
$dn = dirname(__FILE__) . $ds . 'emptyDir';
|
||||
|
||||
$exp = array('Usage: pci [options]',
|
||||
'',
|
||||
' -d --dir (optional)value Parse DIR to get its',
|
||||
' compatibility info ()',
|
||||
' -f --file (optional)value Parse FILE to get its',
|
||||
' compatibility info ()',
|
||||
' -s --string (optional)value Parse STRING to get its',
|
||||
' compatibility info ()',
|
||||
' -v --verbose (optional)value Set the verbose level (1)',
|
||||
' -n --no-recurse Do not recursively parse files',
|
||||
' when using --dir',
|
||||
' -if --ignore-files (optional)value Data file name which contains',
|
||||
' a list of file to ignore',
|
||||
' (files.txt)',
|
||||
' -id --ignore-dirs (optional)value Data file name which contains',
|
||||
' a list of directory to ignore',
|
||||
' (dirs.txt)',
|
||||
' -in --ignore-functions (optional)value Data file name which contains',
|
||||
' a list of php function to',
|
||||
' ignore (functions.txt)',
|
||||
' -ic --ignore-constants (optional)value Data file name which contains',
|
||||
' a list of php constant to',
|
||||
' ignore (constants.txt)',
|
||||
' -ie --ignore-extensions (optional)value Data file name which contains',
|
||||
' a list of php extension to',
|
||||
' ignore (extensions.txt)',
|
||||
' -iv --ignore-versions values(optional) PHP versions - functions to',
|
||||
' exclude when parsing source',
|
||||
' code (5.0.0)',
|
||||
' -inm --ignore-functions-match (optional)value Data file name which contains',
|
||||
' a list of php function pattern',
|
||||
' to ignore',
|
||||
' (functions-match.txt)',
|
||||
' -iem --ignore-extensions-match (optional)value Data file name which contains',
|
||||
' a list of php extension',
|
||||
' pattern to ignore',
|
||||
' (extensions-match.txt)',
|
||||
' -icm --ignore-constants-match (optional)value Data file name which contains',
|
||||
' a list of php constant pattern',
|
||||
' to ignore',
|
||||
' (constants-match.txt)',
|
||||
' -fe --file-ext (optional)value A comma separated list of file',
|
||||
' extensions to parse (only',
|
||||
' valid if parsing a directory)',
|
||||
' (php, php4, inc, phtml)',
|
||||
' -r --report (optional)value Print either "xml" or "csv"',
|
||||
' report (text)',
|
||||
' -o --output-level (optional)value Print Path/File + Version with',
|
||||
' additional data (31)',
|
||||
' -t --tab (optional)value Columns width (29,12,20)',
|
||||
' -p --progress (optional)value Show a wait message [text] or',
|
||||
' a progress bar [bar] (bar)',
|
||||
' -S --summarize Print only summary when',
|
||||
' parsing directory',
|
||||
' -V --version Print version information',
|
||||
' -h --help Show this help',
|
||||
'',
|
||||
'No valid files into directory "'. $dn .
|
||||
'". Please check your spelling and try again.',
|
||||
'');
|
||||
|
||||
$args = '-d ' . $dn;
|
||||
$this->assertPhpExec($args, $exp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for bug #12350
|
||||
*
|
||||
* Be sure ( chdir() ) to check
|
||||
* if file (checkMax.php) is in current directory ( dirname(__FILE__) )
|
||||
*
|
||||
* @return void
|
||||
* @link http://pear.php.net/bugs/bug.php?id=12350
|
||||
* file in current directory is not found
|
||||
* @covers PHP_CompatInfo::parseFile
|
||||
* @group parseFile
|
||||
* @group cli
|
||||
*/
|
||||
public function testBug12350()
|
||||
{
|
||||
$exp = array('+-----------------------------+---------+------------+--------------------+',
|
||||
'| File | Version | Extensions | Constants/Tokens |',
|
||||
'+-----------------------------+---------+------------+--------------------+',
|
||||
'| checkMax.php | 4.0.7 | | ...CTORY_SEPARATOR |',
|
||||
'| | | | TRUE |',
|
||||
'| | | | __FILE__ |',
|
||||
'+-----------------------------+---------+------------+--------------------+');
|
||||
|
||||
chdir(dirname(__FILE__));
|
||||
$args = '-o 30 -f checkMax.php';
|
||||
$this->assertPhpExec($args, $exp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parsing string with -s | --string parameter
|
||||
*
|
||||
* @return void
|
||||
* @covers PHP_CompatInfo::parseString
|
||||
* @group parseString
|
||||
* @group cli
|
||||
*/
|
||||
public function testParseString()
|
||||
{
|
||||
$exp = array('+-----------------------------+---------+---+------------+--------------------+',
|
||||
'| Source code | Version | C | Extensions | Constants/Tokens |',
|
||||
'+-----------------------------+---------+---+------------+--------------------+',
|
||||
'| <?php ... ?> | 5.1.1 | 0 | | DATE_RSS |',
|
||||
'+-----------------------------+---------+---+------------+--------------------+');
|
||||
|
||||
$str = "\"echo DATE_RSS;\"";
|
||||
|
||||
$args = '-s ' . $str;
|
||||
$this->assertPhpExec($args, $exp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for request#13147
|
||||
*
|
||||
* @return void
|
||||
* @link http://pear.php.net/bugs/bug.php?id=13147
|
||||
* CLI: add filter file extension option on parsing directory
|
||||
* @covers PHP_CompatInfo::parseDir
|
||||
* @group parseDir
|
||||
* @group cli
|
||||
*/
|
||||
public function testRequest13147()
|
||||
{
|
||||
$resources = array('gd', 'SQLite', 'xdebug');
|
||||
$testSkipped = array();
|
||||
if (!$this->isResourceAvailable($resources, $testSkipped)) {
|
||||
foreach ($testSkipped as $reason) {
|
||||
$this->markTestSkipped($reason);
|
||||
}
|
||||
}
|
||||
|
||||
$ds = DIRECTORY_SEPARATOR;
|
||||
$exp = array('+-----------------------------+---------+------------+--------------------+',
|
||||
'| Files | Version | Extensions | Constants/Tokens |',
|
||||
'+-----------------------------+---------+------------+--------------------+',
|
||||
'| ...patInfo'.$ds.'tests'.$ds.'parseDir'.$ds.'* | 5.2.0 | gd | PHP_SHLIB_SUFFIX |',
|
||||
'| | | SQLite | TRUE |',
|
||||
'| | | xdebug | ..._ERR_CANT_WRITE |',
|
||||
'| | | | ...D_ERR_EXTENSION |',
|
||||
'| | | | ...D_ERR_FORM_SIZE |',
|
||||
'| | | | ...AD_ERR_INI_SIZE |',
|
||||
'| | | | UPLOAD_ERR_NO_FILE |',
|
||||
'| | | | ..._ERR_NO_TMP_DIR |',
|
||||
'| | | | UPLOAD_ERR_OK |',
|
||||
'| | | | UPLOAD_ERR_PARTIAL |',
|
||||
'| | | | abstract |',
|
||||
'| | | | catch |',
|
||||
'| | | | clone |',
|
||||
'| | | | final |',
|
||||
'| | | | implements |',
|
||||
'| | | | instanceof |',
|
||||
'| | | | interface |',
|
||||
'| | | | private |',
|
||||
'| | | | protected |',
|
||||
'| | | | public |',
|
||||
'| | | | throw |',
|
||||
'| | | | try |',
|
||||
'+-----------------------------+---------+------------+--------------------+',
|
||||
'| ...'.$ds.'parseDir'.$ds.'extensions.php | 4.3.2 | gd | PHP_SHLIB_SUFFIX |',
|
||||
'| | | SQLite | TRUE |',
|
||||
'| | | xdebug | |',
|
||||
'+-----------------------------+---------+------------+--------------------+',
|
||||
'| ...sts'.$ds.'parseDir'.$ds.'phpinfo.php | 4.0.0 | | |',
|
||||
'+-----------------------------+---------+------------+--------------------+',
|
||||
'| ...arseDir'.$ds.'PHP5'.$ds.'tokens.php5 | 5.0.0 | | abstract |',
|
||||
'| | | | catch |',
|
||||
'| | | | clone |',
|
||||
'| | | | final |',
|
||||
'| | | | implements |',
|
||||
'| | | | instanceof |',
|
||||
'| | | | interface |',
|
||||
'| | | | private |',
|
||||
'| | | | protected |',
|
||||
'| | | | public |',
|
||||
'| | | | throw |',
|
||||
'| | | | try |',
|
||||
'+-----------------------------+---------+------------+--------------------+',
|
||||
'| ...ir'.$ds.'PHP5'.$ds.'upload_error.php | 5.2.0 | | ..._ERR_CANT_WRITE |',
|
||||
'| | | | ...D_ERR_EXTENSION |',
|
||||
'| | | | ...D_ERR_FORM_SIZE |',
|
||||
'| | | | ...AD_ERR_INI_SIZE |',
|
||||
'| | | | UPLOAD_ERR_NO_FILE |',
|
||||
'| | | | ..._ERR_NO_TMP_DIR |',
|
||||
'| | | | UPLOAD_ERR_OK |',
|
||||
'| | | | UPLOAD_ERR_PARTIAL |',
|
||||
'| | | | throw |',
|
||||
'+-----------------------------+---------+------------+--------------------+');
|
||||
|
||||
$dn = dirname(__FILE__) . $ds . 'parseDir';
|
||||
$fe = 'php,php5';
|
||||
|
||||
$args = '-o 30 -fe '. $fe . ' -d '. $dn;
|
||||
$this->assertPhpExec($args, $exp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for request#13147
|
||||
* with a better reading of Extensions and Constants/Tokens columns
|
||||
*
|
||||
* @return void
|
||||
* @see testRequest13147()
|
||||
* @link http://pear.php.net/bugs/bug.php?id=13147
|
||||
* CLI: add filter file extension option on parsing directory
|
||||
* @covers PHP_CompatInfo::parseDir
|
||||
* @group parseDir
|
||||
* @group cli
|
||||
*/
|
||||
public function testReq13147ImproveRender()
|
||||
{
|
||||
$resources = array('gd', 'SQLite', 'xdebug');
|
||||
$testSkipped = array();
|
||||
if (!$this->isResourceAvailable($resources, $testSkipped)) {
|
||||
foreach ($testSkipped as $reason) {
|
||||
$this->markTestSkipped($reason);
|
||||
}
|
||||
}
|
||||
|
||||
$ds = DIRECTORY_SEPARATOR;
|
||||
$exp = array('+-----------------------------+---------+-------------+-----------------------+',
|
||||
'| Files | Version | Extensions | Constants/Tokens |',
|
||||
'+-----------------------------+---------+-------------+-----------------------+',
|
||||
'| ...patInfo'.$ds.'tests'.$ds.'parseDir'.$ds.'* | 5.2.0 | gd | PHP_SHLIB_SUFFIX |',
|
||||
'| | | SQLite | TRUE |',
|
||||
'| | | xdebug | UPLOAD_ERR_CANT_WRITE |',
|
||||
'| | | | UPLOAD_ERR_EXTENSION |',
|
||||
'| | | | UPLOAD_ERR_FORM_SIZE |',
|
||||
'| | | | UPLOAD_ERR_INI_SIZE |',
|
||||
'| | | | UPLOAD_ERR_NO_FILE |',
|
||||
'| | | | UPLOAD_ERR_NO_TMP_DIR |',
|
||||
'| | | | UPLOAD_ERR_OK |',
|
||||
'| | | | UPLOAD_ERR_PARTIAL |',
|
||||
'| | | | abstract |',
|
||||
'| | | | catch |',
|
||||
'| | | | clone |',
|
||||
'| | | | final |',
|
||||
'| | | | implements |',
|
||||
'| | | | instanceof |',
|
||||
'| | | | interface |',
|
||||
'| | | | private |',
|
||||
'| | | | protected |',
|
||||
'| | | | public |',
|
||||
'| | | | throw |',
|
||||
'| | | | try |',
|
||||
'+-----------------------------+---------+-------------+-----------------------+',
|
||||
'| ...'.$ds.'parseDir'.$ds.'extensions.php | 4.3.2 | gd | PHP_SHLIB_SUFFIX |',
|
||||
'| | | SQLite | TRUE |',
|
||||
'| | | xdebug | |',
|
||||
'+-----------------------------+---------+-------------+-----------------------+',
|
||||
'| ...sts'.$ds.'parseDir'.$ds.'phpinfo.php | 4.0.0 | | |',
|
||||
'+-----------------------------+---------+-------------+-----------------------+',
|
||||
'| ...arseDir'.$ds.'PHP5'.$ds.'tokens.php5 | 5.0.0 | | abstract |',
|
||||
'| | | | catch |',
|
||||
'| | | | clone |',
|
||||
'| | | | final |',
|
||||
'| | | | implements |',
|
||||
'| | | | instanceof |',
|
||||
'| | | | interface |',
|
||||
'| | | | private |',
|
||||
'| | | | protected |',
|
||||
'| | | | public |',
|
||||
'| | | | throw |',
|
||||
'| | | | try |',
|
||||
'+-----------------------------+---------+-------------+-----------------------+',
|
||||
'| ...ir'.$ds.'PHP5'.$ds.'upload_error.php | 5.2.0 | | UPLOAD_ERR_CANT_WRITE |',
|
||||
'| | | | UPLOAD_ERR_EXTENSION |',
|
||||
'| | | | UPLOAD_ERR_FORM_SIZE |',
|
||||
'| | | | UPLOAD_ERR_INI_SIZE |',
|
||||
'| | | | UPLOAD_ERR_NO_FILE |',
|
||||
'| | | | UPLOAD_ERR_NO_TMP_DIR |',
|
||||
'| | | | UPLOAD_ERR_OK |',
|
||||
'| | | | UPLOAD_ERR_PARTIAL |',
|
||||
'| | | | throw |',
|
||||
'+-----------------------------+---------+-------------+-----------------------+');
|
||||
|
||||
$dn = dirname(__FILE__) . $ds . 'parseDir';
|
||||
$fe = 'php,php5';
|
||||
|
||||
$args = '-o 30 -t 29,13,23 -fe '. $fe . ' -d '. $dn;
|
||||
$this->assertPhpExec($args, $exp);
|
||||
}
|
||||
}
|
||||
|
||||
// Call PHP_CompatInfo_TestSuite_Cli::main() if file is executed directly.
|
||||
if (PHPUnit_MAIN_METHOD == "PHP_CompatInfo_TestSuite_Cli::main") {
|
||||
PHP_CompatInfo_TestSuite_Cli::main();
|
||||
}
|
||||
?>
|
||||
2859
database/php/tests/PHP_CompatInfo_TestSuite_Standard.php
Normal file
2859
database/php/tests/PHP_CompatInfo_TestSuite_Standard.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
require_once dirname(__FILE__) . '/helper.inc';
|
||||
require_once 'Structures/Graph/Manipulator/AcyclicTest.php';
|
||||
|
||||
class AcyclicTestTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testIsAcyclicFalse()
|
||||
{
|
||||
$graph = new Structures_Graph();
|
||||
$node1 = new Structures_Graph_Node();
|
||||
$graph->addNode($node1);
|
||||
|
||||
$node2 = new Structures_Graph_Node();
|
||||
$graph->addNode($node2);
|
||||
$node1->connectTo($node2);
|
||||
|
||||
$node3 = new Structures_Graph_Node();
|
||||
$graph->addNode($node3);
|
||||
$node2->connectTo($node3);
|
||||
|
||||
$node3->connectTo($node1);
|
||||
|
||||
$this->assertFalse(
|
||||
Structures_Graph_Manipulator_AcyclicTest::isAcyclic($graph),
|
||||
'Graph is cyclic'
|
||||
);
|
||||
}
|
||||
|
||||
public function testIsAcyclicTrue()
|
||||
{
|
||||
$graph = new Structures_Graph();
|
||||
$node1 = new Structures_Graph_Node();
|
||||
$graph->addNode($node1);
|
||||
|
||||
$node2 = new Structures_Graph_Node();
|
||||
$graph->addNode($node2);
|
||||
$node1->connectTo($node2);
|
||||
|
||||
$node3 = new Structures_Graph_Node();
|
||||
$graph->addNode($node3);
|
||||
$node2->connectTo($node3);
|
||||
|
||||
$this->assertTrue(
|
||||
Structures_Graph_Manipulator_AcyclicTest::isAcyclic($graph),
|
||||
'Graph is acyclic'
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
20
database/php/tests/Structures_Graph/tests/AllTests.php
Normal file
20
database/php/tests/Structures_Graph/tests/AllTests.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
require_once dirname(__FILE__) . '/helper.inc';
|
||||
|
||||
class Structures_Graph_AllTests
|
||||
{
|
||||
public static function main()
|
||||
{
|
||||
PHPUnit_TextUI_TestRunner::run(self::suite());
|
||||
}
|
||||
|
||||
public static function suite()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite('Structures_Graph Tests');
|
||||
|
||||
$dir = new GlobIterator(dirname(__FILE__) . '/*Test.php');
|
||||
$suite->addTestFiles($dir);
|
||||
|
||||
return $suite;
|
||||
}
|
||||
}
|
||||
170
database/php/tests/Structures_Graph/tests/BasicGraphTest.php
Normal file
170
database/php/tests/Structures_Graph/tests/BasicGraphTest.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
|
||||
// +-----------------------------------------------------------------------------+
|
||||
// | Copyright (c) 2003 S<>rgio Gon<6F>alves Carvalho |
|
||||
// +-----------------------------------------------------------------------------+
|
||||
// | This file is part of Structures_Graph. |
|
||||
// | |
|
||||
// | Structures_Graph is free software; you can redistribute it and/or modify |
|
||||
// | it under the terms of the GNU Lesser General Public License as published by |
|
||||
// | the Free Software Foundation; either version 2.1 of the License, or |
|
||||
// | (at your option) any later version. |
|
||||
// | |
|
||||
// | Structures_Graph is distributed in the hope that it will be useful, |
|
||||
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
// | GNU Lesser General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU Lesser General Public License |
|
||||
// | along with Structures_Graph; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
||||
// | 02111-1307 USA |
|
||||
// +-----------------------------------------------------------------------------+
|
||||
// | Author: S<>rgio Carvalho <sergio.carvalho@portugalmail.com> |
|
||||
// +-----------------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
require_once dirname(__FILE__) . '/helper.inc';
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
class BasicGraph extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
var $_graph = null;
|
||||
|
||||
function test_create_graph() {
|
||||
$this->_graph = new Structures_Graph();
|
||||
$this->assertTrue(is_a($this->_graph, 'Structures_Graph'));
|
||||
}
|
||||
|
||||
function test_add_node() {
|
||||
$this->_graph = new Structures_Graph();
|
||||
$data = 1;
|
||||
$node = new Structures_Graph_Node($data);
|
||||
$this->_graph->addNode($node);
|
||||
$node = new Structures_Graph_Node($data);
|
||||
$this->_graph->addNode($node);
|
||||
$node = new Structures_Graph_Node($data);
|
||||
$this->_graph->addNode($node);
|
||||
}
|
||||
|
||||
function test_connect_node() {
|
||||
$this->_graph = new Structures_Graph();
|
||||
$data = 1;
|
||||
$node1 = new Structures_Graph_Node($data);
|
||||
$node2 = new Structures_Graph_Node($data);
|
||||
$this->_graph->addNode($node1);
|
||||
$this->_graph->addNode($node2);
|
||||
$node1->connectTo($node2);
|
||||
|
||||
$node =& $this->_graph->getNodes();
|
||||
$node =& $node[0];
|
||||
$node = $node->getNeighbours();
|
||||
$node =& $node[0];
|
||||
/*
|
||||
ZE1 == and === operators fail on $node,$node2 because of the recursion introduced
|
||||
by the _graph field in the Node object. So, we'll use the stupid method for reference
|
||||
testing
|
||||
*/
|
||||
$node = true;
|
||||
$this->assertTrue($node2);
|
||||
$node = false;
|
||||
$this->assertFalse($node2);
|
||||
}
|
||||
|
||||
function test_data_references() {
|
||||
$this->_graph = new Structures_Graph();
|
||||
$data = 1;
|
||||
$node = new Structures_Graph_Node();
|
||||
$node->setData($data);
|
||||
$this->_graph->addNode($node);
|
||||
$data = 2;
|
||||
$dataInNode =& $this->_graph->getNodes();
|
||||
$dataInNode =& $dataInNode[0];
|
||||
$dataInNode =& $dataInNode->getData();
|
||||
$this->assertEquals($data, $dataInNode);
|
||||
}
|
||||
|
||||
function test_metadata_references() {
|
||||
$this->_graph = new Structures_Graph();
|
||||
$data = 1;
|
||||
$node = new Structures_Graph_Node();
|
||||
$node->setMetadata('5', $data);
|
||||
$data = 2;
|
||||
$dataInNode =& $node->getMetadata('5');
|
||||
$this->assertEquals($data, $dataInNode);
|
||||
}
|
||||
|
||||
function test_metadata_key_exists() {
|
||||
$this->_graph = new Structures_Graph();
|
||||
$data = 1;
|
||||
$node = new Structures_Graph_Node();
|
||||
$node->setMetadata('5', $data);
|
||||
$this->assertTrue($node->metadataKeyExists('5'));
|
||||
$this->assertFalse($node->metadataKeyExists('1'));
|
||||
}
|
||||
|
||||
function test_directed_degree() {
|
||||
$this->_graph = new Structures_Graph(true);
|
||||
$node = array();
|
||||
$node[] = new Structures_Graph_Node();
|
||||
$node[] = new Structures_Graph_Node();
|
||||
$node[] = new Structures_Graph_Node();
|
||||
$this->_graph->addNode($node[0]);
|
||||
$this->_graph->addNode($node[1]);
|
||||
$this->_graph->addNode($node[2]);
|
||||
$this->assertEquals(0, $node[0]->inDegree(), 'inDegree test failed for node 0 with 0 arcs');
|
||||
$this->assertEquals(0, $node[1]->inDegree(), 'inDegree test failed for node 1 with 0 arcs');
|
||||
$this->assertEquals(0, $node[2]->inDegree(), 'inDegree test failed for node 2 with 0 arcs');
|
||||
$this->assertEquals(0, $node[0]->outDegree(), 'outDegree test failed for node 0 with 0 arcs');
|
||||
$this->assertEquals(0, $node[1]->outDegree(), 'outDegree test failed for node 1 with 0 arcs');
|
||||
$this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 0 arcs');
|
||||
$node[0]->connectTo($node[1]);
|
||||
$this->assertEquals(0, $node[0]->inDegree(), 'inDegree test failed for node 0 with 1 arc');
|
||||
$this->assertEquals(1, $node[1]->inDegree(), 'inDegree test failed for node 1 with 1 arc');
|
||||
$this->assertEquals(0, $node[2]->inDegree(), 'inDegree test failed for node 2 with 1 arc');
|
||||
$this->assertEquals(1, $node[0]->outDegree(), 'outDegree test failed for node 0 with 1 arc');
|
||||
$this->assertEquals(0, $node[1]->outDegree(), 'outDegree test failed for node 1 with 1 arc');
|
||||
$this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 1 arc');
|
||||
$node[0]->connectTo($node[2]);
|
||||
$this->assertEquals(0, $node[0]->inDegree(), 'inDegree test failed for node 0 with 2 arcs');
|
||||
$this->assertEquals(1, $node[1]->inDegree(), 'inDegree test failed for node 1 with 2 arcs');
|
||||
$this->assertEquals(1, $node[2]->inDegree(), 'inDegree test failed for node 2 with 2 arcs');
|
||||
$this->assertEquals(2, $node[0]->outDegree(), 'outDegree test failed for node 0 with 2 arcs');
|
||||
$this->assertEquals(0, $node[1]->outDegree(), 'outDegree test failed for node 1 with 2 arcs');
|
||||
$this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 2 arcs');
|
||||
}
|
||||
|
||||
function test_undirected_degree() {
|
||||
$this->_graph = new Structures_Graph(false);
|
||||
$node = array();
|
||||
$node[] = new Structures_Graph_Node();
|
||||
$node[] = new Structures_Graph_Node();
|
||||
$node[] = new Structures_Graph_Node();
|
||||
$this->_graph->addNode($node[0]);
|
||||
$this->_graph->addNode($node[1]);
|
||||
$this->_graph->addNode($node[2]);
|
||||
$this->assertEquals(0, $node[0]->inDegree(), 'inDegree test failed for node 0 with 0 arcs');
|
||||
$this->assertEquals(0, $node[1]->inDegree(), 'inDegree test failed for node 1 with 0 arcs');
|
||||
$this->assertEquals(0, $node[2]->inDegree(), 'inDegree test failed for node 2 with 0 arcs');
|
||||
$this->assertEquals(0, $node[0]->outDegree(), 'outDegree test failed for node 0 with 0 arcs');
|
||||
$this->assertEquals(0, $node[1]->outDegree(), 'outDegree test failed for node 1 with 0 arcs');
|
||||
$this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 0 arcs');
|
||||
$node[0]->connectTo($node[1]);
|
||||
$this->assertEquals(1, $node[0]->inDegree(), 'inDegree test failed for node 0 with 1 arc');
|
||||
$this->assertEquals(1, $node[1]->inDegree(), 'inDegree test failed for node 1 with 1 arc');
|
||||
$this->assertEquals(0, $node[2]->inDegree(), 'inDegree test failed for node 2 with 1 arc');
|
||||
$this->assertEquals(1, $node[0]->outDegree(), 'outDegree test failed for node 0 with 1 arc');
|
||||
$this->assertEquals(1, $node[1]->outDegree(), 'outDegree test failed for node 1 with 1 arc');
|
||||
$this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 1 arc');
|
||||
$node[0]->connectTo($node[2]);
|
||||
$this->assertEquals(2, $node[0]->inDegree(), 'inDegree test failed for node 0 with 2 arcs');
|
||||
$this->assertEquals(1, $node[1]->inDegree(), 'inDegree test failed for node 1 with 2 arcs');
|
||||
$this->assertEquals(1, $node[2]->inDegree(), 'inDegree test failed for node 2 with 2 arcs');
|
||||
$this->assertEquals(2, $node[0]->outDegree(), 'outDegree test failed for node 0 with 2 arcs');
|
||||
$this->assertEquals(1, $node[1]->outDegree(), 'outDegree test failed for node 1 with 2 arcs');
|
||||
$this->assertEquals(1, $node[2]->outDegree(), 'outDegree test failed for node 2 with 2 arcs');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
require_once dirname(__FILE__) . '/helper.inc';
|
||||
require_once 'Structures/Graph/Manipulator/TopologicalSorter.php';
|
||||
|
||||
class TopologicalSorterTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testSort()
|
||||
{
|
||||
$graph = new Structures_Graph();
|
||||
|
||||
$name1 = 'node1';
|
||||
$node1 = new Structures_Graph_Node();
|
||||
$node1->setData($name1);
|
||||
$graph->addNode($node1);
|
||||
|
||||
$name11 = 'node11';
|
||||
$node11 = new Structures_Graph_Node();
|
||||
$node11->setData($name11);
|
||||
$graph->addNode($node11);
|
||||
$node1->connectTo($node11);
|
||||
|
||||
$name12 = 'node12';
|
||||
$node12 = new Structures_Graph_Node();
|
||||
$node12->setData($name12);
|
||||
$graph->addNode($node12);
|
||||
$node1->connectTo($node12);
|
||||
|
||||
$name121 = 'node121';
|
||||
$node121 = new Structures_Graph_Node();
|
||||
$node121->setData($name121);
|
||||
$graph->addNode($node121);
|
||||
$node12->connectTo($node121);
|
||||
|
||||
$name2 = 'node2';
|
||||
$node2 = new Structures_Graph_Node();
|
||||
$node2->setData($name2);
|
||||
$graph->addNode($node2);
|
||||
|
||||
$name21 = 'node21';
|
||||
$node21 = new Structures_Graph_Node();
|
||||
$node21->setData($name21);
|
||||
$graph->addNode($node21);
|
||||
$node2->connectTo($node21);
|
||||
|
||||
$nodes = Structures_Graph_Manipulator_TopologicalSorter::sort($graph);
|
||||
$this->assertCount(2, $nodes[0]);
|
||||
$this->assertEquals('node1', $nodes[0][0]->getData());
|
||||
$this->assertEquals('node2', $nodes[0][1]->getData());
|
||||
|
||||
$this->assertCount(3, $nodes[1]);
|
||||
$this->assertEquals('node11', $nodes[1][0]->getData());
|
||||
$this->assertEquals('node12', $nodes[1][1]->getData());
|
||||
$this->assertEquals('node21', $nodes[1][2]->getData());
|
||||
|
||||
$this->assertCount(1, $nodes[2]);
|
||||
$this->assertEquals('node121', $nodes[2][0]->getData());
|
||||
}
|
||||
}
|
||||
?>
|
||||
10
database/php/tests/Structures_Graph/tests/helper.inc
Normal file
10
database/php/tests/Structures_Graph/tests/helper.inc
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
if ('C:\xampp\php\pear' == '@'.'php_dir'.'@') {
|
||||
// This package hasn't been installed.
|
||||
// Adjust path to ensure includes find files in working directory.
|
||||
set_include_path(dirname(dirname(__FILE__))
|
||||
. PATH_SEPARATOR . dirname(__FILE__)
|
||||
. PATH_SEPARATOR . get_include_path());
|
||||
}
|
||||
|
||||
require_once 'Structures/Graph.php';
|
||||
18
database/php/tests/XML_Util/tests/testBasic_apiVersion.phpt
Normal file
18
database/php/tests/XML_Util/tests/testBasic_apiVersion.phpt
Normal file
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
XML_Util::apiVersion() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::apiVersion() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic apiVersion() call" . PHP_EOL;
|
||||
echo XML_Util::apiVersion() . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::apiVersion() basic tests=====
|
||||
|
||||
TEST: basic apiVersion() call
|
||||
1.1
|
||||
@@ -0,0 +1,118 @@
|
||||
--TEST--
|
||||
XML_Util::attributesToString() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::attributesToString() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$att = array("foo" => "bar", "boo" => "baz");
|
||||
$sort1 = array(
|
||||
'multiline' => true,
|
||||
'indent' => '----',
|
||||
'linebreak' => "^",
|
||||
'entities' => XML_UTIL_ENTITIES_XML,
|
||||
'sort' => true
|
||||
);
|
||||
$sort2 = array(
|
||||
'multiline' => true,
|
||||
'indent' => '----',
|
||||
'linebreak' => "^",
|
||||
'entities' => XML_UTIL_ENTITIES_XML,
|
||||
);
|
||||
|
||||
echo "TEST: basic usage" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: explicit \$sort = true" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att, true) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: explicit \$sort = false" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att, false) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: explicit \$multiline = false" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att, true, false) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: explicit \$multiline = true" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att, true, true) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: explicit \$indent = ' ' (8 spaces)" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att, true, true, ' ') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: explicit \$linebreak = '^' (some dummy char)" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att, true, true, '^') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: passing \$sort array of options that includes 'sort'" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att, $sort1) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: passing \$sort array of options that doesn't include 'sort'" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att, $sort2) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: do not replace entities" . PHP_EOL;
|
||||
$arr = array("foo" => "b@&r", "boo" => "b><z");
|
||||
echo XML_Util::attributesToString($arr, true, false, ' ', PHP_EOL,
|
||||
XML_UTIL_ENTITIES_NONE) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: replace all XML entities" . PHP_EOL;
|
||||
$arr = array("foo" => "b@&r", "boo" => "b><z");
|
||||
echo XML_Util::attributesToString($arr, true, false, ' ', PHP_EOL,
|
||||
XML_UTIL_ENTITIES_XML) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: replace only required XML entities" . PHP_EOL;
|
||||
$arr = array("foo" => "b@&r", "boo" => "b><z");
|
||||
echo XML_Util::attributesToString($arr, true, false, ' ', PHP_EOL,
|
||||
XML_UTIL_ENTITIES_XML_REQUIRED) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: replace HTML entities" . PHP_EOL;
|
||||
$arr = array("foo" => "b@&r", "boo" => "b><z");
|
||||
echo XML_Util::attributesToString($arr, true, false, ' ', PHP_EOL,
|
||||
XML_UTIL_ENTITIES_HTML) . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::attributesToString() basic tests=====
|
||||
|
||||
TEST: basic usage
|
||||
boo="baz" foo="bar"
|
||||
|
||||
TEST: explicit $sort = true
|
||||
boo="baz" foo="bar"
|
||||
|
||||
TEST: explicit $sort = false
|
||||
foo="bar" boo="baz"
|
||||
|
||||
TEST: explicit $multiline = false
|
||||
boo="baz" foo="bar"
|
||||
|
||||
TEST: explicit $multiline = true
|
||||
boo="baz"
|
||||
foo="bar"
|
||||
|
||||
TEST: explicit $indent = ' ' (8 spaces)
|
||||
boo="baz"
|
||||
foo="bar"
|
||||
|
||||
TEST: explicit $linebreak = '^' (some dummy char)
|
||||
boo="baz"
|
||||
^foo="bar"
|
||||
|
||||
TEST: passing $sort array of options that includes 'sort'
|
||||
boo="baz"
|
||||
----foo="bar"
|
||||
|
||||
TEST: passing $sort array of options that doesn't include 'sort'
|
||||
boo="baz"
|
||||
----foo="bar"
|
||||
|
||||
TEST: do not replace entities
|
||||
boo="b><z" foo="b@&r"
|
||||
|
||||
TEST: replace all XML entities
|
||||
boo="b><z" foo="b@&r"
|
||||
|
||||
TEST: replace only required XML entities
|
||||
boo="b><z" foo="b@&r"
|
||||
|
||||
TEST: replace HTML entities
|
||||
boo="b><z" foo="b@&r"
|
||||
@@ -0,0 +1,52 @@
|
||||
--TEST--
|
||||
XML_Util::collapseEmptyTags() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::collapseEmptyTags() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$emptyTag = "<foo></foo>";
|
||||
$otherTag = "<bar>baz</bar>";
|
||||
$xhtmlTag = "<b></b>";
|
||||
|
||||
echo "TEST: basic usage" . PHP_EOL;
|
||||
echo XML_Util::collapseEmptyTags($emptyTag) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage alongside non-empty tag" . PHP_EOL;
|
||||
echo XML_Util::collapseEmptyTags($emptyTag . $otherTag) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: one empty tag, with COLLAPSE_ALL set" . PHP_EOL;
|
||||
echo XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_ALL) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: one empty tag alongside non-empty tag, with COLLAPSE_ALL set" . PHP_EOL;
|
||||
echo XML_Util::collapseEmptyTags($emptyTag . $otherTag, XML_UTIL_COLLAPSE_ALL) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: one empty tag, with COLLAPSE_XHTML_ONLY set" . PHP_EOL;
|
||||
echo XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_XHTML_ONLY) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: one empty tag alongside non-empty tag, with COLLAPSE_XHTML_ONLY set" . PHP_EOL;
|
||||
echo XML_Util::collapseEmptyTags($emptyTag . $xhtmlTag . $otherTag, XML_UTIL_COLLAPSE_XHTML_ONLY) . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::collapseEmptyTags() basic tests=====
|
||||
|
||||
TEST: basic usage
|
||||
<foo />
|
||||
|
||||
TEST: basic usage alongside non-empty tag
|
||||
<foo /><bar>baz</bar>
|
||||
|
||||
TEST: one empty tag, with COLLAPSE_ALL set
|
||||
<foo />
|
||||
|
||||
TEST: one empty tag alongside non-empty tag, with COLLAPSE_ALL set
|
||||
<foo /><bar>baz</bar>
|
||||
|
||||
TEST: one empty tag, with COLLAPSE_XHTML_ONLY set
|
||||
<foo></foo>
|
||||
|
||||
TEST: one empty tag alongside non-empty tag, with COLLAPSE_XHTML_ONLY set
|
||||
<foo></foo><b></b><bar>baz</bar>
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
XML_Util::createCDataSection() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::createCDataSection() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage" . PHP_EOL;
|
||||
echo XML_Util::createCDataSection("I am content.") . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::createCDataSection() basic tests=====
|
||||
|
||||
TEST: basic usage
|
||||
<![CDATA[I am content.]]>
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
XML_Util::createComment() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::createComment() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage" . PHP_EOL;
|
||||
echo XML_Util::createComment("I am comment.") . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::createComment() basic tests=====
|
||||
|
||||
TEST: basic usage
|
||||
<!-- I am comment. -->
|
||||
@@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
XML_Util::createEndElement() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::createEndElement() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage (myTag)" . PHP_EOL;
|
||||
echo XML_Util::createEndElement("myTag") . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a namespaced tag (myNs:myTag)" . PHP_EOL;
|
||||
echo XML_Util::createEndElement("myNs:myTag") . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::createEndElement() basic tests=====
|
||||
|
||||
TEST: basic usage (myTag)
|
||||
</myTag>
|
||||
|
||||
TEST: basic usage with a namespaced tag (myNs:myTag)
|
||||
</myNs:myTag>
|
||||
@@ -0,0 +1,124 @@
|
||||
--TEST--
|
||||
XML_Util::createStartElement() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::createStartElement() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag only" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag"
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar")
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag only, passing '' as attribute arg" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
'myNs:myTag',
|
||||
''
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes and namespace" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"http://www.w3c.org/myNs#"
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with empty attributes, whose namespaceUri is not a full namespace" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
'myTag',
|
||||
'',
|
||||
'foo'
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes, namespace, and multiline = true" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"http://www.w3c.org/myNs#",
|
||||
true
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes, namespace, multiline = true, and indent = (2 spaces only)" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"http://www.w3c.org/myNs#",
|
||||
true,
|
||||
' '
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), and linebreak = '^'" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"http://www.w3c.org/myNs#",
|
||||
true,
|
||||
' ',
|
||||
'^'
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = true" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar", "boo" => "baz"),
|
||||
"http://www.w3c.org/myNs#",
|
||||
true,
|
||||
' ',
|
||||
'^',
|
||||
true
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = false" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar", "boo" => "baz"),
|
||||
"http://www.w3c.org/myNs#",
|
||||
true,
|
||||
' ',
|
||||
'^',
|
||||
false
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::createStartElement() basic tests=====
|
||||
|
||||
TEST: tag only
|
||||
<myNs:myTag>
|
||||
|
||||
TEST: tag with attributes
|
||||
<myNs:myTag foo="bar">
|
||||
|
||||
TEST: tag only, passing '' as attribute arg
|
||||
<myNs:myTag>
|
||||
|
||||
TEST: tag with attributes and namespace
|
||||
<myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#">
|
||||
|
||||
TEST: tag with empty attributes, whose namespaceUri is not a full namespace
|
||||
<myTag xmlns="foo">
|
||||
|
||||
TEST: tag with attributes, namespace, and multiline = true
|
||||
<myNs:myTag foo="bar"
|
||||
xmlns:myNs="http://www.w3c.org/myNs#">
|
||||
|
||||
TEST: tag with attributes, namespace, multiline = true, and indent = (2 spaces only)
|
||||
<myNs:myTag foo="bar"
|
||||
xmlns:myNs="http://www.w3c.org/myNs#">
|
||||
|
||||
TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), and linebreak = '^'
|
||||
<myNs:myTag foo="bar"^ xmlns:myNs="http://www.w3c.org/myNs#">
|
||||
|
||||
TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = true
|
||||
<myNs:myTag boo="baz"^ foo="bar"^ xmlns:myNs="http://www.w3c.org/myNs#">
|
||||
|
||||
TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = false
|
||||
<myNs:myTag foo="bar"^ boo="baz"^ xmlns:myNs="http://www.w3c.org/myNs#">
|
||||
155
database/php/tests/XML_Util/tests/testBasic_createTag.phpt
Normal file
155
database/php/tests/XML_Util/tests/testBasic_createTag.phpt
Normal file
@@ -0,0 +1,155 @@
|
||||
--TEST--
|
||||
XML_Util::createTag() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::createTag() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar")
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute and content" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag"
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, and namespace" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag",
|
||||
"http://www.w3c.org/myNs#"
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, and REPLACE_ENTITIES" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, and CDATA_SECTION" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_CDATA_SECTION
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, and multiline = false" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES,
|
||||
false
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, and multiline = true" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES,
|
||||
true
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, and indent = (2 spaces)" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES,
|
||||
true,
|
||||
' '
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), and linebreak = '^'" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES,
|
||||
true,
|
||||
' ',
|
||||
'^'
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = true" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar", "boo" => "baz"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES,
|
||||
true,
|
||||
' ',
|
||||
'^',
|
||||
true
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = false" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar", "boo" => "baz"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES,
|
||||
true,
|
||||
' ',
|
||||
'^',
|
||||
false
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::createTag() basic tests=====
|
||||
|
||||
TEST: tag with attribute
|
||||
<myNs:myTag foo="bar" />
|
||||
|
||||
TEST: tag with attribute and content
|
||||
<myNs:myTag foo="bar">This is inside the tag</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, and namespace
|
||||
<myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, and REPLACE_ENTITIES
|
||||
<myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, and CDATA_SECTION
|
||||
<myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#"><![CDATA[This is inside the tag and has < & @ > in it]]></myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, and multiline = false
|
||||
<myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, and multiline = true
|
||||
<myNs:myTag foo="bar"
|
||||
xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, and indent = (2 spaces)
|
||||
<myNs:myTag foo="bar"
|
||||
xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), and linebreak = '^'
|
||||
<myNs:myTag foo="bar"^ xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = true
|
||||
<myNs:myTag boo="baz"^ foo="bar"^ xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = false
|
||||
<myNs:myTag foo="bar"^ boo="baz"^ xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
@@ -0,0 +1,203 @@
|
||||
--TEST--
|
||||
XML_Util::createTagFromArray() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::createTagFromArray() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$bad = array(
|
||||
"foo" => "bar",
|
||||
);
|
||||
$tag1 = array(
|
||||
"qname" => "foo:bar",
|
||||
);
|
||||
$tag2 = array(
|
||||
"qname" => "foo:bar",
|
||||
"namespaceUri" => "http://foo.com",
|
||||
);
|
||||
$tag3 = array(
|
||||
"qname" => "foo:bar",
|
||||
"namespaceUri" => "http://foo.com",
|
||||
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
|
||||
);
|
||||
$tag4 = array(
|
||||
"qname" => "foo:bar",
|
||||
"namespaceUri" => "http://foo.com",
|
||||
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
|
||||
"content" => "I'm inside the tag",
|
||||
);
|
||||
$tag5 = array(
|
||||
"qname" => "foo:bar",
|
||||
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
|
||||
"content" => "I'm inside the tag",
|
||||
);
|
||||
$tag6 = array(
|
||||
"qname" => "foo:bar",
|
||||
"namespaceUri" => "http://foo.com",
|
||||
"content" => "I'm inside the tag",
|
||||
);
|
||||
$tag7 = array(
|
||||
"namespaceUri" => "http://foo.com",
|
||||
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
|
||||
"content" => "I'm inside the tag",
|
||||
);
|
||||
|
||||
$tag8 = array(
|
||||
'content' => array('foo', 'bar')
|
||||
);
|
||||
|
||||
$tag9 = array(
|
||||
'qname' => 'foo:bar',
|
||||
'namespaces' => array('ns1' => 'uri1', 'ns2' => 'uri2')
|
||||
);
|
||||
|
||||
$tag10 = array(
|
||||
'namespace' => 'http://foo.org',
|
||||
'localPart' => 'bar'
|
||||
);
|
||||
|
||||
$tag11 = array(
|
||||
'namespace' => '',
|
||||
'localPart' => 'bar'
|
||||
);
|
||||
|
||||
$tag12 = array(
|
||||
'localPart' => 'foo',
|
||||
'namespaceUri' => 'http://bar.org'
|
||||
);
|
||||
|
||||
echo "TEST: basic usage with an invalid array" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($bad) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname only)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag1) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname and namespaceUri)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag2) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, and attributes)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag3) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, attributes, and content)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag5) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, and content)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag6) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (namespaceUri, attributes, and content)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag7) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), plus REPLACE_ENTITIES" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), plus ENTITIES_NONE" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_ENTITIES_NONE) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, and multiline = false" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, false) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, and multiline = true" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, and indent = (2 spaces)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true, ' ') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), and linebreak = '^'" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true, ' ', '^') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = true" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true, ' ', '^', true) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = false" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true, ' ', '^', false) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo 'TEST: cause a non-scalar error on the content tag' . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag8) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo 'TEST: handle an array of namespaces being passed' . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag9) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo 'TEST: qname is derived from namespace + localPart' . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag10) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo 'TEST: qname is derived from localPart only' . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag11) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo 'TEST: namespaceUri is given, but namespace is not' . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag12) . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::createTagFromArray() basic tests=====
|
||||
|
||||
TEST: basic usage with an invalid array
|
||||
You must either supply a qualified name (qname) or local tag name (localPart).
|
||||
|
||||
TEST: basic usage with a valid array (qname only)
|
||||
<foo:bar />
|
||||
|
||||
TEST: basic usage with a valid array (qname and namespaceUri)
|
||||
<foo:bar xmlns:foo="http://foo.com" />
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, and attributes)
|
||||
<foo:bar argh="fruit&vegetable" key="value" xmlns:foo="http://foo.com" />
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content)
|
||||
<foo:bar argh="fruit&vegetable" key="value" xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, attributes, and content)
|
||||
<foo:bar argh="fruit&vegetable" key="value">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, and content)
|
||||
<foo:bar xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (namespaceUri, attributes, and content)
|
||||
You must either supply a qualified name (qname) or local tag name (localPart).
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), plus REPLACE_ENTITIES
|
||||
<foo:bar argh="fruit&vegetable" key="value" xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), plus ENTITIES_NONE
|
||||
<foo:bar argh="fruit&vegetable" key="value" xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, and multiline = false
|
||||
<foo:bar argh="fruit&vegetable" key="value" xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, and multiline = true
|
||||
<foo:bar argh="fruit&vegetable"
|
||||
key="value"
|
||||
xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, and indent = (2 spaces)
|
||||
<foo:bar argh="fruit&vegetable"
|
||||
key="value"
|
||||
xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), and linebreak = '^'
|
||||
<foo:bar argh="fruit&vegetable"^ key="value"^ xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = true
|
||||
<foo:bar argh="fruit&vegetable"^ key="value"^ xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = false
|
||||
<foo:bar key="value"^ argh="fruit&vegetable"^ xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: cause a non-scalar error on the content tag
|
||||
Supplied non-scalar value as tag content
|
||||
|
||||
TEST: handle an array of namespaces being passed
|
||||
<foo:bar xmlns:ns1="uri1" xmlns:ns2="uri2" />
|
||||
|
||||
TEST: qname is derived from namespace + localPart
|
||||
<http://foo.org:bar />
|
||||
|
||||
TEST: qname is derived from localPart only
|
||||
<bar />
|
||||
|
||||
TEST: namespaceUri is given, but namespace is not
|
||||
<foo xmlns="http://bar.org" />
|
||||
@@ -0,0 +1,44 @@
|
||||
--TEST--
|
||||
XML_Util::getDocTypeDeclaration() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::getDocTypeDeclaration() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: using root only" . PHP_EOL;
|
||||
echo XML_Util::getDocTypeDeclaration("rootTag") . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: using root and a string URI" . PHP_EOL;
|
||||
echo XML_Util::getDocTypeDeclaration("rootTag", "myDocType.dtd") . PHP_EOL . PHP_EOL;
|
||||
|
||||
$uri = array(
|
||||
'uri' => 'http://pear.php.net/dtd/package-1.0',
|
||||
'id' => '-//PHP//PEAR/DTD PACKAGE 0.1'
|
||||
);
|
||||
$dtdEntry = '<!ELEMENT additionalInfo (#PCDATA)>';
|
||||
|
||||
echo "TEST: using root and an array URI" . PHP_EOL;
|
||||
echo XML_Util::getDocTypeDeclaration("rootTag", $uri) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: using root and an array URI and an internal DTD entry" . PHP_EOL;
|
||||
echo XML_Util::getDocTypeDeclaration("rootTag", $uri, $dtdEntry) . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::getDocTypeDeclaration() basic tests=====
|
||||
|
||||
TEST: using root only
|
||||
<!DOCTYPE rootTag>
|
||||
|
||||
TEST: using root and a string URI
|
||||
<!DOCTYPE rootTag SYSTEM "myDocType.dtd">
|
||||
|
||||
TEST: using root and an array URI
|
||||
<!DOCTYPE rootTag PUBLIC "-//PHP//PEAR/DTD PACKAGE 0.1" "http://pear.php.net/dtd/package-1.0">
|
||||
|
||||
TEST: using root and an array URI and an internal DTD entry
|
||||
<!DOCTYPE rootTag PUBLIC "-//PHP//PEAR/DTD PACKAGE 0.1" "http://pear.php.net/dtd/package-1.0" [
|
||||
<!ELEMENT additionalInfo (#PCDATA)>
|
||||
]>
|
||||
@@ -0,0 +1,36 @@
|
||||
--TEST--
|
||||
XML_Util::getXmlDeclaration() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::getXmlDeclaration() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: using version only" . PHP_EOL;
|
||||
echo XML_Util::getXMLDeclaration("1.0") . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: using version and encoding" . PHP_EOL;
|
||||
echo XML_Util::getXMLDeclaration("1.0", "UTF-8") . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: using version, encoding, and standalone flag" . PHP_EOL;
|
||||
echo XML_Util::getXMLDeclaration("1.0", "UTF-8", true) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: using version and standalone flag" . PHP_EOL;
|
||||
echo XML_Util::getXMLDeclaration("1.0", null, true) . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::getXmlDeclaration() basic tests=====
|
||||
|
||||
TEST: using version only
|
||||
<?xml version="1.0"?>
|
||||
|
||||
TEST: using version and encoding
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
TEST: using version, encoding, and standalone flag
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
|
||||
TEST: using version and standalone flag
|
||||
<?xml version="1.0" standalone="yes"?>
|
||||
46
database/php/tests/XML_Util/tests/testBasic_isValidName.phpt
Normal file
46
database/php/tests/XML_Util/tests/testBasic_isValidName.phpt
Normal file
@@ -0,0 +1,46 @@
|
||||
--TEST--
|
||||
XML_Util::isValidName() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::isValidName() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: valid tag" . PHP_EOL;
|
||||
$result = XML_Util::isValidName("alpha-x_y_z.123");
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
print "Invalid XML name: " . $result->getMessage() . PHP_EOL . PHP_EOL;
|
||||
} else {
|
||||
print "Valid XML name." . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
echo "TEST: invalid tag" . PHP_EOL;
|
||||
$result = XML_Util::isValidName("invalidTag?");
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
print "Invalid XML name: " . $result->getMessage() . PHP_EOL . PHP_EOL;
|
||||
} else {
|
||||
print "Valid XML name." . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
echo "TEST: invalid tag that doesn't start with a letter" . PHP_EOL;
|
||||
$result = XML_Util::isValidName("1234five");
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
print "Invalid XML name: " . $result->getMessage() . PHP_EOL . PHP_EOL;
|
||||
} else {
|
||||
print "Valid XML name." . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::isValidName() basic tests=====
|
||||
|
||||
TEST: valid tag
|
||||
Valid XML name.
|
||||
|
||||
TEST: invalid tag
|
||||
Invalid XML name: XML names may only contain alphanumeric chars, period, hyphen, colon and underscores
|
||||
|
||||
TEST: invalid tag that doesn't start with a letter
|
||||
Invalid XML name: XML names may only start with letter or underscore
|
||||
19
database/php/tests/XML_Util/tests/testBasic_raiseError.phpt
Normal file
19
database/php/tests/XML_Util/tests/testBasic_raiseError.phpt
Normal file
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
XML_Util::raiseError() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::raiseError() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$error = XML_Util::raiseError("I am an error", 12345);
|
||||
if (is_a($error, 'PEAR_Error')) {
|
||||
print "PEAR Error: " . $error->getMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::raiseError() basic tests=====
|
||||
|
||||
PEAR Error: I am an error
|
||||
@@ -0,0 +1,82 @@
|
||||
--TEST--
|
||||
XML_Util::replaceEntities() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::replaceEntities() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$data = 'This string contains < & >.';
|
||||
$utf8 = 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê';
|
||||
|
||||
echo "TEST: basic usage" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($data) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage but with bogus \$replaceEntities arg" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($data, 'I_AM_BOGUS') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_XML) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_XML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: utf8 usage with ENTITIES_XML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($utf8, XML_UTIL_ENTITIES_XML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML_REQUIRED" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_XML_REQUIRED) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML_REQUIRED and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_XML_REQUIRED, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: utf8 usage with ENTITIES_XML_REQUIRED and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($utf8, XML_UTIL_ENTITIES_XML_REQUIRED, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_HTML" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_HTML) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_HTML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_HTML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: utf8 usage with ENTITIES_HTML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($utf8, XML_UTIL_ENTITIES_HTML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::replaceEntities() basic tests=====
|
||||
|
||||
TEST: basic usage
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage but with bogus $replaceEntities arg
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_XML
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_XML and UTF-8
|
||||
This string contains < & >.
|
||||
|
||||
TEST: utf8 usage with ENTITIES_XML and UTF-8
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
|
||||
TEST: basic usage with ENTITIES_XML_REQUIRED
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_XML_REQUIRED and UTF-8
|
||||
This string contains < & >.
|
||||
|
||||
TEST: utf8 usage with ENTITIES_XML_REQUIRED and UTF-8
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
|
||||
TEST: basic usage with ENTITIES_HTML
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_HTML and UTF-8
|
||||
This string contains < & >.
|
||||
|
||||
TEST: utf8 usage with ENTITIES_HTML and UTF-8
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
--TEST--
|
||||
XML_Util::reverseEntities() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::reverseEntities() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$data = 'This string contains < & >.';
|
||||
$utf8 = 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê';
|
||||
|
||||
echo "TEST: basic usage" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($data) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage but with bogus \$replaceEntities arg" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($data, 'I_AM_BOGUS') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($data, XML_UTIL_ENTITIES_XML) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($data, XML_UTIL_ENTITIES_XML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: utf8 usage with ENTITIES_XML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($utf8, XML_UTIL_ENTITIES_XML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML_REQUIRED" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($data, XML_UTIL_ENTITIES_XML_REQUIRED) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML_REQUIRED and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($data, XML_UTIL_ENTITIES_XML_REQUIRED, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: utf8 usage with ENTITIES_XML_REQUIRED and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($utf8, XML_UTIL_ENTITIES_XML_REQUIRED, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_HTML" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($data, XML_UTIL_ENTITIES_HTML) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_HTML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($data, XML_UTIL_ENTITIES_HTML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: utf8 usage with ENTITIES_HTML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($utf8, XML_UTIL_ENTITIES_HTML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::reverseEntities() basic tests=====
|
||||
|
||||
TEST: basic usage
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage but with bogus $replaceEntities arg
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_XML
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_XML and UTF-8
|
||||
This string contains < & >.
|
||||
|
||||
TEST: utf8 usage with ENTITIES_XML and UTF-8
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
|
||||
TEST: basic usage with ENTITIES_XML_REQUIRED
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_XML_REQUIRED and UTF-8
|
||||
This string contains < & >.
|
||||
|
||||
TEST: utf8 usage with ENTITIES_XML_REQUIRED and UTF-8
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
|
||||
TEST: basic usage with ENTITIES_HTML
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_HTML and UTF-8
|
||||
This string contains < & >.
|
||||
|
||||
TEST: utf8 usage with ENTITIES_HTML and UTF-8
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
@@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
XML_Util::splitQualifiedName() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::splitQualifiedName() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage without namespace" . PHP_EOL;
|
||||
$return = XML_Util::splitQualifiedName("xslt:stylesheet");
|
||||
echo "namespace => " . $return['namespace'] . PHP_EOL;
|
||||
echo "localPart => " . $return['localPart'] . PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with namespace" . PHP_EOL;
|
||||
$return = XML_Util::splitQualifiedName("stylesheet", "myNs");
|
||||
echo "namespace => " . $return['namespace'] . PHP_EOL;
|
||||
echo "localPart => " . $return['localPart'] . PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::splitQualifiedName() basic tests=====
|
||||
|
||||
TEST: basic usage without namespace
|
||||
namespace => xslt
|
||||
localPart => stylesheet
|
||||
|
||||
TEST: basic usage with namespace
|
||||
namespace => myNs
|
||||
localPart => stylesheet
|
||||
62
database/php/tests/XML_Util/tests/testBug_18343.phpt
Normal file
62
database/php/tests/XML_Util/tests/testBug_18343.phpt
Normal file
@@ -0,0 +1,62 @@
|
||||
--TEST--
|
||||
XML_Util tests for Bug #18343 Entities in file names decoded during packaging
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.2a1 2014-06-03
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util tests for Bug #18343 "Entities in file names decoded during packaging"=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: test case provided in bug report" . PHP_EOL;
|
||||
$array = array(
|
||||
"qname" => "install",
|
||||
"attributes" => array(
|
||||
"as" => "Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek",
|
||||
"name" => "test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek",
|
||||
)
|
||||
);
|
||||
|
||||
echo "No matter what flags are given to createTagFromArray(), an attribute must *always* be at least ENTITIES_XML encoded..." . PHP_EOL . PHP_EOL;
|
||||
|
||||
$flags = array(
|
||||
'no flag' => null,
|
||||
'false' => false,
|
||||
'ENTITIES_NONE' => XML_UTIL_ENTITIES_NONE,
|
||||
'ENTITIES_XML' => XML_UTIL_ENTITIES_XML,
|
||||
'ENTITIES_XML_REQUIRED' => XML_UTIL_ENTITIES_XML_REQUIRED,
|
||||
'ENTITIES_HTML' => XML_UTIL_ENTITIES_HTML,
|
||||
'REPLACE_ENTITIES' => XML_UTIL_REPLACE_ENTITIES,
|
||||
);
|
||||
foreach ($flags as $flagKey => $flagValue) {
|
||||
echo "Testing with $flagKey:" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($array, $flagValue) . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util tests for Bug #18343 "Entities in file names decoded during packaging"=====
|
||||
|
||||
TEST: test case provided in bug report
|
||||
No matter what flags are given to createTagFromArray(), an attribute must *always* be at least ENTITIES_XML encoded...
|
||||
|
||||
Testing with no flag:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
Testing with false:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
Testing with ENTITIES_NONE:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
Testing with ENTITIES_XML:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
Testing with ENTITIES_XML_REQUIRED:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
Testing with ENTITIES_HTML:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
Testing with REPLACE_ENTITIES:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
21
database/php/tests/XML_Util/tests/testBug_4950.phpt
Normal file
21
database/php/tests/XML_Util/tests/testBug_4950.phpt
Normal file
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
XML_Util tests for Bug #4950 "Incorrect CDATA serializing"
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util tests for Bug #4950 "Incorrect CDATA serializing"=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: test case provided in bug report" . PHP_EOL;
|
||||
echo XML_Util::createTag("test", array(), "Content ]]></test> here!",
|
||||
null, XML_UTIL_CDATA_SECTION) . PHP_EOL;
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util tests for Bug #4950 "Incorrect CDATA serializing"=====
|
||||
|
||||
TEST: test case provided in bug report
|
||||
<test><![CDATA[Content ]]]]><![CDATA[></test> here!]]></test>
|
||||
|
||||
27
database/php/tests/XML_Util/tests/testBug_5392.phpt
Normal file
27
database/php/tests/XML_Util/tests/testBug_5392.phpt
Normal file
@@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
XML_Util tests for Bug #5392 "encoding of ISO-8859-1 is the only supported encoding"
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util tests for Bug #5392 "encoding of ISO-8859-1 is the only supported encoding"=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: test case provided in bug report" . PHP_EOL;
|
||||
$data = 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê';
|
||||
|
||||
$replaced = XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_HTML, 'UTF-8');
|
||||
|
||||
$reversed = XML_Util::reverseEntities($replaced, XML_UTIL_ENTITIES_HTML, 'UTF-8');
|
||||
|
||||
echo $replaced . PHP_EOL;
|
||||
echo $reversed . PHP_EOL;
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util tests for Bug #5392 "encoding of ISO-8859-1 is the only supported encoding"=====
|
||||
|
||||
TEST: test case provided in bug report
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
2623
database/php/tests/beehiveforum082/forum/include/forum.inc.php
Normal file
2623
database/php/tests/beehiveforum082/forum/include/forum.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
48
database/php/tests/checkMax.php
Normal file
48
database/php/tests/checkMax.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Request #6056 Add support for reporting max PHP version
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CompatInfo
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD
|
||||
* @version CVS: $Id: checkMax.php,v 1.5 2008/07/22 20:27:11 farell Exp $
|
||||
* @link http://pear.php.net/bugs/bug.php?id=6056
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
require_once 'PHP/CompatInfo.php';
|
||||
|
||||
$info = new PHP_CompatInfo();
|
||||
|
||||
$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'sample_req6056.php';
|
||||
$arr = array($file, __FILE__);
|
||||
|
||||
$options = array('debug' => true);
|
||||
|
||||
$res = $info->parseArray($arr, $options);
|
||||
|
||||
echo 'PHP min = ' . $res['version'] . "<br />\n";
|
||||
if ($res['max_version'] != '') {
|
||||
echo 'PHP max = ' . $res['max_version'] . "<br />\n";
|
||||
|
||||
foreach ($arr as $file) {
|
||||
$min = $res[$file]['version'];
|
||||
$max = $res[$file]['max_version'];
|
||||
if (($max != '') && (version_compare($min, $max) === 1)) {
|
||||
echo 'ATTENTION file "'.$file.
|
||||
'" cannot run : PHP version Min > Max '."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($res['extensions'])) {
|
||||
echo 'Extensions required : ' . implode(', ', $res['extensions']) . "<br />\n";
|
||||
}
|
||||
|
||||
echo '<pre>';
|
||||
var_dump($res);
|
||||
echo '</pre>';
|
||||
|
||||
?>
|
||||
2
database/php/tests/emptyDir/empty_dir.txt
Normal file
2
database/php/tests/emptyDir/empty_dir.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Force PEAR_PackageFileManager2 to create empty dir.
|
||||
You can remove this file safely after PHP_CompatInfo install
|
||||
21
database/php/tests/kohana22/modules/gmaps/javascript.php
Normal file
21
database/php/tests/kohana22/modules/gmaps/javascript.php
Normal file
@@ -0,0 +1,21 @@
|
||||
google.load("maps", "2.x", {"language" : "<?php echo substr(Kohana::config('locale.language.0'), 0, 2);?>"});
|
||||
function initialize() {
|
||||
if (GBrowserIsCompatible()) {
|
||||
// Initialize the GMap
|
||||
<?php echo $map, "\n" ?>
|
||||
<?php echo $controls, "\n" ?>
|
||||
<?php echo $center, "\n" ?>
|
||||
<?php echo $options->render(1), "\n" ?>
|
||||
|
||||
// Build custom marker icons
|
||||
<?php foreach($icons as $icon): ?>
|
||||
<?php echo $icon->render(1), "\n" ?>
|
||||
<?php endforeach ?>
|
||||
|
||||
// Show map points
|
||||
<?php foreach($markers as $marker): ?>
|
||||
<?php echo $marker->render(1), "\n" ?>
|
||||
<?php endforeach ?>
|
||||
}
|
||||
}
|
||||
google.setOnLoadCallback(initialize);
|
||||
106
database/php/tests/parseDir/PHP5/tokens.php5
Normal file
106
database/php/tests/parseDir/PHP5/tokens.php5
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* Test tokens that appeared in PHP 5
|
||||
* T_ABSTRACT
|
||||
* T_CATCH
|
||||
* T_FINAL
|
||||
* T_INSTANCEOF
|
||||
* T_PRIVATE
|
||||
* T_PROTECTED
|
||||
* T_PUBLIC
|
||||
* T_THROW
|
||||
* T_TRY
|
||||
* T_CLONE
|
||||
* T_INTERFACE
|
||||
* T_IMPLEMENTS
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CompatInfo
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD
|
||||
* @version CVS: $Id: tokens.php5,v 1.2 2008/07/22 20:27:11 farell Exp $
|
||||
* @link http://pear.php.net/package/PHP_CompatInfo
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
require_once 'PHP/CompatInfo.php';
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
abstract class AbstractClass
|
||||
{
|
||||
abstract protected function getValue();
|
||||
}
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
interface ITemplate
|
||||
{
|
||||
public function setVariable($name, $var);
|
||||
public function getHtml($template);
|
||||
}
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
class Template implements ITemplate
|
||||
{
|
||||
private $vars = array();
|
||||
|
||||
public function setVariable($name, $var)
|
||||
{
|
||||
$this->vars[$name] = $var;
|
||||
}
|
||||
|
||||
public function getHtml($template)
|
||||
{
|
||||
foreach ($this->vars as $name => $value) {
|
||||
$template = str_replace('{' . $name . '}', $value, $template);
|
||||
}
|
||||
return $template;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
class BaseClass
|
||||
{
|
||||
public $objet1;
|
||||
public $objet2;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->object1 = clone($this->object1);
|
||||
}
|
||||
|
||||
private function foo()
|
||||
{
|
||||
}
|
||||
|
||||
protected function bar()
|
||||
{
|
||||
if ($this->object1 instanceof BaseClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$error = 'my error';
|
||||
throw new Exception($error);
|
||||
|
||||
} catch(Exception $__bar_exception) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
final public function moreTesting()
|
||||
{
|
||||
echo "BaseClass::moreTesting() called \n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
21
database/php/tests/parseDir/PHP5/upload_error.php
Normal file
21
database/php/tests/parseDir/PHP5/upload_error.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
$uploadErrors = array(
|
||||
UPLOAD_ERR_INI_SIZE => "The uploaded file exceeds the upload_max_filesize directive in php.ini.",
|
||||
UPLOAD_ERR_FORM_SIZE => "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.",
|
||||
UPLOAD_ERR_PARTIAL => "The uploaded file was only partially uploaded.",
|
||||
UPLOAD_ERR_NO_FILE => "No file was uploaded.",
|
||||
UPLOAD_ERR_NO_TMP_DIR => "Missing a temporary folder.",
|
||||
UPLOAD_ERR_CANT_WRITE => "Failed to write file to disk.",
|
||||
UPLOAD_ERR_EXTENSION => "File upload stopped by extension.",
|
||||
);
|
||||
|
||||
$errorCode = $_FILES["myUpload"]["error"];
|
||||
|
||||
if ($errorCode !== UPLOAD_ERR_OK) {
|
||||
if (isset($uploadErrors[$errorCode])) {
|
||||
throw new Exception($uploadErrors[$errorCode]);
|
||||
} else {
|
||||
throw new Exception("Unknown error uploading file.");
|
||||
}
|
||||
}
|
||||
?>
|
||||
20
database/php/tests/parseDir/extensions.php
Normal file
20
database/php/tests/parseDir/extensions.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
xdebug_start_trace();
|
||||
|
||||
function test_extensions()
|
||||
{
|
||||
$image = imagecreate(320, 240);
|
||||
imageantialias($image, true);
|
||||
return $image;
|
||||
}
|
||||
|
||||
print_r(apache_get_modules());
|
||||
|
||||
if (!extension_loaded('SQLite')) {
|
||||
$prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
|
||||
dl($prefix . 'sqlite.' . PHP_SHLIB_SUFFIX);
|
||||
echo 'SQLite version : ' . sqlite_libversion();
|
||||
}
|
||||
|
||||
xdebug_stop_trace();
|
||||
?>
|
||||
1
database/php/tests/parseDir/phpinfo.php
Normal file
1
database/php/tests/parseDir/phpinfo.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php phpinfo(); ?>
|
||||
485
database/php/tests/parseFile/File_Find-1.3.0__Find.php
Normal file
485
database/php/tests/parseFile/File_Find-1.3.0__Find.php
Normal file
@@ -0,0 +1,485 @@
|
||||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2005 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Sterling Hughes <sterling@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: File_Find-1.3.0__Find.php,v 1.1 2008/06/28 13:04:01 farell Exp $
|
||||
//
|
||||
|
||||
require_once 'PEAR.php';
|
||||
|
||||
define('FILE_FIND_VERSION', '@package_version@');
|
||||
|
||||
// to debug uncomment this string
|
||||
// define('FILE_FIND_DEBUG', '');
|
||||
|
||||
/**
|
||||
* Commonly needed functions searching directory trees
|
||||
*
|
||||
* @access public
|
||||
* @version $Id: File_Find-1.3.0__Find.php,v 1.1 2008/06/28 13:04:01 farell Exp $
|
||||
* @package File
|
||||
* @author Sterling Hughes <sterling@php.net>
|
||||
*/
|
||||
class File_Find
|
||||
{
|
||||
/**
|
||||
* internal dir-list
|
||||
* @var array
|
||||
*/
|
||||
var $_dirs = array();
|
||||
|
||||
/**
|
||||
* directory separator
|
||||
* @var string
|
||||
*/
|
||||
var $dirsep = "/";
|
||||
|
||||
/**
|
||||
* found files
|
||||
* @var array
|
||||
*/
|
||||
var $files = array();
|
||||
|
||||
/**
|
||||
* found dirs
|
||||
* @var array
|
||||
*/
|
||||
var $directories = array();
|
||||
|
||||
/**
|
||||
* Search specified directory to find matches for specified pattern
|
||||
*
|
||||
* @param string $pattern a string containing the pattern to search
|
||||
* the directory for.
|
||||
*
|
||||
* @param string $dirpath a string containing the directory path
|
||||
* to search.
|
||||
*
|
||||
* @param string $pattern_type a string containing the type of
|
||||
* pattern matching functions to use (can either be 'php',
|
||||
* 'perl' or 'shell').
|
||||
*
|
||||
* @return array containing all of the files and directories
|
||||
* matching the pattern or null if no matches
|
||||
*
|
||||
* @author Sterling Hughes <sterling@php.net>
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
function &glob($pattern, $dirpath, $pattern_type = 'php')
|
||||
{
|
||||
$dh = @opendir($dirpath);
|
||||
|
||||
if (!$dh) {
|
||||
$pe = PEAR::raiseError("Cannot open directory $dirpath");
|
||||
return $pe;
|
||||
}
|
||||
|
||||
$match_function = File_Find::_determineRegex($pattern, $pattern_type);
|
||||
$matches = array();
|
||||
|
||||
// empty string cannot be specified for 'php' and 'perl' pattern
|
||||
if ($pattern || ($pattern_type != 'php' && $pattern_type != 'perl')) {
|
||||
while (false !== ($entry = @readdir($dh))) {
|
||||
if ($match_function($pattern, $entry) &&
|
||||
$entry != '.' && $entry != '..') {
|
||||
$matches[] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@closedir($dh);
|
||||
|
||||
if (0 == count($matches)) {
|
||||
$matches = null;
|
||||
}
|
||||
|
||||
return $matches ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map the directory tree given by the directory_path parameter.
|
||||
*
|
||||
* @param string $directory contains the directory path that you
|
||||
* want to map.
|
||||
*
|
||||
* @return array a two element array, the first element containing a list
|
||||
* of all the directories, the second element containing a list of all the
|
||||
* files.
|
||||
*
|
||||
* @author Sterling Hughes <sterling@php.net>
|
||||
* @access public
|
||||
*/
|
||||
function &maptree($directory)
|
||||
{
|
||||
|
||||
/* if called statically */
|
||||
if (!isset($this) || !is_a($this, "File_Find")) {
|
||||
$obj = &new File_Find();
|
||||
return $obj->maptree($directory);
|
||||
}
|
||||
|
||||
/* clear the results just in case */
|
||||
$this->files = array();
|
||||
$this->directories = array();
|
||||
|
||||
/* strip out trailing slashes */
|
||||
$directory = preg_replace('![\\\\/]+$!', '', $directory);
|
||||
|
||||
$this->_dirs = array($directory);
|
||||
|
||||
while (count($this->_dirs)) {
|
||||
$dir = array_pop($this->_dirs);
|
||||
File_Find::_build($dir, $this->dirsep);
|
||||
array_push($this->directories, $dir);
|
||||
}
|
||||
|
||||
$retval = array($this->directories, $this->files);
|
||||
return $retval;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Map the directory tree given by the directory parameter.
|
||||
*
|
||||
* @param string $directory contains the directory path that you
|
||||
* want to map.
|
||||
* @param integer $maxrecursion maximun number of folders to recursive
|
||||
* map
|
||||
*
|
||||
* @return array a multidimensional array containing all subdirectories
|
||||
* and their files. For example:
|
||||
*
|
||||
* Array
|
||||
* (
|
||||
* [0] => file_1.php
|
||||
* [1] => file_2.php
|
||||
* [subdirname] => Array
|
||||
* (
|
||||
* [0] => file_1.php
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* @author Mika Tuupola <tuupola@appelsiini.net>
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
function &mapTreeMultiple($directory, $maxrecursion = 0, $count = 0)
|
||||
{
|
||||
$retval = array();
|
||||
|
||||
$count++;
|
||||
|
||||
/* strip trailing slashes */
|
||||
$directory = preg_replace('![\\\\/]+$!', '', $directory);
|
||||
|
||||
if (is_readable($directory)) {
|
||||
$dh = opendir($directory);
|
||||
while (false !== ($entry = @readdir($dh))) {
|
||||
if ($entry != '.' && $entry != '..') {
|
||||
array_push($retval, $entry);
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
|
||||
while (list($key, $val) = each($retval)) {
|
||||
$path = $directory . "/" . $val;
|
||||
|
||||
if (!is_array($val) && is_dir($path)) {
|
||||
unset($retval[$key]);
|
||||
if ($maxrecursion == 0 || $count < $maxrecursion) {
|
||||
$retval[$val] = &File_Find::mapTreeMultiple($path,
|
||||
$maxrecursion, $count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the specified directory tree with the specified pattern. Return
|
||||
* an array containing all matching files (no directories included).
|
||||
*
|
||||
* @param string $pattern the pattern to match every file with.
|
||||
*
|
||||
* @param string $directory the directory tree to search in.
|
||||
*
|
||||
* @param string $type the type of regular expression support to use, either
|
||||
* 'php', 'perl' or 'shell'.
|
||||
*
|
||||
* @param bool $fullpath whether the regex should be matched against the
|
||||
* full path or only against the filename
|
||||
*
|
||||
* @param string $match can be either 'files', 'dirs' or 'both' to specify
|
||||
* the kind of list to return
|
||||
*
|
||||
* @return array a list of files matching the pattern parameter in the the
|
||||
* directory path specified by the directory parameter
|
||||
*
|
||||
* @author Sterling Hughes <sterling@php.net>
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
function &search($pattern, $directory, $type = 'php', $fullpath = true, $match = 'files')
|
||||
{
|
||||
|
||||
$matches = array();
|
||||
list ($directories,$files) = File_Find::maptree($directory);
|
||||
switch($match) {
|
||||
case 'directories':
|
||||
$data = $directories;
|
||||
break;
|
||||
case 'both':
|
||||
$data = array_merge($directories, $files);
|
||||
break;
|
||||
case 'files':
|
||||
default:
|
||||
$data = $files;
|
||||
}
|
||||
unset($files, $directories);
|
||||
|
||||
$match_function = File_Find::_determineRegex($pattern, $type);
|
||||
|
||||
reset($data);
|
||||
// check if empty string given (ok for 'shell' method, but bad for others)
|
||||
if ($pattern || ($type != 'php' && $type != 'perl')) {
|
||||
while (list(,$entry) = each($data)) {
|
||||
if ($match_function($pattern,
|
||||
$fullpath ? $entry : basename($entry))) {
|
||||
$matches[] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether or not a variable is a PEAR error
|
||||
*
|
||||
* @param object PEAR_Error $var the variable to test.
|
||||
*
|
||||
* @return boolean returns true if the variable is a PEAR error, otherwise
|
||||
* it returns false.
|
||||
* @access public
|
||||
*/
|
||||
function isError(&$var)
|
||||
{
|
||||
return PEAR::isError($var);
|
||||
}
|
||||
|
||||
/**
|
||||
* internal function to build singular directory trees, used by
|
||||
* File_Find::maptree()
|
||||
*
|
||||
* @param string $directory name of the directory to read
|
||||
* @param string $separator directory separator
|
||||
* @return void
|
||||
*/
|
||||
function _build($directory, $separator = "/")
|
||||
{
|
||||
|
||||
$dh = @opendir($directory);
|
||||
|
||||
if (!$dh) {
|
||||
$pe = PEAR::raiseError("Cannot open directory");
|
||||
return $pe;
|
||||
}
|
||||
|
||||
while (false !== ($entry = @readdir($dh))) {
|
||||
if ($entry != '.' && $entry != '..') {
|
||||
|
||||
$entry = $directory.$separator.$entry;
|
||||
|
||||
if (is_dir($entry)) {
|
||||
array_push($this->_dirs, $entry);
|
||||
} else {
|
||||
array_push($this->files, $entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@closedir($dh);
|
||||
}
|
||||
|
||||
/**
|
||||
* internal function to determine the type of regular expression to
|
||||
* use, implemented by File_Find::glob() and File_Find::search()
|
||||
*
|
||||
* @param string $type given RegExp type
|
||||
* @return string kind of function ( "eregi", "ereg" or "preg_match") ;
|
||||
*
|
||||
*/
|
||||
function _determineRegex($pattern, $type)
|
||||
{
|
||||
if (!strcasecmp($type, 'shell')) {
|
||||
$match_function = 'File_Find_match_shell';
|
||||
} else if (!strcasecmp($type, 'perl')) {
|
||||
$match_function = 'preg_match';
|
||||
} else if (!strcasecmp(substr($pattern, -2), '/i')) {
|
||||
$match_function = 'eregi';
|
||||
} else {
|
||||
$match_function = 'ereg';
|
||||
}
|
||||
return $match_function;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Package method to match via 'shell' pattern. Provided in global
|
||||
* scope, because it should be called like 'preg_match' and 'eregi'
|
||||
* and can be easily copied into other packages
|
||||
*
|
||||
* @author techtonik <techtonik@php.net>
|
||||
* @return mixed bool on success and PEAR_Error on failure
|
||||
*/
|
||||
function File_Find_match_shell($pattern, $filename)
|
||||
{
|
||||
// {{{ convert pattern to positive and negative regexps
|
||||
$positive = $pattern;
|
||||
$negation = substr_count($pattern, "|");
|
||||
|
||||
if ($negation > 1) {
|
||||
PEAR::raiseError("Mask string contains errors!");
|
||||
return FALSE;
|
||||
} elseif ($negation) {
|
||||
list($positive, $negative) = explode("|", $pattern);
|
||||
if (strlen($negative) == 0) {
|
||||
PEAR::raiseError("File-mask string contains errors!");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
$positive = _File_Find_match_shell_get_pattern($positive);
|
||||
if ($negation) {
|
||||
$negative = _File_Find_match_shell_get_pattern($negative);
|
||||
}
|
||||
// }}} convert end
|
||||
|
||||
|
||||
if (defined("FILE_FIND_DEBUG")) {
|
||||
print("Method: $type\nPattern: $pattern\n Converted pattern:");
|
||||
print_r($positive);
|
||||
if (isset($negative)) print_r($negative);
|
||||
}
|
||||
|
||||
if (!preg_match($positive, $filename)) {
|
||||
return FALSE;
|
||||
} else {
|
||||
if (isset($negative)
|
||||
&& preg_match($negative, $filename)) {
|
||||
return FALSE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function used by File_Find_match_shell to convert 'shell' mask
|
||||
* into pcre regexp. Some of the rules (see testcases for more):
|
||||
* escaping all special chars and replacing
|
||||
* . with \.
|
||||
* * with .*
|
||||
* ? with .{1}
|
||||
* also adding ^ and $ as the pattern matches whole filename
|
||||
*
|
||||
* @author techtonik <techtonik@php.net>
|
||||
* @return string pcre regexp for preg_match
|
||||
*/
|
||||
function _File_Find_match_shell_get_pattern($mask) {
|
||||
// get array of several masks (if any) delimited by comma
|
||||
// do not touch commas in char class
|
||||
$premasks = preg_split("|(\[[^\]]+\])|", $mask, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
|
||||
if (defined("FILE_FIND_DEBUG")) {
|
||||
print("\nPremask: ");
|
||||
print_r($premasks);
|
||||
}
|
||||
$pi = 0;
|
||||
foreach($premasks as $pm) {
|
||||
if (!isset($masks[$pi])) $masks[$pi] = "";
|
||||
if ($pm{0} == '[' && $pm{strlen($pm)-1} == ']') {
|
||||
// strip commas from character class
|
||||
$masks[$pi] .= str_replace(",", "", $pm);
|
||||
} else {
|
||||
$tarr = explode(",", $pm);
|
||||
if (sizeof($tarr) == 1) {
|
||||
$masks[$pi] .= $pm;
|
||||
} else {
|
||||
foreach ($tarr as $te) {
|
||||
$masks[$pi++] .= $te;
|
||||
$masks[$pi] = "";
|
||||
}
|
||||
unset($masks[$pi--]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if empty string given return *.* pattern
|
||||
if (strlen($mask) == 0) return "!^.*$!";
|
||||
|
||||
// convert to preg regexp
|
||||
$regexmask = implode("|", $masks);
|
||||
if (defined("FILE_FIND_DEBUG")) {
|
||||
print("regexMask step one(implode): $regexmask");
|
||||
}
|
||||
$regexmask = addcslashes($regexmask, '^$}!{)(\/.+');
|
||||
if (defined("FILE_FIND_DEBUG")) {
|
||||
print("\nregexMask step two(addcslashes): $regexmask");
|
||||
}
|
||||
$regexmask = preg_replace("!(\*|\?)!", ".$1", $regexmask);
|
||||
if (defined("FILE_FIND_DEBUG")) {
|
||||
print("\nregexMask step three(* ? -> .* .?): $regexmask");
|
||||
}
|
||||
// a special case '*.' at the end means that there is no extension
|
||||
$regexmask = preg_replace("!\.\*\\\.(\||$)!", "[^\.]*$1", $regexmask);
|
||||
// it is impossible to have dot at the end of filename
|
||||
$regexmask = preg_replace("!\\\.(\||$)!", "$1", $regexmask);
|
||||
// and .* at the end also means that there could be nothing at all
|
||||
// (i.e. no dot at the end also)
|
||||
$regexmask = preg_replace("!\\\.\.\*(\||$)!", "(\\\\..*)?$1", $regexmask);
|
||||
if (defined("FILE_FIND_DEBUG")) {
|
||||
print("\nregexMask step two and half(*.$ \\..*$ .$ -> [^.]*$ .?.* $): $regexmask");
|
||||
}
|
||||
// if no extension supplied - add .* to match partially from filename start
|
||||
if (strpos($regexmask, "\\.") === FALSE) $regexmask .= ".*";
|
||||
|
||||
// file mask match whole name - adding restrictions
|
||||
$regexmask = preg_replace("!(\|)!", '^'."$1".'$', $regexmask);
|
||||
$regexmask = '^'.$regexmask.'$';
|
||||
if (defined("FILE_FIND_DEBUG")) {
|
||||
print("\nregexMask step three(^ and $ to match whole name): $regexmask");
|
||||
}
|
||||
// wrap regex into ! since all ! are already escaped
|
||||
$regexmask = "!$regexmask!i";
|
||||
if (defined("FILE_FIND_DEBUG")) {
|
||||
print("\nWrapped regex: $regexmask\n");
|
||||
}
|
||||
return $regexmask;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
1094
database/php/tests/parseFile/PackageUpdate.php
Normal file
1094
database/php/tests/parseFile/PackageUpdate.php
Normal file
File diff suppressed because it is too large
Load Diff
38
database/php/tests/parseFile/conditional.php
Normal file
38
database/php/tests/parseFile/conditional.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// PHP 4.0.0 : __FILE__
|
||||
// PHP 4.0.6 : DIRECTORY_SEPARATOR
|
||||
// PHP 4.0.7 : version compare
|
||||
// PHP 4.3.0 : ob_get_clean
|
||||
// PHP 4.3.0 : debug_backtrace
|
||||
// PHP 4.3.10 and 5.0.2 : PHP_EOL
|
||||
// PHP 5.0.0 : simplexml_load_file
|
||||
|
||||
if (!defined('DIRECTORY_SEPARATOR')) {
|
||||
define('DIRECTORY_SEPARATOR',
|
||||
strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? '\\' : '/'
|
||||
);
|
||||
}
|
||||
|
||||
if (function_exists('debug_backtrace')) {
|
||||
$backtrace = debug_backtrace();
|
||||
} else {
|
||||
$backtrace = false;
|
||||
}
|
||||
|
||||
if (function_exists('simplexml_load_file')) {
|
||||
$xml = simplexml_load_file('C:\php\pear\PHP_CompatInfo\scripts\version.xml');
|
||||
}
|
||||
|
||||
if (version_compare(phpversion(), '5.0.0', '<')) {
|
||||
include_once 'PHP/Compat.php';
|
||||
PHP_Compat::loadFunction('ob_get_clean');
|
||||
PHP_Compat::loadConstant('PHP_EOL');
|
||||
}
|
||||
|
||||
echo "Hello World" . PHP_EOL;
|
||||
|
||||
$ds = DIRECTORY_SEPARATOR;
|
||||
$fn = dirname(__FILE__) . $ds . basename(__FILE__);
|
||||
echo "You have run file : $fn at " . date(DATE_W3C) . PHP_EOL;
|
||||
|
||||
?>
|
||||
1
database/php/tests/parseFile/empty.php
Normal file
1
database/php/tests/parseFile/empty.php
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
20
database/php/tests/parseFile/ignore_functions_match.php
Normal file
20
database/php/tests/parseFile/ignore_functions_match.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
function toFile($filename, $data)
|
||||
{
|
||||
if (function_exists('file_put_contents')) {
|
||||
file_put_contents($filename, $data);
|
||||
} else {
|
||||
$file = fopen($filename, 'wb');
|
||||
fwrite($file, $data);
|
||||
fclose($file);
|
||||
}
|
||||
}
|
||||
|
||||
if (function_exists('debug_backtrace')) {
|
||||
$backtrace = debug_backtrace();
|
||||
} else {
|
||||
$backtrace = false;
|
||||
}
|
||||
|
||||
debug_print_backtrace();
|
||||
?>
|
||||
6
database/php/tests/parseFile/math.php
Normal file
6
database/php/tests/parseFile/math.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$nb = bcsub(1.234, 5, 4);
|
||||
if (preg_match('/^-/', $nb)) {
|
||||
echo 'minus';
|
||||
}
|
||||
?>
|
||||
39
database/php/tests/parseFile/php5_method_chaining.php
Normal file
39
database/php/tests/parseFile/php5_method_chaining.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* This Person class encapsulates a couple of properties which
|
||||
* a person might have: their name and age.
|
||||
* We also give the Person the opportunity to introduce themselves.
|
||||
*
|
||||
* @link http://cowburn.info/php/php5-method-chaining/
|
||||
*/
|
||||
class Person
|
||||
{
|
||||
var $m_szName;
|
||||
var $m_iAge;
|
||||
|
||||
function setName($szName)
|
||||
{
|
||||
$this->m_szName = $szName;
|
||||
return $this; // We now return $this (the Person)
|
||||
}
|
||||
|
||||
function setAge($iAge)
|
||||
{
|
||||
$this->m_iAge = $iAge;
|
||||
return $this; // Again, return our Person
|
||||
}
|
||||
|
||||
function introduce()
|
||||
{
|
||||
printf('Hello my name is %s and I am %d years old.',
|
||||
$this->m_szName,
|
||||
$this->m_iAge);
|
||||
}
|
||||
}
|
||||
|
||||
// We'll be creating me, digitally.
|
||||
$peter = new Person();
|
||||
// Let's set some attributes and let me introduce myself,
|
||||
// all in one line of code.
|
||||
$peter->setName('Peter')->setAge(23)->introduce();
|
||||
?>
|
||||
26
database/php/tests/parseFile/php5_method_chaining_samp2.php
Normal file
26
database/php/tests/parseFile/php5_method_chaining_samp2.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Another example of PHP method chaining
|
||||
*
|
||||
* @link http://sebastian-bergmann.de/archives/738-Support-for-BDD-and-Stories-in-PHPUnit-3.3.html
|
||||
*/
|
||||
|
||||
require_once 'PHPUnit/Extensions/Story/TestCase.php';
|
||||
|
||||
require_once 'BowlingGame.php';
|
||||
|
||||
class BowlingGameSpec extends PHPUnit_Extensions_Story_TestCase
|
||||
{
|
||||
/**
|
||||
* @scenario
|
||||
*/
|
||||
function scoreForOneSpareIs16()
|
||||
{
|
||||
$this->given('New game')
|
||||
->when('Player rolls', 5)
|
||||
->and('Player rolls', 5)
|
||||
->and('Player rolls', 3)
|
||||
->then('Score should be', 16);
|
||||
}
|
||||
}
|
||||
?>
|
||||
64
database/php/tests/parseFile/phpweb-entities.php
Normal file
64
database/php/tests/parseFile/phpweb-entities.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2008 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Gabor Hojtsy <goba@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
$Id: phpweb-entities.php,v 1.1 2008/02/02 15:09:40 farell Exp $
|
||||
*/
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
// Too few or too many parameters
|
||||
if ($argc != 3) { die("ERROR in " . __FILE__ . ": Too few or too many parameters"); }
|
||||
|
||||
// Workdir is the first param
|
||||
$workdir = $argv[1];
|
||||
|
||||
// Whether we are in phpweb mode
|
||||
$phpweb_mode = ($argv[2] == "phpweb");
|
||||
|
||||
// Entity file for phpweb entities
|
||||
$phpweb_ent = "$workdir/entities/phpweb.ent";
|
||||
|
||||
// Automatically generated file note
|
||||
$autonote = "<!-- This file is autogenerated - don't touch it by hand! -->\n";
|
||||
|
||||
// Replace current phpweb.ent with a 0 byte file
|
||||
if (!$phpweb_mode) {
|
||||
$pe = fopen($phpweb_ent, "w");
|
||||
fwrite($pe, $autonote);
|
||||
fclose($pe);
|
||||
echo "$phpweb_ent should be empty now...\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
echo "creating $phpweb_ent...\n";
|
||||
|
||||
// Read in global.ent from the source dir
|
||||
$lines = file("@SRCDIR@/entities/global.ent");
|
||||
|
||||
// Collect all phpweb entities
|
||||
$phpweb_entities = array($autonote);
|
||||
foreach ($lines as $line) {
|
||||
if (strpos($line, "http://www.php.net") !== FALSE) {
|
||||
$phpweb_entities[] = str_replace("http://www.php.net", "", $line);
|
||||
}
|
||||
}
|
||||
|
||||
// Write out entity file
|
||||
$pe = fopen($phpweb_ent, "w");
|
||||
fwrite($pe, join("", $phpweb_entities));
|
||||
fclose($pe);
|
||||
13
database/php/tests/parseFile/zip.php
Normal file
13
database/php/tests/parseFile/zip.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
$zip = zip_open("/tmp/test2.zip");
|
||||
|
||||
if ($zip) {
|
||||
while ($zip_entry = zip_read($zip)) {
|
||||
echo "Name: " . zip_entry_name($zip_entry) . "\n";
|
||||
echo "Actual Filesize: " . zip_entry_filesize($zip_entry) . "\n";
|
||||
echo "Compressed Size: " . zip_entry_compressedsize($zip_entry) . "\n";
|
||||
echo "Compression Method: " . zip_entry_compressionmethod($zip_entry) . "\n";
|
||||
}
|
||||
zip_close($zip);
|
||||
}
|
||||
?>
|
||||
36
database/php/tests/sample_req6056.php
Normal file
36
database/php/tests/sample_req6056.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Request #6056 Add support for reporting max PHP version. Sample code.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CompatInfo
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id: sample_req6056.php,v 1.4 2007/11/15 18:23:40 farell Exp $
|
||||
* @link http://pear.php.net/bugs/bug.php?id=6056
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
class Request6056
|
||||
{
|
||||
/**
|
||||
* Sample code to check max php version
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testMaxVersion()
|
||||
{
|
||||
// PHP 5 <= 5.0.4
|
||||
$res = php_check_syntax('bug6581.php');
|
||||
|
||||
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3);
|
||||
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7);
|
||||
|
||||
// PHP 5 >= 5.1.0RC1
|
||||
$diff = array_diff_key($array1, $array2);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user