10

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

closed as off-topic by Dawny33, Romeo Ninov, JonMark Perry, Pierre.Vriens, Tensibai Mar 3 '17 at 16:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about DevOps, within the scope defined in the help center." – Dawny33, Romeo Ninov, JonMark Perry, Pierre.Vriens, Tensibai
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    The link to the build report is broken... – 7ochem Mar 3 '17 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 '17 at 16:11
  • 4
    This seems to be on topic to me, as Continuous Integration (CI) is quite important to DevOps. – wogsland Mar 6 '17 at 2:53
9

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.