@@ -178,6 +178,9 @@ public function testCreate()
178
178
$ this ->assertInstanceOf ('Jenssegers\Mongodb\Model ' , $ user );
179
179
$ this ->assertEquals (true , $ user ->exists );
180
180
$ this ->assertEquals ('Jane Poe ' , $ user ->name );
181
+
182
+ $ check = User::where ('name ' , 'Jane Poe ' )->first ();
183
+ $ this ->assertEquals ($ user , $ check );
181
184
}
182
185
183
186
public function testDestroy ()
@@ -280,6 +283,14 @@ public function testToArray()
280
283
$ items = Item::all ();
281
284
$ this ->assertEquals ($ original , $ items ->toArray ());
282
285
$ this ->assertEquals ($ original [0 ], $ items [0 ]->toArray ());
286
+
287
+ // with date
288
+ $ item = Item::create (array ('name ' => 'fork ' , 'type ' => 'sharp ' ));
289
+ $ array = $ item ->toArray ();
290
+ $ this ->assertTrue (array_key_exists ('created_at ' , $ array ));
291
+ $ this ->assertTrue (array_key_exists ('updated_at ' , $ array ));
292
+ $ this ->assertTrue (is_string ($ array ['created_at ' ]));
293
+ $ this ->assertTrue (is_string ($ array ['updated_at ' ]));
283
294
}
284
295
285
296
public function testUnset ()
@@ -312,14 +323,11 @@ public function testUnset()
312
323
public function testDates ()
313
324
{
314
325
$ user = User::create (array ('name ' => 'John Doe ' , 'birthday ' => new DateTime ('1980/1/1 ' )));
315
-
316
326
$ this ->assertInstanceOf ('Carbon\Carbon ' , $ user ->birthday );
317
327
318
328
$ check = User::find ($ user ->_id );
319
-
320
329
$ this ->assertInstanceOf ('Carbon\Carbon ' , $ check ->birthday );
321
330
$ this ->assertEquals ($ user ->birthday , $ check ->birthday );
322
-
323
331
324
332
$ user = User::where ('birthday ' , '> ' , new DateTime ('1975/1/1 ' ))->first ();
325
333
$ this ->assertEquals ('John Doe ' , $ user ->name );
0 commit comments