Any chance that you are setting the connection explicitly on some of your models in the branch?
DB issues when testing
Hello, I'm working on a project and for strange reasons testing give me troubles. On my current branch all works fine, but when I switch on another one tests are not working anymore, it resets completely my database which make me think that tests are not run in memory.
This is my phpunit config :
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
<server name="MAIL_DRIVER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
And when I launch : ./vendor/bin/phpunit
I've got this message : PDOException: SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) which not match the sqlite value found in the XML file.
I tried all the solutions implying cache clearing but nothing works at all... the setup of PHPunit can be really tricky, if someone could help me with that it would be great !
I have the same kind of issue. I made my models extend a model which has this
/**
* Connection to use
*
* @var string
*/
protected $connection = 'hardcoded_connection'; //your hardcoded connection
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
if (App::environment('testing')) {
$this->connection = 'testing'; //I have made this connection inside the database.php config file
}
Please or to participate in this conversation.