Skip to content

Commit c2fb55c

Browse files
committed
Increasing test coverage
1 parent b9e4cda commit c2fb55c

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

src/Jenssegers/Mongodb/Relations/BelongsToMany.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,4 @@ public function getForeignKey()
214214
{
215215
return $this->foreignKey;
216216
}
217-
218-
/**
219-
* Get the fully qualified "other key" for the relation.
220-
*
221-
* @return string
222-
*/
223-
public function getOtherKey()
224-
{
225-
return $this->otherKey;
226-
}
227217
}

tests/RelationsTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ public function testMorph()
287287

288288
$photo = Photo::first();
289289
$this->assertEquals($photo->imageable->name, $user->name);
290+
291+
$user = User::with('photos')->find($user->_id);
292+
$relations = $user->getRelations();
293+
$this->assertTrue(array_key_exists('photos', $relations));
294+
$this->assertEquals(1, $relations['photos']->count());
290295
}
291296

292297
public function testEmbedsManySave()
@@ -579,4 +584,20 @@ public function testEmbedsManyFindOrContains()
579584
$this->assertFalse($user->addresses()->contains('123'));
580585
}
581586

587+
public function testEmbedsManyEagerLoading()
588+
{
589+
$user = User::create(array('name' => 'John Doe'));
590+
$address1 = $user->addresses()->save(new Address(array('city' => 'New York')));
591+
$address2 = $user->addresses()->save(new Address(array('city' => 'Paris')));
592+
593+
$user = User::find($user->id);
594+
$relations = $user->getRelations();
595+
$this->assertFalse(array_key_exists('addresses', $relations));
596+
597+
$user = User::with('addresses')->find($user->id);
598+
$relations = $user->getRelations();
599+
$this->assertTrue(array_key_exists('addresses', $relations));
600+
$this->assertEquals(2, $relations['addresses']->count());
601+
}
602+
582603
}

tests/models/User.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
class User extends Eloquent implements UserInterface, RemindableInterface {
99

10-
protected $collection = 'users';
1110
protected $dates = array('birthday');
1211
protected static $unguarded = true;
1312

0 commit comments

Comments
 (0)