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 Dec 11, 2023
1 parent b95f3e7 commit 82980db
Show file tree
Hide file tree
Showing 7 changed files with 1,704 additions and 4,330 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, json, mbstring, tokenizer"
extensions: "none, dom, json, mbstring, tokenizer"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
Expand Down Expand Up @@ -72,11 +72,27 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "none"
extensions: "none, 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: "Run tests"
run: "php tests/run-tests.php -j3 -q --show-diff"
- 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: "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
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
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
vendor/bin/phpunit --configuration=tests/phpunit.xml --coverage-text

.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

.PHONY: tests
tests: ## Runs tests
php tests/run-tests.php -j3 -q
tests: vendor ## Runs tests with phpunit/phpunit
vendor/bin/phpunit --configuration=tests/phpunit.xml

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 @@ -11,7 +11,8 @@
"php": "~8.2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.40.2"
"friendsofphp/php-cs-fixer": "^3.40.2",
"phpunit/phpunit": "^10.5.2"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 82980db

Please sign in to comment.