How to submit form and move to next page with PHPUnit I am in full on test mode at the moment but struggling.
I have a multi page user journey that I am looking to test. Here's what I have
$response->assertViewIs('view1');
$this->post('/create-new-item', [
'name' => 'Test',
]);
$response->assertViewIs('view2);
So submit the form on view1 which should then take you to view2 but this isn't happening. it's staying on view 1. What am I doing wrong?
Laravel 9.
EDITED TO ADD
Even if someone could point me at the official docs. I looked hard and couldn't find them for navigating forms in L9.
@mick79 You shouldn’t be trying to perform multiple requests in a single test; a test isn’t a web browser. Instead, execute a request and then make assertions about the response. If you expect to be redirected, then assert that:
$response = $this->post('/page-one', $data);
$response->assertRedirect('/page-two');
Please sign in or create an account to participate in this conversation.