some tests find by id

This commit is contained in:
fogelito committed 2022-10-06 13:28:50 +03:00
1 parent 94e2e5e71c
commit 9cdf6f9953
1 file changed
+4 -2
+4 -2
View File
@@ -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'];