Codeception / module-yii2

Codeception module for Yii2 framework
MIT License
16 stars 36 forks source link

Yii2 configFile path variations #37

Closed vercotux closed 2 years ago

vercotux commented 6 years ago

What are you trying to achieve?

Run Yii2 module tests along with main Yii2 app tests (one runner). See related issue.

The modules are installed via composer and thus reside in the main app's vendor/ folder and each contain their own codeception.yml file. The setup does not work for modules which require DB access, because they would need to load a Yii2 config file from the main app (not their own). This however is impossible due to the fact that Codeception's Yii2 configFile parameter only generates a path that is relative to the module (which could be anywhere when symlinked from composer's 'path' repository). I need to be able to provide a path relative to the main Yii2 application (where the root codeception.yml file is) in order to read the main application's database config.

What do you get instead?

[yii\base\InvalidConfigException] Unknown component ID: db because I cannot include DB access credentials in a module that is provided through composer.

There needs to be a way to pass the main Yii2 app configuration to included codeception.yml's.

Details

The relevant part:

include:
    - common
    - frontend
    - backend
    - vendor/vercotux/yii2-module