This commit introduces a more reliable and consistent approach to setting up the development environment using backups: - Add setup-from-backup.sh script for environment setup from existing backups - Standardize script naming and organization - Move obsolete scripts to bin/obsolete directory - Update documentation with new workflow instructions - Create migration guide for transitioning to new workflow - Update Memory Bank with workflow improvements The new workflow provides: - More reliable environment setup - Faster setup process - Offline development capability - Consistent development environments across team members Breaking changes: - setup-dev.sh is replaced by setup-from-backup.sh - sync-and-setup.sh is replaced by separate scripts - verify-with-wpcli.sh is no longer used Migration path is documented in MIGRATION_GUIDE.md
4.3 KiB
4.3 KiB
Testing Guide
Status: Active/Authoritative Last Updated: March 26, 2025 Scope: Testing the HVAC Trainer Network Events plugin
This guide covers testing the HVAC Trainer Network Events plugin using our unified test suite.
Test Environment Requirements
Required Plugins
The test environment requires specific plugins with their minimum versions. These plugins should be installed but not updated during testing:
- The Events Calendar (6.10.2 or higher)
- The Events Calendar Pro (7.4.2 or higher)
- Event Tickets (5.19.3 or higher)
- Event Tickets Plus (6.2.0 or higher)
- The Events Calendar: Community Events (latest version)
- Note: Use only 'the-events-calendar-community-events' plugin, not the legacy 'community-events' plugin
- Spectra Pro (2.0.0 or higher)
- Premium Starter Templates (4.4.14 or higher)
- Essential Blocks (5.3.2 or higher)
Important:
- Do not update plugins as part of testing
- Plugin updates should be tested separately
- If you need to test with different plugin versions, use a separate test environment
Quick Start
# Set up the development environment from backup
./bin/setup-from-backup.sh
# Run all tests
./bin/run-tests.sh -t all
# Run specific test types
./bin/run-tests.sh -t unit
./bin/run-tests.sh -t integration
./bin/run-tests.sh -t e2e
# Run with specific browser (for E2E tests)
./bin/run-tests.sh -t e2e --browser firefox
# Run in debug mode
./bin/run-tests.sh -t all --debug
Test Types
Unit Tests
Located in tests/unit/
- Test individual classes and functions
- No WordPress environment required
- Fast execution
- Focus on business logic
Integration Tests
Located in tests/integration/
- Test WordPress-specific functionality
- Requires WordPress test environment
- Tests database interactions
- Tests hooks and filters
E2E Tests
Located in tests/playwright/
- Test complete user journeys
- Requires running WordPress environment
- Tests UI interactions
- Tests real-world scenarios
Test Environment Setup
Prerequisites
- Docker and Docker Compose
- PHP 8.1+
- Node.js 16+ (for E2E tests)
- Composer
Setup Process
# Set up the development environment from backup
./bin/setup-from-backup.sh
# Verify the environment
./bin/verify-dev.sh
Test Runner Options
Usage: ./tests/run-tests.sh [options] [test-pattern]
Options:
-t, --type TYPE Test type (unit|integration|e2e|all)
-b, --browser TYPE Browser for E2E tests (chromium|firefox|webkit)
-p, --parallel Run tests in parallel
--headed Run E2E tests in headed mode
--retry N Number of retries for failed tests
--debug Enable debug mode
--skip-db Skip database setup
-v, --verbose Increase output verbosity
-h, --help Show this help message
Writing Tests
Test Utilities
The TestUtils class provides helper functions:
// Create test data
$post = TestUtils::createTestPost();
$user = TestUtils::createTestUser();
$event = TestUtils::createTestEvent();
// Clean up
TestUtils::cleanupTestData();
Best Practices
- One test class per feature/component
- Clear test method names
- Clean up after tests
- Use meaningful test data
- Test both positive and negative cases
Test Data Management
Database Management
# Manage database operations
./bin/manage-db.sh backup test_backup
# Restore test database
./bin/manage-db.sh restore test_backup
Debugging Tests
Debug Mode
./tests/run-tests.sh -t all --debug
Log Files
- WordPress Debug Log:
wp-content/debug.log - Test Results:
test-results/ - Diagnostic Results:
diagnostic-results/
Continuous Integration
Tests run automatically on:
- Pull requests
- Pushes to main
- Nightly for regression testing
Local CI Testing
# Install act
brew install act
# Run CI locally
act -j test
Common Issues
-
Database Connection Issues
# Check database container docker ps | grep mariadb # Reset database ./bin/reset-dev.sh -
Permission Issues
# Fix permissions docker-compose exec wordpress chown -R www-data:www-data /var/www/html -
Test Environment Issues
# Reset test environment ./bin/reset-dev.sh
Last Updated: March 26, 2025