This project provides a comprehensive testing and refactoring infrastructure for Joomla 1.0, a legacy CMS that requires modernization while maintaining 100% backward compatibility. The refactoring approach follows a test-first methodology to ensure zero functionality regression during the modernization process.
- 100% Code Coverage before refactoring begins
- Zero Regression during modernization
- Modern Development Environment with Docker
- Professional Testing Suite with PHPUnit and Cypress
- Email Testing Infrastructure with Mailpit
Joomla-1.0/
βββ [Original Joomla 1.0 files] # Untouched legacy codebase
βββ REFACTO/ # Modern testing & refactoring tools
β βββ docker/ # Containerized development environment
β β βββ docker-compose.yml # Multi-service orchestration
β β βββ Dockerfile # PHP 7.4 + Apache (Joomla compatible)
β β βββ Dockerfile.test # PHP 8.4.13 + testing tools
β β βββ configs/ # Configuration files
β βββ tests/ # PHPUnit test suite
β β βββ unit/ # Unit tests (80% target)
β β βββ integration/ # Integration tests (15% target)
β β βββ functional/ # Functional tests (5% target)
β β βββ helpers/ # Test utilities
β βββ cypress/ # End-to-end browser tests
β β βββ e2e/ # Test scenarios
β β βββ support/ # Custom commands
β βββ composer.json # PHP dependencies
β βββ phpunit.xml # PHPUnit configuration
β βββ mysql_compat.php # PHP 7.4+ compatibility layer
β βββ start-refacto.sh # Quick start (Linux/Mac)
β βββ start-refacto.bat # Quick start (Windows)
- Docker Desktop (latest version)
- Git (for version control)
- Node.js 18+ (for Cypress tests)
# Clone the repository
git clone <repository-url>
cd Joomla-1.0
# Start the development environment
# Windows
REFACTO\start-refacto.bat
# Linux/Mac
chmod +x REFACTO/start-refacto.sh
./REFACTO/start-refacto.sh# Check all services are running
docker-compose -f docker/docker-compose.yml ps
# Access the application
# Joomla Site: http://localhost:8082
# Admin Panel: http://localhost:8082/administrator
# Mailpit UI: http://localhost:8025# Navigate to REFACTO directory
cd REFACTO
# Install dependencies
composer install
npm install
# Run all tests
npm run test:allFor quick setup, the following default credentials are configured:
| Setting | Value | Description |
|---|---|---|
| Database Host | joomla-db (Docker) / localhost:3307 (External) |
MySQL server |
| Database Name | joomla_test |
Default database name |
| Username | joomla |
Database user |
| Password | joomlapassword |
Database password |
| Port | 3307 |
External access port |
The database is automatically configured with:
- MySQL 8.0 with legacy compatibility
- Relaxed SQL mode for Joomla 1.0 compatibility
- Native password authentication for older PHP versions
- Pre-created database and user with proper permissions
If you need to connect externally:
# Connect via command line
mysql -h localhost -P 3307 -u joomla -pjoomlapassword joomla_test
# Or update your Joomla configuration
# Edit configuration.php with these values:
$mosConfig_host = 'localhost:3307';
$mosConfig_user = 'joomla';
$mosConfig_password = 'joomlapassword';
$mosConfig_db = 'joomla_test';| Service | Technology | Port | Purpose |
|---|---|---|---|
| joomla-web | PHP 7.4 + Apache | 8082 | Joomla 1.0 compatible web server |
| joomla-db | MySQL 8.0 | 3307 | Database with legacy compatibility |
| joomla-test | PHP 8.4.13 + Tools | - | Testing environment with latest tools |
| cypress | Node.js + Browsers | - | End-to-end testing |
| mailpit | SMTP Server | 8025/1025 | Email testing and debugging |
- PHP Compatibility Layer: Automatic polyfills for deprecated functions
- MySQL Legacy Support: Relaxed SQL modes for Joomla 1.0 compatibility
- Email Testing: All
mail()calls captured in Mailpit UI - Session Management: Proper session handling for authentication
- Hot Reloading: Code changes reflected immediately
This project follows a comprehensive test-first approach to ensure safe refactoring:
- Establish Baseline: Create tests for existing functionality
- Achieve Coverage: Reach 100% code coverage
- Refactor Safely: Modernize code with confidence
- Validate Continuously: Ensure no regression
- Unit Tests (80%): Individual functions, classes, and methods
- Integration Tests (15%): Component interactions and data flow
- Functional Tests (5%): End-to-end user workflows
- PHPUnit 10.5: Modern PHP testing framework
- PHPStan: Static analysis for code quality
- PHP CodeSniffer: PSR-12 compliance checking
- PHPCPD: Copy-paste detection
- Cypress: Modern end-to-end testing
- Multiple Browsers: Chrome, Firefox, Edge support
- Visual Testing: Screenshot comparison capabilities
- Mailpit: SMTP server with web UI
- Message Capture: All emails intercepted and displayed
- No External Dependencies: Self-contained email testing
# Run all test suites
npm run test:all
# Generate coverage report
npm run test:coverage
# Run tests in watch mode
npm run test:watch# Unit tests only
docker-compose -f docker/docker-compose.yml exec joomla-test composer test-unit
# Integration tests only
docker-compose -f docker/docker-compose.yml exec joomla-test composer test-integration
# All PHP tests with coverage
docker-compose -f docker/docker-compose.yml exec joomla-test composer test-coverage
# Static analysis
docker-compose -f docker/docker-compose.yml exec joomla-test composer phpstan
# Code style checking
docker-compose -f docker/docker-compose.yml exec joomla-test composer phpcs# Run Cypress tests
npm run test:e2e
# Open Cypress Test Runner
npm run cypress:open
# Run specific test file
npx cypress run --spec "cypress/e2e/admin-login.cy.js"# Access Mailpit UI
open http://localhost:8025
# Send test email via PHP
docker-compose -f docker/docker-compose.yml exec joomla-web php -r "mail('test@example.com', 'Test Subject', 'Test Body');"- Docker environment setup
- Testing framework installation
- Database configuration with legacy support
- Email testing infrastructure
- PHP compatibility layer
- Core components testing (
com_content,com_user, etc.) - Module testing (
mod_mainmenu,mod_login, etc.) - Mambot testing (content filters, editors)
- Template testing (frontend and admin)
- Database layer testing
- 95%+ overall code coverage
- 100% critical path coverage
- Performance benchmarks establishment
- Security validation
- Regression test suite completion
- Modern PHP patterns implementation
- Security improvements
- Performance optimization
- Code quality enhancement
- Documentation updates
The project uses MySQL 8.0 with legacy compatibility settings:
-- Relaxed SQL mode for Joomla 1.0 compatibility
SET GLOBAL sql_mode='';
-- Native password authentication
ALTER USER 'joomla'@'%' IDENTIFIED WITH mysql_native_password BY 'joomlapassword';PHP 7.4 configured for Joomla 1.0 compatibility:
# Legacy compatibility settings
register_globals = Off
magic_quotes_gpc = Off
session.auto_start = Off
short_open_tag = On
# Performance settings
memory_limit = 128M
upload_max_filesize = 32M
max_execution_time = 300All emails are captured by Mailpit for testing:
# msmtp configuration
sendmail_path = /usr/bin/msmtp -t- Separate Test Database: No production data exposure
- Isolated Containers: Complete environment isolation
- Automatic Cleanup: Temporary files and data removed after tests
- No External Dependencies: Self-contained testing environment
- Test Data Only: No real user credentials or sensitive data
- Database Transactions: Automatic rollback after tests
- File System Isolation: Temporary directories for test files
- Network Isolation: No external network access during tests
- β Environment Setup: Complete
- β Testing Framework: Complete
- β Email Infrastructure: Complete
- π Component Testing: In Progress
- β³ Coverage Achievement: Planned
- β³ Refactoring: Planned
- Code Coverage: Target 95%+ overall, 100% critical paths
- Test Execution Time: < 5 minutes for full suite
- Zero Regressions: All existing functionality preserved
- Performance: No degradation in response times
# Check Docker is running
docker --version
docker-compose --version
# Restart services
docker-compose -f docker/docker-compose.yml down
docker-compose -f docker/docker-compose.yml up -d
# View logs
docker-compose -f docker/docker-compose.yml logs joomla-web# Check port usage
netstat -an | findstr :8082
netstat -an | findstr :3307
netstat -an | findstr :8025
# Stop conflicting services
# Update ports in docker/docker-compose.yml if needed# Test database connection
docker-compose -f docker/docker-compose.yml exec joomla-web php -r "
\$link = mysqli_connect('joomla-db', 'joomla', 'joomlapassword', 'joomla_test');
if (\$link) echo 'Connected successfully'; else echo 'Connection failed';
"# Check PHP compatibility layer
docker-compose -f docker/docker-compose.yml exec joomla-web php -r "
echo 'mysql_connect: ' . (function_exists('mysql_connect') ? 'OK' : 'MISSING') . PHP_EOL;
echo 'ereg: ' . (function_exists('ereg') ? 'OK' : 'MISSING') . PHP_EOL;
"- Check Logs:
docker-compose -f docker/docker-compose.yml logs [service] - Verify Services:
docker-compose -f docker/docker-compose.yml ps - Test Connectivity: Use the troubleshooting commands above
- Review Documentation: Check this README and inline comments
- README.md: This comprehensive guide
- docker/docker-compose.yml: Service configuration
- REFACTO/phpunit.xml: PHPUnit test configuration
- REFACTO/cypress.config.js: Cypress test configuration
- REFACTO/composer.json: PHP dependencies and scripts
- REFACTO/tests/unit/: Unit test examples
- REFACTO/cypress/e2e/: End-to-end test examples
- REFACTO/tests/helpers/: Test utility examples
- 95%+ overall code coverage
- 100% critical path coverage
- All tests passing consistently
- Performance benchmarks established
- Security validation complete
- Email functionality verified
- All tests still passing
- Zero functionality regression
- Improved code quality metrics
- Enhanced security posture
- Better performance characteristics
- Modern PHP patterns implemented
- Fork and Clone: Create your development branch
- Start Environment: Use
start-refacto.batorstart-refacto.sh - Write Tests: Create tests for new functionality
- Implement: Write code to pass tests
- Validate: Run full test suite
- Submit: Create pull request with test coverage
- PSR-12: PHP coding standards
- Test Coverage: New code must have tests
- Documentation: Update README for significant changes
- Backward Compatibility: Maintain Joomla 1.0 compatibility
This project maintains the original Joomla 1.0 GPL v2 license. See LICENSE.php for details.
Quick Start Command:
# Windows
REFACTO\start-refacto.bat
# Linux/Mac
chmod +x REFACTO/start-refacto.sh && ./REFACTO/start-refacto.shAccess Points:
- Joomla Site: http://localhost:8082
- Admin Panel: http://localhost:8082/administrator
- Mailpit UI: http://localhost:8025
- Database: localhost:3307
Remember: The goal is to achieve comprehensive test coverage before beginning any refactoring work. This ensures that all functionality is preserved during the modernization process.
Built with β€οΈ for the Joomla community