Skip to content

Commit

Permalink
Enhancement: Use phpunit/phpunit to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Feb 1, 2024
1 parent 555ac83 commit fa57317
Show file tree
Hide file tree
Showing 7 changed files with 1,711 additions and 4,331 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "none, curl, json, mbstring, tokenizer"
extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

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

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

- name: "Set up problem matchers for phpunit/phpunit"
run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\""

- name: "Determine composer cache directory"
run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v3"
with:
path: "${{ env.COMPOSER_CACHE_DIR }}"
key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-"

- name: "Install dependencies with composer"
run: "composer install --ansi --no-interaction --no-progress"

- name: "Start built-in web server for PHP"
run: "php -S ${{ env.HTTP_HOST }} .router.php &"

- name: "Run tests"
run: "php tests/run-tests.php -j3 -q --show-diff"
- name: "Run phpunit/phpunit"
run: "vendor/bin/phpunit --colors=always --configuration=tests/phpunit.xml"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.build/
/vendor/

backend/mirror.gif
Expand Down
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@

HTTP_HOST:=localhost:8080

.PHONY: it
it: coding-standards tests ## Runs all the targets

.PHONY: help
help: ## Displays this list of targets with descriptions
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: code-coverage
code-coverage: vendor ## Collects coverage from running tests with phpunit/phpunit
tests/server start; vendor/bin/phpunit --configuration=tests/phpunit.xml --coverage-text; tests/server stop

.PHONY: coding-standards
coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fixer
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --verbose
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --show-progress=dots --verbose

.PHONY: tests
tests: vendor ## Runs tests
tests/server start; php tests/run-tests.php -j3 -q; tests/server stop
tests: vendor ## Runs tests with phpunit/phpunit
rm -rf tests/server.log
tests/server start; vendor/bin/phpunit --configuration=tests/phpunit.xml; tests/server stop

vendor: composer.json composer.lock
composer validate --strict
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
},
"require-dev": {
"ext-curl": "*",
"friendsofphp/php-cs-fixer": "^3.40.2"
"friendsofphp/php-cs-fixer": "^3.40.2",
"phpunit/phpunit": "^10.5.9"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit fa57317

Please sign in to comment.