Skip to content

Commit 96f07a9

Browse files
committed
Adding tests for #212
1 parent 79c0fdb commit 96f07a9

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tests/ConnectionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ public function testConnection()
66
{
77
$connection = DB::connection('mongodb');
88
$this->assertInstanceOf('Jenssegers\Mongodb\Connection', $connection);
9+
}
910

11+
public function testReconnect()
12+
{
1013
$c1 = DB::connection('mongodb');
1114
$c2 = DB::connection('mongodb');
1215
$this->assertEquals(spl_object_hash($c1), spl_object_hash($c2));

tests/RelationsTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ public function testHasOne()
5757

5858
$role = $user->role;
5959
$this->assertEquals('admin', $role->type);
60+
$this->assertEquals($user->_id, $role->user_id);
61+
62+
$user = User::create(array('name' => 'Jane Doe'));
63+
$role = new Role(array('type' => 'user'));
64+
$user->role()->save($role);
65+
66+
$role = $user->role;
67+
$this->assertEquals('user', $role->type);
68+
$this->assertEquals($user->_id, $role->user_id);
69+
70+
$user = User::where('name', 'Jane Doe')->first();
71+
$role = $user->role;
72+
$this->assertEquals('user', $role->type);
73+
$this->assertEquals($user->_id, $role->user_id);
6074
}
6175

6276
public function testWithBelongsTo()

0 commit comments

Comments
 (0)