Skip to content

Commit

Permalink
add unit test for constants in .ini values
Browse files Browse the repository at this point in the history
This currently fails in 3.0.0 and passes in 2.0.13
  • Loading branch information
zytzagoo committed Aug 3, 2016
1 parent 5372ac7 commit cb5af1f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/_data/config/config-with-constants.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; this is an INI file
test = TEST_CONST
path = TEST_CONST"/something/else"
[section]
test = TEST_CONST
path = TEST_CONST"/another-thing/somewhere"
parent.property = TEST_CONST
parent.property2 = TEST_CONST"hello"
32 changes: 32 additions & 0 deletions tests/unit/Config/Adapter/IniTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,38 @@
*/
class IniTest extends ConfigBase
{
/**
* Tests constants in option values
* @author zytzagoo
* @since 2016-08-03
*/
public function testConstants()
{
$this->specify(
"Constants in option values are not parsed properly",
function () {
define('TEST_CONST', 'foo');

$expected = [
'test' => 'foo',
'path' => 'foo/something/else',
'section' => [
'test' => 'foo',
'path' => 'foo/another-thing/somewhere',
'parent' => [
'property' => 'foo',
'property2' =>'foohello'
]
]
];

$config = new Ini(PATH_DATA . 'config/config-with-constants.ini');

expect($config->toArray())->equals($expected);
}
);
}

/**
* Tests toArray method
*
Expand Down

0 comments on commit cb5af1f

Please sign in to comment.