I'm trying to create a functional test in codeception where I can check if the database table was pupulated here is the test:
<?php
$I = new FunctionalTester($scenario);
$I->am('A guest');
$I->wantTo('Sign up for an account');
$I->amOnPage('auth/register');
$I->fillField('username', 'testuser');
$I->fillField('first_name', 'test_name');
$I->fillField('last_name', 'test_last');
$I->fillField('email', '[email protected]');
$I->fillField('password', 'test');
$I->click('Sign up!');
$I->seeInDatabase('users', ['username' => 'testuser', 'first_name' => 'test_name', 'last_name' => 'test_last', 'email' => '[email protected]', 'slug' => 'testuser']);
Here is the yaml file:
class_name: FunctionalTester
modules:
enabled: [Filesystem, FunctionalHelper, Db, PhpBrowser]
config:
Db:
dsn: 'mysql:host=localhost;dbname='db''
user: 'root'
password: 'pass!'
dump: 'tests/_data/dump.sql'
populate: true
cleanup: false
PhpBrowser:
url: 'http://localhost:8000'
I get the error :
Couldn't see in database "users", {"username":"testuser","first_name":"test_name","last_name":"test_last","email":"[email protected]","slug":"testuser"}:
No matching records found
Failed asserting that '0' is greater than 0.
however when i fill out the form in the browser the code works and the user is registered