-
-
Notifications
You must be signed in to change notification settings - Fork 1
Testing
Home · Adding a protocol · Contributing
GameQ's protocol suite replays captured responses without contacting live game servers. This protects old and poorly documented protocols from regressions when shared parsers change.
composer installcomposer testThis runs:
- parallel PHP syntax checks;
- the PSR-12/PHPCS ruleset;
- PHPStan at maximum level;
- PHPUnit.
Also run when relevant:
composer validate --strict
composer audit
composer bc-checkcomposer bc-check compares public and protected APIs with GameQ 4.0.0 and should be run before changing an extension point.
vendor/bin/phpunit tests/Protocols/Source.php
vendor/bin/phpunit --filter 'GameQ\\Tests\\Protocols\\Source'Use a focused test while iterating, then run composer test before considering the change complete.
The extensionless CLI script queries one real server and stores its raw and parsed responses:
php tests/Protocols/generate_provider \
-p css \
-s 192.0.2.10:27015Pass per-server options as JSON:
php tests/Protocols/generate_provider \
-p teamspeak3 \
-s 192.0.2.10:9987 \
-o '{"query_port":10011}'The script writes pairs beneath tests/Protocols/Providers/<Protocol>/:
1_response.txt
1_result.json
2_response.txt
2_result.json
Raw response files are binary even when their extension is .txt. Do not normalize encoding or line endings.
Capture several representative cases where possible:
- zero and many players;
- split and unsplit packets;
- optional fields present and absent;
- passworded and public servers;
- multiple server/game versions;
- pagination or challenge variants;
- malformed/truncated synthetic packets for validation paths.
Query a server normally before capturing it. An offline server only creates an unhelpful empty fixture.
Prefer a stable IP in recorded server metadata. Tests never contact the recorded game server, but legacy fixtures can still contain hostnames that code attempts to resolve. Use MockDNS in a test when a meaningful hostname must remain stable.
Fixtures can contain player names, addresses, rules, server descriptions, tokens, and other operational data. Never commit:
- administrator passwords;
- query-plugin tokens or administration codes;
- API usernames and passwords;
- private master endpoints;
- internal addresses or identifiers that should not be public.
Use synthetic responses for credentialed HTTP protocols. Existing tests inject decoded API/master responses specifically to avoid live network calls and secrets.
- Mirror
src/GameQ/Protocols/Examplegame.phpwithtests/Protocols/Examplegame.php. - Extend
GameQ\Tests\Protocols\Basefor fixture-driven named protocols. - Test packet bytes and challenge/follow-up behavior for a new wire protocol.
- Assert invalid headers, lengths, counts, truncation, and oversized values.
- Add issue regressions under
tests/Issues/Issue<number>.phpwhen the issue spans more than one normal protocol fixture. - Let unexpected exceptions fail the test; do not catch them merely to make the suite green.
Review fixture-result changes manually. A mass rewrite can hide a parser regression. Confirm that changed native and normalized fields reflect an intentional behavior change, then update the relevant changelog entry.
Getting started
Configuration
Guides
Reference
Development
Migration