mardi 15 novembre 2016

Codeception DB module: invalid config details

I am quite new to Codeception but have not found much online about this issue either. So, I am testing my API and this is my codeception.yml:

actor: Tester
paths:
    tests: tests
    log: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
settings:
    bootstrap: _bootstrap.php
    colors: true
    memory_limit: 1024M
extensions:
    enabled:
        - Codeception\Extension\RunFailed
modules:
    config:
        Db:
            dsn: ''
            user: ''
            password: ''
            dump: 'tests/_data/dump.sql'
            populate: false
            cleanup: false
            reconnect: true

Pretty basic, right?

To continue with, this is the api.suite.yml contents:

class_name: ApiTester
modules:
    enabled:
        - \Helper\Api
        - REST:
                url: http://localhost:8000/v1
                depends: PhpBrowser
                part: JSON
        - Db:
                dsn: ''
                user: ''
                password: ''
                dump: 'tests/_data/dump.sql'
                populate: false
                cleanup: false
                reconnect: true

Straightforward too, I guess.

Because I want to hide the login credentials, I put them in _bootstrap.php:

\Codeception\Configuration::$defaultSuiteSettings['modules']['config'] = [
    'Db' => array(
        'dsn' => 'mysql:host=' . getenv('CODECEPTION_DB_HOST') . ';dbname=' . getenv('jupix_branch_dev'),
        'user' => getenv('CODECEPTION_DB_USER'),
        'password' => getenv('CODECEPTION_DB_PASS'),
        'dump' => 'tests/_data/dump.sql',
        'populate' => getenv('CODECEPTION_POPULATE'),
        'cleanup' => getenv('CODECEPTION_CLEANUP'),
        'reconnect' => getenv('CODECEPTION_RECONNECT'),
    )
];

However, when I try to run the tests I receive:

[Codeception\Exception\ModuleException]
  Db: invalid data source name while creating PDO connection

Quite stuck on this one.

Aucun commentaire:

Enregistrer un commentaire