如何在 Laravel 项目中安装 PHPunit
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22571587/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install PHPunit in a Laravel project
提问by iconoclast
I'm trying to set up PHPunit in a Laravel project (which is being running in a Linux VM using Vagrant and VirtualBox). I've added PHPunit to composer.jsonand run composer installand composer update, and yet nothing is working. Running phpunitfrom the command line does nothing. (Nor does php phpunitor php phpunit.phar.)
我正在尝试在 Laravel 项目中设置 PHPunit(该项目正在使用 Vagrant 和 VirtualBox 在 Linux VM 中运行)。我已将 PHPunit 添加到composer.json并运行composer installand composer update,但没有任何效果。phpunit从命令行运行什么都不做。(也没有php phpunit或php phpunit.phar。)
How do I get PHPunit to run my tests?
如何让 PHPunit 运行我的测试?
回答by Antonio Carlos Ribeiro
You must now run it using:
您现在必须使用以下命令运行它:
vendor/bin/phpunit
回答by Ali A. Dhillon
Install phpunit globally and then can you can use it with just phpunitcommand in your local project instead of vendor/bin/phpunit
全局安装 phpunit,然后您可以phpunit在本地项目中使用命令而不是vendor/bin/phpunit
composer global require phpunit/phpunit
or you can add following alias in your VM and then you can run it with just phpunitcommand
或者您可以在您的虚拟机中添加以下别名,然后您只需使用phpunit命令即可运行它
alias phpunit='vendor/bin/phpunit'

