Skip to content

Instantly share code, notes, and snippets.

@cioddi
Last active December 21, 2015 15:18
Show Gist options
  • Save cioddi/6325426 to your computer and use it in GitHub Desktop.
Save cioddi/6325426 to your computer and use it in GitHub Desktop.
Simple travis setup for php projects PHPUnit, Selenium, Saucelab

#Test PHP projects using Travis-ci

##Required Files

  • .travis.yml (in the root folder of your project)
language: php
php:
  - 5.2
  - 5.3

before_script:
  - ./tests/before_script.sh #this script is run before the tests and performs all tasks needed to setup the test server

script: phpunit --verbose -c tests/phpunit.xml
notifications:
  email:
    - [_YOUR_EMAIL_ADDRESS_]
  • tests/phpunit.xml (path "tests" is optional but must match the path tests/phpunit.xml set in your .travis.yml)
<?xml version="1.0" encoding="UTF-8"?>

<phpunit colors="true">
  <testsuites>
    <testsuite name="simpleTest">
      <file>tests/simpleTest.php</file>
    </testsuite>
  </testsuites>
</phpunit>
  • tests/simpleTest.php (filepath must match the reference <file>tests/simpleTest.php</file> in phpunit.xml)
<?php

 
class FleximgTest extends PHPUnit_Framework_TestCase
{

    public function test1()
    {
        $this->assertEqual(true,true);
    }

    /**
     * @depends test1
     */
    public function test2()
    {
        $this->assertEqual(false,false);
    }

}
?>

##Templates

Some test environment setups

###Travis-ci - PHPUnit - Unit tests https://github.com/cioddi/travis-ci-phpunit-template

###Travis-ci - PHPUnit, Selenium - Functional tests https://github.com/cioddi/travis-ci-phpunit-selenium-template

###Travis-ci, Saucelabs - PHPUnit, Selenium - Functional tests https://github.com/cioddi/travis-ci-saucelabs-template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment