lundi 25 juin 2018

migration fails as route middleware selects from non-existing table during tests

I can't run tests as migration fails as a route middleware queries from a table during (or even before the start of) migration that needs to be created while migrating.

I've tried to run my test with ->withoutMiddleware() or ->withoutMiddleware(ThatMiddleware::class) with not much of a success.

So my current workaround is as following. In the middleware in question I do this:

class ThatMiddleware extends ServiceProvider {
    public function boot() {
        if(Schema::hasTable('table_in_question')) {
            // ... code that queries the table
        }
    }
}

But this seems a bit insecure especially considering the middleware is for authentication. I'm not sure this error is a result of a poorly written middleware or test.

Is there any better way to fix this?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2tvGUXk
via IFTTT

Aucun commentaire:

Enregistrer un commentaire