@@ -10,6 +10,7 @@ public function tearDown()
1010 User::truncate ();
1111 Soft::truncate ();
1212 Book::truncate ();
13+ Item::truncate ();
1314 }
1415
1516 public function testNewModel ()
@@ -120,6 +121,31 @@ public function testFind()
120121 $ this ->assertEquals (35 , $ check ->age );
121122 }
122123
124+ public function testGet ()
125+ {
126+ User::insert (array (
127+ array ('name ' => 'John Doe ' ),
128+ array ('name ' => 'Jane Doe ' )
129+ ));
130+
131+ $ users = User::get ();
132+ $ this ->assertEquals (2 , count ($ users ));
133+ $ this ->assertInstanceOf ('Illuminate\Database\Eloquent\Collection ' , $ users );
134+ $ this ->assertInstanceOf ('Jenssegers\Mongodb\Model ' , $ users [0 ]);
135+ }
136+
137+ public function testFirst ()
138+ {
139+ User::insert (array (
140+ array ('name ' => 'John Doe ' ),
141+ array ('name ' => 'Jane Doe ' )
142+ ));
143+
144+ $ user = User::get ()->first ();
145+ $ this ->assertInstanceOf ('Jenssegers\Mongodb\Model ' , $ user );
146+ $ this ->assertEquals ('John Doe ' , $ user ->name );
147+ }
148+
123149 /**
124150 * @expectedException Illuminate\Database\Eloquent\ModelNotFoundException
125151 */
@@ -225,4 +251,18 @@ public function testScope()
225251 $ this ->assertEquals (1 , $ sharp ->count ());
226252 }
227253
254+ public function testToArray ()
255+ {
256+ $ original = array (
257+ array ('name ' => 'knife ' , 'type ' => 'sharp ' ),
258+ array ('name ' => 'spoon ' , 'type ' => 'round ' )
259+ );
260+
261+ Item::insert ($ original );
262+
263+ $ items = Item::all ();
264+ $ this ->assertEquals ($ original , $ items ->toArray ());
265+ $ this ->assertEquals ($ original [0 ], $ items [0 ]->toArray ());
266+ }
267+
228268}
0 commit comments