Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamline local test environment setup #916

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

schlessera
Copy link
Member

@schlessera schlessera commented Dec 11, 2024

Refactored the test environment setup to make it more robust and user-friendly. This consolidates multiple test commands and improves process management for local development.

What Changed

  • Added shell scripts to manage test environment lifecycle
  • Consolidated PHPUnit commands to auto-detect version and config
  • Improved process management with proper PID tracking
  • Added mitmproxy version verification (≥11.0.2 required)
  • Adapted CONTRIBUTING.md to explain the new setup

The main improvement is the simplified test workflow. Instead of juggling different commands for PHPUnit versions and remembering to start/stop test servers, everything is now handled through clear, single-purpose commands.

New Scripts

  • scripts/start-test-environment.sh - Boots test and proxy servers - should be sourced to set environment vairables
  • scripts/stop-test-environment.sh - Clean shutdown of all processes
  • scripts/run-phpunit.sh - Version-agnostic PHPUnit runner
  • scripts/run-tests-with-server.sh - Full test environment run

Usage

Basic testing is now simpler:

composer test # Run tests (auto-detects PHPUnit version)
composer coverage # Same, but with coverage

For development with local test servers:

# Direct usage (sets env vars in your shell)
source scripts/start-test-environment.sh
scripts/run-phpunit.sh
scripts/stop-test-environment.sh

# Or through composer (automated start/stop)
composer test:withserver

Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good.

Will still need a note in CONTRIBUTING that this will not work on Windows for now.

As discussed, not merging yet until a shellcheck check has been added in CI to safeguard the scripts.

@jrfnl
Copy link
Member

jrfnl commented Dec 11, 2024

Future scope: add a Docker config file to get up & running with even less effort (and which would work on Windows too).

@jrfnl
Copy link
Member

jrfnl commented Dec 11, 2024

Just noticed, just running the script on my machine created some .test-pids/*.pid files. You may want to add those to the .gitignore file ?

@schlessera
Copy link
Member Author

I changed the folder where PIDs are stored and added that location to .gitignore: tests/utils/pids

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants