@@ -10,6 +10,7 @@ public function tearDown()
10
10
User::truncate ();
11
11
Soft::truncate ();
12
12
Book::truncate ();
13
+ Item::truncate ();
13
14
}
14
15
15
16
public function testNewModel ()
@@ -120,6 +121,31 @@ public function testFind()
120
121
$ this ->assertEquals (35 , $ check ->age );
121
122
}
122
123
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
+
123
149
/**
124
150
* @expectedException Illuminate\Database\Eloquent\ModelNotFoundException
125
151
*/
@@ -225,4 +251,18 @@ public function testScope()
225
251
$ this ->assertEquals (1 , $ sharp ->count ());
226
252
}
227
253
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
+
228
268
}
0 commit comments