Works with SQL database.
The most important function of this module is to clean a database before each test.
That’s why this module was added to the global configuration file
To have your database properly cleaned you should configure it to access the database.
This module also provides actions to perform checks in a database.
In order to have your database populated with data you need a raw SQL dump.
Simply put the dump in the
tests/_data directory (by default) and specify the path in the config.
The next time after the database is cleared, all your data will be restored from the dump.
Don’t forget to include
CREATE TABLE statements in the dump.
Supported and tested databases are:
Supported but not tested.
Connection is done by database Drivers, which are stored in the
Check out the drivers if you run into problems loading dumps and cleaning databases.
Please review the code of non-stable modules and provide patches if you have issues.
modules: enabled: - Db: dsn: 'mysql:host=localhost;dbname=testdb' user: 'root' password: '' dump: 'tests/_data/dump.sql' populate: true cleanup: false reconnect: true
dump.sqlmay contain multiline statements.
Effect is opposite to ->seeInDatabase
Asserts that there is no record with the given column values in a database. Provide table name and column values.
Fails if such user was found.
Fetches a single column value from a database. Provide table name, desired column and criteria.
Available since 1.1
Inserts an SQL record into a database. This record will be erased after the test.
param array $data
Asserts that a row with the given column values exists. Provide table name and column values.
Fails if no such user found.
Asserts that the given number of records were found in the database.
param int$expectedNumber Expected number
param string$table Table name
param array$criteria Search criteria [Optional]