diff --git a/.gitignore b/.gitignore index 869f498..11685a9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ composer.lock composer.phar vendor +tests/coverage +clover.xml diff --git a/.travis.yml b/.travis.yml index 1a7578e..3f74dee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,14 @@ language: php install: - - pear install -a package.xml + - composer install --prefer-dist --no-progress + php: - - 5.5 -script: phpunit test/ \ No newline at end of file + - 5.6 + - 7.0 + - 7.1 + - 7.2 + - 7.3 + - 7.4 + +script: + - vendor/bin/phpunit diff --git a/Config.php b/Config.php index 0e0b751..a0a59f3 100644 --- a/Config.php +++ b/Config.php @@ -17,9 +17,6 @@ // // $Id$ -require_once('PEAR.php'); -require_once('Config/Container.php'); - $GLOBALS['CONFIG_TYPES'] = array( 'apache' => array('Config/Container/Apache.php', 'Config_Container_Apache'), diff --git a/Config/Container.php b/Config/Container.php index ba05e3a..14323de 100644 --- a/Config/Container.php +++ b/Config/Container.php @@ -17,8 +17,6 @@ // // $Id$ -require_once 'Config.php'; - /** * Interface for Config containers * @@ -62,7 +60,7 @@ class Config_Container { * Array of attributes for this item * @var array */ - var $attributes; + var $attributes = []; /** * Unique id to differenciate nodes @@ -82,7 +80,7 @@ class Config_Container { * @param string $content Content of container object * @param array $attributes Array of attributes for container object */ - function __construct($type = 'section', $name = '', $content = '', $attributes = null) + function __construct($type = 'section', $name = '', $content = '', $attributes = []) { $this->type = $type; $this->name = $name; @@ -694,7 +692,7 @@ function toArray($useAttr = true) $array[$this->name] = array(); switch ($this->type) { case 'directive': - if ($useAttr && count($this->attributes) > 0) { + if ($useAttr && !empty($this->attributes)) { $array[$this->name]['#'] = $this->content; $array[$this->name]['@'] = $this->attributes; } else { @@ -702,7 +700,7 @@ function toArray($useAttr = true) } break; case 'section': - if ($useAttr && count($this->attributes) > 0) { + if ($useAttr && !empty($this->attributes)) { $array[$this->name]['@'] = $this->attributes; } if ($count = count($this->children)) { @@ -773,4 +771,3 @@ function writeDatasrc($datasrc, $configType, $options = array()) } } // end func writeDatasrc } // end class Config_Container -?> diff --git a/Config/Container/IniCommented.php b/Config/Container/IniCommented.php index 2360806..6963f68 100644 --- a/Config/Container/IniCommented.php +++ b/Config/Container/IniCommented.php @@ -164,7 +164,7 @@ function _quoteAndCommaParser($text) $pos = 0; // position in $text do { - $char = $text{$pos}; + $char = $text[$pos]; $state = $this->_getQACEvent($stack); if ($tokens[$state]) { diff --git a/Config/Container/IniFile.php b/Config/Container/IniFile.php index 776e7b0..90c7d3a 100644 --- a/Config/Container/IniFile.php +++ b/Config/Container/IniFile.php @@ -66,6 +66,7 @@ function parseDatasrc($datasrc, $obj) null, PEAR_ERROR_RETURN ); } + $currentSection = $obj->container; $confArray = parse_ini_file($datasrc, true); if (!$confArray) { @@ -74,6 +75,7 @@ function parseDatasrc($datasrc, $obj) null, PEAR_ERROR_RETURN ); } + foreach ($confArray as $key => $value) { if (is_array($value)) { $currentSection =& $obj->container->createSection($key); @@ -213,4 +215,4 @@ function contentToString($content) return $content; } -} // end class Config_Container_IniFile \ No newline at end of file +} // end class Config_Container_IniFile diff --git a/Config/Container/PHPConstants.php b/Config/Container/PHPConstants.php index fc0b130..b9e0c9d 100644 --- a/Config/Container/PHPConstants.php +++ b/Config/Container/PHPConstants.php @@ -11,7 +11,6 @@ * @version SVN: $Id$ * @link http://pear.php.net/package/Config */ -require_once 'Config/Container.php'; /** * Config parser for PHP constant files @@ -22,7 +21,7 @@ * @license http://www.php.net/license PHP License * @link http://pear.php.net/package/Config */ -class Config_Container_PHPConstants extends Config_Container +class Config_Container_PHPConstants { /** * Valid config options: @@ -125,7 +124,7 @@ function &parseDatasrc($datasrc, &$obj) * * @access public */ - function toString(&$obj) + function toString(&$obj, $options = array()) { $string = ''; diff --git a/Config/Container/XML.php b/Config/Container/XML.php index 1183fcb..77b22cc 100644 --- a/Config/Container/XML.php +++ b/Config/Container/XML.php @@ -17,9 +17,6 @@ // // $Id$ -require_once('XML/Parser.php'); -require_once('XML/Util.php'); - /** * Config parser for XML Files * diff --git a/README.md b/README.md new file mode 100644 index 0000000..8594dfa --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Pear / Config +Configuration parsers for Apache, Ini files, PHP constants, Xml and generic .conf files. + +[![Build Status](https://travis-ci.org/pear/config.png?branch=master)](https://travis-ci.org/pear/config) + +## Installation +Add the following to your composer.json: +``` +{ + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/pear/Config" + "no-api": true + } + ], + "require": { + "pear/Config": "dev-master", + } +} +``` diff --git a/composer.json b/composer.json index 6796f9f..5afcd1b 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,8 @@ }, "type": "library", "require": { - "pear/pear_exception": "*" + "pear/pear": "^1.10", + "pear/xml_parser": "^1.3" }, "require-dev": { "phpunit/phpunit": "*" @@ -46,4 +47,4 @@ "suggest": { "pear/xml_parser": "Install optionally via your project's composer.json" } -} \ No newline at end of file +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..e98ef7d --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,28 @@ + + + + + + + ./tests/integration + ./tests/legacy + + + + + + + ./Config + + + + + + + + diff --git a/test/phpt_test.php.inc b/test/phpt_test.php.inc deleted file mode 100644 index d7ecafb..0000000 --- a/test/phpt_test.php.inc +++ /dev/null @@ -1,404 +0,0 @@ -_diffonly = $diffonly; - $this->_errors = array(); - PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array(&$this, 'pearerrorCallback')); - PEAR_ErrorStack::setDefaultCallback(array(&$this, 'pearerrorstackCallback')); - } - - function pearerrorCallback($err) - { - PEAR_ErrorStack::staticPush('PEAR_Error', -1, 'error', array('obj' => $err), - $err->getMessage()); - } - - function pearerrorstackCallback($err) - { - $this->_errors[] = $err; - } - - function assertPEARError($err, $message) - { - if (is_a($err, 'PEAR_Error')) { - return true; - } - $this->_failTest(debug_backtrace(), $message); - echo "Not a PEAR_Error\n"; - return false; - } - - function assertNoErrors($message, $trace = null) - { - if (count($this->_errors) == 0) { - return true; - } - if ($trace === null) { - $trace = debug_backtrace(); - } - $this->_failTest($trace, $message); - foreach ($this->_errors as $err) { - if ($err['package'] == 'PEAR_Error') { - echo "Unexpected PEAR_Error:\n"; - echo 'message "' . $err['message'] . "\"\n"; - } else { - echo "Unexpected PEAR_ErrorStack error:\n"; - echo 'package "' . $err['package'] . "\"\n"; - echo 'message "' . $err['message'] . "\"\n"; - } - } - $this->_errors = array(); - return false; - } - - function assertErrors($errors, $message, $trace = null) - { - if (!count($this->_errors)) { - if ($trace === null) { - $trace = debug_backtrace(); - } - $this->_failTest($trace, $message); - echo "No errors caught, but errors were expected\n"; - return false; - } - if (!isset($errors[0])) { - $errors = array($errors); - } - $failed = false; - foreach ($errors as $err) { - $found = false; - foreach ($this->_errors as $i => $caughterror) { - if ($caughterror['package'] == $err['package']) { - if ($caughterror['message'] == $err['message']) { - $found = true; - break; - } - } - } - if ($found) { - unset($this->_errors[$i]); - continue; - } - if (!$failed) { - if ($trace === null) { - $trace = debug_backtrace(); - } - $failed = true; - $this->_failTest($trace, $message); - } - echo "Unthrown error:\n"; - if ($err['package'] == 'PEAR_Error') { - echo "PEAR_Error:\n"; - } else { - echo "error package: \"$err[package]\"\n"; - } - echo "message: \"$err[message]\"\n"; - } - if (count($this->_errors)) { - if (!$failed) { - if ($trace === null) { - $trace = debug_backtrace(); - } - $failed = true; - $this->_failTest($trace, $message); - } - foreach ($this->_errors as $err) { - echo "Unexpected error:\n"; - if ($err['package'] == 'PEAR_Error') { - echo "PEAR_Error:\n"; - } else { - echo "error package: \"$err[package]\"\n"; - } - echo "message: \"$err[message]\"\n"; - } - } - $this->_errors = array(); - return !$failed; - } - - function assertTrue($test, $message) - { - $this->assertNoErrors($message, debug_backtrace()); - if ($test === true) { - return true; - } - $this->_failTest(debug_backtrace(), $message); - echo "Unexpected non-true value: \n"; - var_export($test); - echo "\n'$message'\n"; - return false; - } - - function assertIsa($control, $test, $message) - { - $this->assertNoErrors($message, debug_backtrace()); - if (is_a($test, $control)) { - return true; - } - $this->_failTest(debug_backtrace(), $message); - echo "Unexpected non-$control object: \n"; - var_export($test); - echo "\n'$message'\n"; - return false; - } - - function assertNull($test, $message) - { - $this->assertNoErrors($message, debug_backtrace()); - if ($test === null) { - return true; - } - $this->_failTest(debug_backtrace(), $message); - echo "Unexpected non-null value: \n"; - var_export($test); - echo "\n'$message'\n"; - return false; - } - - function assertNotNull($test, $message) - { - $this->assertNoErrors($message, debug_backtrace()); - if ($test !== null) { - return true; - } - $this->_failTest(debug_backtrace(), $message); - echo "Unexpected null: \n"; - var_export($test); - echo "\n'$message'\n"; - return false; - } - - function assertSame($test, $test1, $message) - { - $this->assertNoErrors($message, debug_backtrace()); - if ($test === $test1) { - return true; - } - $this->_failTest(debug_backtrace(), $message); - echo "Unexpectedly two vars are not the same thing: \n"; - echo "\n'$message'\n"; - return false; - } - - function assertNotSame($test, $test1, $message) - { - $this->assertNoErrors($message, debug_backtrace()); - if ($test !== $test1) { - return true; - } - $this->_failTest(debug_backtrace(), $message); - echo "Unexpectedly two vars are the same thing: \n"; - echo "\n'$message'\n"; - return false; - } - - function assertFalse($test, $message) - { - $this->assertNoErrors($message, debug_backtrace()); - if ($test === false) { - return true; - } - $this->_failTest(debug_backtrace(), $message); - echo "Unexpected non-false value: \n"; - var_export($test); - echo "\n'$message'\n"; - return false; - } - - function assertNotTrue($test, $message) - { - $this->assertNoErrors($message, debug_backtrace()); - if (!$test) { - return true; - } - $this->_failTest(debug_backtrace(), $message); - echo "Unexpected loose true value: \n"; - var_export($test); - echo "\n'$message'\n"; - return false; - } - - function assertNotFalse($test, $message) - { - $this->assertNoErrors($message, debug_backtrace()); - if ($test) { - return true; - } - $this->_failTest(debug_backtrace(), $message); - echo "Unexpected loose false value: \n"; - var_export($test); - echo "\n'$message'\n"; - return false; - } - - function assertEquals($control, $test, $message) - { - $this->assertNoErrors($message, debug_backtrace()); - if (str_replace(array("\r", "\n"), array('', ''), - var_export($control, true)) != str_replace(array("\r", "\n"), array('', ''), - var_export($test, true))) { - $this->_failTest(debug_backtrace(), $message); - if (class_exists('Text_Diff')) { - echo "Diff of expecting/received:\n"; - $diff = &new Text_Diff( - explode("\n", var_export($control, true)), - explode("\n", var_export($test, true))); - - // Output the diff in unified format. - $renderer = &new Text_Diff_Renderer_unified(); - echo $renderer->render($diff); - if ($this->_diffonly) { - return false; - } - } - echo "Expecting:\n"; - var_export($control); - echo "\nReceived:\n"; - var_export($test); - return false; - } - return true; - } - - function assertFileExists($fname, $message) - { - $this->assertNoErrors($message, debug_backtrace()); - if (!@file_exists($fname)) { - $this->_failTest(debug_backtrace(), $message); - echo "File '$fname' does not exist, and should\n"; - return false; - } - return true; - } - - function assertFileNotExists($fname, $message) - { - $this->assertNoErrors($message, debug_backtrace()); - if (@file_exists($fname)) { - $this->_failTest(debug_backtrace(), $message); - echo "File '$fname' exists, and should not\n"; - return false; - } - return true; - } - - function assertRegEquals($dump, &$reg, $message) - { - $actualdump = var_export(trim($this->dumpReg($reg)), true); - $testdump = var_export(trim($dump), true); - return $this->assertEquals($testdump, $actualdump, $message); - } - - function assertPackageInfoEquals($control, $test, $message) - { - $this->assertNoErrors($message, debug_backtrace()); - if (isset($control[0])) { - if (!isset($test[0]) || (count($control) != count($test))) { - echo "Invalid packageInfo\n"; - $ret = $this->assertEquals($control, $test, $message); - } - $ret = true; - foreach ($control as $i => $packageinfo) { - $ret = $ret && - $this->assertPackageInfoEquals($packageinfo, $test[$i], $message . $i); - } - return $ret; - } - if (isset($control['_lastmodified'])) { - if (!isset($test['_lastmodified'])) { - echo "_lastmodified is not set in packageInfo() output\n"; - $this->_failTest(debug_backtrace(), $message); - return false; - } - } - $savecontrol = $control; - $savetest = $test; - unset($control['_lastmodified']); - unset($test['_lastmodified']); - if (var_export($control, true) != var_export($test, true)) { - $this->_failTest(debug_backtrace(), $message); - if (class_exists('Text_Diff')) { - echo "Diff of expecting/received:\n"; - $diff = &new Text_Diff( - explode("\n", var_export($control, true)), - explode("\n", var_export($test, true))); - - // Output the diff in unified format. - $renderer = &new Text_Diff_Renderer_unified(); - echo $renderer->render($diff); - if ($this->_diffonly) { - return false; - } - } - echo "Expecting:\n"; - var_export($savecontrol); - echo "\nReceived:\n"; - var_export($savetest); - return false; - } - return true; - } - - function dumpReg(&$reg) - { - ob_start(); - print "dumping registry...\n"; - $infos = $reg->packageInfo(null, null, null); - foreach ($infos as $channel => $info) { - echo "channel $channel:\n"; - foreach ($info as $pkg) { - print $pkg["name"] . ":"; - unset($pkg["name"]); - foreach ($pkg as $k => $v) { - if ($k == '_lastmodified') { - print " _lastmodified is set"; - continue; - } - if (is_array($v) && $k == 'filelist') { - print " $k=array("; - $i = 0; - foreach ($v as $k2 => $v2) { - if ($i++ > 0) print ","; - print "{$k2}["; - $j = 0; - foreach ($v2 as $k3 => $v3) { - if ($j++ > 0) print ","; - print "$k3=$v3"; - } - print "]"; - } - print ")"; - } else { - print " $k=\"$v\""; - } - } - print "\n"; - } - } - print "dump done\n"; - $ret = ob_get_contents(); - ob_end_clean(); - return $ret; - } - - function _failTest($trace, $message) - { - echo 'Test Failure: "' . $message . "\"\n in " . $trace[0]['file'] . ' line ' . - $trace[0]['line'] . "\n"; - } - - function showAll() - { - $this->_diffonly = false; - } -} -?> \ No newline at end of file diff --git a/tests/AbstractTest.php b/tests/AbstractTest.php new file mode 100644 index 0000000..114c55c --- /dev/null +++ b/tests/AbstractTest.php @@ -0,0 +1,4 @@ + $legacy_test) { + $out[] = [$filename, $legacy_test]; + } + + return $out; + } + + /** + * @dataProvider dataProvider_legacy_unit_tests + */ + public function test_legacy_unit_tests($filename, $parts) + { + $php_version = explode('.',phpversion()); + $php_version = $php_version[0] . '.' . $php_version[1]; + + $current_test_filename = __DIR__ . '/current_test.php'; + file_exists($current_test_filename) && unlink($current_test_filename); + file_put_contents($current_test_filename, $parts['FILE']); + $output = shell_exec("php$php_version $current_test_filename"); + + $this->assertEquals( + trim($parts['EXPECT']), + trim($output) + ); + + if (isset($parts['CLEAN'])) { + $current_clean_filename = __DIR__ . '/current_clean.php'; + file_put_contents($current_clean_filename, $parts['CLEAN']); + require_once $current_clean_filename; + unlink($current_clean_filename); + } + } + + /**/ +} diff --git a/test/bug10010.phpt b/tests/legacy/bug10010.phpt similarity index 100% rename from test/bug10010.phpt rename to tests/legacy/bug10010.phpt diff --git a/test/bug10185.phpt b/tests/legacy/bug10185.phpt similarity index 100% rename from test/bug10185.phpt rename to tests/legacy/bug10185.phpt diff --git a/test/bug11184.phpt b/tests/legacy/bug11184.phpt similarity index 100% rename from test/bug11184.phpt rename to tests/legacy/bug11184.phpt diff --git a/test/bug11435-inicommented.phpt b/tests/legacy/bug11435-inicommented.phpt similarity index 100% rename from test/bug11435-inicommented.phpt rename to tests/legacy/bug11435-inicommented.phpt diff --git a/test/bug11435-inifile.phpt b/tests/legacy/bug11435-inifile.phpt similarity index 100% rename from test/bug11435-inifile.phpt rename to tests/legacy/bug11435-inifile.phpt diff --git a/test/bug11435.ini b/tests/legacy/bug11435.ini similarity index 100% rename from test/bug11435.ini rename to tests/legacy/bug11435.ini diff --git a/test/bug11807.phpt b/tests/legacy/bug11807.phpt similarity index 93% rename from test/bug11807.phpt rename to tests/legacy/bug11807.phpt index 44db8d8..b6f3b0d 100644 --- a/test/bug11807.phpt +++ b/tests/legacy/bug11807.phpt @@ -27,7 +27,7 @@ print file_get_contents($path); ?> --CLEAN-- --EXPECT-- \ No newline at end of file +?> diff --git a/tests/legacy/bug11807.txt b/tests/legacy/bug11807.txt new file mode 100644 index 0000000..c0bf2db --- /dev/null +++ b/tests/legacy/bug11807.txt @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/test/bug11827.ini b/tests/legacy/bug11827.ini similarity index 100% rename from test/bug11827.ini rename to tests/legacy/bug11827.ini diff --git a/test/bug11827.phpt b/tests/legacy/bug11827.phpt similarity index 66% rename from test/bug11827.phpt rename to tests/legacy/bug11827.phpt index a14cced..f58151d 100644 --- a/test/bug11827.phpt +++ b/tests/legacy/bug11827.phpt @@ -5,12 +5,10 @@ regression test for bug #11827 require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc'; $datasrc = dirname(__FILE__) . '/bug11827.ini'; $root = $config->parseConfig($datasrc, 'inifile'); -var_dump($root->children[0]->children[0]->content); +var_export($root->children[0]->children[0]->content); ?> --EXPECT-- -array(2) { - [0]=> - string(6) "value1" - [1]=> - string(6) "value2" -} +array ( + 0 => 'value1', + 1 => 'value2', +) diff --git a/test/bug12291.ini b/tests/legacy/bug12291.ini similarity index 100% rename from test/bug12291.ini rename to tests/legacy/bug12291.ini diff --git a/test/bug12291.phpt b/tests/legacy/bug12291.phpt similarity index 69% rename from test/bug12291.phpt rename to tests/legacy/bug12291.phpt index 3edf905..1eb036d 100644 --- a/test/bug12291.phpt +++ b/tests/legacy/bug12291.phpt @@ -10,17 +10,14 @@ regression test for bug #12291: do not require space before newline require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc'; $datasrc = dirname(__FILE__) . '/bug12291.ini'; $root = $config->parseConfig($datasrc, 'genericconf'); -var_dump($root->toArray()); +var_export($root->toArray()); ?> --EXPECT-- -array(1) { - ["root"]=> - array(3) { - ["keyword"]=> - string(11) "foo,bar,baz" - ["keyword_with_space"]=> - string(13) "foo, bar, baz" - ["keyword_with_two_spaces"]=> - string(14) "foo, bar, baz" - } -} +array ( + 'root' => + array ( + 'keyword' => 'foo,bar,baz', + 'keyword_with_space' => 'foo, bar, baz', + 'keyword_with_two_spaces' => 'foo, bar, baz', + ), +) diff --git a/test/bug12387.ini b/tests/legacy/bug12387.ini similarity index 100% rename from test/bug12387.ini rename to tests/legacy/bug12387.ini diff --git a/test/bug12387.phpt b/tests/legacy/bug12387.phpt similarity index 70% rename from test/bug12387.phpt rename to tests/legacy/bug12387.phpt index 37f151e..b0fd895 100644 --- a/test/bug12387.phpt +++ b/tests/legacy/bug12387.phpt @@ -5,13 +5,12 @@ Test for request #12387: Allow hyphens in the key require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc'; $datasrc = dirname(__FILE__) . '/bug12387.ini'; $root = $config->parseConfig($datasrc, 'genericconf'); -var_dump($root->toArray()); +var_export($root->toArray()); ?> --EXPECT-- -array(1) { - ["root"]=> - array(1) { - ["hy-phen"]=> - string(5) "value" - } -} +array ( + 'root' => + array ( + 'hy-phen' => 'value', + ), +) diff --git a/test/bug12388.ini b/tests/legacy/bug12388.ini similarity index 100% rename from test/bug12388.ini rename to tests/legacy/bug12388.ini diff --git a/test/bug12388.phpt b/tests/legacy/bug12388.phpt similarity index 51% rename from test/bug12388.phpt rename to tests/legacy/bug12388.phpt index 7b91fb9..880fa89 100644 --- a/test/bug12388.phpt +++ b/tests/legacy/bug12388.phpt @@ -5,19 +5,15 @@ Test for request #12388: Allow spaces after the key require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc'; $datasrc = dirname(__FILE__) . '/bug12388.ini'; $root = $config->parseConfig($datasrc, 'genericconf'); -var_dump($root->toArray()); +var_export($root->toArray()); ?> --EXPECT-- -array(1) { - ["root"]=> - array(4) { - ["nospace"]=> - string(5) "value" - ["space_before"]=> - string(5) "value" - ["space_after"]=> - string(5) "value" - ["two_spaces_after"]=> - string(5) "value" - } -} +array ( + 'root' => + array ( + 'nospace' => 'value', + 'space_before' => 'value', + 'space_after' => 'value', + 'two_spaces_after' => 'value', + ), +) diff --git a/test/bug13791.phpt b/tests/legacy/bug13791.phpt similarity index 100% rename from test/bug13791.phpt rename to tests/legacy/bug13791.phpt diff --git a/test/bug16590-2.phpt b/tests/legacy/bug16590-2.phpt similarity index 100% rename from test/bug16590-2.phpt rename to tests/legacy/bug16590-2.phpt diff --git a/test/bug16590.phpt b/tests/legacy/bug16590.phpt similarity index 100% rename from test/bug16590.phpt rename to tests/legacy/bug16590.phpt diff --git a/test/bug16656.ini b/tests/legacy/bug16656.ini similarity index 100% rename from test/bug16656.ini rename to tests/legacy/bug16656.ini diff --git a/test/bug16656.phpt b/tests/legacy/bug16656.phpt similarity index 100% rename from test/bug16656.phpt rename to tests/legacy/bug16656.phpt diff --git a/test/bug16724-config.php b/tests/legacy/bug16724-config.php similarity index 100% rename from test/bug16724-config.php rename to tests/legacy/bug16724-config.php diff --git a/test/bug16724.phpt b/tests/legacy/bug16724.phpt similarity index 100% rename from test/bug16724.phpt rename to tests/legacy/bug16724.phpt diff --git a/test/bug18124.phpt b/tests/legacy/bug18124.phpt similarity index 100% rename from test/bug18124.phpt rename to tests/legacy/bug18124.phpt diff --git a/test/bug2742.ini b/tests/legacy/bug2742.ini similarity index 100% rename from test/bug2742.ini rename to tests/legacy/bug2742.ini diff --git a/test/bug2742.phpt b/tests/legacy/bug2742.phpt similarity index 100% rename from test/bug2742.phpt rename to tests/legacy/bug2742.phpt diff --git a/test/bug2780.phpt b/tests/legacy/bug2780.phpt similarity index 72% rename from test/bug2780.phpt rename to tests/legacy/bug2780.phpt index 3acfbc2..ac23a4d 100644 --- a/test/bug2780.phpt +++ b/tests/legacy/bug2780.phpt @@ -2,8 +2,7 @@ bug 2780 regression --FILE-- parseConfig($datasrc, 'inicommented'); $temp = $conf_obj->toArray(); $conf = $temp['root']; -var_dump($conf); +var_export($conf); ?> --EXPECT-- -array(8) { - ["val1"]=> - string(1) "1" - ["val2"]=> - string(0) "" - ["val3"]=> - string(1) "1" - ["val4"]=> - string(0) "" - ["val5"]=> - string(1) "1" - ["val6"]=> - string(0) "" - ["val7"]=> - string(4) "true" - ["val8"]=> - string(5) "false" -} +array ( + 'val1' => '1', + 'val2' => '', + 'val3' => '1', + 'val4' => '', + 'val5' => '1', + 'val6' => '', + 'val7' => 'true', + 'val8' => 'false', +) diff --git a/test/bug7544-inicommented.phpt b/tests/legacy/bug7544-inicommented.phpt similarity index 100% rename from test/bug7544-inicommented.phpt rename to tests/legacy/bug7544-inicommented.phpt diff --git a/test/bug7544-inifile.phpt b/tests/legacy/bug7544-inifile.phpt similarity index 100% rename from test/bug7544-inifile.phpt rename to tests/legacy/bug7544-inifile.phpt diff --git a/test/bug7544.ini b/tests/legacy/bug7544.ini similarity index 100% rename from test/bug7544.ini rename to tests/legacy/bug7544.ini diff --git a/test/bug7652.phpt b/tests/legacy/bug7652.phpt similarity index 100% rename from test/bug7652.phpt rename to tests/legacy/bug7652.phpt diff --git a/test/bug7652.xml b/tests/legacy/bug7652.xml similarity index 100% rename from test/bug7652.xml rename to tests/legacy/bug7652.xml diff --git a/test/bug8357-inicommented.phpt b/tests/legacy/bug8357-inicommented.phpt similarity index 100% rename from test/bug8357-inicommented.phpt rename to tests/legacy/bug8357-inicommented.phpt diff --git a/test/bug8357-inifile.phpt b/tests/legacy/bug8357-inifile.phpt similarity index 100% rename from test/bug8357-inifile.phpt rename to tests/legacy/bug8357-inifile.phpt diff --git a/test/bug8357.ini b/tests/legacy/bug8357.ini similarity index 100% rename from test/bug8357.ini rename to tests/legacy/bug8357.ini diff --git a/tests/legacy/current_test.php b/tests/legacy/current_test.php new file mode 100644 index 0000000..78a037a --- /dev/null +++ b/tests/legacy/current_test.php @@ -0,0 +1,24 @@ +getRoot()->createDirective('STRING', 'this is a string'); +$config->getRoot()->createDirective('STRING_WITH_QUOTES', 'double: " single:\' end'); +$config->getRoot()->createDirective('NUMBER', 12345); +$config->getRoot()->createDirective('NUMERIC_STRING', '67890'); +$config->getRoot()->createDirective('CONSTANT_NAME', 'NUMERIC_STRING'); +$config->getRoot()->createDirective('TRUE', true); +$config->getRoot()->createDirective('FALSE', false); +$config->getRoot()->createDirective('TRUE_STRING', 'true'); +$config->getRoot()->createDirective('FALSE_STRING', 'false'); +$config->getRoot()->createDirective('lowercase_name', 'gets uppercased'); + +$config->getRoot()->createBlank(); +$config->getRoot()->createDirective('AFTER_BLANK', '1'); + +$config->getRoot()->createSection('Comments'); + +$config->getRoot()->createComment('Some comment'); +$config->getRoot()->createDirective('AFTER_COMMENT', '1'); + +echo $config->getRoot()->toString('phpconstants'); +?> \ No newline at end of file diff --git a/test/inifile.ini b/tests/legacy/inifile.ini similarity index 100% rename from test/inifile.ini rename to tests/legacy/inifile.ini diff --git a/test/inifile.phpt b/tests/legacy/inifile.phpt similarity index 100% rename from test/inifile.phpt rename to tests/legacy/inifile.phpt diff --git a/test/phpconstants.phpt b/tests/legacy/phpconstants.phpt similarity index 100% rename from test/phpconstants.phpt rename to tests/legacy/phpconstants.phpt diff --git a/test/setup.php.inc b/tests/legacy/setup.php.inc similarity index 63% rename from test/setup.php.inc rename to tests/legacy/setup.php.inc index 1c82501..6b0afd2 100644 --- a/test/setup.php.inc +++ b/tests/legacy/setup.php.inc @@ -1,6 +1,5 @@