File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -648,6 +648,7 @@ public function testSaveEmptyModel()
648648 $ user = User::create (array ('name ' => 'John Doe ' ));
649649 $ user ->addresses ()->save (new Address );
650650 $ this ->assertNotNull ($ user ->addresses );
651+ $ this ->assertEquals (1 , $ user ->addresses ()->count ());
651652 }
652653
653654}
Original file line number Diff line number Diff line change @@ -417,4 +417,23 @@ public function testNestedKeys()
417417 $ this ->assertEquals ('Paris ' , $ address ->data ['city ' ]);
418418 }
419419
420+ public function testDoubleSave ()
421+ {
422+ $ author = User::create (array ('name ' => 'George R. R. Martin ' ));
423+ $ book = Book::create (array ('title ' => 'A Game of Thrones ' ));
424+
425+ $ author ->books ()->save ($ book );
426+ $ author ->books ()->save ($ book );
427+ $ author ->save ();
428+ $ this ->assertEquals (1 , $ author ->books ()->count ());
429+
430+ $ author = User::where ('name ' , 'George R. R. Martin ' )->first ();
431+ $ this ->assertEquals (1 , $ author ->books ()->count ());
432+
433+ $ author ->books ()->save ($ book );
434+ $ author ->books ()->save ($ book );
435+ $ author ->save ();
436+ $ this ->assertEquals (1 , $ author ->books ()->count ());
437+ }
438+
420439}
You can’t perform that action at this time.
0 commit comments