为什么全局 phpunit 忽略 xml 配置文件?

Why does global phpunit ignore xml configuration file?

我已经启动了一个小型 Web 应用程序 运行ning,其中包括 phpunit 测试。它是用 composer 构建的,并且有一个非常标准的目录结构:

src/
    application files
tests/
    bootstrap.php
    test files
web/
    index.php
.travis.yml
composer.json
composer.lock
phpunit.xml

phpunit.xml内容:

<?xml version="1.0" encoding="UTF-8" ?>

<phpunit boostrap="./tests/bootstrap.php">
    <testsuites>
        <testsuite name="Chronos">
            <directory>./tests</directory>
        </testsuite>
    </testsuites>
</phpunit>

bootstrap.php内容:

<?php

require __DIR__ . "/../vendor/autoload.php";

我的问题

运行 以下命令完美运行并且我的测试通过了:

$ vendor/bin/phpunit
PHPUnit 4.8.26 by Sebastian Bergmann and contributors.

..

Time: 104 ms, Memory: 4.00MB

OK (2 tests, 2 assertions)

但是,当我 运行 我的全局安装版本的 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.

在我的项目根目录中 运行 全局安装 phpunit 似乎没有 include/resolve 我的 phpunit.xml 文件(指定自动加载器)。我在 TravisCI 上得到了相同的结果。

有谁知道为什么会这样?我可以在我的 .travis.yml 文件中指定 phpunit 的本地版本,但我想知道是什么导致了这里的差异。

啊,我明白了。我的 phpunit.xml 文件中存在愚蠢的拼写错误(缺少 "boostrap" 中的 t)。事实证明,phpunit 的作曲家版本自动包含自动加载,因此它工作正常,而全局 phpunit 包含 phpunit.xml,因此找不到 bootstrap 脚本。