| 148 |
lars |
1 |
# Contributing
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
We'd love you to help out with mockery and no contribution is too small.
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
## Reporting Bugs
|
|
|
8 |
|
|
|
9 |
Issues can be reported on the [issue
|
|
|
10 |
tracker](https://github.com/padraic/mockery/issues). Please try and report any
|
|
|
11 |
bugs with a minimal reproducible example, it will make things easier for other
|
|
|
12 |
contributors and your problems will hopefully be resolved quickly.
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
## Requesting Features
|
|
|
16 |
|
|
|
17 |
We're always interested to hear about your ideas and you can request features by
|
|
|
18 |
creating a ticket in the [issue
|
|
|
19 |
tracker](https://github.com/padraic/mockery/issues). We can't always guarantee
|
|
|
20 |
someone will jump on it straight away, but putting it out there to see if anyone
|
|
|
21 |
else is interested is a good idea.
|
|
|
22 |
|
|
|
23 |
Likewise, if a feature you would like is already listed in
|
|
|
24 |
the issue tracker, add a :+1: so that other contributors know it's a feature
|
|
|
25 |
that would help others.
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
## Contributing code and documentation
|
|
|
29 |
|
|
|
30 |
We loosely follow the
|
|
|
31 |
[PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md)
|
|
|
32 |
and
|
|
|
33 |
[PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) coding standards,
|
|
|
34 |
but we'll probably merge any code that looks close enough.
|
|
|
35 |
|
|
|
36 |
* Fork the [repository](https://github.com/padraic/mockery) on GitHub
|
|
|
37 |
* Add the code for your feature or bug
|
|
|
38 |
* Add some tests for your feature or bug
|
|
|
39 |
* Optionally, but preferably, write some documentation
|
|
|
40 |
* Optionally, update the CHANGELOG.md file with your feature or
|
|
|
41 |
[BC](http://en.wikipedia.org/wiki/Backward_compatibility) break
|
|
|
42 |
* Send a [Pull
|
|
|
43 |
Request](https://help.github.com/articles/creating-a-pull-request) to the
|
|
|
44 |
correct target branch (see below)
|
|
|
45 |
|
|
|
46 |
If you have a big change or would like to discuss something, create an issue in
|
|
|
47 |
the [issue tracker](https://github.com/padraic/mockery/issues) or jump in to
|
|
|
48 |
\#mockery on freenode
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
Any code you contribute must be licensed under the [BSD 3-Clause
|
|
|
52 |
License](http://opensource.org/licenses/BSD-3-Clause).
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
## Target Branch
|
|
|
56 |
|
|
|
57 |
Mockery may have several active branches at any one time and roughly follows a
|
|
|
58 |
[Git Branching Model](https://igor.io/2013/10/21/git-branching-model.html).
|
|
|
59 |
Generally, if you're developing a new feature, you want to be targeting the
|
|
|
60 |
master branch, if it's a bug fix, you want to be targeting a release branch,
|
|
|
61 |
e.g. 0.8.
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
## Testing Mockery
|
|
|
65 |
|
|
|
66 |
To run the unit tests for Mockery, clone the git repository, download Composer using
|
|
|
67 |
the instructions at [http://getcomposer.org/download/](http://getcomposer.org/download/),
|
|
|
68 |
then install the dependencies with `php /path/to/composer.phar install`.
|
|
|
69 |
|
|
|
70 |
This will install the required PHPUnit and Hamcrest dev dependencies and create the
|
|
|
71 |
autoload files required by the unit tests. You may run the `vendor/bin/phpunit` command
|
|
|
72 |
to run the unit tests. If everything goes to plan, there will be no failed tests!
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
## Debugging Mockery
|
|
|
76 |
|
|
|
77 |
Mockery and its code generation can be difficult to debug. A good start is to
|
|
|
78 |
use the `RequireLoader`, which will dump the code generated by mockery to a file
|
|
|
79 |
before requiring it, rather than using eval. This will help with stack traces,
|
|
|
80 |
and you will be able to open the mock class in your editor.
|
|
|
81 |
|
|
|
82 |
``` php
|
|
|
83 |
|
|
|
84 |
// tests/bootstrap.php
|
|
|
85 |
|
|
|
86 |
Mockery::setLoader(new Mockery\Loader\RequireLoader(sys_get_temp_dir()));
|
|
|
87 |
|
|
|
88 |
```
|