11

I am trying to integrate my project coded in core PHP, with Travis-CI but it always fails.

Travis reports a failure even when I have only one file in my project.

PHP file Code :

<?php

phpinfo();

?>

.travis.yml File Code

language: php
php:
  - '5.4'
  - '5.5'
  - '5.6'
  - '7.0'
  - '7.1'
  - hhvm
  - nightly
3
  • 2
    The link to the build report is broken...
    – 7ochem
    Mar 3, 2017 at 14:49
  • As is, it sounds better suited for software engineering. It is not really related to a devopsy, to one of many tools used but not with a particular target on a devops subject.
    – Tensibai
    Mar 3, 2017 at 16:11
  • 4
    This seems to be on topic to me, as Continuous Integration (CI) is quite important to DevOps.
    – wogsland
    Mar 6, 2017 at 2:53

1 Answer 1

10

You need to write some unit tests and set the script variable in your .travis.yml to actually run a file.

By default, Travis CI runs the command phpunit without any arguments. When this happens, phpunit doesn't know what you're asking it to do, and shows a help message, then exits with error code 2 (i.e. non-zero, which indicates an error occurred).

The Beginner's Guide shows you a possible solution of setting the script variable to run a Test.php file with your tests in (insert this into your .travis.yml):

script: phpunit Test.php

There is an example of a valid Test.php in the example repo that Travis provides:

<?php
    class Test extends PHPUnit_Framework_TestCase
    {
        public function testOnePlusOne() {
            $this->assertEquals(1+1,1);
        }
    }
?>

Not the answer you're looking for? Browse other questions tagged or ask your own question.