I'm testing my Rest APIs.
I want to pass a parameter to my request.
This is in my controller, I have:
public function index(Request $request)
{
$abuse = Abuse::where('bombId', $request->input('bombId'))->get();
}
Thing is with PhpUnit, I can never simulate the bombId parameter...
Here is my code:
$_SERVER['PHP_AUTH_USER'] = 'name@email.com';
$_SERVER['PHP_AUTH_PW'] = 'xxx';
$_REQUEST['bombId'] = 25; // I also tried $bombId = 25;
$this->get('api/v1/abuse', [$_SERVER,$_REQUEST])
->seeJson(['total' => 11]);
$this->assertResponseStatus(200);
Any Idea?
Aucun commentaire:
Enregistrer un commentaire