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()
146146 $ this ->assertEquals ('John Doe ' , $ user ->name );
147147 }
148148
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+
149162 /**
150163 * @expectedException Illuminate\Database\Eloquent\ModelNotFoundException
151164 */
Original file line number Diff line number Diff line change @@ -29,6 +29,18 @@ public function testGet()
2929 $ this ->assertEquals (1 , count ($ users ));
3030 }
3131
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+
3244 public function testInsert ()
3345 {
3446 DB ::collection ('users ' )->insert (array (
You can’t perform that action at this time.
0 commit comments