codeception icon indicating copy to clipboard operation
codeception copied to clipboard

Codeception Tests take 'default' datasource instead of 'test'

Open tgaertner opened this issue 7 years ago • 0 comments

I use a ddev docker for running the tests. I'm able to run UnitTests via Codeception, but when it comes to database and fixtures its confusing...

My codeception.dist.yml

namespace: App\TestSuite\Codeception
paths:
    tests: tests
    output: tmp/tests
    data: tests/Fixture
    support: src/TestSuite/Codeception
    envs: tests/Envs
settings:
    bootstrap: bootstrap.php
    colors: true
    memory_limit: 1024M
actor_suffix: Tester
extensions:
    enabled:
        - Codeception\Extension\RunFailed
modules:
    config:
        Db:
            dsn: 'mysql:host=%DB_HOST_TEST%;dbname=%DB_NAME_TEST%'
            user: '%DB_USER_TEST%'
            password: '%DB_PASSWORD_TEST%'
            dump: tests/_data/dump.sql
            cleanup: true # reload dump between tests
            populate: true # load dump before all tests
            reconnect: true
    enabled:
        - Db
params:
    - env

The dump.sql is imported into the test database on running my tests. Fixtures are not inserted...

Then in my Test "class HashableBehaviorTest extends \Codeception\Test\Unit" I do something like: $user = $this->UsersTable->get(1); This gives me the first record from my default database and not from the test database. I have no Idea what is missing here... Glad for any help!

tgaertner avatar Nov 22 '18 12:11 tgaertner