Skip to content
This repository was archived by the owner on Feb 20, 2023. It is now read-only.
This repository was archived by the owner on Feb 20, 2023. It is now read-only.

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

Description

@tgaertner

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\Codeceptionpaths:
tests: testsoutput: tmp/testsdata: tests/Fixturesupport: src/TestSuite/Codeceptionenvs: tests/Envssettings:
bootstrap: bootstrap.phpcolors: truememory_limit: 1024Mactor_suffix: Testerextensions:
enabled:
- Codeception\Extension\RunFailedmodules:
config:
Db:
dsn: 'mysql:host=%DB_HOST_TEST%;dbname=%DB_NAME_TEST%'user: '%DB_USER_TEST%'password: '%DB_PASSWORD_TEST%'dump: tests/_data/dump.sqlcleanup: true # reload dump between testspopulate: true # load dump before all testsreconnect: trueenabled:
- Dbparams:
- 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions