Skip to content

Commit 3c4676b

Browse files
authored
Merge pull request #85 from bluem-development/linting-and-tests
2.5 release - Linting and tests
2 parents ae85288 + a170d15 commit 3c4676b

66 files changed

Lines changed: 882 additions & 462 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
strategy:
77
matrix:
8-
php-version: ['8.3', '8.4']
8+
php-version: ['8.3', '8.4', '8.5']
99

1010
steps:
1111
- name: Checkout code
@@ -41,6 +41,6 @@ jobs:
4141
uses: php-actions/phpunit@v4
4242
with:
4343
php_version: ${{ matrix.php-version }}
44-
version: 11
44+
version: 12
4545
bootstrap: ./vendor/autoload.php
4646
configuration: ./.github/workflows/phpunit.xml

.github/workflows/phpunit.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
bootstrap="vendor/autoload.php" colors="true"
5-
stopOnFailure="false"
6-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
stopOnFailure="false"
7+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
78
>
89
<testsuites>
910
<testsuite name="Unit">

Makefile

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,81 @@
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
114
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)
417

518
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)
922

1023
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)
1326

1427
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
1932

33+
# Code style
2034
lint:
21-
./vendor/bin/phpcs --standard=phpcs.xml.dist --extensions=php --ignore=vendor/ .
35+
@echo "Running PHP CodeSniffer..."
36+
$(PHPCS) $(PHPCS_FLAGS) .
2237

2338
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
2552

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
2661

2762
setup-git-hooks:
2863
@echo "Setting up Git hooks..."
2964
git config core.hooksPath .githooks
3065
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

Comments
 (0)