3
votes

Is there a way to configure test parameters with Symfony2?

I tried importing parameters_test.yml from the config_test.yml file but the variables still come from the parameters.yml file which is imported by config.yml which is imported by config_dev.yml which is imported by config_test.yml.

Basically I want to setup different variables in a test parameter file so I can access the values and also use them in the config files. If I hardcode the variables directly into config_test.yml I don't have access to them.

The variable I'm interested in particular is database_name or doctrine->dbal->dbname.

Thanks

2

2 Answers

2
votes

In config_test.yml simple write this configuration:

# Doctrine Configuration
doctrine:
    dbal:
        driver:   %database_driver_test%
        host:     %database_host_test%
        port:     %database_port_test%
        dbname:   %database_name_test%
        user:     %database_user_test%
        password: %database_password_test%
6
votes

Of course ensure your two first lines your config_test.yml are:

imports:
    - { resource: config_dev.yml }
    - { resource: parameters_test.yml }