PHPUnit is a popular programmer-oriented testing framework for PHP. You can use it to test your code before the deployment so that you know the copy on your server is free of errors.

PHPUnit action details
PHPUnit action details

Configuring tests and delivery with Buddy

There's still a wide range of developers who haven't heard or don't know how to introduce Continuous Integration to their process. Buddy lets you set up the whole workflow in 10-15 minutes (either through GUI or YAML) and easily scale and expand once your projects grow bigger.

  1. Create a new project, choose your Git provider, and select your PHP repository.
  2. Add a new pipeline and switch the trigger mode to On every push
  3. Add PHPUnit action. You can install any missing modules in the Packages & Setup tab
  4. Add FTP/SFTP file transfer action and configure your deployment

You can also add the SSH action and use it, eg. to run composer install on your server.

This way every time you'll make a push to the selected branch, Buddy will automatically test and deploy the changes to the server + run the desired SSH commands:

PHPUnit workflow
PHPUnit workflow

If your tests require a database to run, eg. MySQL, you can easily activate them in the Services tab:

Attaching database
Attaching database

A good practice is to add a conditional notification in the end that will send you a message in case the tests or the deployment have failed, for example to your Slack channel:

Slack conditional notification
Slack conditional notification

Summary

If you'd like to learn more about using Buddy in PHP development, check out our guides on automating PHP dependencies and Wordpress themes with Buddy.

Happy coding!