Can you not just override the ENV variables to change the database?
Jul 17, 2016
4
Level 9
Different database in different tests - is it possible?
I know that it is possible to setup a separate database for testing and local.
I have been using an in memory sqlite database to test my models/repositories and seeders but would now like to work with a live database to test my api.
Is it possible to have different tests use different databases? Perhaps there is a property that can be overridden on a test by test basis?
Level 88
@smnhunt The seeInDatabase function also has accepts an extra parameter for a database connection
protected function seeInDatabase($table, array $data, $connection = null)
Not sure what you want to test. But I think you can do something with this as well ;)
For example
public function setUp()
{
$this->connection = 'sqlite-testing';
}
public function test_something()
{
$this->seeInDatabase('users', [
'id' => 1,
], $this->connection);
}
1 like
Please or to participate in this conversation.