Feature spotlight: PHP Unit

February 23, 2017

Feature spotlight: PHP Unit

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 detailsPHPUnit 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 workflowPHPUnit workflow

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

Attaching databaseAttaching 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 notificationSlack 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!

Share:

Alexander Kus

Alexander Kus

Customer Success Manager

A story-teller and conversation-lover, Alexander decided to invest his skills to help his friends at Buddy transform the cold language of patch notes into exciting narratives. Also: an avid gamer, hip-hop DJ, Liverpool FC fan, absentminded husband, and the father of two.