statamic / eloquent-driver

Provides support for storing your Statamic data in a database, rather than flat files.
https://statamic.dev/tips/storing-content-in-a-database
MIT License
104 stars 72 forks source link

Using eloquent-driver makes pest tests throw NotFoundHttpException #205

Closed aknEvrnky closed 10 months ago

aknEvrnky commented 10 months ago

Hi, this is a bug report.

the problem

Any route related with statamic frontend is not working in testing stage. I tested with pest. Sample testing code:

it('returns a successful response', function () {
    $this->withoutExceptionHandling();
    $response = $this->get('/');

    $response->assertStatus(200);
});

Symfony\Component\HttpKernel\Exception\NotFoundHttpException: GET http://localhost:8000

how to reproduce this error?

ryanmitchell commented 10 months ago

Does the homepage load when you view it in browser - trying to work out if this is test specific or whether its a setup issue.

aknEvrnky commented 10 months ago

I can clearly see either homepage or other pages in browser. Here is my curl response:

curl -I 127.0.0.1:8000                   
HTTP/1.1 200 OK
Host: 127.0.0.1:8000
Date: Thu, 21 Sep 2023 10:21:58 GMT
Connection: close
X-Powered-By: PHP/8.2.7
Cache-Control: no-cache, private
Date: Thu, 21 Sep 2023 10:21:58 GMT
Content-Type: text/html; charset=UTF-8
Permissions-Policy: interest-cohort=()
X-Powered-By: Statamic
ryanmitchell commented 10 months ago

Ok, and did you populate your testing db with any data? Do you have a seeder or factories of any sort?

aknEvrnky commented 10 months ago

Good question, I think the issue is using a memory db with RefreshDatabase trait causes that. Since my entries are stored in my actual db it must throw the exception as it should be.

Thanks for your attention. Issue can be closed.