|
| 1 | +# Laravel Installation Tests |
| 2 | + |
| 3 | +This directory contains comprehensive tests to verify that the `egyjs/progressive-json-php` package installs and works correctly across multiple Laravel versions (9.x through 12.x). |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The installation tests verify: |
| 8 | + |
| 9 | +- ✅ **Package Installation**: Composer can successfully install the package |
| 10 | +- ✅ **Autoloading**: Classes are properly autoloaded in Laravel context |
| 11 | +- ✅ **Basic Functionality**: Core package features work as expected |
| 12 | +- ✅ **Laravel Integration**: Package integrates well with Laravel's ecosystem |
| 13 | + |
| 14 | +## Test Matrix |
| 15 | + |
| 16 | +| PHP Version | Laravel 9.x | Laravel 10.x | Laravel 11.x | Laravel 12.x | |
| 17 | +|-------------|-------------|--------------|--------------|--------------| |
| 18 | +| PHP 8.1 | ✅ | ✅ | ❌* | ❌* | |
| 19 | +| PHP 8.2 | ✅ | ✅ | ✅ | ❌* | |
| 20 | +| PHP 8.3 | ✅ | ✅ | ✅ | ✅ | |
| 21 | +| PHP 8.4 | ✅ | ✅ | ✅ | ✅ | |
| 22 | + |
| 23 | +_*Laravel version requirements exclude certain PHP versions_ |
| 24 | + |
| 25 | +## Automated Testing (GitHub Actions) |
| 26 | + |
| 27 | +The GitHub Actions workflow (`.github/workflows/laravel-installation-test.yml`) automatically runs these tests: |
| 28 | + |
| 29 | +- **Triggers**: Push to master, Pull requests, Weekly schedule |
| 30 | +- **Matrix Strategy**: Tests all compatible PHP/Laravel version combinations |
| 31 | +- **Unified Testing**: Uses the same `scripts/test-laravel-installation.sh` script for consistency |
| 32 | +- **Comprehensive Testing**: Full integration testing in clean Laravel installations |
| 33 | +- **Performance Monitoring**: Tracks performance across versions |
| 34 | +- **Summary Reporting**: Provides detailed test results and summaries |
| 35 | + |
| 36 | +### Workflow Architecture |
| 37 | + |
| 38 | +The GitHub Actions workflow leverages the same local test script for consistency: |
| 39 | + |
| 40 | +1. **Setup**: Configures PHP environment with required extensions |
| 41 | +2. **Script Execution**: Runs `./scripts/test-laravel-installation.sh [VERSION] --keep-files` |
| 42 | +3. **PHPUnit Integration**: Executes package tests within the Laravel context |
| 43 | +4. **Summary Generation**: Provides comprehensive test results |
| 44 | + |
| 45 | +This unified approach ensures that: |
| 46 | +- Local and CI testing use identical logic |
| 47 | +- Debugging is easier (run the same script locally) |
| 48 | +- Maintenance is simplified (single source of truth) |
| 49 | + |
| 50 | +### Viewing Test Results |
| 51 | + |
| 52 | +1. Go to the "Actions" tab in your GitHub repository |
| 53 | +2. Look for "Laravel Installation Tests" workflow runs |
| 54 | +3. Click on any run to see detailed results for each PHP/Laravel combination |
| 55 | +4. Check the summary for a quick overview of test results |
| 56 | + |
| 57 | +## Local Testing |
| 58 | + |
| 59 | +### Prerequisites |
| 60 | + |
| 61 | +- PHP 8.1+ with Composer installed |
| 62 | +- Git (for cloning Laravel projects) |
| 63 | +- Sufficient disk space (each Laravel installation ~100MB) |
| 64 | + |
| 65 | +### Running Tests |
| 66 | + |
| 67 | +The test script accepts Laravel version parameters for flexible testing: |
| 68 | + |
| 69 | +#### On Linux/macOS: |
| 70 | + |
| 71 | +```bash |
| 72 | +# Make the script executable |
| 73 | +chmod +x scripts/test-laravel-installation.sh |
| 74 | + |
| 75 | +# Run all tests (default: Laravel 9.*, 10.*, 11.*, 12.*) |
| 76 | +./scripts/test-laravel-installation.sh |
| 77 | + |
| 78 | +# Test specific Laravel version |
| 79 | +./scripts/test-laravel-installation.sh 10.* |
| 80 | + |
| 81 | +# Test multiple specific versions |
| 82 | +./scripts/test-laravel-installation.sh 9.* 11.* |
| 83 | + |
| 84 | +# Keep test files for inspection (don't auto-cleanup) |
| 85 | +./scripts/test-laravel-installation.sh --keep-files |
| 86 | + |
| 87 | +# Combine version selection with file preservation |
| 88 | +./scripts/test-laravel-installation.sh 10.* 11.* --keep-files |
| 89 | + |
| 90 | +# Show help information |
| 91 | +./scripts/test-laravel-installation.sh --help |
| 92 | +``` |
| 93 | + |
| 94 | +#### Script Parameters |
| 95 | + |
| 96 | +- **Laravel Versions**: Specify one or more Laravel versions (e.g., `9.*`, `10.*`, `11.*`, `12.*`) |
| 97 | +- **`--keep-files`**: Preserve test directories after completion for debugging |
| 98 | +- **`--help`**: Display usage information and examples |
| 99 | + |
| 100 | +If no Laravel versions are specified, the script tests all default versions (9.* through 12.*). |
| 101 | + |
| 102 | +#### Examples |
| 103 | + |
| 104 | +```bash |
| 105 | +# Test only Laravel 10 and 11 |
| 106 | +./scripts/test-laravel-installation.sh 10.* 11.* |
| 107 | + |
| 108 | +# Test Laravel 9 and keep files for inspection |
| 109 | +./scripts/test-laravel-installation.sh 9.* --keep-files |
| 110 | + |
| 111 | +# Quick test of latest Laravel version |
| 112 | +./scripts/test-laravel-installation.sh 12.* |
| 113 | +``` |
| 114 | + |
| 115 | +### Understanding Test Output |
| 116 | + |
| 117 | +The scripts provide colored output to help you understand the test progress: |
| 118 | + |
| 119 | +- 🔵 **[INFO]**: General information about test progress |
| 120 | +- 🟢 **[SUCCESS]**: Test step completed successfully |
| 121 | +- 🟡 **[WARNING]**: Non-critical issues or warnings |
| 122 | +- 🔴 **[ERROR]**: Test failures that need attention |
| 123 | + |
| 124 | +### Example Output |
| 125 | + |
| 126 | +``` |
| 127 | +[INFO] Starting Laravel Installation Tests |
| 128 | +[INFO] PHP Version: 8.3.0 |
| 129 | +[INFO] Package: egyjs/progressive-json-php |
| 130 | +
|
| 131 | +[INFO] Testing Laravel 10.* |
| 132 | +[INFO] Creating Laravel 10.* application... |
| 133 | +[INFO] Created: Laravel Framework 10.48.22 |
| 134 | +[INFO] Installing egyjs/progressive-json-php... |
| 135 | +[SUCCESS] Autoloading: ✓ |
| 136 | +[SUCCESS] Basic functionality: ✓ |
| 137 | +[SUCCESS] Laravel 10.* tests completed successfully! |
| 138 | +
|
| 139 | +=== TEST SUMMARY === |
| 140 | +[SUCCESS] All Laravel installation tests passed! 🎉 |
| 141 | +[INFO] Your package is compatible with Laravel versions: 9.* 10.* 11.* 12.* |
| 142 | +``` |
| 143 | + |
| 144 | +## Test Details |
| 145 | + |
| 146 | +### Package Installation Test |
| 147 | +- Creates fresh Laravel applications using `composer create-project` |
| 148 | +- Configures local package repository to simulate Packagist installation |
| 149 | +- Installs package via `composer require egyjs/progressive-json-php:@dev` |
| 150 | +- Verifies package appears in `composer show` output |
| 151 | + |
| 152 | +### Autoloading Test |
| 153 | +- Requires vendor autoload file |
| 154 | +- Attempts to instantiate `Egyjs\ProgressiveJson\ProgressiveJsonStreamer` |
| 155 | +- Verifies class exists and can be loaded |
| 156 | + |
| 157 | +### Basic Functionality Test |
| 158 | +- Creates ProgressiveJsonStreamer instance within Laravel application context |
| 159 | +- Processes sample data including Laravel version and PHP version information |
| 160 | +- Uses Laravel's `app()->version()` helper to verify Laravel integration |
| 161 | +- Verifies output is generated correctly and not empty |
| 162 | +- Tests that the package works seamlessly within Laravel's environment |
| 163 | + |
| 164 | + |
| 165 | +## Continuous Integration |
| 166 | + |
| 167 | +### GitHub Actions Integration |
| 168 | + |
| 169 | +The workflow is designed to: |
| 170 | +- Run automatically on code changes |
| 171 | +- Test against all supported Laravel/PHP combinations |
| 172 | +- Provide detailed failure information |
| 173 | +- Cache dependencies for faster execution |
| 174 | +- Generate test summaries |
| 175 | + |
| 176 | +### Test Scope |
| 177 | + |
| 178 | +The current implementation focuses on essential compatibility testing: |
| 179 | +- **Installation verification**: Ensures the package can be installed via Composer |
| 180 | +- **Autoloading verification**: Confirms classes load correctly in Laravel |
| 181 | +- **Basic functionality**: Tests core features work within Laravel context |
| 182 | +- **Future enhancements**: Additional tests (service providers, routes, performance) may be added |
| 183 | + |
| 184 | +### Adding New Laravel Versions |
| 185 | + |
| 186 | +To test new Laravel versions: |
| 187 | + |
| 188 | +1. Update the matrix in `.github/workflows/laravel-installation-test.yml` |
| 189 | +2. Add version to `LARAVEL_VERSIONS` array in test scripts |
| 190 | +3. Update compatibility matrix in this documentation |
| 191 | +4. Test locally before committing |
| 192 | + |
| 193 | +### Custom Test Scenarios |
| 194 | + |
| 195 | +You can extend the tests by: |
| 196 | +- Adding service provider integration tests |
| 197 | +- Testing route context functionality |
| 198 | +- Adding performance benchmarks |
| 199 | +- Testing HTTP response generation |
| 200 | +- Adding package removal verification |
| 201 | +- Testing with different PHP extensions |
| 202 | + |
| 203 | +## Contributing |
| 204 | + |
| 205 | +When contributing to the package: |
| 206 | + |
| 207 | +1. Run installation tests locally before submitting PRs |
| 208 | +2. Update tests if adding Laravel-specific features |
| 209 | +3. Ensure tests pass in CI before merging |
| 210 | +4. Update this documentation for any test changes |
| 211 | + |
| 212 | +## Support |
| 213 | + |
| 214 | +If you encounter issues with the installation tests: |
| 215 | + |
| 216 | +1. Check the troubleshooting section above |
| 217 | +2. Review GitHub Actions logs for detailed error information |
| 218 | +3. Run tests locally with `--keep-files` for debugging |
| 219 | +4. Open an issue with test output and environment details |
0 commit comments