I want to Unit test my Authentication. I'm using Service-Repository pattern, so i already wrote unit tests for Controller and Service, but now i need to test AuthRepository.php For example i have "Register" method in repository, which looks like this:
public function register(RegisterAuthRequest $fields)
{
$user = $this->_user->create([
'name' => $fields['name'],
'email' => $fields['email'],
'password' => bcrypt($fields['password']),
]);
$token = $user->createToken('wcgtoken')->plainTextToken;
$response = [
'user' => $user,
'token' => $token,
];
return response($response, 201);
}
And i have Custom Form Request RegisterAuthRequest.php
public function rules()
{
return [
'name' => 'required|string',
'email' => 'required|string|unique:users,email',
'password' => 'required|string|confirmed',
];
}
So i want to make unit test which will assert failed validation, like if request would have empty data