The test below runs the login page to login to the site, then runs a user import script. The import script inserts a new user record. From the application logs I can see that the record is inserted correctly during the test, however the
seeInDatabase assertion doesn't find the record. This is using a database dump as suggested by the docs and I believe my test database is set up correctly.
I am not using
haveInDatabase because the application does the insert already.
What am I doing wrong?
--debug I can see that there are a few 302 responses but I don't think that's the problem.
I can see that the application is inserting the record but instead of inserting it to the test database configured in my yaml file, it is writing to my local environment's database – which is configured in the app's bootstrap config which sets the database for the app to be something else based on the environment.
I guess I'm not really understanding how to make use of the test database which is populated from the _data/dump.sql file for Functional tests.
My understanding is that Functional tests are there to test the application runs correctly – so how would I get it to write to the test database instead of the local database which would be used by normal browser tests?
public function standardUserTest(FunctionalTester $I)
# What's this test about
$I->wantTo('log in to site and import a user account');
$I->see('Sign in', 'h1');
$I->submitForm('form#UserLoginForm', array('title' => 'Login Form'));
$I->see('Import a user', 'h1');
$I->submitForm('form#ImportForm', array('title' => 'Login Form'));
$I->fillField('data[UserProfile][id]', '234'); //Used member number
# Check that the user record has been added
$I->seeInDatabase('users',array('email'=>'firstname.lastname@example.org')); // Doesn't work... although from the system logs I can see that the record was added successfully