@@ -18,7 +18,7 @@ public function tearDown()
1818 Photo::truncate ();
1919 }
2020
21- public function testHasMany ()
21+ /* public function testHasMany()
2222 {
2323 $author = User::create(array('name' => 'George R. R. Martin'));
2424 Book::create(array('title' => 'A Game of Thrones', 'author_id' => $author->_id));
@@ -281,7 +281,7 @@ public function testMorph()
281281
282282 $photo = Photo::first();
283283 $this->assertEquals($photo->imageable->name, $user->name);
284- }
284+ }*/
285285
286286 public function testEmbedsManySave ()
287287 {
@@ -312,6 +312,17 @@ public function testEmbedsManySave()
312312 $ this ->assertInstanceOf ('DateTime ' , $ address ->created_at );
313313 $ this ->assertInstanceOf ('DateTime ' , $ address ->updated_at );
314314 $ 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 ' ));
315326 }
316327
317328 public function testEmbedsManySaveMany ()
@@ -326,7 +337,7 @@ public function testEmbedsManySaveMany()
326337
327338 public function testEmbedsManyCreate ()
328339 {
329- $ user = new User (array ('name ' => 'John Doe ' ));
340+ $ user = User:: create (array ('name ' => 'John Doe ' ));
330341 $ user ->addresses ()->create (array ('city ' => 'Bruxelles ' ));
331342 $ this ->assertEquals (array ('Bruxelles ' ), $ user ->addresses ->lists ('city ' ));
332343
@@ -346,6 +357,19 @@ public function testEmbedsManyDestroy()
346357 $ address = $ user ->addresses ->first ();
347358 $ user ->addresses ()->destroy ($ address );
348359 $ 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 ' ));
349373 }
350374
351375 public function testEmbedsManyAliases ()
0 commit comments