我正在使用 Homestead 来为我的 Laravel 应用程序提供服务。我正在尝试运行 PHPUnit。根据docs :
An example test file is provided in the app/tests directory. After installing a new Laravel application, simply run
phpunit
on the command line to run your tests.
好吧,当我在我的项目根目录(在 Homestead 环境中)“简单地运行”phpunit
时,我得到了这个:
当前未安装程序“phpunit”。
我需要单独安装 PHPUnit 吗?文档没有提到它。我做错了什么?
最佳答案
您可以在系统上使用全局安装它。
composer global require phpunit/phpunit
但是,如果您需要为不同的项目使用不同的版本,这可能会导致问题。
另一种选择是通过引用您的 vendor
目录的路径,将安装的版本用作依赖项的一部分。
./vendor/bin/phpunit
您甚至可以在 ~/Homestead
目录中的别名文件中添加别名。这样您就可以始终使用随项目依赖项一起安装的 phpunit 版本。
alias phpunit=./vendor/bin/phpunit
您需要重新启动 homestead box 才能使用别名。
关于php - 在 Laravel 的 Homestead 中运行 PHPUnit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28114434/