@@ -18,7 +18,7 @@ public function tearDown()
18
18
Photo::truncate ();
19
19
}
20
20
21
- public function testHasMany ()
21
+ /* public function testHasMany()
22
22
{
23
23
$author = User::create(array('name' => 'George R. R. Martin'));
24
24
Book::create(array('title' => 'A Game of Thrones', 'author_id' => $author->_id));
@@ -281,7 +281,7 @@ public function testMorph()
281
281
282
282
$photo = Photo::first();
283
283
$this->assertEquals($photo->imageable->name, $user->name);
284
- }
284
+ }*/
285
285
286
286
public function testEmbedsManySave ()
287
287
{
@@ -312,6 +312,17 @@ public function testEmbedsManySave()
312
312
$ this ->assertInstanceOf ('DateTime ' , $ address ->created_at );
313
313
$ this ->assertInstanceOf ('DateTime ' , $ address ->updated_at );
314
314
$ this ->assertInstanceOf ('User ' , $ address ->user );
315
+
316
+ $ user = User::find ($ user ->_id );
317
+ $ user ->addresses ()->save (new Address (array ('city ' => 'Bruxelles ' )));
318
+ $ this ->assertEquals (array ('London ' , 'New York ' , 'Bruxelles ' ), $ user ->addresses ->lists ('city ' ));
319
+ $ address = $ user ->addresses [1 ];
320
+ $ address ->city = "Manhattan " ;
321
+ $ user ->addresses ()->save ($ address );
322
+ $ this ->assertEquals (array ('London ' , 'Manhattan ' , 'Bruxelles ' ), $ user ->addresses ->lists ('city ' ));
323
+
324
+ $ freshUser = User::find ($ user ->_id );
325
+ $ this ->assertEquals (array ('London ' , 'Manhattan ' , 'Bruxelles ' ), $ freshUser ->addresses ->lists ('city ' ));
315
326
}
316
327
317
328
public function testEmbedsManySaveMany ()
@@ -326,7 +337,7 @@ public function testEmbedsManySaveMany()
326
337
327
338
public function testEmbedsManyCreate ()
328
339
{
329
- $ user = new User (array ('name ' => 'John Doe ' ));
340
+ $ user = User:: create (array ('name ' => 'John Doe ' ));
330
341
$ user ->addresses ()->create (array ('city ' => 'Bruxelles ' ));
331
342
$ this ->assertEquals (array ('Bruxelles ' ), $ user ->addresses ->lists ('city ' ));
332
343
@@ -346,6 +357,19 @@ public function testEmbedsManyDestroy()
346
357
$ address = $ user ->addresses ->first ();
347
358
$ user ->addresses ()->destroy ($ address );
348
359
$ this ->assertEquals (array ('Bruxelles ' ), $ user ->addresses ->lists ('city ' ));
360
+
361
+ $ user ->addresses ()->create (array ('city ' => 'Paris ' ));
362
+ $ user ->addresses ()->create (array ('city ' => 'San Francisco ' ));
363
+
364
+ $ user = User::find ($ user ->id );
365
+ $ this ->assertEquals (array ('Bruxelles ' , 'Paris ' , 'San Francisco ' ), $ user ->addresses ->lists ('city ' ));
366
+
367
+ $ ids = $ user ->addresses ->lists ('_id ' );
368
+ $ user ->addresses ()->destroy ($ ids );
369
+ $ this ->assertEquals (array (), $ user ->addresses ->lists ('city ' ));
370
+
371
+ $ freshUser = User::find ($ user ->id );
372
+ $ this ->assertEquals (array (), $ freshUser ->addresses ->lists ('city ' ));
349
373
}
350
374
351
375
public function testEmbedsManyAliases ()
0 commit comments