File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,19 @@ public function testFirst()
146
146
$ this ->assertEquals ('John Doe ' , $ user ->name );
147
147
}
148
148
149
+ public function testNoDocument ()
150
+ {
151
+ $ items = Item::where ('name ' , 'nothing ' )->get ();
152
+ $ this ->assertInstanceOf ('Illuminate\Database\Eloquent\Collection ' , $ items );
153
+ $ this ->assertEquals (0 , $ items ->count ());
154
+
155
+ $ item =Item::where ('name ' , 'nothing ' )->first ();
156
+ $ this ->assertEquals (null , $ item );
157
+
158
+ $ item = Item::find ('51c33d8981fec6813e00000a ' );
159
+ $ this ->assertEquals (null , $ item );
160
+ }
161
+
149
162
/**
150
163
* @expectedException Illuminate\Database\Eloquent\ModelNotFoundException
151
164
*/
Original file line number Diff line number Diff line change @@ -29,6 +29,18 @@ public function testGet()
29
29
$ this ->assertEquals (1 , count ($ users ));
30
30
}
31
31
32
+ public function testNoDocument ()
33
+ {
34
+ $ items = DB ::collection ('items ' )->where ('name ' , 'nothing ' )->get ();
35
+ $ this ->assertEquals (array (), $ items );
36
+
37
+ $ item = DB ::collection ('items ' )->where ('name ' , 'nothing ' )->first ();
38
+ $ this ->assertEquals (null , $ item );
39
+
40
+ $ item = DB ::collection ('items ' )->where ('_id ' , '51c33d8981fec6813e00000a ' )->first ();
41
+ $ this ->assertEquals (null , $ item );
42
+ }
43
+
32
44
public function testInsert ()
33
45
{
34
46
DB ::collection ('users ' )->insert (array (
You can’t perform that action at this time.
0 commit comments