Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adding arguments to php-unit hook #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ A systems hook that just runs `php -l` against stage files that have the `.php`
rev: 1.4.0
hooks:
- id: php-unit
args: [--debug]
```

A bash script that will run the appropriate phpunit executable. It will assume
Expand All @@ -47,6 +48,8 @@ A bash script that will run the appropriate phpunit executable. It will assume

Note in its current state, it will run the whole PHPUnit test as along as `.php` file was committed.

An `args` property in your hook declaration can be used for passing any valid PHPUnit arguments.

## php-cs

```yaml
Expand Down
10 changes: 7 additions & 3 deletions pre_commit_hooks/php-unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# - php
#
# Arguments
# - None
# See: https://phpunit.readthedocs.io/en/9.0/textui.html

# Plugin title
title="PHP Unit Task Runner"
Expand All @@ -26,8 +26,12 @@ source $DIR/helpers/formatters.sh
source $DIR/helpers/welcome.sh
source $DIR/helpers/locate.sh

echo -e "${bldwht}Running command ${txtgrn} ${exec_command}"
command_result=`eval $exec_command`
command_args=$1
command_to_run="${exec_command} ${command_args}"

echo -e "${bldwht}Running command ${txtgrn} ${exec_command} ${command_args}"
hr
command_result=`eval $command_to_run`
if [[ $command_result =~ FAILURES ]]
then
hr
Expand Down