I'm doing the unit testing in Laravel. I wrote a test for the if function (data store). but I want to know how to write test for else part. when data save is failure, an error message return.
public function store(Request $request)
{
$user = $this->user->create($request->all());
if ($user) {
return response()->json([
'message' => 'Data saved successfully,
'data' => [
'user' => $user
]
]);
} else {
return response()->json([
'message' => 'Data save failed.'
], 400);
}
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/lWErAyq
via IFTTT
Aucun commentaire:
Enregistrer un commentaire