Skip to content

Commit

Permalink
Properly set the document
Browse files Browse the repository at this point in the history
  • Loading branch information
kschroeder committed Dec 30, 2017
1 parent 98cf0c9 commit 7ba49c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/Config/Storage/Mongo.php
Expand Up @@ -31,10 +31,13 @@ public function getValue($path, $context = ConfigurationRepository::CONTEXT_DEFA
]);
$paths = explode('/', $path);
if ($document === null) {
$document = [];
$document = [
'context' => $context,
'document'=> []
];
}
if (isset($document[$paths[0]][$paths[1]][$paths[2]])) {
return $document[$paths[0]][$paths[1]][$paths[2]];
if (isset($document['document'][$paths[0]][$paths[1]][$paths[2]])) {
return $document['document'][$paths[0]][$paths[1]][$paths[2]];
}
return null;
}
Expand Down
5 changes: 4 additions & 1 deletion tests/Storage/MongoTest.php
@@ -1,6 +1,7 @@
<?php

namespace Magium\Configuration\Tests\Storage;

use Magium\Configuration\Config\Repository\ConfigInterface;
use Magium\Configuration\Config\Storage\Mongo;
use MongoDB\BSON\ObjectId;
Expand Down Expand Up @@ -35,7 +36,9 @@ public function testGetOnDocumentReturnsValue()
{
$storageDocument = new BSONDocument([
'_id' => new ObjectId(),
'a' => ['b' => ['c' => 'test']]
'document' => [
'a' => ['b' => ['c' => 'test']]
]
]);
$collection = $this->getMockBuilder(Collection::class)->disableOriginalConstructor()
->setMethods(['findOne', 'insertOne'])->getMock();
Expand Down

0 comments on commit 7ba49c3

Please sign in to comment.