1
1
<?php
2
- require_once ('tests/app.php ' );
3
2
4
3
use Illuminate \Support \Facades \DB ;
5
4
@@ -56,7 +55,7 @@ public function testInsert()
56
55
$ this ->assertTrue (is_array ($ user ['tags ' ]));
57
56
}
58
57
59
- public function testInsertGetId ()
58
+ public function testInsertGetId ()
60
59
{
61
60
$ id = DB ::collection ('users ' )->insertGetId (array ('name ' => 'John Doe ' ));
62
61
@@ -69,7 +68,7 @@ public function testBatchInsert()
69
68
DB ::collection ('users ' )->insert (array (
70
69
array (
71
70
'tags ' => array ('tag1 ' , 'tag2 ' ),
72
- 'name ' => 'Jane Doe ' ,
71
+ 'name ' => 'Jane Doe ' ,
73
72
),
74
73
array (
75
74
'tags ' => array ('tag3 ' ),
@@ -93,6 +92,12 @@ public function testFind()
93
92
$ this ->assertEquals ('John Doe ' , $ user ['name ' ]);
94
93
}
95
94
95
+ public function testFindNull ()
96
+ {
97
+ $ user = DB ::collection ('users ' )->find (null );
98
+ $ this ->assertEquals (null , $ user );
99
+ }
100
+
96
101
public function testCount ()
97
102
{
98
103
DB ::collection ('users ' )->insert (array (
@@ -201,14 +206,14 @@ public function testPush()
201
206
));
202
207
203
208
DB ::collection ('users ' )->where ('_id ' , $ id )->push ('tags ' , 'tag1 ' );
204
-
209
+
205
210
$ user = DB ::collection ('users ' )->find ($ id );
206
211
$ this ->assertTrue (is_array ($ user ['tags ' ]));
207
212
$ this ->assertEquals (1 , count ($ user ['tags ' ]));
208
213
$ this ->assertEquals ('tag1 ' , $ user ['tags ' ][0 ]);
209
214
210
215
DB ::collection ('users ' )->where ('_id ' , $ id )->push ('tags ' , 'tag2 ' );
211
-
216
+
212
217
$ user = DB ::collection ('users ' )->find ($ id );
213
218
$ this ->assertTrue (is_array ($ user ['tags ' ]));
214
219
$ this ->assertEquals (2 , count ($ user ['tags ' ]));
@@ -233,7 +238,7 @@ public function testPull()
233
238
));
234
239
235
240
DB ::collection ('users ' )->where ('_id ' , $ id )->pull ('tags ' , 'tag3 ' );
236
-
241
+
237
242
$ user = DB ::collection ('users ' )->find ($ id );
238
243
$ this ->assertTrue (is_array ($ user ['tags ' ]));
239
244
$ this ->assertEquals (3 , count ($ user ['tags ' ]));
@@ -408,4 +413,4 @@ public function testUnset()
408
413
$ this ->assertFalse (isset ($ user2 ['note2 ' ]));
409
414
}
410
415
411
- }
416
+ }
0 commit comments