I've got a small web application up and running, with phpunit testing included. It's built with composer, and has a pretty standard directory structure:
src/
application files
tests/
bootstrap.php
test files
web/
index.php
.travis.yml
composer.json
composer.lock
phpunit.xml
phpunit.xml contents:
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit boostrap="./tests/bootstrap.php">
<testsuites>
<testsuite name="Chronos">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
bootstrap.php contents:
<?php
require __DIR__ . "/../vendor/autoload.php";
My Problem
Running the following command works perfectly and my tests pass:
$ vendor/bin/phpunit
PHPUnit 4.8.26 by Sebastian Bergmann and contributors.
..
Time: 104 ms, Memory: 4.00MB
OK (2 tests, 2 assertions)
However, it fails when I run my globally installed version of phpunit:
$ phpunit
PHPUnit 4.8.26 by Sebastian Bergmann and contributors.
EE
Time: 117 ms, Memory: 4.00MB
There were 2 errors:
1) WelcomeTest::testReturnsAPayload
Error: Class 'Equip\Payload' not found
/Users/tony/Documents/projects/chronos/tests/Domain/WelcomeTest.php:13
2) WelcomeTest::testReturnsOkStatus
Error: Class 'Equip\Payload' not found
/Users/tony/Documents/projects/chronos/tests/Domain/WelcomeTest.php:13
FAILURES!
Tests: 2, Assertions: 0, Errors: 2.
It would seem that running the global installation of phpunit in my project's root directory does not include/resolve my phpunit.xml file (which specifies the autoloader). I get the same results on TravisCI.
Does anyone know why this is happening? I could just specify the local version of phpunit in my .travis.yml file, but I'd rather know what causes the difference here.