Testomatio - Test Management for Codeception
composer require --dev codeception/module-dbAccess a database.
The most important function of this module is to clean a database before each test. This module also provides actions to perform checks in a database, e.g. seeInDatabase()
In order to have your database populated with data you need a raw SQL dump.
Simply put the dump in the tests/Support/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:
Also available:
Connection is done by database drivers, which are stored in the Codeception\Lib\Driver namespace.
Check out the drivers if you run into problems loading dumps and cleaning databases.
Functional.suite.ymlmodules:
enabled:
- Db:
dsn: 'mysql:host=localhost;dbname=testdb'
user: 'root'
password: ''
dump: 'tests/Support/Data/dump.sql'
populate: true # whether the dump should be loaded before the test suite is started
cleanup: true # whether the dump should be reloaded before each test
reconnect: true # whether the module should reconnect to the database before each test
waitlock: 10 # wait lock (in seconds) that the database session should use for DDL statements
databases: # include more database configs and switch between them in tests.
skip_cleanup_if_failed: true # Do not perform the cleanup if the tests failed. If this is used, manual cleanup might be required when re-running
ssl_key: '/path/to/client-key.pem' # path to the SSL key (MySQL specific, see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-key)
ssl_cert: '/path/to/client-cert.pem' # path to the SSL certificate (MySQL specific, see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-cert)
ssl_ca: '/path/to/ca-cert.pem' # path to the SSL certificate authority (MySQL specific, see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-ca)
ssl_verify_server_cert: false # disables certificate CN verification (MySQL specific, see https://php.net/manual/de/ref.pdo-mysql.php)
ssl_cipher: '