Skip to content

Commit

Permalink
test: add PHPUnit test suites
Browse files Browse the repository at this point in the history
  • Loading branch information
COil committed Jan 24, 2025
1 parent 8a15cf2 commit fef5314
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
31 changes: 27 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COVERAGE_THRESHOLD = 100
## —— 🎶 The MicroSymfony Makefile 🎶 ——————————————————————————————————————————
help: ## Outputs this help screen
@grep -E '(^[a-zA-Z0-9_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
.PHONY: help start stop go-prod go-dev purge test coverage cov-report stan fix-php lint-php lint-container lint-twig lint-yaml fix lint ci deploy
.PHONY: help start stop go-prod go-dev purge test test-api test-e2e test-functional test-integration test-unit coverage cov-report stan fix-php lint-php lint-container lint-twig lint-yaml fix lint ci deploy
.PHONY: version-php version-composer version-symfony version-phpunit version-phpstan version-php-cs-fixer check-requirements le-renew


Expand Down Expand Up @@ -42,8 +42,31 @@ purge: ## Purge all Symfony cache and logs


## —— Tests ✅ —————————————————————————————————————————————————————————————————
test: ## Run all PHPUnit tests
@vendor/bin/phpunit
test: ## Run tests with optional suite, filter and options (to debug use "make test options=--debug")
@$(eval testsuite ?= 'api,e2e,functional,integration,unit') # Run all suites by default, to run a specific suite see other "test-*" targets, eg: "make test-unit"
@$(eval filter ?= '.') # Use this parameter to spot a given test, eg: "make test filter=testSlugify"
@$(eval options ?= --stop-on-failure) # Use this use other options, eg: "make test options=--testdox"
@vendor/bin/phpunit --testsuite=$(testsuite) --filter=$(filter) $(options)

test-api: ## Run API tests only
test-api: testsuite=api
test-api: test

test-e2e: ## Run E2E tests only
test-e2e: testsuite=e2e
test-e2e: test

test-functional: ## Run functional tests only
test-functional: testsuite=functional
test-functional: test

test-integration: ## Run integration tests only
test-integration: testsuite=integration
test-integration: test

test-unit: ## Run unit tests only
test-unit: testsuite=unit
test-unit: test

coverage: ## Generate the HTML PHPUnit code coverage report (stored in var/coverage)
coverage: purge
Expand Down Expand Up @@ -94,7 +117,7 @@ version-make:
@echo '—— Make ———————————————————————————————————————————————————————————'
@$(MAKE) --version
version-php:
@echo '—— PHP ————————————————————————————————————————————————————————————'
@echo '\n—— PHP ——————————————————————————————————————————————————————————'
@php -v
version-composer:
@echo '\n—— Composer ———————————————————————————————————————————————————————'
Expand Down
27 changes: 20 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<!-- https://docs.phpunit.de/en/11.5/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
Expand All @@ -15,14 +15,27 @@
<server name="KERNEL_CLASS" value="App\Kernel" />
<server name="APP_ENV" value="test" force="true"/>
<server name="APP_DEBUG" value="true"/> <!-- set this to false on your CI to speed up tests by 2x -->

<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<server name="SYMFONY_PHPUNIT_VERSION" value="10.5"/>
</php>

<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
<testsuite name="unit">
<directory>tests/Unit</directory>
</testsuite>

<testsuite name="integration">
<directory>tests/Integration</directory>
</testsuite>

<testsuite name="api">
<directory>tests/Api</directory>
</testsuite>

<testsuite name="functional">
<directory>tests/Functional</directory>
</testsuite>

<testsuite name="e2e">
<directory>tests/E2E</directory>
</testsuite>
</testsuites>

Expand Down

0 comments on commit fef5314

Please sign in to comment.