Testing
The bundle's tests run in Docker (image ufotech/php:8.4-fpm, see the repository's docker-compose.yaml):
make up-d
make composer-install
make test # all suites
make test ARGS="--testsuite Unit" # one suite
make test needs a TTY; without one (for example, in scripts):
docker exec -w /app php_mcp vendor/bin/phpunit --testsuite Functional
| Suite | What it checks | How |
|---|---|---|
Unit |
The configuration tree and the typed configuration, server.json, client manifests, the session store, the request carrier, the tool executor, route import, default extension points |
PHPUnit, mocks |
Functional |
The bundle inside an application: routing, 404/401/403, initialize, tools/list (groups, versions, translations, schemas, annotations), tools/call (results, errors, events, cache, batch), sessions, the stateless protocol, CORS, DNS rebinding, body limit, server.json, manifests, extension points |
Fixtures\TestKernel, HTTP requests through handle() + terminate() |
E2E |
The official mcp/sdk client over real HTTP in three protocol versions (2025-06-18, 2025-11-25, 2026-07-28) |
PHP built-in server with tests/Fixtures/public/index.php |
The fixture application (tests/Fixtures): procedures in the groups mcp, internal, off, bad, a version 2 procedure, translations, routes like an application's config/routes/ufo_mcp.yaml. TestKernel::$mcpConfig and TestKernel::$serviceOverrides change the configuration or replace a service for one test.
Coverage
With Xdebug 3.4.2 (image ufotech/php:8.4-fpm), collecting coverage for the tests that start the SDK server ends in a segmentation fault. Use pcov.
docker exec php_mcp pecl install pcov # once per container
docker exec -w /app -e XDEBUG_MODE=off php_mcp php -d extension=pcov.so -d pcov.enabled=1 \
vendor/bin/phpunit --testsuite Unit,Functional --coverage-text
Checking with MCP Inspector
docker exec -d -w /app php_mcp php -S 0.0.0.0:8099 tests/Fixtures/public/index.php
docker run --rm --network container:php_mcp node:22-alpine npx -y @modelcontextprotocol/inspector --cli \
http://127.0.0.1:8099/mcp --transport http --header "Ufo-RPC-Token: test-token" --method tools/list