Level 61
I never tested images with $this->get(). Always used HTTP client for that. So just use the first example.
I am trying to create a test to check the response status for an image.
The image works fine in browser:
https://mydomain.test/storage/images/j2L3G12eel9sqsuNSGOYmcdqwUdchZtsfFGMeY90.jpg
Also Http get works fine:
$response = Http::get('https://mydomain.test/storage/images/j2L3G12eel9sqsuNSGOYmcdqwUdchZtsfFGMeY90.jpg');
$this->assertEquals(200, $response->status());
$this->get() fails.
public function test_can_see_image()
{
$this->get('https://mydomain.test/storage/images/j2L3G12eel9sqsuNSGOYmcdqwUdchZtsfFGMeY90.jpg')->assertOk();
}
Response status code [404] does not match expected 200 status code. Failed asserting that false is true.
I mention that the issue is only for files (images). The pages can be tested properly:
public function test_pages()
{
$this->get('https://mydomain.test/page')->assertOk();
}
Please or to participate in this conversation.