I have this in my codeception.yml
in tests root folder config:
include:
- codeception/backend
- codeception/common
- codeception/console
paths:
log: codeception/_output
settings:
colors: true
modules:
enabled:
- Db
config:
Db:
dsn: 'mysql:host=localhost;dbname=db1_test'
user: 'root'
password: 'qwerty'
cleanup: true
Then this in mu codeception/codeception.yml
:
namespace: tests\codeception\backend
actor: Tester
paths:
tests: .
log: _output
data: _data
helpers: _support
settings:
bootstrap: _bootstrap.php
suite_class: \PHPUnit_Framework_TestSuite
colors: true
memory_limit: 1024M
log: true
config:
# the entry script URL (without host info) for functional and acceptance tests
# PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
test_entry_url: http://ds3/index-test.php
And then this in my codeception/unit.suite.yml
:
class_name: UnitTester
modules:
enabled:
- Db
But I get the following error when I run codecept build
from tests root folder:
[Codeception\Exception\ModuleConfigException]
Db module is not configured!
Options: dsn, user, password are required
Please, update the configuration and set all the required fields
If I remove - Db
from codeception/unit.suite.yml
the module just doesn't run at all. It seems like global config's modules
section is ignored completely. It won't even affect anything if there is a typo in Db
in global config. But I need to have only one config for Db for each suite and each application. What am I doing wrong? Documentation says it should be possible to declare modules globally.
Ok, to clarify: This is my codecetion.yml file (different project from above, but tested for your scenario):
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
colors: false
memory_limit: 1024M
modules:
config:
DataHelper:
db:
host: 02corm.za.ds.xxxxxxx.com
user: xxxxxxx
password: yyyyyyy
port: 3306
env:
stubDelay: 2
otdWebhook: http://xxxxxx.com:9080/api/webhook/
otdStubUrl: http://xxxxxx.com:9080/api/
and my api.suite.yml:
class_name: ApiTester
modules:
enabled:
- PhpBrowser
- REST
- ApiHelper
- DataHelper
- CurlHelper
- OtdHelper
- Asserts
- WooCommerceHelper
- ResponseHelper
config:
PhpBrowser:
url: http://dev.xxxx.co.za
curl:
CURLOPT_TIMEOUT: 50000 # timeout in seconds
REST:
url: http://dev.xxxx.co.za
timeout: 90
env:
mini:
modules:
config:
PhpBrowser:
url: http://xxxxxx.com:9080/api/
curl:
CURLOPT_TIMEOUT: 50000 # timeout in seconds
REST:
url: http://xxxxxx.com:9080/api/
dcr-static:
modules:
config:
PhpBrowser:
url: http://x.x.x.x:10080/api
curl:
CURLOPT_TIMEOUT: 50000 # timeout in seconds
REST:
url: http://x.x.x.x:10080/api
DataHelper:
db:
host: x.x.x.x
user: xxxxx
password: yyyy
port: 3307
env:
stubDelay: 2
otdWebhook: http://x.x.x.x:10080/api/webhook/otd
otdStubUrl: http://x.x.x.x:10080/otd-stub/service
In the above setup, I have two environments: mini and dcr-static.
In 'mini' there was no DataHelper configs supplied, so it is using the configs from codecetion.yml file.
In 'dcr-static' I supplied an alternative config for this environment, which gets used instead of the one given in the codecetion.yml file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With