Fix key and value sanitazion in ini writer

This commit is contained in:
Matthias Jentsch 2015-06-08 13:10:21 +02:00
parent ddba1d86fa
commit 3600e1088c
2 changed files with 29 additions and 1 deletions

View File

@ -620,6 +620,6 @@ class IniEditor
private function sanitize($value)
{
return str_replace('\n', '', $value);
return str_replace("\n", '', $value);
}
}

View File

@ -719,6 +719,34 @@ EOD;
);
}
public function testWhetherLinebreaksAreRemoved()
{
$target = $this->writeConfigToTemporaryFile('');
$writer = new IniWriter(
array(
'config' => Config::fromArray(
array(
'section' => array(
'foo' => 'linebreak
in line',
'linebreak
inkey' => 'blarg'
)
)
),
'filename' => $target
)
);
$rendered = $writer->render();
var_dump($rendered);
$this->assertEquals(
count(explode("\n", $rendered)),
4,
'generated config should not contain more than three line breaks'
);
}
/**
* Write a INI-configuration string to a temporary file and return its path
*