Complex how?
Aug 14, 2019
5
Level 15
unit test relations
I have complex relations, witch is the best way to test relations ? Any best practice examples ?
Level 104
If you only wanted to test the relation, then it would be enough to test that the result of calling the relation method is an instance of the appropriate Relation, e.g.
$this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\HasOne::class, $plan->region());
If you want to know that the result of the relation is a particular class of Eloquent Model, then you would need to set up the relationship in your test database.
Please or to participate in this conversation.