Ad

In Codeception Functional Test SeeInDatabase Not Works From Laravel

I am using codeception for testing in laravel 5.2.
Here is my codeception.yml file:

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

and here is functional.suite.yml file:

class_name: FunctionalTester
modules:
    enabled:
        # add framework module here
        - \Helper\Functional
        - Asserts
        - Laravel5:
            environment_file: .env.testing
        - Db

here is my test method:

public function provera_dodavanja_novog_klijenta(FunctionalTester $I)
{

    $this->authenticate($I);

    $I->amOnPage('/kancelarija/komitenti/create');
    $I->see('Kreiranje novog komitenta');
    $I->fillField('input[name=komitent_code]', 'kom1');
    $I->fillField('input[name=komitent_name]', 'Komitent 1');
    $I->click('btnSave');
    $I->seeInDatabase('komitenti', ['code' => 'kom1', 'name' => 'Komitent 1']);
    $I->see('Komitent Komitent 1 je uspešno kreiran.');

}

Running functional test fails with message:

 Step  I see in database "komitenti",{"code":"kom1","name":"Komitent 1"}
 Fail  No matching records found for criteria {"code":"kom1","name":"Komitent 1"} in table komitenti
Failed asserting that 0 is greater than 0.

What I am doing wrong?

I have seen question Codeception seeInDatabase() doesn't work for me but this didn't helpe me.

Ad

Answer

You should probably useseeRecord method instead of seeInDatabase. I don't know why but for me first one was working and second one - not.

Ad
source: stackoverflow.com
Ad