Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pre-commit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Running tests as pre-commit hooks

If you want to run some of the tests as git hooks to avoid comitting "bad" code, you can do that. It would probably make most sense to only run static tests.

Usually static tests are run with the command `composer test-static`. To run this as a git hook you can simply add this file to a file called `.git/hooks/pre-commit` in your project:

```sh
#!/bin/sh

composer test-static
```

If you think that takes too long, and you just want to run code style checks with phpcs, you can instead change it to something like this:

```sh
#!/bin/sh

vendor/bin/phpcs -pn
```