Everything I've googled for relating to this suggests that you shouldn't unit test Eloquent as it's already unit tested within Laravel.
However in this case I have another class, that is not an Eloquent model, but it does insert an Eloquent model record into the database. I want to unit test this class.
For example:
public function methodIWantToTest()
{
$record = new User();
$user->name = 'Bob';
$user->email = 'bob@example.com';
$user->save();
}
How would I unit test this method? When I try it actually inserts into the database. Surely I should be able to do this without even having to go near the database?
Aucun commentaire:
Enregistrer un commentaire