Ryan
Ryan

Reputation: 10131

Run syntax check on all files before running PHP Unit

I want to check the syntax (i.e. php -l) on all scripts before running the test using phpunit, and it fail there is no need to run phpunit.

Is it possible to integrate into one step process?

Upvotes: 1

Views: 1064

Answers (1)

Fabian Schmengler
Fabian Schmengler

Reputation: 24576

Without additional tools, you can use this line to check all PHP files below the current directory and only execute phpunit if no syntax errors are found:

find . -type f -iname "*.php" -print0 | xargs -0 -n1 php -l && phpunit

You could set it up as an alias:

alias phpunitl='find . -type f -iname "*.php" -print0 | xargs -0 -n1 php -l && phpunit'

and then use phpunitl instead of phpunit (with the same parameters that you would use for phpunit)

Upvotes: 2

Related Questions