I have already written many tests. All were passing in this config of phpunit.xml
<env name="DB_CONNECTION" value="mysql"/>
<env name="DB_DATABASE" value="testing"/>
But they were slow so I changed it to in-memory sqlite:
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
This is very fast but gives error on some tests.
example:
/** @test */
public function a_user_can_create_a_post()
{
$payload = [
'title' => 'This is title',
'body' => 'This is body',
];
$this->actingAs($this->adminUser)
->json('POST', '/post', $payload)
->assertRedirect(route('post.index'))
->assertSessionHas('message', 'Post Created!');
}
It gives 500 status code instead of redirect code. When I remove the json line and simply assert some path 200 then it works fine.
What is the problem ?