Codeception — automated database dumps

Why Codeception?

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.

Did you like this post?
Previous post

It's very common for web applications to deal with image uploads, image resizing and other manipulations. Arguably the best approach to the problem (apart from offloading the task to a service like imgix) is to store the uploads in the cloud and resize and manipulate the images on the fly.

Next post

Laravel Cashier is already handling Braintree's 'subscription_canceled' and 'subscription_expired' webhooks and will cancel a subscription when any of those webhooks get triggered. The webhooks are handled in WebhookController, which can be easily extended to add support for other kinds of webhooks.