【发布时间】:2021-03-11 09:00:29
【问题描述】:
我正在尝试设置 Phpunit,并且在我的整个项目中,$_SERVER['DOCUMENT_ROOT'] 用于链接所有文件/函数/连接等。在我的测试类中,如果我链接我的 global_php_includes.php 文件的绝对路径(其中是包含更多其他内容的父文件)然后每次调用 $_SERVER['DOCUMENT_ROOT'] 时都会出错。
我对 Phpunit 很陌生,有什么办法可以解决这个问题吗?我使用作曲家安装它。这是我的 xml 文件:
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit bootstrap="vendor/autoload.php" colors="true" verbose="true" stopOnFailure="true">
<testsuites>
<testsuite name="unit">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
【问题讨论】:
-
您遇到了哪个错误?
-
提到了使用 Document_Root 的所有内容我收到一个错误,指出存在
No such file or directory
标签: php unit-testing phpunit