Commit c2fb55c4 authored by Jens Segers's avatar Jens Segers

Increasing test coverage

parent b9e4cdae
......@@ -214,14 +214,4 @@ class BelongsToMany extends EloquentBelongsToMany {
{
return $this->foreignKey;
}
/**
* Get the fully qualified "other key" for the relation.
*
* @return string
*/
public function getOtherKey()
{
return $this->otherKey;
}
}
......@@ -287,6 +287,11 @@ class RelationsTest extends TestCase {
$photo = Photo::first();
$this->assertEquals($photo->imageable->name, $user->name);
$user = User::with('photos')->find($user->_id);
$relations = $user->getRelations();
$this->assertTrue(array_key_exists('photos', $relations));
$this->assertEquals(1, $relations['photos']->count());
}
public function testEmbedsManySave()
......@@ -579,4 +584,20 @@ class RelationsTest extends TestCase {
$this->assertFalse($user->addresses()->contains('123'));
}
public function testEmbedsManyEagerLoading()
{
$user = User::create(array('name' => 'John Doe'));
$address1 = $user->addresses()->save(new Address(array('city' => 'New York')));
$address2 = $user->addresses()->save(new Address(array('city' => 'Paris')));
$user = User::find($user->id);
$relations = $user->getRelations();
$this->assertFalse(array_key_exists('addresses', $relations));
$user = User::with('addresses')->find($user->id);
$relations = $user->getRelations();
$this->assertTrue(array_key_exists('addresses', $relations));
$this->assertEquals(2, $relations['addresses']->count());
}
}
......@@ -7,7 +7,6 @@ use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface {
protected $collection = 'users';
protected $dates = array('birthday');
protected static $unguarded = true;
......
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