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

main
Jordi Boggiano 10 years ago
parent 2ed0bfc1ba
commit 7131607ad1

@ -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);
} }

@ -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('{

Loading…
Cancel
Save