phpMick's avatar
Level 15

An error occurred while connecting to the database ':memory:'

I get this error when trying to execute my tests:

PHPUnit 5.7.13 by Sebastian Bergmann and contributors.

E{"sError":"An error occurred while connecting to the database ':memory:'. The error reported by the server was: SQLSTATE[HY000] [1044] Access denied for user 'mick'@'%' to database ':memory:'"}

phpUnit.xml

 <php>
        <env name="APP_ENV" value="testing"/>
        <env name="DB_CONNECTION" value="sqlite"/>
        <env name="DB_DATABASE" value=":memory:"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
    </php>

database.php

 'sqlite' => [
            'driver' => 'sqlite',
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
        ],

What am I doing wrong? These settings work OK in another project?

The username mick is coming from my .env.

I am not using config caching.

Mick

0 likes
2 replies
phpMick's avatar
Level 15

Give up on this for now, using a mySQL db for testing.

phpMick's avatar
Level 15

Do I need a separate .env for testing?

I didn't think I did any more. I am using Laravel 5.3.4.

Mick

Please or to participate in this conversation.