K
K
knowledge2020-06-30 23:22:14
symfony
knowledge, 2020-06-30 23:22:14

How to set environment variable during acceptance test in codeception?

acceptance.suite.yml

actor: AcceptanceTester
modules:
    enabled:
        - WebDriver:
            url: 'http://172.17.0.1:5011/'
            browser: chrome
            port: 4444
            host: chrome
        - Db:
            dsn: 'mysql:host=mysql;dbname=db_test'
            user: 'root'
            password: '1234'

I specify the base db_test, but the tests go through the usual base, I searched in the documentation, I didn’t find it anywhere, --env=test does not give a result when starting the test, you can specify it in functional tests, but not here

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2020-06-30
@Maksclub

Your application in the test environment must connect to the test database. There is no magic if the application in its config sees the dev-base, and not the test one - it will (expectedly) connect to it, even if you really want the other way around and decided to look into some test database in the tests.
Total: Make the application look in the same database when running tests as the test framework
For Symfony, a couple of options:
- make a test domain that would be raised with a test Kernel
- raise the application with environment variables not through environment imitation in .env, but through the environment itself (roughly speaking, http://172.17.0.1in the environment variables (not in the file imitating them .env) the connection parameters must be correct
- use Symfony module with explicit env: test, but suitable for functional tests, not acceptance tests

A
andead, 2020-07-01
@andead

> I specify the base db_test
This is the base only for the operation of the Db module (import, cleaning, queries via getModule('Db')->_getDbh()->query()). These settings have nothing to do with how the site works.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question