Skip to content

Commit 4d00587

Browse files
committed
Adding tests for issue #68
1 parent 29dfdbf commit 4d00587

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/RelationsTest.php

+23
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,27 @@ public function testWithHasOne()
102102
$this->assertEquals('admin', $role->type);
103103
}
104104

105+
public function testEasyRelation()
106+
{
107+
// Has Many
108+
$user = User::create(array('name' => 'John Doe'));
109+
$item = Item::create(array('type' => 'knife'));
110+
$user->items()->save($item);
111+
112+
$user = User::find($user->_id);
113+
$items = $user->items;
114+
$this->assertEquals(1, count($items));
115+
$this->assertInstanceOf('Item', $items[0]);
116+
117+
// Has one
118+
$user = User::create(array('name' => 'John Doe'));
119+
$role = Role::create(array('type' => 'admin'));
120+
$user->role()->save($role);
121+
122+
$user = User::find($user->_id);
123+
$role = $user->role;
124+
$this->assertInstanceOf('Role', $role);
125+
$this->assertEquals('admin', $role->type);
126+
}
127+
105128
}

0 commit comments

Comments
 (0)