Skip to content

Commit e5cba0a

Browse files
committed
Adding test for MorpOne
1 parent ab64c58 commit e5cba0a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

tests/RelationsTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,15 @@ public function testMorph()
275275
$this->assertEquals(1, $user->photos->count());
276276
$this->assertEquals($photo->id, $user->photos->first()->id);
277277

278-
$photo = Photo::create(array('url' => 'http://graph.facebook.com/john.doe/picture'));
279-
$client->photos()->save($photo);
278+
$photo = Photo::create(array('url' => 'http://graph.facebook.com/jane.doe/picture'));
279+
$client->photo()->save($photo);
280280

281-
$this->assertEquals(1, $client->photos->count());
282-
$this->assertEquals($photo->id, $client->photos->first()->id);
281+
$this->assertNotNull($client->photo);
282+
$this->assertEquals($photo->id, $client->photo->id);
283283

284284
$client = Client::find($client->_id);
285-
$this->assertEquals(1, $client->photos->count());
286-
$this->assertEquals($photo->id, $client->photos->first()->id);
285+
$this->assertNotNull($client->photo);
286+
$this->assertEquals($photo->id, $client->photo->id);
287287

288288
$photo = Photo::first();
289289
$this->assertEquals($photo->imageable->name, $user->name);

tests/models/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public function users()
1212
return $this->belongsToMany('User');
1313
}
1414

15-
public function photos()
15+
public function photo()
1616
{
17-
return $this->morphMany('Photo', 'imageable');
17+
return $this->morphOne('Photo', 'imageable');
1818
}
1919
}

0 commit comments

Comments
 (0)