Skip to content

Commit fa57317

Browse files
committed
Enhancement: Use phpunit/phpunit to run tests
1 parent 555ac83 commit fa57317

File tree

7 files changed

+1711
-4331
lines changed

7 files changed

+1711
-4331
lines changed

.github/workflows/integrate.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: "shivammathur/setup-php@v2"
2828
with:
2929
coverage: "none"
30-
extensions: "none, curl, json, mbstring, tokenizer"
30+
extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter"
3131
php-version: "${{ matrix.php-version }}"
3232

3333
- name: "Set up problem matchers for PHP"
@@ -75,14 +75,30 @@ jobs:
7575
uses: "shivammathur/setup-php@v2"
7676
with:
7777
coverage: "none"
78-
extensions: "none, curl"
78+
extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter"
7979
php-version: "${{ matrix.php-version }}"
8080

8181
- name: "Set up problem matchers for PHP"
8282
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""
8383

84+
- name: "Set up problem matchers for phpunit/phpunit"
85+
run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\""
86+
87+
- name: "Determine composer cache directory"
88+
run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV"
89+
90+
- name: "Cache dependencies installed with composer"
91+
uses: "actions/cache@v3"
92+
with:
93+
path: "${{ env.COMPOSER_CACHE_DIR }}"
94+
key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}"
95+
restore-keys: "php-${{ matrix.php-version }}-composer-"
96+
97+
- name: "Install dependencies with composer"
98+
run: "composer install --ansi --no-interaction --no-progress"
99+
84100
- name: "Start built-in web server for PHP"
85101
run: "php -S ${{ env.HTTP_HOST }} .router.php &"
86102

87-
- name: "Run tests"
88-
run: "php tests/run-tests.php -j3 -q --show-diff"
103+
- name: "Run phpunit/phpunit"
104+
run: "vendor/bin/phpunit --colors=always --configuration=tests/phpunit.xml"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.build/
12
/vendor/
23

34
backend/mirror.gif

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@
22

33
HTTP_HOST:=localhost:8080
44

5+
.PHONY: it
6+
it: coding-standards tests ## Runs all the targets
7+
58
.PHONY: help
69
help: ## Displays this list of targets with descriptions
710
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
811

12+
.PHONY: code-coverage
13+
code-coverage: vendor ## Collects coverage from running tests with phpunit/phpunit
14+
tests/server start; vendor/bin/phpunit --configuration=tests/phpunit.xml --coverage-text; tests/server stop
15+
916
.PHONY: coding-standards
1017
coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fixer
11-
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --verbose
18+
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --show-progress=dots --verbose
1219

1320
.PHONY: tests
14-
tests: vendor ## Runs tests
15-
tests/server start; php tests/run-tests.php -j3 -q; tests/server stop
21+
tests: vendor ## Runs tests with phpunit/phpunit
22+
rm -rf tests/server.log
23+
tests/server start; vendor/bin/phpunit --configuration=tests/phpunit.xml; tests/server stop
1624

1725
vendor: composer.json composer.lock
1826
composer validate --strict

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
},
1313
"require-dev": {
1414
"ext-curl": "*",
15-
"friendsofphp/php-cs-fixer": "^3.40.2"
15+
"friendsofphp/php-cs-fixer": "^3.40.2",
16+
"phpunit/phpunit": "^10.5.9"
1617
},
1718
"autoload": {
1819
"psr-4": {

0 commit comments

Comments
 (0)