Skip to content

馃摑 Docs - POST application/x-www-form-urlencoded #617

Answered by Rikj000
Rikj000 asked this question in Q&A
Discussion options

You must be logged in to vote

I hope there is a better way to do this,
but for now I've managed to work around the issue,
through directly initializing the $_POST parameter inside the it() function:

it('/api/endpoint route asserts status code 200 + expected response', function () {
    // Initialize the POST data
    $_POST = ['parameter' => 'foo'];
    // Initialize the expected response data
    $expected_response = ['code' => 200, 'result' => 'bar'];

    // Run the test case
    $test_response = $this->post('/api/endpoint', $_POST);
    $test_response->assertStatus(200)->assertJson($expected_response);
});

Recommendations for improvements are very welcome! 馃檪

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Rikj000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant