Commit 66de10e3 authored by Jens Segers's avatar Jens Segers

Adding tests for #236

parent bc842c01
...@@ -7,6 +7,8 @@ class RelationsTest extends TestCase { ...@@ -7,6 +7,8 @@ class RelationsTest extends TestCase {
Mockery::close(); Mockery::close();
User::truncate(); User::truncate();
Client::truncate();
Address::truncate();
Book::truncate(); Book::truncate();
Item::truncate(); Item::truncate();
Role::truncate(); Role::truncate();
...@@ -392,4 +394,27 @@ class RelationsTest extends TestCase { ...@@ -392,4 +394,27 @@ class RelationsTest extends TestCase {
$this->assertCount(2, $users); $this->assertCount(2, $users);
} }
public function testNestedKeys()
{
$client = Client::create(array(
'data' => array(
'client_id' => 35298,
'name' => 'John Doe'
)
));
$address = $client->addresses()->create(array(
'data' => array(
'address_id' => 1432,
'city' => 'Paris'
)
));
$client = Client::where('data.client_id', 35298)->first();
$this->assertEquals(1, $client->addresses->count());
$address = $client->addresses->first();
$this->assertEquals('Paris', $address->data['city']);
}
} }
...@@ -16,4 +16,9 @@ class Client extends Eloquent { ...@@ -16,4 +16,9 @@ class Client extends Eloquent {
{ {
return $this->morphOne('Photo', 'imageable'); return $this->morphOne('Photo', 'imageable');
} }
public function addresses()
{
return $this->hasMany('Address', 'data.client_id', 'data.address_id');
}
} }
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