Using placeholders in codeception.yml

I am setting up a Codeception Db module and would like to use the parameters from my Symfony 2 parameters file. Parameters.yml.

Basically something like this:

paths:
    tests: tests
    log: tests/_log
    data: tests/_data
    helpers: tests/_helpers
settings:
    bootstrap: _bootstrap.php
    suite_class: \PHPUnit_Framework_TestSuite
    colors: true
    memory_limit: 1024M
    log: true
modules:
    config:
        Symfony2:
            app_path: 'app'
            var_path: 'app'
            environment: 'test'
        Db:
            dsn: "mysql:host='%test_database_host%';dbname='%test_database_name%'"
            user: "%test_database_user%"
            password: "%test_database_password%"
            dump: tests/_data/test_data.sql

Placeholders (e.g.% test_database_user%) are not replaced by the values ​​in the parameters.yml file in the / config symfony 2 application directory.

parameters.yml:

parameters:
    test_database_name: testdb
    test_database_host: 127.0.0.1
    test_database_user: root
    test_database_password: thisismypassword

What is the best way to do this?

Thank.

+4
source share
1 answer

To use parameters, you must add params configuration to codeception.yml:

params:
    - env # to get params from environment vars
    - params.yml # to get params from yaml (Symfony style)
    - params.env # to get params from .env (Laravel style)

you can use parameter values ​​with placeholders '%':

modules:
    enabled:
        - Db:
            dsn: %DB_DSN%
            user: %DB_USER%
            password: %DB_PASS%

PR: https://github.com/Codeception/Codeception/pull/2855

params ception.yml, :

params:
    - app/config/parameters.yml
paths:
    tests: tests
    log: tests/_log
    data: tests/_data
    helpers: tests/_helpers
settings:
    bootstrap: _bootstrap.php
    suite_class: \PHPUnit_Framework_TestSuite
    colors: true
    memory_limit: 1024M
    log: true
modules:
    config:
        Symfony2:
            app_path: 'app'
            var_path: 'app'
            environment: 'test'
        Db:
            dsn: "mysql:host='%test_database_host%';dbname='%test_database_name%'"
            user: "%test_database_user%"
            password: "%test_database_password%"
            dump: tests/_data/test_data.sql

, , % kernel.project_dir%

0

All Articles