1
0
Fork 0

Fix indenting detection in JsonManipulator, fixes #1788

pull/1789/head
Jordi Boggiano 2013-04-11 10:34:26 +02:00
parent c1ff6ea62b
commit 3d953384fa
2 changed files with 18 additions and 18 deletions

View File

@ -283,7 +283,7 @@ class JsonManipulator
protected function detectIndenting()
{
if (preg_match('{^(\s+)"}', $this->contents, $match)) {
if (preg_match('{^(\s+)"}m', $this->contents, $match)) {
$this->indent = $match[1];
} else {
$this->indent = ' ';

View File

@ -328,20 +328,20 @@ class JsonManipulatorTest extends \PHPUnit_Framework_TestCase
public function testAddRepositoryCanInitializeFromScratch()
{
$manipulator = new JsonManipulator('{
"a": "b"
}');
$manipulator = new JsonManipulator("{
\t\"a\": \"b\"
}");
$this->assertTrue($manipulator->addRepository('bar2', array('type' => 'composer')));
$this->assertEquals('{
"a": "b",
"repositories": {
"bar2": {
"type": "composer"
}
}
$this->assertEquals("{
\t\"a\": \"b\",
\t\"repositories\": {
\t\t\"bar2\": {
\t\t\t\"type\": \"composer\"
\t\t}
\t}
}
', $manipulator->getContents());
", $manipulator->getContents());
}
public function testAddRepositoryCanAdd()