Just use a different connection: https://laravel.com/docs/5.6/database#using-multiple-database-connections
Apr 6, 2018
2
Level 51
Use a different Database for a single Test?
I have the following test setup that tries to add an entry to a model and when I run the following test with the sqlite in-memory database everything passes.
$this->json('POST', 'api/v1/authentications/ssh/credentials', [
'username' => 'root',
'password' => 'goofFnBfo9mi0Y',
'description' => 'test'
])->assertStatus(Response::HTTP_CREATED);
However when I try to replicate the test with the production API I get a "Data too long for column" error from MySQL because the password value is being encrypted and is longer that the 191 character limit on the field.
I am going to change the column type to fix the problem but I really want to make the test fail first so I know that it is really fixed.
Is it possible to configure this single test to override the default database to use a MySQL database?
Level 75
1 like
Please or to participate in this conversation.