Commit 54e6ff97 authored by Jens Segers's avatar Jens Segers

Adding test for #272

parent 1767b0d8
......@@ -648,6 +648,7 @@ class EmbeddedRelationsTest extends TestCase {
$user = User::create(array('name' => 'John Doe'));
$user->addresses()->save(new Address);
$this->assertNotNull($user->addresses);
$this->assertEquals(1, $user->addresses()->count());
}
}
......@@ -417,4 +417,23 @@ class RelationsTest extends TestCase {
$this->assertEquals('Paris', $address->data['city']);
}
public function testDoubleSave()
{
$author = User::create(array('name' => 'George R. R. Martin'));
$book = Book::create(array('title' => 'A Game of Thrones'));
$author->books()->save($book);
$author->books()->save($book);
$author->save();
$this->assertEquals(1, $author->books()->count());
$author = User::where('name', 'George R. R. Martin')->first();
$this->assertEquals(1, $author->books()->count());
$author->books()->save($book);
$author->books()->save($book);
$author->save();
$this->assertEquals(1, $author->books()->count());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment