You are happy user of the Symfony framework, and you heard something about Travis than you decide to test it. In this article, I describe how to connect popular tests’ tools (PHPUnit, phpspec, Behat) to Travis, when you have Symfony on your backend.
Before, we started configuring Symfony for supporting Travis you should know what is Continuous Integration and why that idea is very useful.
In simple words, Continuous Integration is when your code is merged with master branch and tested a few times of a day automatically. In previous ages, programmer deployed application once, maybe twice a year, now we can publish our changes in minutes to a production server, and millions of users can start using it immediately.
Check their website.
Travis – what is it?
In open source community, Travis is the most popular tool for Continuous Integrations. There are some reasons why:
- it’s free for open source projects,
- integration with GitHub is extremely easy,
- looks modern,
- easy to configure.
You can configure it for running test application and deploy it to production, stage servers on Amazon (AWS S3) or Heroku. In this article, I will focus on configuration for automation tests.
How to use it in Symfony project
As I said, the configuration Symfony project to co-works with Travis is so easy. You have to only create one file
.travis.yml which contains that code:
language: php php: - '7.0' - '7.1' - nightly install: - composer install --dev
As you see it is regular YAML file with three parameters.
languagedeclares language that you can use.
phptells Travis with that version of php you want to test your app.
installlist of commands that Travis has to run before run tests.
Assign the tests framework
Before you start you have to add that following line to your
.travis.yml. There we will declare command to run particular test’s framework.
Below you have lines which you need to add to
.travis.yml then you want to add some test framework to Travis. Of course, you have to install each framework in your project before you configure Travis to work with it.
- ./vendor/bin/phpspec run