Fix indenting detection in JsonManipulator, fixes #1788
parent
c1ff6ea62b
commit
3d953384fa
|
@ -283,7 +283,7 @@ class JsonManipulator
|
||||||
|
|
||||||
protected function detectIndenting()
|
protected function detectIndenting()
|
||||||
{
|
{
|
||||||
if (preg_match('{^(\s+)"}', $this->contents, $match)) {
|
if (preg_match('{^(\s+)"}m', $this->contents, $match)) {
|
||||||
$this->indent = $match[1];
|
$this->indent = $match[1];
|
||||||
} else {
|
} else {
|
||||||
$this->indent = ' ';
|
$this->indent = ' ';
|
||||||
|
|
|
@ -311,37 +311,37 @@ class JsonManipulatorTest extends \PHPUnit_Framework_TestCase
|
||||||
public function testAddRepositoryCanInitializeEmptyRepositories()
|
public function testAddRepositoryCanInitializeEmptyRepositories()
|
||||||
{
|
{
|
||||||
$manipulator = new JsonManipulator('{
|
$manipulator = new JsonManipulator('{
|
||||||
"repositories": {
|
"repositories": {
|
||||||
}
|
}
|
||||||
}');
|
}');
|
||||||
|
|
||||||
$this->assertTrue($manipulator->addRepository('bar', array('type' => 'composer')));
|
$this->assertTrue($manipulator->addRepository('bar', array('type' => 'composer')));
|
||||||
$this->assertEquals('{
|
$this->assertEquals('{
|
||||||
"repositories": {
|
"repositories": {
|
||||||
"bar": {
|
"bar": {
|
||||||
"type": "composer"
|
"type": "composer"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
', $manipulator->getContents());
|
', $manipulator->getContents());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddRepositoryCanInitializeFromScratch()
|
public function testAddRepositoryCanInitializeFromScratch()
|
||||||
{
|
{
|
||||||
$manipulator = new JsonManipulator('{
|
$manipulator = new JsonManipulator("{
|
||||||
"a": "b"
|
\t\"a\": \"b\"
|
||||||
}');
|
}");
|
||||||
|
|
||||||
$this->assertTrue($manipulator->addRepository('bar2', array('type' => 'composer')));
|
$this->assertTrue($manipulator->addRepository('bar2', array('type' => 'composer')));
|
||||||
$this->assertEquals('{
|
$this->assertEquals("{
|
||||||
"a": "b",
|
\t\"a\": \"b\",
|
||||||
"repositories": {
|
\t\"repositories\": {
|
||||||
"bar2": {
|
\t\t\"bar2\": {
|
||||||
"type": "composer"
|
\t\t\t\"type\": \"composer\"
|
||||||
}
|
\t\t}
|
||||||
}
|
\t}
|
||||||
}
|
}
|
||||||
', $manipulator->getContents());
|
", $manipulator->getContents());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddRepositoryCanAdd()
|
public function testAddRepositoryCanAdd()
|
||||||
|
|
Loading…
Reference in New Issue