单元测试时的奇怪问题


Strange issue when unit testing

我在使用CakePHP框架对一个PHP应用程序进行单元测试时遇到了一个非常奇怪的问题。问题是测试控制器简单功能的单元测试失败了。但是奇怪的是,同样的测试通过了我正在使用的其他一些开发人员,而对于其他一些开发人员则没有。我在Windows机器上使用XAMPP堆栈,并试图重新安装所有内容(包括PHP和Apache服务器),但仍然不起作用。另一个重新安装了整个操作系统(Mac OS)的开发者也是如此。

phpunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="true"
     colors="false"
     convertErrorsToExceptions="true"
     convertNoticesToExceptions="true"
     convertWarningsToExceptions="true"
     mapTestClassNameToCoveredClassName="false"
     strict="false"
     verbose="false"
     bootstrap="./CakePHP/tests/bootstrap.php">
    <testsuites>
        <testsuite name="phpcs">
            <file>./CakePHP/tests/CakePHPStandardTest.php</file>
        </testsuite>
    </testsuites>
</phpunit>

我认为这可能是一些错误的配置,所以如果你有更好的建议,请分享。

尝试检查PHPUnit的配置。也许这些选项有不同的值:

convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"