1
0
Fork 0

Fix regression in handling github-oauth settings in auth.json

pull/3025/head
Jordi Boggiano 2014-05-27 16:26:24 +02:00
parent 2ed0bfc1ba
commit 7131607ad1
2 changed files with 20 additions and 2 deletions

View File

@ -125,7 +125,7 @@ class JsonManipulator
} }
$subName = null; $subName = null;
if (false !== strpos($name, '.')) { if (in_array($mainNode, array('config', 'repositories')) && false !== strpos($name, '.')) {
list($name, $subName) = explode('.', $name, 2); list($name, $subName) = explode('.', $name, 2);
} }
@ -203,7 +203,7 @@ class JsonManipulator
} }
$subName = null; $subName = null;
if (false !== strpos($name, '.')) { if (in_array($mainNode, array('config', 'repositories')) && false !== strpos($name, '.')) {
list($name, $subName) = explode('.', $name, 2); list($name, $subName) = explode('.', $name, 2);
} }

View File

@ -735,6 +735,24 @@ class JsonManipulatorTest extends \PHPUnit_Framework_TestCase
', $manipulator->getContents()); ', $manipulator->getContents());
} }
public function testAddRootSettingDoesNotBreakDots()
{
$manipulator = new JsonManipulator('{
"github-oauth": {
"github.com": "foo"
}
}');
$this->assertTrue($manipulator->addSubNode('github-oauth', 'bar', 'baz'));
$this->assertEquals('{
"github-oauth": {
"github.com": "foo",
"bar": "baz"
}
}
', $manipulator->getContents());
}
public function testRemoveConfigSettingCanRemoveSubKeyInHash() public function testRemoveConfigSettingCanRemoveSubKeyInHash()
{ {
$manipulator = new JsonManipulator('{ $manipulator = new JsonManipulator('{