Using parameter placeholders in codeception.yml

浪尽此生 提交于 2019-12-03 15:07:05

In order to use params you should add params config 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 param values using '%' placeholders:

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

This possibility exists since this PR : https://github.com/Codeception/Codeception/pull/2855

In your example, you can add the params into your codeception.yml, like this :

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

Be aware that you can not access parameters like %kernel.project_dir%

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!