JeffreyWay / Laravel-Test-Helpers

Easier testing in Laravel.
https://packagist.org/packages/way/laravel-test-helpers
217 stars 40 forks source link

->withPivot() makes assertBelongsToMany() fail #30

Open martindilling opened 11 years ago

martindilling commented 11 years ago

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? :)

Fuhrmann commented 11 years ago

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');
}
SammyK commented 10 years ago

Just added pull request #52 that fixes this. :)