OSDN Git Service

add more info about Behat
[wvm/wvm.git] / CONTRIBUTING.md
1 Contribute
2 ==========
3
4 So you've got an awesome idea to throw into WP-CLI. Great! Here's the process, in a nutshell:
5
6 1. [Fork](https://github.com/wp-cli/wp-cli/fork) the repository.
7 2. Make the code changes in your fork.
8 3. Open a pull request.
9
10 It doesn't matter if the code isn't perfect. The idea is to get feedback early and iterate.
11
12 If you're adding a new feature, please add one or more functional tests for it in the `features` directory. See below.
13
14 Also, please create or update the appropriate `.txt` file in the `man-src` directory. See below.
15
16 Lastly, please follow the [WordPress Coding Standards](http://make.wordpress.org/core/handbook/coding-standards/).
17
18 Running the tests
19 -----------------
20
21 There are two types of tests:
22
23 * unit tests, implemented using [PHPUnit](http://phpunit.de/)
24 * functional tests, implemented using [Behat](http://behat.org)
25
26 All the test dependencies can be installed using [Composer](http://getcomposer.org/):
27
28     php composer.phar install --dev
29
30 ### Unit tests
31
32 To run the unit tests, just execute:
33
34     vendor/bin/phpunit
35
36 ### Functional tests
37
38 Before running the functional tests, you'll need a MySQL user called `wp_cli_test` with the
39 password `password1` that has full privileges on the MySQL database `wp_cli_test`.
40 Running the following as root in MySQL should do the trick:
41
42     GRANT ALL PRIVILEGES ON wp_cli_test.* TO "wp_cli_test"@"localhost" IDENTIFIED BY "password1";
43
44 Then, to run the entire test suite:
45
46     vendor/bin/behat --expand
47
48 Or to test a single feature:
49
50     vendor/bin/behat features/core.feature
51
52 More info can be found from `vendor/bin/behat --help`.
53
54 Finally...
55 ----------
56
57 Thanks! Hacking on WP-CLI should be fun. If you find any of this hard to figure
58 out, let us know so we can improve our process or documentation!