概述 快速入门 教程 手册 最佳实践 组件 参考 贡献

发布于 2015-08-27 16:46:18 | 109 次阅读 | 评论: 0 | 来源: 网络整理

Before submitting a patch for inclusion, you need to run the Symfony test suite to check that you have not broken anything.

PHPUnit

To run the Symfony test suite, install PHPUnit 4.2 (or later) first.

Dependencies (optional)

To run the entire test suite, including tests that depend on external dependencies, Symfony needs to be able to autoload them. By default, they are autoloaded from vendor/ under the main root directory (see autoload.php.dist).

The test suite needs the following third-party libraries:

  • Doctrine
  • Swift Mailer
  • Twig
  • Monolog

To install them all, use Composer:

Step 1: Install Composer globally

Step 2: Install vendors.

$ composer install

注解

Note that the script takes some time to finish.

After installation, you can update the vendors to their latest version with the follow command:

$ composer --dev update

Running

First, update the vendors (see above).

Then, run the test suite from the Symfony root directory with the following command:

$ phpunit

The output should display OK. If not, you need to figure out what’s going on and if the tests are broken because of your modifications.

小技巧

If you want to test a single component type its path after the phpunit command, e.g.:

$ phpunit src/Symfony/Component/Finder/

小技巧

Run the test suite before applying your modifications to check that they run fine on your configuration.

Code Coverage

If you add a new feature, you also need to check the code coverage by using the coverage-html option:

$ phpunit --coverage-html=cov/

Check the code coverage by opening the generated cov/index.html page in a browser.

小技巧

The code coverage only works if you have Xdebug enabled and all dependencies installed.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务