diff --git a/src/MongoClient.php b/src/MongoClient.php index 530a4ca5b4..1c1426983d 100644 --- a/src/MongoClient.php +++ b/src/MongoClient.php @@ -123,7 +123,6 @@ class MongoClient public function send(mixed $data): stdClass|array|int { $this->client->send($data); - return $this->receive(); } @@ -282,6 +281,7 @@ class MongoClient */ public function listCollectionNames(array $filter = [], array $options = []): stdClass { + $qry = array_merge( [ "listCollections" => 1.0, diff --git a/tests/MongoTest.php b/tests/MongoTest.php index a8cfc6ed6c..96abb6522a 100644 --- a/tests/MongoTest.php +++ b/tests/MongoTest.php @@ -25,43 +25,43 @@ class MongoTest extends TestCase ); $client = new MongoClient($options, false); + $client->connect(); + self::$db = $client; return self::$db; } - public function testListDatabases() - { - $this->getDatabase()->listDatabaseNames(); - } - public function testDeleteDatabase() { - $this->getDatabase()->dropDatabase([]); + self::assertTrue(!!$this->getDatabase()->dropDatabase([])); } public function testCreateCollection() { - $this->getDatabase()->createCollection('movies'); + self::assertTrue(!!$this->getDatabase()->createCollection('movies')); + } + + public function testListDatabases() + { + self::assertCount(4, $this->getDatabase()->listDatabaseNames()->databases); } public function testCreateDocument() { - $this->getDatabase()->insert('movies', [ + $doc = $this->getDatabase()->insert('movies', [ 'name' => 'Armageddon', 'country' => 'USA', 'language' => 'English' ] ); + var_dump($doc['_id']); + $this->getDatabase()->insert('movies', ['9 Monkeys']); } - public function testCreateExistsDelete() - { - var_dump($this->getDatabase()->selectDatabase()); - } }