如何使用从composer安装的phpunit? [英] How to use phpunit installed from composer?

查看:45
本文介绍了如何使用从composer安装的phpunit?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 phpunit 开始对我的 symfony 2 应用程序进行单元测试.我使用composer(每个项目的依赖)安装了phpunit.http://www.phpunit.de/manual/current/en/installation.html

I want to start unit testing my symfony 2 application with phpunit. I installed phpunit using composer (per-project dependancy). http://www.phpunit.de/manual/current/en/installation.html

我现在如何在 Zend Server 上运行 phpunit 命令?我没有安装梨.

How do I now run the phpunit command on Zend Server? I don't have pear installed.

推荐答案

如果您按照文档进行操作,则您已将 phpunit/phpunit 依赖项设置为dev-dependency".

If you followed the documentation, you have set the phpunit/phpunit dependency as a 'dev-dependency'.

如果没有composer,需要先安装.这在文档中进行了解释:安装 *nix安装窗口.如果您已经安装了 Composer,最好通过运行 self-update 命令将 Composer 更新到最新版本:

If you don't have composer, you need to install it first. This is explained in the documentation: Installation *nix or Installation Windows. If you already installed composer, it is a good practise to update composer to the latest version by running the self-update command:

$ php composer.phar self-update

完成后,您需要安装所有依赖项,包括开发依赖项.这是通过运行带有 --dev 开关的 update 命令来完成的:

After your have done that, you need to install all dependencies, including the dev dependencies. This is done by running the update command with the --dev switch:

$ php composer.phar update --dev

所有依赖项都安装在vendor 目录中.PHPunit 从控制台运行.Composer 自动将控制台文件放在 vendor/bin 目录中.您需要在那里执行 phpunit 文件:

All the dependencies are installed in the vendor directory. PHPunit runs from the console. Composer automatic put the console files inside the vendor/bin directory. You need to execute the phpunit file in there:

$ vendor/bin/phpunit -c app/

-c 开关告诉 PHPUnit 在 app 目录中查找配置文件,Symfony2 已经设置了正确的配置来运行 app 目录中的所有测试code>/Tests 目录.

The -c switch tells PHPUnit to look for the configuration file in the app directory, Symfony2 already set up the correct configuration to run all tests that are in the <bundle>/Tests directory.

Composer 已更改其更新/安装命令.update 会默认安装 dev 依赖,如果你想安装 dev 依赖,你需要使用 --dev 选项.

Composer has changed their update/install commands. update will install dev dependencies by default and if you want to install dev dependencies, you need to use the --dev option.

Composer 再次更改了他们的命令,install 命令也将安装开发依赖项.

Composer has changed their commands again, the install command will also install dev dependencies.

这篇关于如何使用从composer安装的phpunit?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆