Codeception — automated database dumps
April 16, 2016 🕒 56 seconds
I've been recently using Codeception and really appreciate what it can do. I see Codeception as PHPUnit on steroids. What's nice about Codeception is that existing PHPUnit tests are compatible with it, so not all work is lost for people moving from PHPUnit to Codeception.
Dumping a database for Codeception can be inconvenient
There’s a slight inconvenience related to functional and acceptance testing in Codeception though.
Functional and acceptance tests run against a test database. Codeception comes with a nice Db module that refreshes the test database before each test is run. But in order to use it you are expected to put a database dump in 'tests/_data' directory. This is a major pain, because each time the database schema changes, a new dump is required.
Since I plan to use Codeception more in the future I made a package that adds a single command to a project that will migrate, seed and dump a test database making it ready to be used in Codeception tests.
It's a timesaver and finally I don't have to waste time on creating a database dump manually.