Functional test running locally, fails on CI

I’ve set up testing for my app. The test suite runs fine locally, while it fails when executed via Gitlab CI.

Locally, whether I run:

./vendor/bin/codecept run functional EndingEndUserPresenceInStructureCest
./vendor/bin/codecept run functional
./vendor/bin/codecept run

it all works. On CI, running the single test passes, while the functional suite fails only on this single test, other passes.

./vendor/bin/codecept run functional EndingEndUserPresenceInStructureCest

The test performs simple database tasks:

class EndingEndUserPresenceInStructureCest
{
    public function _before(FunctionalTester $I)
    {
    }

    public function endingEndUserPresenceInStructure(FunctionalTester $I)
    {
        $I->haveFixtures(['user' => UtenteFixture::className()]);
        $I->haveFixtures(['anagrafica' => AnagraficaFixture::className()]);
        $user = $I->grabFixture('user', 'user');
        $I->amLoggedInAs($user->id);
        $I->amOnRoute('anagrafica', ['tipologia' => '9']);
        $I->see('test_struttura', 'td');
        $I->see('Nuova Anagrafica', 'a');
        $enduser1 = $I->grabFixture('anagrafica', 'enduser1');
        $enduser2 = $I->grabFixture('anagrafica', 'enduser2');
        $I->see($enduser1->cognome, 'a');
        $I->see($enduser2->cognome, 'a');
        $I->amOnRoute('/passaggio/dimissione', ['anagrafica' => $enduser1->idanagrafica]);
        $I->see('data dimissione');
        $I->fillField('Passaggio[data_uscita]', date('Y-m-d H:i:s'));
        $I->fillField('Passaggio[motivazione]', 'Test motivazione della dimissione');
        $I->fillField('Passaggio[destinazione_uscita]', 'Test destinazione uscita');
        $I->click('Salva');
        $I->see('Anagrafica di ' . $enduser1->cognome, 'h1');
    }
}

Codeception.xml is:

actor: Tester
paths:
    tests: tests
    log: tests/_output
    data: tests/_data
    helpers: tests/_support
bootstrap: _bootstrap.php
settings:
    colors: true
    memory_limit: 1024M
modules:
    config:
        Yii2:
            configFile: 'config/test.php'
            cleanup: false
            transaction: false
        Db:
            dsn: 'mysql:host=app_db;dbname=app_test'
            user: 'root'
            password: 'password'
            populate: true
            cleanup: true
            dump: tests/_data/app_test.sql

I cannot figure out what’s wrong with the config! Any hint is welcome.
thanks

P.S. using

Codeception PHP Testing Framework v4.2.2 https://helpukrainewin.org
Powered by PHPUnit 8.5.31 by Sebastian Bergmann and contributors.
1 Like

Apparently there was an error on the SQL data dump. I had an _old table around, linked to other tables via FK. I’m not 100% sure, but 99%… :slight_smile: