mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
Support to read ini files without section in IniReader.
This commit is contained in:
parent
c970770c8d
commit
55c557d5a1
3 changed files with 24 additions and 1 deletions
|
@ -77,7 +77,12 @@ class IniReader implements ConfigReaderInterface {
|
|||
} else {
|
||||
$values = array();
|
||||
foreach ($contents as $section => $attribs) {
|
||||
if (is_array($attribs)) {
|
||||
$values[$section] = $this->_parseNestedValues($attribs);
|
||||
} else {
|
||||
$parse = $this->_parseNestedValues(array($attribs));
|
||||
$values[$section] = array_shift($parse);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $values;
|
||||
|
|
|
@ -64,6 +64,22 @@ class IniReaderTest extends CakeTestCase {
|
|||
$this->assertEquals('administrators', $config['groups']);
|
||||
}
|
||||
|
||||
/**
|
||||
* test without section
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testReadingWithoutSection() {
|
||||
$reader = new IniReader($this->path);
|
||||
$config = $reader->read('no_section.ini');
|
||||
|
||||
$expected = array(
|
||||
'some_key' => 'some_value',
|
||||
'bool_key' => true
|
||||
);
|
||||
$this->assertEquals($config, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that names with .'s get exploded into arrays.
|
||||
*
|
||||
|
|
2
cake/tests/test_app/config/no_section.ini
Normal file
2
cake/tests/test_app/config/no_section.ini
Normal file
|
@ -0,0 +1,2 @@
|
|||
some_key = some_value
|
||||
bool_key = 1
|
Loading…
Add table
Reference in a new issue