Writing Code¶
General¶
Coding Style Guide¶
For convenience we follow the PSR-1 and PSR-2 coding style guides of PHP Framework Interop Group. Please be so nice to take care of this during code contribution (e.g. pull requests). To check your code against this standards you can use tools like PHP_CodeSniffer.
Pull requests¶
With Gerrit we follow the standard code contribution of the GitHub platform. This means:
- Fork the project into a personal username space and clone the repository.
$ git clone https://github.com/andygrunwald/Gerrie.git
- Create a new git branch for your change (bugfix, feature, improvement, etc.).
$ git checkout -b my-new-feature
- Make your changes in the codebase until your changes are working.
$ vim ./file $ # Hack hack hack
- Commit your changes into your local git repository.
$ git commit -am 'Add some feature'
- Push your new branch to your fork repository.
$ git push origin my-new-feature
- Visit the forked repository via the GitHub website and create the pull request based on your new branch.
$ # Ploepp (beer open) $ # gluck gluck gluck (beer drinking)
This are the necessary steps described in a really rough way. If you need more help the GitHub help pages are a a excellent source:
Testing¶
PHPUnit¶
Gerrie uses PHPUnit to create unit and integration tests.
The tests are located in the tests
folder.
To execute the unit tests ensure that you have installed all development dependencies via --dev
and start PHPUnit:
$ composer install --dev
$ # Without code coverage generation
$ ./vendor/bin/phpunit --coverage-clover=coverage.clover
$ # With code coverage generation
$ ./vendor/bin/phpunit
Note
To generate the code coverage you need the PHP Extension xDebug
installed.
To create mock objects we use the standard functionality of PHPUnit.
Quality services¶
Travis CI¶
Travis CI is a free hosted Continuous Integration Platform for Open Source projects. We make us of this service to execute our tests continuous. One of the biggest advantages is that all pull request will be checked with Travis CI as well. So if you want to contribute please do not fear to break something. Every pull request you create will be checked and you will be notified if something go wrong. So just try it :)
Scrutinizer¶
Scrutinizer is a free hosted Continuous inspection Platform for Open Source projects. This service executes several checks for us like * checking the coding styleguide for us * observe the code documentation about possible bugs in return values * determine a quality score for Gerrie * and adds small tipps of how to improve the code quality of the software
As a small additional feature we push the generated code coverage from our unit tests from Travis CI to Scrutinizer. With this Scrutinizer can determine the overall code coverage for us.