Commit f3e9e1e9 authored by Derick Rethans's avatar Derick Rethans Committed by Jeremy Mikola

PHPLIB-118: Specify "root" option in typemap, as it's separate from "document"

parent ab3f0510
...@@ -85,7 +85,7 @@ class Count implements Executable ...@@ -85,7 +85,7 @@ class Count implements Executable
public function execute(Server $server) public function execute(Server $server)
{ {
$cursor = $server->executeCommand($this->databaseName, $this->createCommand()); $cursor = $server->executeCommand($this->databaseName, $this->createCommand());
$cursor->setTypeMap(array('document' => 'array')); $cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
$result = current($cursor->toArray()); $result = current($cursor->toArray());
if (empty($result['ok'])) { if (empty($result['ok'])) {
......
...@@ -91,7 +91,7 @@ class CreateIndexes implements Executable ...@@ -91,7 +91,7 @@ class CreateIndexes implements Executable
)); ));
$cursor = $server->executeCommand($this->databaseName, $command); $cursor = $server->executeCommand($this->databaseName, $command);
$cursor->setTypeMap(array('document' => 'array')); $cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
$result = current($cursor->toArray()); $result = current($cursor->toArray());
if (empty($result['ok'])) { if (empty($result['ok'])) {
......
...@@ -85,7 +85,7 @@ class ListCollections implements Executable ...@@ -85,7 +85,7 @@ class ListCollections implements Executable
} }
$cursor = $server->executeCommand($this->databaseName, new Command($cmd)); $cursor = $server->executeCommand($this->databaseName, new Command($cmd));
$cursor->setTypeMap(array('document' => 'array')); $cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
return new CollectionInfoCommandIterator($cursor); return new CollectionInfoCommandIterator($cursor);
} }
...@@ -115,7 +115,7 @@ class ListCollections implements Executable ...@@ -115,7 +115,7 @@ class ListCollections implements Executable
: array(); : array();
$cursor = $server->executeQuery($this->databaseName . '.system.namespaces', new Query($filter, $options)); $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); return new CollectionInfoLegacyIterator($cursor);
} }
......
...@@ -55,7 +55,7 @@ class ListDatabases implements Executable ...@@ -55,7 +55,7 @@ class ListDatabases implements Executable
} }
$cursor = $server->executeCommand('admin', new Command($cmd)); $cursor = $server->executeCommand('admin', new Command($cmd));
$cursor->setTypeMap(array('document' => 'array')); $cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
$result = current($cursor->toArray()); $result = current($cursor->toArray());
if (empty($result['ok'])) { if (empty($result['ok'])) {
......
...@@ -76,7 +76,7 @@ class ListIndexes implements Executable ...@@ -76,7 +76,7 @@ class ListIndexes implements Executable
} }
$cursor = $server->executeCommand($this->databaseName, new Command($cmd)); $cursor = $server->executeCommand($this->databaseName, new Command($cmd));
$cursor->setTypeMap(array('document' => 'array')); $cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
return new IndexInfoIteratorIterator($cursor); return new IndexInfoIteratorIterator($cursor);
} }
...@@ -97,7 +97,7 @@ class ListIndexes implements Executable ...@@ -97,7 +97,7 @@ class ListIndexes implements Executable
: array(); : array();
$cursor = $server->executeQuery($this->databaseName . '.system.indexes', new Query($filter, $options)); $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); return new IndexInfoIteratorIterator($cursor);
} }
......
...@@ -23,7 +23,7 @@ abstract class FunctionalTestCase extends TestCase ...@@ -23,7 +23,7 @@ abstract class FunctionalTestCase extends TestCase
list($databaseName, $collectionName) = explode('.', $namespace, 2); list($databaseName, $collectionName) = explode('.', $namespace, 2);
$cursor = $this->manager->executeCommand($databaseName, new Command(array('count' => $collectionName))); $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()); $document = current($cursor->toArray());
$this->assertArrayHasKey('n', $document); $this->assertArrayHasKey('n', $document);
...@@ -76,7 +76,7 @@ abstract class FunctionalTestCase extends TestCase ...@@ -76,7 +76,7 @@ abstract class FunctionalTestCase extends TestCase
$readPreference ?: new ReadPreference(ReadPreference::RP_PRIMARY) $readPreference ?: new ReadPreference(ReadPreference::RP_PRIMARY)
); );
$cursor->setTypeMap(array('document' => 'array')); $cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
$document = current($cursor->toArray()); $document = current($cursor->toArray());
return $document['version']; return $document['version'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment