http://four.laravel.com/docs/testing Says "After installing a new Laravel application, simply run phpunit
on the command line to run your tests."
http://four.laravel.com/docs/testing说:“安装了一个新的Laravel应用程序后,只需在命令行上运行phpunit就可以运行你的测试了。”
phpunit
isn't recognized, I also tried php artisian test
and php artisan phpunit
phpunit没有被识别,我也尝试了php artisian测试和php artisan phpunit
Is phpunit
in some weird folder, or is it actually not included with Laravel? I don't want to install it and have two if it is.
phpunit是在某个奇怪的文件夹中,还是它实际上没有包含在Laravel中?我不想安装它,如果有两个的话。
5 个解决方案
#1
60
Install with composer
An easy way to get up and running with PHPUnit (without needing to install Pear and clutter up every system you want to use this on) is to include it in your composer.json file, like
使用PHPUnit(不需要安装Pear并将其用于所有系统)的简单方法是将其包含在您的编写器中。json文件,如
"phpunit/phpunit": "4.0.*",
Then after doing a composer update
you'll be able to run PHPUnit from command line like this:
然后,在执行编写器更新之后,您将能够从命令行运行PHPUnit,如下所示:
vendor/bin/phpunit
Since phpunit will be installed into the vendor/bin folder.
因为phpunit将被安装到供应商/bin文件夹中。
This will install PHPUnit to this project only, not your whole system. So when you want it gone, you simply remove the line from your composer.json file, run composer update, and poof, not a trace.
这将只向这个项目安装PHPUnit,而不是整个系统。所以当你想要它消失时,你只需从你的作曲家中删除这行。json文件,运行composer更新,和poof,而不是跟踪。
Installing for development environments only
If you only want to use this during development, add the composer line inside the "require-dev" section. That way it will only be installed when you opt to install dev dependancies via:
如果您只想在开发期间使用它,请在“require-dev”部分中添加编写器行。这样,只有当您选择通过以下方式安装依赖于开发的程序时,才会安装它:
php composer.phar install --dev
or
或
php composer.phar update
#2
4
If you are a window user and you are having this issue, do this:
如果你是一个窗口用户,你有这个问题,做以下的:
You need to tell Window where to find PHPUnit command, you can first of all verify that this file exists in your Laravel project under /vendor/bin
您需要告诉窗口在哪里可以找到PHPUnit命令,您可以首先验证这个文件是否存在于/vendor/bin下的Laravel项目中
Finally you need to append the full path to /vendor/bin
in your window PATH variable,
最后,需要在窗口路径变量中添加到/vendor/bin的完整路径,
To do this: 1. Right-click on 'Computer' then click properties
这样做:1。右键单击“Computer”,然后单击properties
- On the second window click
Advanced system settings
- 在第二个窗口中,单击高级系统设置
- On the next window under
Advanced
clickEnvironmental Variables
- 在“高级环境变量”下的下一个窗口中单击“环境变量”
- On the next window double-click
PATH
then set PATH variable by appending - 在下一个窗口中双击PATH,然后通过追加设置PATH变量
the full path to your laravel-project/vendor/bin;
Notice the ;
at the end.
通往laravel-project/vendor/bin的完整路径;注意到;在最后。
NB: Other variables might already exists in the PATH, so ensure you don't overwrite them by appending your own at the very end
NB:其他变量可能已经存在于路径中,所以确保您不会在最后添加您自己的变量来覆盖它们
- Finally click
Ok
on all the dialog boxes - 最后在所有对话框上单击Ok
#3
0
The easiest way to use phpunit is to put phpunit.phar in the root of your application and to run it with php phpunit.phar.
使用phpunit最简单的方法是放置phpunit。在应用程序的根目录中设置phar,并使用php phpunit.phar运行它。
#4
-1
If you run into "phpunit requires ext-dom" it's because php-xml isn't installed.
如果您遇到“phpunit需要ext-dom”,那是因为没有安装php-xml。
#5
-3
You need to install phpunit and the best way is with pear.
您需要安装phpunit,最好的方法是使用pear。
pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit
If you don't have pear installed, check this regarding pear installation.
如果没有安装pear,请检查这个关于pear安装的问题。
#1
60
Install with composer
An easy way to get up and running with PHPUnit (without needing to install Pear and clutter up every system you want to use this on) is to include it in your composer.json file, like
使用PHPUnit(不需要安装Pear并将其用于所有系统)的简单方法是将其包含在您的编写器中。json文件,如
"phpunit/phpunit": "4.0.*",
Then after doing a composer update
you'll be able to run PHPUnit from command line like this:
然后,在执行编写器更新之后,您将能够从命令行运行PHPUnit,如下所示:
vendor/bin/phpunit
Since phpunit will be installed into the vendor/bin folder.
因为phpunit将被安装到供应商/bin文件夹中。
This will install PHPUnit to this project only, not your whole system. So when you want it gone, you simply remove the line from your composer.json file, run composer update, and poof, not a trace.
这将只向这个项目安装PHPUnit,而不是整个系统。所以当你想要它消失时,你只需从你的作曲家中删除这行。json文件,运行composer更新,和poof,而不是跟踪。
Installing for development environments only
If you only want to use this during development, add the composer line inside the "require-dev" section. That way it will only be installed when you opt to install dev dependancies via:
如果您只想在开发期间使用它,请在“require-dev”部分中添加编写器行。这样,只有当您选择通过以下方式安装依赖于开发的程序时,才会安装它:
php composer.phar install --dev
or
或
php composer.phar update
#2
4
If you are a window user and you are having this issue, do this:
如果你是一个窗口用户,你有这个问题,做以下的:
You need to tell Window where to find PHPUnit command, you can first of all verify that this file exists in your Laravel project under /vendor/bin
您需要告诉窗口在哪里可以找到PHPUnit命令,您可以首先验证这个文件是否存在于/vendor/bin下的Laravel项目中
Finally you need to append the full path to /vendor/bin
in your window PATH variable,
最后,需要在窗口路径变量中添加到/vendor/bin的完整路径,
To do this: 1. Right-click on 'Computer' then click properties
这样做:1。右键单击“Computer”,然后单击properties
- On the second window click
Advanced system settings
- 在第二个窗口中,单击高级系统设置
- On the next window under
Advanced
clickEnvironmental Variables
- 在“高级环境变量”下的下一个窗口中单击“环境变量”
- On the next window double-click
PATH
then set PATH variable by appending - 在下一个窗口中双击PATH,然后通过追加设置PATH变量
the full path to your laravel-project/vendor/bin;
Notice the ;
at the end.
通往laravel-project/vendor/bin的完整路径;注意到;在最后。
NB: Other variables might already exists in the PATH, so ensure you don't overwrite them by appending your own at the very end
NB:其他变量可能已经存在于路径中,所以确保您不会在最后添加您自己的变量来覆盖它们
- Finally click
Ok
on all the dialog boxes - 最后在所有对话框上单击Ok
#3
0
The easiest way to use phpunit is to put phpunit.phar in the root of your application and to run it with php phpunit.phar.
使用phpunit最简单的方法是放置phpunit。在应用程序的根目录中设置phar,并使用php phpunit.phar运行它。
#4
-1
If you run into "phpunit requires ext-dom" it's because php-xml isn't installed.
如果您遇到“phpunit需要ext-dom”,那是因为没有安装php-xml。
#5
-3
You need to install phpunit and the best way is with pear.
您需要安装phpunit,最好的方法是使用pear。
pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit
If you don't have pear installed, check this regarding pear installation.
如果没有安装pear,请检查这个关于pear安装的问题。