OSDN Git Service

Merge pull request #944 from johnbillion/whether
[wvm/wvm.git] / CONTRIBUTING.md
1 Contribute
2 ==========
3
4 Whether you want to fix a bug or implement a new feature, the process is pretty much the same:
5
6 0. [Search existing issues](https://github.com/wp-cli/wp-cli/issues); if you can't find anything related to what you want to work on, open a new issue so that you can get some initial feedback.
7 1. [Fork](https://github.com/wp-cli/wp-cli/fork) the repository.
8 2. Make the code changes in your fork.
9 3. Open a pull request.
10
11 It doesn't matter if the code isn't perfect. The idea is to get it reviewed early and iterate on it.
12
13 If you're adding a new feature, please add one or more functional tests for it in the `features/` directory. See below.
14
15 Lastly, please follow the [WordPress Coding Standards](http://make.wordpress.org/core/handbook/coding-standards/).
16
17 Running and writing tests
18 -------------------------
19
20 There are two types of automated tests:
21
22 * unit tests, implemented using [PHPUnit](http://phpunit.de/)
23 * functional tests, implemented using [Behat](http://behat.org)
24
25 To set everything up, just run:
26
27 ```bash
28 ./utils/dev-build
29 ```
30
31 ### Unit tests
32
33 The unit test files are in the `tests/` directory.
34
35 To run the unit tests, just execute:
36
37     php phpunit.phar
38
39 ### Functional tests
40
41 The functional test files are in the `features/` directory.
42
43 Before running the functional tests, you'll need a MySQL user called `wp_cli_test` with the
44 password `password1` that has full privileges on the MySQL database `wp_cli_test`.
45 Running the following as root in MySQL should do the trick:
46
47     GRANT ALL PRIVILEGES ON wp_cli_test.* TO "wp_cli_test"@"localhost" IDENTIFIED BY "password1";
48
49 Then, to run the entire test suite:
50
51     php behat.phar --expand
52
53 Or to test a single feature:
54
55     php behat.phar features/core.feature
56
57 More info can be found from `php behat.phar --help`.
58
59 Finally...
60 ----------
61
62 Thanks! Hacking on WP-CLI should be fun. If you find any of this hard to figure
63 out, let us know so we can improve our process or documentation!