Unit Testing
To run unit tests locally refer to the Github Workflows and in your local container run:
Unit Testing the PHP Modules
Interactive:
podman exec -it zms-web bashcd {zmsadmin, zmscalldisplay, zmsdldb, zmsentities, zmsmessaging, zmsslim, zmsstatistic, zmsticketprinter}./vendor/bin/phpunitLocal 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:
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:
--display-warnings
--display-deprecations
--display-notices
--display-errors
--display-failures
--debugSpecial 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).
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):
./zmsbackend/zmsbackend-testOr manually (inside zms-web):
cd zmsbackend && bin/importTestData --commit
cd zmsbackend && bin/configure && ./vendor/bin/phpunitPHP Containerized Unit Testing (Recommended - isolated environment)
Run your tests in clean, disposable containers to ensure they don’t affect your local system or database:
# 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 testAvailable PHPUnit Flags:
# 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 suiteExamples:
# 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:
cd zmscitizenviewnpm testFilter by test name pattern:
npm test -- -t "AppointmentView"zmsautomation
zmsautomation is not a unit-test module. Its API/UI test suites are documented in zmsautomation Documentation.