Skip to content

Commit 4eabd6c

Browse files
committed
Enhancement: Use phpunit/phpunit to run tests
1 parent fe0679e commit 4eabd6c

File tree

7 files changed

+1710
-4330
lines changed

7 files changed

+1710
-4330
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"
@@ -73,14 +73,30 @@ jobs:
7373
uses: "shivammathur/setup-php@v2"
7474
with:
7575
coverage: "none"
76-
extensions: "none, curl"
76+
extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter"
7777
php-version: "${{ matrix.php-version }}"
7878

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

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

85-
- name: "Run tests"
86-
run: "php tests/run-tests.php -j3 -q --show-diff"
101+
- name: "Run phpunit/phpunit"
102+
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: 10 additions & 2 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
1118
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.49.0"
15+
"friendsofphp/php-cs-fixer": "^3.49.0",
16+
"phpunit/phpunit": "^10.5.10"
1617
},
1718
"autoload": {
1819
"psr-4": {

0 commit comments

Comments
 (0)