Skip to content

Unit Testing

To run unit tests locally refer to the Github Workflows and in your local container run:

Unit Testing the PHP Modules

Interactive:

bash
podman exec -it zms-web bash
bash
cd {zmsadmin, zmscalldisplay, zmsdldb, zmsentities, zmsmessaging, zmsslim, zmsstatistic, zmsticketprinter}
bash
./vendor/bin/phpunit

Local zms-web mounts .devcontainer/php/xdebug.ini with xdebug.mode=debug,develop and xdebug.start_with_request=yes. That makes PHPUnit (especially zmsadmin and other Slim apps) hang or run very slowly on macOS Podman. Turn Xdebug off for the PHPUnit process:

bash
podman exec -it zms-web bash -lc 'export XDEBUG_MODE=off; cd zmsadmin && ./vendor/bin/phpunit --no-coverage'

Swap zmsadmin for the module you need. Use export XDEBUG_MODE=off; before cd. XDEBUG_MODE=off cd zmsadmin && ./vendor/bin/phpunit only applies the variable to cd, so PHPUnit still runs with the debugger enabled.

Useful flags for ./vendor/bin/phpunit:

bash
--display-warnings
--display-deprecations
--display-notices
--display-errors
--display-failures
--debug

Special Cases (zmsbackend & zmsclient)

zmsclient:

For zmsclient you need the php base image which starts a local mock server. This json in the mocks must match the signature the entity returned in the requests (usually this is the issue whenever tests fail in zmsclient).

bash
cd zmsclient
./zmsclient-test
./zmsclient-test --filter "testSetKeyBasic"

The zmsclient-test script starts the mock and test containers and runs PHPUnit.

Traditional Method (overwrites local DB)

For zmsbackend, test data must be imported. Please note that this will overwrite your local database.

zmsbackend (unified REST API and database module for /terminvereinbarung/api/2):

bash
./zmsbackend/zmsbackend-test

Or manually (inside zms-web):

bash
cd zmsbackend && bin/importTestData --commit
cd zmsbackend && bin/configure && ./vendor/bin/phpunit

Run your tests in clean, disposable containers to ensure they don’t affect your local system or database:

bash
# Enter your web container
podman exec -it zms-web bash

# Run zmsbackend tests
./zmsbackend/zmsbackend-test                    # Run all tests
./zmsbackend/zmsbackend-test --filter="StatusTest::testBasic"  # Run specific test
./zmsbackend/zmsbackend-test --filter="StatusGetTest::testRendering"  # Run specific test

Available PHPUnit Flags:

bash
# Test Selection (filter is a regex matching against "Namespace\TestClass::testMethod")
--filter="TestClass::testMethod"  # Run specific test method
--filter="TestClass"              # Run all tests in a class
--filter="testMethod"             # Run all tests with matching method name
--filter="pattern"                # Run tests matching regex pattern

# Output & Verbosity
--verbose                         # More detailed output
--debug                           # Debug information
--stop-on-failure                 # Stop on first failure
--stop-on-error                   # Stop on first error
--stop-on-warning                 # Stop on first warning

# Coverage & Reports
--coverage-text                   # Text coverage report
--coverage-html=dir               # HTML coverage report
--coverage-clover=file.xml        # XML coverage report

# Test Execution
--group="groupName"               # Run tests in specific group
--exclude-group="groupName"       # Exclude tests in group
--testsuite="suiteName"           # Run specific test suite

Examples:

bash
# Run specific test with verbose output
./zmsbackend/zmsbackend-test --filter="StatusTest::testBasic" --verbose

# Run all tests in a class and stop on first failure
./zmsbackend/zmsbackend-test --filter="StatusGetTest" --stop-on-failure

# Run tests with coverage report
./zmsbackend/zmsbackend-test --coverage-text

# Run tests excluding a specific group
./zmsbackend/zmsbackend-test --exclude-group="slow"

zmscitizenview Unit Testing

Run frontend unit tests with Vitest/Jest setup from the module:

bash
cd zmscitizenview
bash
npm test

Filter by test name pattern:

bash
npm test -- -t "AppointmentView"

zmsautomation

zmsautomation is not a unit-test module. Its API/UI test suites are documented in zmsautomation Documentation.