Browse Source

Method "execute()" added to Mongo Database.

tags/2.0.0-beta
Paul Klimov 11 years ago
parent
commit
10bdd6b858
  1. 11
      extensions/mongo/Database.php
  2. 12
      tests/unit/extensions/mongo/DatabaseTest.php

11
extensions/mongo/Database.php

@ -75,4 +75,15 @@ class Database extends Object
{
return $this->mongoDb->createCollection($name, $options);
}
/**
* Executes Mongo command.
* @param array $command command specification.
* @param array $options options in format: "name" => "value"
* @return array database response.
*/
public function execute($command, $options = [])
{
return $this->mongoDb->command($command, $options);
}
}

12
tests/unit/extensions/mongo/DatabaseTest.php

@ -31,4 +31,16 @@ class DatabaseTest extends MongoTestCase
$collectionRefreshed = $database->getCollection('customer', true);
$this->assertFalse($collection === $collectionRefreshed);
}
public function testCommand()
{
$database = $connection = $this->getConnection()->getDatabase();
$result = $database->execute([
'distinct' => 'customer',
'key' => 'name'
]);
$this->assertTrue(array_key_exists('ok', $result));
$this->assertTrue(array_key_exists('values', $result));
}
}
Loading…
Cancel
Save