Unit Test: Table does not exist on load fixture

Hello,

I tried to populate a fixture in the test database (sqlite), but the following exception is thrown:




[yii\base\InvalidConfigException]

Table does not exist: user



I use the advanced template and have the following configuration:

./codeception.yml




include:

    - common

paths:

    log: console/runtime/logs

settings:

    colors: false



./common/codeception.yml




namespace: common\tests

actor: Tester

paths:

    tests: tests

    log: tests/_output

    data: tests/_data

    helpers: tests/_support

settings:

    bootstrap: _bootstrap.php

    colors: true

    memory_limit: 1024M

modules:

    enabled: 

    config:

        Yii2:

            configFile: 'config/test-local.php'

        Db:

            dsn: 'sqlite:database.sqlite'

            user: 'root'

            password: 'root'

            dump: tests/_data/dump.sql



./common/tests/unit.suite.yml




class_name: UnitTester

bootstrap: false

modules:

    enabled:

        - Yii2:

            part: fixtures

        - Db:

            #dsn: 'sqlite:database.sqlite'

            #user: 'root'

            #password: ''

            #dump: tests/_data/dump.sql

            populate: true

            cleanup: true

            reconnect: false



./common/tests/unit/models/LoginFormTest.php




<?php


namespace common\tests\unit\models;


use Yii;

use common\models\LoginForm;

use common\fixtures\User as UserFixture;


class LoginFormTest extends \Codeception\Test\Unit

{

    protected $tester;


    public function _fixtures()

    {

        return [

            'user' => [

                'class' => UserFixture::className(),

                'dataFile' => codecept_data_dir() . 'user.php'

            ]

        ];

    }



As stated above, the application tries to load the fixture for the table name user, but it seems to be the table user does not exist. But when I’m open the created ./common/database.sqlite, the table exists there.

Does somebody have any ideas?

Thank you in advance.

Regards

Markus

I found the solution. After adjusting the file common/config/test-local.php with the correct path for the SQLite database, all works fine:




<?php

return yii\helpers\ArrayHelper::merge(

    require(__DIR__ . '/main.php'),

    require(__DIR__ . '/main-local.php'),

    require(__DIR__ . '/test.php'),

    [

        'components' => [

            'db' => [

                'dsn' => 'sqlite:common/database.sqlite',

                'username' => 'root',

                'password' => '',

            ]

        ],

    ]

);