diff --git a/src/Operation/Count.php b/src/Operation/Count.php index c989761cb..fe43eb6de 100644 --- a/src/Operation/Count.php +++ b/src/Operation/Count.php @@ -85,7 +85,7 @@ public function __construct($databaseName, $collectionName, array $filter = arra public function execute(Server $server) { $cursor = $server->executeCommand($this->databaseName, $this->createCommand()); - $cursor->setTypeMap(array('document' => 'array')); + $cursor->setTypeMap(array('root' => 'array', 'document' => 'array')); $result = current($cursor->toArray()); if (empty($result['ok'])) { diff --git a/src/Operation/CreateIndexes.php b/src/Operation/CreateIndexes.php index 9d4b708a4..98237bbd0 100644 --- a/src/Operation/CreateIndexes.php +++ b/src/Operation/CreateIndexes.php @@ -91,7 +91,7 @@ private function executeCommand(Server $server) )); $cursor = $server->executeCommand($this->databaseName, $command); - $cursor->setTypeMap(array('document' => 'array')); + $cursor->setTypeMap(array('root' => 'array', 'document' => 'array')); $result = current($cursor->toArray()); if (empty($result['ok'])) { diff --git a/src/Operation/ListCollections.php b/src/Operation/ListCollections.php index 40a2b3cb6..1aa6fc665 100644 --- a/src/Operation/ListCollections.php +++ b/src/Operation/ListCollections.php @@ -85,7 +85,7 @@ private function executeCommand(Server $server) } $cursor = $server->executeCommand($this->databaseName, new Command($cmd)); - $cursor->setTypeMap(array('document' => 'array')); + $cursor->setTypeMap(array('root' => 'array', 'document' => 'array')); return new CollectionInfoCommandIterator($cursor); } @@ -115,7 +115,7 @@ private function executeLegacy(Server $server) : array(); $cursor = $server->executeQuery($this->databaseName . '.system.namespaces', new Query($filter, $options)); - $cursor->setTypeMap(array('document' => 'array')); + $cursor->setTypeMap(array('root' => 'array', 'document' => 'array')); return new CollectionInfoLegacyIterator($cursor); } diff --git a/src/Operation/ListDatabases.php b/src/Operation/ListDatabases.php index 1f9f200ed..e4189d4ff 100644 --- a/src/Operation/ListDatabases.php +++ b/src/Operation/ListDatabases.php @@ -55,7 +55,7 @@ public function execute(Server $server) } $cursor = $server->executeCommand('admin', new Command($cmd)); - $cursor->setTypeMap(array('document' => 'array')); + $cursor->setTypeMap(array('root' => 'array', 'document' => 'array')); $result = current($cursor->toArray()); if (empty($result['ok'])) { diff --git a/src/Operation/ListIndexes.php b/src/Operation/ListIndexes.php index 1e223a010..e682d2189 100644 --- a/src/Operation/ListIndexes.php +++ b/src/Operation/ListIndexes.php @@ -76,7 +76,7 @@ private function executeCommand(Server $server) } $cursor = $server->executeCommand($this->databaseName, new Command($cmd)); - $cursor->setTypeMap(array('document' => 'array')); + $cursor->setTypeMap(array('root' => 'array', 'document' => 'array')); return new IndexInfoIteratorIterator($cursor); } @@ -97,7 +97,7 @@ private function executeLegacy(Server $server) : array(); $cursor = $server->executeQuery($this->databaseName . '.system.indexes', new Query($filter, $options)); - $cursor->setTypeMap(array('document' => 'array')); + $cursor->setTypeMap(array('root' => 'array', 'document' => 'array')); return new IndexInfoIteratorIterator($cursor); } diff --git a/tests/Collection/CollectionFunctionalTest.php b/tests/Collection/CollectionFunctionalTest.php index 4e1b5141d..3fe5c20ce 100644 --- a/tests/Collection/CollectionFunctionalTest.php +++ b/tests/Collection/CollectionFunctionalTest.php @@ -29,9 +29,9 @@ public function testFindOne() 'sort' => array('x' => -1), ); - $expected = array('_id' => 3, 'x' => 33); + $expected = (object) array('_id' => 3, 'x' => 33); - $this->assertSame($expected, $this->collection->findOne($filter, $options)); + $this->assertEquals($expected, $this->collection->findOne($filter, $options)); } /** diff --git a/tests/FunctionalTestCase.php b/tests/FunctionalTestCase.php index 18a897885..3ab948bc2 100644 --- a/tests/FunctionalTestCase.php +++ b/tests/FunctionalTestCase.php @@ -23,7 +23,7 @@ protected function assertCollectionCount($namespace, $count) list($databaseName, $collectionName) = explode('.', $namespace, 2); $cursor = $this->manager->executeCommand($databaseName, new Command(array('count' => $collectionName))); - $cursor->setTypeMap(array('document' => 'array')); + $cursor->setTypeMap(array('root' => 'array', 'document' => 'array')); $document = current($cursor->toArray()); $this->assertArrayHasKey('n', $document); @@ -76,7 +76,7 @@ protected function getServerVersion(ReadPreference $readPreference = null) $readPreference ?: new ReadPreference(ReadPreference::RP_PRIMARY) ); - $cursor->setTypeMap(array('document' => 'array')); + $cursor->setTypeMap(array('root' => 'array', 'document' => 'array')); $document = current($cursor->toArray()); return $document['version'];