Skip to content

Params source is ignored if yml file is extended #6799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Eseperio opened this issue Sep 26, 2024 · 2 comments
Open

Params source is ignored if yml file is extended #6799

Eseperio opened this issue Sep 26, 2024 · 2 comments

Comments

@Eseperio
Copy link

What are you trying to achieve?

I am developing a Yii2 module that is designed for applications with both frontend and backend components, requiring separate test configurations. To simplify configuration management, I created a base configuration file, codeception.base.yml, which contains common settings such as database, Yii2 modules, and paths. Then, I extended this base configuration in two separate codeception.yml files for the frontend and backend.

However, I noticed that when I define the params: - .env in the base configuration file, Codeception ignores it during test execution. The .env file is not loaded, which causes the tests to fail. If I explicitly define the params: - .env in each extended configuration file, then everything works as expected.

What do you get instead?

The tests fail to run correctly because the environment variables from .env are not being loaded from the base configuration file. If i run with debug-d enabled there is not call to any params loader.


Code Example

Here is an example of my setup:

codeception.base.yml:

paths:
    log: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs

modules:
    enabled:
        - Yii2:
            configFile: 'config/test.php'
        - Db:
            dsn: 'mysql:host=127.0.0.1;dbname=testdb'
            user: 'root'
            password: '%MYSQL_PASS%'
            populate: false
            cleanup: false

params:
    - .env

frontend/codeception.yml:

extends: ../codeception.base.yml
# i also set here the custom config file for yii2 module
paths:
    tests: frontend/tests
    output: frontend/tests/_output
    support: frontend/tests/_support
    envs: frontend/tests/_envs
    

backend/codeception.yml:

extends: ../codeception.base.yml
# i also set here the custom config file for yii2 module
paths:
    tests: backend/tests
    output: backend/tests/_output
    support: backend/tests/_support
    envs: backend/tests/_envs

When params: - .env is only defined in codeception.base.yml, it is ignored. But if I add it to each codeception.yml like this, the tests run successfully:

params:
    - .env

Details

  • Codeception version: 4.2.2
  • PHP Version: php8.1
  • Operating System: MacOs
  • Installation type: Composer
  • List of installed packages: (skipped since is huge: +100)
@W0rma
Copy link
Contributor

W0rma commented Dec 6, 2024

@Eseperio Is the "extends" keyword documented somewhere?

Internally, Codeception uses symfony/yaml to parse yaml config files. I'm not sure if "extends" is something which is supported by the current parsing logic.

@Eseperio
Copy link
Author

Eseperio commented Dec 13, 2024

@W0rma is within Codeception official docs: https://codeception.com/docs/reference/Configuration#extends

EDIT: Is working for me for other settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy