Commit e5cba0a9 authored by Jens Segers's avatar Jens Segers

Adding test for MorpOne

parent ab64c586
...@@ -275,15 +275,15 @@ class RelationsTest extends TestCase { ...@@ -275,15 +275,15 @@ class RelationsTest extends TestCase {
$this->assertEquals(1, $user->photos->count()); $this->assertEquals(1, $user->photos->count());
$this->assertEquals($photo->id, $user->photos->first()->id); $this->assertEquals($photo->id, $user->photos->first()->id);
$photo = Photo::create(array('url' => 'http://graph.facebook.com/john.doe/picture')); $photo = Photo::create(array('url' => 'http://graph.facebook.com/jane.doe/picture'));
$client->photos()->save($photo); $client->photo()->save($photo);
$this->assertEquals(1, $client->photos->count()); $this->assertNotNull($client->photo);
$this->assertEquals($photo->id, $client->photos->first()->id); $this->assertEquals($photo->id, $client->photo->id);
$client = Client::find($client->_id); $client = Client::find($client->_id);
$this->assertEquals(1, $client->photos->count()); $this->assertNotNull($client->photo);
$this->assertEquals($photo->id, $client->photos->first()->id); $this->assertEquals($photo->id, $client->photo->id);
$photo = Photo::first(); $photo = Photo::first();
$this->assertEquals($photo->imageable->name, $user->name); $this->assertEquals($photo->imageable->name, $user->name);
......
...@@ -12,8 +12,8 @@ class Client extends Eloquent { ...@@ -12,8 +12,8 @@ class Client extends Eloquent {
return $this->belongsToMany('User'); return $this->belongsToMany('User');
} }
public function photos() public function photo()
{ {
return $this->morphMany('Photo', 'imageable'); return $this->morphOne('Photo', 'imageable');
} }
} }
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