Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Travis autoloader PhpUnit

This is my PHPUnit configuration file. for some reason it works on my local enviorment but when i'm trying using travis its saying that it can't find the classes for some reason.

and bootstrap="./vendor/autoload.php" is not found on the Travis machine

   <?xml version="1.0" encoding="UTF-8"?>
    <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.2/phpunit.xsd"
             backupGlobals="false"
             verbose="true"
             bootstrap="./vendor/autoload.php">
        <testsuite name="aaaa">
            <directory suffix="Test.php">tests</directory>
        </testsuite>

        <logging>
            <log type="coverage-html" target="build/coverage"/>
        </logging>

        <filter>
            <whitelist processUncoveredFilesFromWhitelist="true">
                <directory suffix=".php">src</directory>
            </whitelist>
        </filter>
    </phpunit>

1 Answers

If you are using composer, it installs the autoloader and any dependencies to the vendor directory. It is common to put the vendor directory into your .gitignore file.

This means that when travis checks out your project, it will not have the vendor directory. You need to run composer to install the dependencies and autoloader before running your tests.

Make sure to commit your composer.json and composer.lock files and put this into your .travis.yml:

install: composer install
like image 168
Justin Howard Avatar answered Oct 01 '26 14:10

Justin Howard