|
| 1 | +# Executables and shared options |
| 2 | +PHP := php |
| 3 | +PHPUNIT := ./vendor/bin/phpunit |
| 4 | +RECTOR := ./vendor/bin/rector |
| 5 | +PHPCS := ./vendor/bin/phpcs |
| 6 | +PHPCBF := ./vendor/bin/phpcbf |
| 7 | +PHPUNIT_FLAGS := --testdox --display-errors --display-warnings --display-deprecations --display-phpunit-deprecations --display-notices |
| 8 | +PHPCS_FLAGS := --standard=phpcs.xml.dist --extensions=php --ignore=vendor/ |
| 9 | + |
| 10 | +# Default target |
| 11 | +all: help |
| 12 | + |
| 13 | +# Tests |
1 | 14 | test_unit: |
2 | | - @printf 'Running unit tests:\n'; |
3 | | - ./vendor/bin/phpunit tests/Unit --testdox --display-errors --display-warnings --display-deprecations --display-phpunit-deprecations --display-notices |
| 15 | + @printf 'Running unit tests:\n' |
| 16 | + $(PHPUNIT) tests/Unit $(PHPUNIT_FLAGS) |
4 | 17 |
|
5 | 18 | test_integration: |
6 | | - @printf 'Running integration tests:\n'; |
7 | | - @echo "Note: Ensure you have the necessary environment variables set for integration tests in the .env file." |
8 | | - ./vendor/bin/phpunit tests/Integration --testdox --display-errors --display-warnings --display-deprecations --display-phpunit-deprecations --display-notices |
| 19 | + @printf 'Running integration tests:\n' |
| 20 | + @echo "Note: ensure the required integration variables are set in .env." |
| 21 | + $(PHPUNIT) tests/Integration $(PHPUNIT_FLAGS) |
9 | 22 |
|
10 | 23 | test_acceptance: |
11 | | - @printf 'Running acceptance tests:\n'; |
12 | | - ./vendor/bin/phpunit tests/Acceptance --testdox --display-errors --display-warnings --display-deprecations --display-phpunit-deprecations --display-notices |
| 24 | + @printf 'Running acceptance tests:\n' |
| 25 | + $(PHPUNIT) tests/Acceptance $(PHPUNIT_FLAGS) |
13 | 26 |
|
14 | 27 | test: |
15 | | - @printf 'Running all tests:\n'; |
16 | | - make test_unit; |
17 | | - make test_acceptance; |
18 | | - make test_integration; |
| 28 | + @printf 'Running all tests:\n' |
| 29 | + $(MAKE) test_unit |
| 30 | + $(MAKE) test_acceptance |
| 31 | + $(MAKE) test_integration |
19 | 32 |
|
| 33 | +# Code style |
20 | 34 | lint: |
21 | | - ./vendor/bin/phpcs --standard=phpcs.xml.dist --extensions=php --ignore=vendor/ . |
| 35 | + @echo "Running PHP CodeSniffer..." |
| 36 | + $(PHPCS) $(PHPCS_FLAGS) . |
22 | 37 |
|
23 | 38 | lint_fix: |
24 | | - ./vendor/bin/phpcbf --standard=phpcs.xml.dist --extensions=php --ignore=vendor/ . |
| 39 | + @echo "Fixing PHP CodeSniffer issues..." |
| 40 | + $(PHPCBF) $(PHPCS_FLAGS) . |
| 41 | + |
| 42 | +lint-fix: lint_fix |
| 43 | + |
| 44 | +# Refactoring |
| 45 | +rector: |
| 46 | + @echo "Running Rector dry-run..." |
| 47 | + $(RECTOR) process src --dry-run --clear-cache --config rector.php |
| 48 | + |
| 49 | +rector_fix: |
| 50 | + @echo "Applying Rector refactoring..." |
| 51 | + $(RECTOR) process src --clear-cache --config rector.php |
25 | 52 |
|
| 53 | +rector-fix: rector_fix |
| 54 | + |
| 55 | +# Utilities |
| 56 | +check: lint test_unit |
| 57 | + |
| 58 | +clean: |
| 59 | + @echo "Cleaning local tool caches..." |
| 60 | + rm -rf .rector/cache .phpunit.result.cache .phpcs.cache |
26 | 61 |
|
27 | 62 | setup-git-hooks: |
28 | 63 | @echo "Setting up Git hooks..." |
29 | 64 | git config core.hooksPath .githooks |
30 | 65 | chmod +x .githooks/pre-commit |
| 66 | + |
| 67 | +help: |
| 68 | + @echo "Available targets:" |
| 69 | + @echo " test_unit Run unit tests" |
| 70 | + @echo " test_integration Run integration tests; requires .env" |
| 71 | + @echo " test_acceptance Run acceptance tests" |
| 72 | + @echo " test Run unit, acceptance, and integration tests" |
| 73 | + @echo " lint Run PHP CodeSniffer" |
| 74 | + @echo " lint_fix Auto-fix code style issues" |
| 75 | + @echo " rector Run Rector in dry-run mode" |
| 76 | + @echo " rector_fix Apply Rector refactoring" |
| 77 | + @echo " check Run lint and unit tests" |
| 78 | + @echo " clean Remove local tool caches" |
| 79 | + @echo " setup-git-hooks Configure repository Git hooks" |
| 80 | + |
| 81 | +.PHONY: all test test_unit test_integration test_acceptance lint lint_fix lint-fix rector rector_fix rector-fix check clean setup-git-hooks help |
0 commit comments