Laravel-Test-Helpers
Laravel-Test-Helpers copied to clipboard
->withPivot() makes assertBelongsToMany() fail
I'm trying to write a test for this
public function challengeoptions()
{
return $this->belongsToMany('Challengeoptions')
->withPivot('donepct')
->withTimestamps();
}
But when trying to use assertBelongsToMany() I'm just getting the error:
PHP Fatal error: Call to a member function withPivot() on a non-object in....
Anyone know a way to fix it, or to test it another way? :)
I get the same error because my relationships are something like this:
public function midias()
{
return $this->hasMany('Midia', 'id_conteudo')
->where('model', '=', 'Blog')
->orderBy('ordem', 'ASC');
}
Just added pull request #52 that fixes this. :)