|
18 | 18 | use MongoDB\BSON\Regex;
|
19 | 19 | use MongoDB\BSON\UTCDateTime;
|
20 | 20 | use MongoDB\Collection;
|
| 21 | +use MongoDB\Driver\Cursor; |
21 | 22 | use MongoDB\Driver\Monitoring\CommandFailedEvent;
|
22 | 23 | use MongoDB\Driver\Monitoring\CommandStartedEvent;
|
23 | 24 | use MongoDB\Driver\Monitoring\CommandSubscriber;
|
@@ -313,16 +314,12 @@ public function testRaw()
|
313 | 314 | ['name' => 'John Doe', 'age' => 25],
|
314 | 315 | ]);
|
315 | 316 |
|
316 |
| - $results = DB::table('users')->raw(function ($collection) { |
317 |
| - return $collection->find(['age' => 20], ['typeMap' => ['root' => 'array', 'document' => 'array']]); |
| 317 | + $cursor = DB::table('users')->raw(function ($collection) { |
| 318 | + return $collection->find(['age' => 20]); |
318 | 319 | });
|
319 | 320 |
|
320 |
| - $this->assertIsArray($results); |
321 |
| - $this->assertCount(1, $results); |
322 |
| - $this->assertArrayNotHasKey('_id', $results[0]); |
323 |
| - $this->assertArrayHasKey('id', $results[0]); |
324 |
| - $this->assertInstanceOf(ObjectId::class, $results[0]['id']); |
325 |
| - $this->assertSame(20, $results[0]['age']); |
| 321 | + $this->assertInstanceOf(Cursor::class, $cursor); |
| 322 | + $this->assertCount(1, $cursor->toArray()); |
326 | 323 |
|
327 | 324 | $collection = DB::table('users')->raw();
|
328 | 325 | $this->assertInstanceOf(Collection::class, $collection);
|
|
0 commit comments