Travis PhpUnit Autoloader

This is my PHPUnit config file. for some reason it works in my local environment, but when I try to use travis it says it can't find the classes for some reason.

and bootstrap = "./vendor/autoload.php" not found on 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>

      

+3


source to share


1 answer


If you are using composer, it installs the autoloader and any dependencies to the directory vendor

. Usually the directory vendor

is placed in your file .gitignore

.

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



Make sure to commit the files composer.json

and composer.lock

and put them in your .travis.yml

:

install: composer install

      

+2


source







All Articles