Answer the question
In order to leave comments, you need to log in
How to test request via codeception in laravel?
there is a username method
public function username()
{
$value = request()->input('login');
$field = filter_var($value, FILTER_VALIDATE_EMAIL) ? 'email' : 'name';
request()->merge([$field => $value]);
return $field;
}
public function usernameFieldTest(UnitTester $I)
{
$name = 'john';
$email = '[email protected]';
$loginController = new \App\Http\Controllers\Auth\LoginController();
$request = new Request();
$request->merge(['login' => $name]);
$I->assertEquals('name', $loginController->username());
$request->merge(['login' => $name]);
$I->assertEquals('email', $loginController->username());
}
Answer the question
In order to leave comments, you need to log in
Do you have Request $request in the username method of the LoginController class ?
Most likely you didn't pass $request to one of the username() parameters .
$I->assertEquals('name', $loginController->username($request));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question