G
G
ganjo8882020-02-26 09:57:28
PHPUnit
ganjo888, 2020-02-26 09:57:28

Why are the settings in phpunit.xml not being applied?

<php>
        <env name="APP_ENV" value="testing"/>
        <env name="BCRYPT_ROUNDS" value="4"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
        <env name="MAIL_DRIVER" value="array"/>
        <env name="DB_CONNECTION" value="test"/>
        <env name="DB_TEST_DATABASE" value="test_database"/>
    </php>

My config
'connections' => [
        'pgsql' => [
            'driver'   => 'pgsql',
            'host'     => env('POSTGRES_HOST', '127.0.0.1'),
            'port'     => env('POSTGRES_PORT', '5432'),
            'database' => env('POSTGRES_DATABASE', 'forge'),
            'username' => env('POSTGRES_USER', 'forge'),
            'password' => env('POSTGRES_PASSWORD', ''),
            'charset'  => 'utf8',
            'prefix'   => '',
            'schema'   => 'public',
            'sslmode'  => 'prefer',
        ],
        'test' => [
            'driver'   => 'pgsql',
            'host'     => env('POSTGRES_HOST', '127.0.0.1'),
            'port'     => env('POSTGRES_PORT', '5432'),
            'database' => env('DB_TEST_DATABASE', 'forge'),
            'username' => env('POSTGRES_USER', 'forge'),
            'password' => env('POSTGRES_PASSWORD', ''),
            'charset'  => 'utf8',
            'prefix'   => '',
            'schema'   => 'public',
            'sslmode'  => 'prefer',
        ],
    ],

For some reason, the settings written in phpunit.xml are not applied and the settings are taken not from 'test' but from 'pgsql'. I am running my application in a docker container. Help me to understand

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Popov, 2020-02-26
@ganjo888

The values ​​from the .env variable will overwrite the values ​​from phpunit.xml. I recommend creating a .env.testing file and overriding the corresponding variables there. Information about this is in the official documentation in the testing chapter .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question