how to write test for this function ?? how to test request-ajax()??
public function getChangeLoc(Request $request, $loc)
{
if ($request->ajax()) {
if(!in_array($loc, config('loc.available'))) {
return response()->json([
'status' => 'ERROR',
'message' => 'Not available'
]);
}
Session::put('locale', $loc);
return response()->json([
'status' => 'OK',
'loc' => $loc,
]);
}
if(!in_array($loc, config('loc.available'))) {
return Redirect::to('/?unknown-loc);
}
Session::put('loc', $loc);
if(filter_var($request->input('redirect_url', ''), FILTER_VALIDATE_URL)) {
return Redirect::to($request->input('redirect_url'));
}
return Redirect::to('/');
}
I test the function like this
$this->visit('/loc/en')
->seePageIs('/admin/client')
but its not see request->ajax?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire