Skip to content

Commit 3d95338

Browse files
committedApr 11, 2013
Fix indenting detection in JsonManipulator, fixes composer#1788
1 parent c1ff6ea commit 3d95338

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed
 

‎src/Composer/Json/JsonManipulator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public function format($data, $depth = 0)
283283

284284
protected function detectIndenting()
285285
{
286-
if (preg_match('{^(\s+)"}', $this->contents, $match)) {
286+
if (preg_match('{^(\s+)"}m', $this->contents, $match)) {
287287
$this->indent = $match[1];
288288
} else {
289289
$this->indent = ' ';

‎tests/Composer/Test/Json/JsonManipulatorTest.php

+17-17
Original file line numberDiff line numberDiff line change
@@ -311,37 +311,37 @@ public function removeSubNodeProvider()
311311
public function testAddRepositoryCanInitializeEmptyRepositories()
312312
{
313313
$manipulator = new JsonManipulator('{
314-
"repositories": {
315-
}
314+
"repositories": {
315+
}
316316
}');
317317

318318
$this->assertTrue($manipulator->addRepository('bar', array('type' => 'composer')));
319319
$this->assertEquals('{
320-
"repositories": {
321-
"bar": {
322-
"type": "composer"
323-
}
320+
"repositories": {
321+
"bar": {
322+
"type": "composer"
324323
}
324+
}
325325
}
326326
', $manipulator->getContents());
327327
}
328328

329329
public function testAddRepositoryCanInitializeFromScratch()
330330
{
331-
$manipulator = new JsonManipulator('{
332-
"a": "b"
333-
}');
331+
$manipulator = new JsonManipulator("{
332+
\t\"a\": \"b\"
333+
}");
334334

335335
$this->assertTrue($manipulator->addRepository('bar2', array('type' => 'composer')));
336-
$this->assertEquals('{
337-
"a": "b",
338-
"repositories": {
339-
"bar2": {
340-
"type": "composer"
341-
}
342-
}
336+
$this->assertEquals("{
337+
\t\"a\": \"b\",
338+
\t\"repositories\": {
339+
\t\t\"bar2\": {
340+
\t\t\t\"type\": \"composer\"
341+
\t\t}
342+
\t}
343343
}
344-
', $manipulator->getContents());
344+
", $manipulator->getContents());
345345
}
346346

347347
public function testAddRepositoryCanAdd()

0 commit comments

Comments
 (0)
Please sign in to comment.