testing
testing copied to clipboard
Asserting relationships not working correctly
Hi,
I have two models: User and his Event.
class Event extends \Eloquent {
// some code
/**
* User relation
*
* @return \Builder
*/
public function user()
{
return $this->belongsTo('User');
}
}
In tests I'd like to test this relationship and I did the following:
/**
* Test belongs to user
*
* @return void
*/
public function testBelongsToUser()
{
$this->assertBelongsTo($this->event, 'user');
}
The test is passed, ok. But if I change the test like:
/**
* Test belongs to user
*
* @return void
*/
public function testBelongsToUser()
{
$this->assertBelongsToMany($this->event, 'user');
// or different relationship, i.e. assertHasMany or assertHasOne
}
The test is passed to. I'm not sure that it's ok. How can I test exactly a kind of a relationship?
Thanks.