Laralvel 5 phpunit and model connection
In laravel I am using multiple mysql connections:
mysql
mysql_web
My models usually connect to mysql
, so this is the default connection. Some models use the connection mysql_web
as follows:
...
class AdminUser extends Model{
protected $connection = 'mysql_web';
...
It still works.
PROBLEM:
When I run phpunit tests, those tests that need to use these models fail. The error message states that the underlying table or view does not exist. (Because it tries to find the table in mysql
instead mysql_web
)
QUESTION (s):
How can I specify which connection these tests should use. Why can't they just just use the one I already gave them in the model classes?
source to share
No one has answered this question yet
Check out similar questions: