From 9cdf6f9953e5d0d277d0d49b41e2694b73e99baf Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 6 Oct 2022 13:28:50 +0300 Subject: [PATCH] some tests find by id --- tests/MongoTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/MongoTest.php b/tests/MongoTest.php index cd5fc428eb..7fd60ec22b 100644 --- a/tests/MongoTest.php +++ b/tests/MongoTest.php @@ -2,6 +2,7 @@ namespace Utopia\Tests; +use MongoDB\BSON\ObjectId; use PHPUnit\Framework\TestCase; use Utopia\Database\Query; use Utopia\Mongo\MongoClient; @@ -59,9 +60,10 @@ class MongoTest extends TestCase self::assertEquals(24, strlen($id)); $doc = $this->getDatabase()->find('movies', ['name' => 'Armageddon'])->cursor->firstBatch ?? []; - //todo:make this work search by id - //$doc = $this->getDatabase()->find('movies', ['_id' => 'ObjectId("'.$id.'") '])->cursor->firstBatch ?? []; + self::assertCount(1, $doc); + $doc = $this->getDatabase()->find('movies', ['_id' => new ObjectId($id)])->cursor->firstBatch ?? []; + self::assertCount(1, $doc); $doc = $this->getDatabase()->insert('movies', ['9 Monkeys']); $id = (string)$doc['_id'];