You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found a 'bug' in AssertHasMany(), AssertHasOne() etc
If I do my relationship like this:
public function photos()
{
$this->hasMany('Photo');
}
Then AssertHasMany will pass 'green' on phpunit.
public function testProjectHasManyPhotos()
{
$this->assertHasMany('photos', 'Project');
}
But this is the wrong syntax as I discovered after hours of debugging to work out why my program was not work. It should be;
public function photos()
{
return $this->hasMany('Photo');
}
So we should make the Asserts ensure the relationship is there AND returned, or it is actually NOT working, and eloquent will fail when you try and use the relationship in your code.
Took me hours to work this out :)
The text was updated successfully, but these errors were encountered:
Hi,
I found a 'bug' in AssertHasMany(), AssertHasOne() etc
If I do my relationship like this:
Then AssertHasMany will pass 'green' on phpunit.
But this is the wrong syntax as I discovered after hours of debugging to work out why my program was not work. It should be;
So we should make the Asserts ensure the relationship is there AND returned, or it is actually NOT working, and eloquent will fail when you try and use the relationship in your code.
Took me hours to work this out :)
The text was updated successfully, but these errors were encountered: