Use the route helper:
$response = $this->actingAs($this->admin)->getJson(route('users.filter', ['search'=>'upgrade']));
Hi, my question is how to send parameter to my endpoint.
route: Route::get('users/plan','DashboardController@filterPlan')->name('users.filter');
test
public function test_upgrade()
{
$billingChange3 = factory(Plan::class)->create([
'user_id' => 1,
'previous_price' => 50,
'current_price' => 100,
]);
$url = route(
'users.filters'
);
$response = $this->actingAs($this->admin)->getJson($url,['search'=>'upgrade']);
$response->assertStatus(200);
//till here correct
//but here it should return 2 since I have upgrade count 2 as correct it gives error
my api response is wrapped within data, so i have used data below
$response->assertJsonCount(2,'data');
}
my seach keyword can be any thing such as ```upgrade,downgrade``` etc.
upgrade is when ```current_price>previous_price``` and I have logic for that in controller
My vue dev tool shows url as below:
first:"https://localhost:800/users/plan?filter=upgrade&page=1"
In test I have passed params as``` getJson($url,['search'=>'upgrade']```
Is that the correct way to pass paramters?
Use the route helper:
$response = $this->actingAs($this->admin)->getJson(route('users.filter', ['search'=>'upgrade']));
Please or to participate in this conversation.