|
| 1 | +# Integrity Tests - Command Cheat Sheet |
| 2 | + |
| 3 | +## Quick Start |
| 4 | + |
| 5 | +### Most Common Commands |
| 6 | + |
| 7 | +```bash |
| 8 | +# Run all integrity tests (recommended) |
| 9 | +cd tests/unit && ../../vendor/bin/phpunit --testsuite Integrity --testdox |
| 10 | + |
| 11 | +# Run from project root |
| 12 | +./vendor/bin/phpunit -c tests/unit/phpunit.xml.dist --testsuite Integrity --testdox |
| 13 | + |
| 14 | +# Quick check (no formatting) |
| 15 | +cd tests/unit && ../../vendor/bin/phpunit --testsuite Integrity |
| 16 | +``` |
| 17 | + |
| 18 | +## All Commands |
| 19 | + |
| 20 | +### 1) Run All Integrity Tests |
| 21 | + |
| 22 | +```bash |
| 23 | +cd tests/unit |
| 24 | +../../vendor/bin/phpunit --testsuite Integrity |
| 25 | +``` |
| 26 | + |
| 27 | +**Expected output:** |
| 28 | +``` |
| 29 | +Tests: 17, Assertions: 19, Skipped: 2 |
| 30 | +Time: ~0.04 seconds |
| 31 | +``` |
| 32 | + |
| 33 | +### 2) Run with Pretty Output (TestDox) |
| 34 | + |
| 35 | +```bash |
| 36 | +cd tests/unit |
| 37 | +../../vendor/bin/phpunit --testsuite Integrity --testdox |
| 38 | +``` |
| 39 | + |
| 40 | +**Shows:** |
| 41 | +- Test passed |
| 42 | +- Test failed |
| 43 | +- Test skipped |
| 44 | + |
| 45 | +### 3) Run Specific Test Class |
| 46 | + |
| 47 | +```bash |
| 48 | +cd tests/unit |
| 49 | + |
| 50 | +# Config Structure Tests (4 tests) |
| 51 | +../../vendor/bin/phpunit ../../src/Test/Integrity/Testsuite/ConfigStructureTest.php |
| 52 | + |
| 53 | +# Patch File Naming Tests (2 tests) |
| 54 | +../../vendor/bin/phpunit ../../src/Test/Integrity/Testsuite/PatchFileNamingTest.php |
| 55 | + |
| 56 | +# Patches Directory Tests (4 tests) |
| 57 | +../../vendor/bin/phpunit ../../src/Test/Integrity/Testsuite/PatchesDirectoryTest.php |
| 58 | + |
| 59 | +# Supported Versions Tests (7 tests) |
| 60 | +../../vendor/bin/phpunit ../../src/Test/Integrity/Testsuite/SupportedVersionsTest.php |
| 61 | +``` |
| 62 | + |
| 63 | +### 4) Run Specific Test Method |
| 64 | + |
| 65 | +```bash |
| 66 | +cd tests/unit |
| 67 | + |
| 68 | +# Test patches.json structure |
| 69 | +../../vendor/bin/phpunit --filter testPatchesJsonStructure |
| 70 | + |
| 71 | +# Test file existence |
| 72 | +../../vendor/bin/phpunit --filter testAllReferencedPatchFilesExist |
| 73 | + |
| 74 | +# Test version constraints |
| 75 | +../../vendor/bin/phpunit --filter testVersionConstraintsAreValid |
| 76 | + |
| 77 | +# Test naming conventions |
| 78 | +../../vendor/bin/phpunit --filter testPatchFileNamingConventions |
| 79 | +``` |
| 80 | + |
| 81 | +### 5) List All Available Tests |
| 82 | + |
| 83 | +```bash |
| 84 | +cd tests/unit |
| 85 | +../../vendor/bin/phpunit --testsuite Integrity --list-tests |
| 86 | +``` |
| 87 | + |
| 88 | +**Output:** List of all 17 tests |
| 89 | + |
| 90 | +### 6) Run with Colors |
| 91 | + |
| 92 | +```bash |
| 93 | +cd tests/unit |
| 94 | +../../vendor/bin/phpunit --testsuite Integrity --colors=always |
| 95 | +``` |
| 96 | + |
| 97 | +### 7) Debug Mode (Verbose) |
| 98 | + |
| 99 | +```bash |
| 100 | +cd tests/unit |
| 101 | +../../vendor/bin/phpunit --testsuite Integrity --debug |
| 102 | +``` |
| 103 | + |
| 104 | +**Shows:** Detailed execution information |
| 105 | + |
| 106 | +### 8) Stop on First Failure |
| 107 | + |
| 108 | +```bash |
| 109 | +cd tests/unit |
| 110 | +../../vendor/bin/phpunit --testsuite Integrity --stop-on-failure |
| 111 | +``` |
| 112 | + |
| 113 | +**Useful for:** Fixing errors one at a time |
| 114 | + |
| 115 | +### 9) Run All Tests (Unit + Integrity) |
| 116 | + |
| 117 | +```bash |
| 118 | +cd tests/unit |
| 119 | +../../vendor/bin/phpunit |
| 120 | +``` |
| 121 | + |
| 122 | +**Runs:** Both Unit and Integrity test suites |
| 123 | + |
| 124 | +### 10) Generate Coverage Report |
| 125 | + |
| 126 | +```bash |
| 127 | +cd tests/unit |
| 128 | +../../vendor/bin/phpunit --testsuite Integrity --coverage-html ../../var/coverage |
| 129 | +``` |
| 130 | + |
| 131 | +**View report:** |
| 132 | +```bash |
| 133 | +open ../../var/coverage/index.html |
| 134 | +``` |
| 135 | + |
| 136 | +## Test Results Explained |
| 137 | + |
| 138 | +### Green Dot (.) |
| 139 | +Test passed successfully |
| 140 | + |
| 141 | +### Red F |
| 142 | +Test failed |
| 143 | + |
| 144 | +### Yellow S |
| 145 | +Test skipped (usually a warning, not a failure) |
| 146 | + |
| 147 | +### D |
| 148 | +Deprecation notice (can be ignored for now) |
| 149 | + |
| 150 | +## Common Use Cases |
| 151 | + |
| 152 | +### Before Committing Changes |
| 153 | + |
| 154 | +```bash |
| 155 | +# Quick validation |
| 156 | +cd tests/unit && ../../vendor/bin/phpunit --testsuite Integrity |
| 157 | +``` |
| 158 | + |
| 159 | +### After Editing patches.json |
| 160 | + |
| 161 | +```bash |
| 162 | +# Validate JSON structure |
| 163 | +cd tests/unit && ../../vendor/bin/phpunit --filter ConfigStructureTest |
| 164 | +``` |
| 165 | + |
| 166 | +### After Adding New Patch File |
| 167 | + |
| 168 | +```bash |
| 169 | +# Check file exists and naming is correct |
| 170 | +cd tests/unit && ../../vendor/bin/phpunit --filter testAllReferencedPatchFilesExist |
| 171 | +cd tests/unit && ../../vendor/bin/phpunit --filter testPatchFileNamingConventions |
| 172 | +``` |
| 173 | + |
| 174 | +### After Changing Version Constraints |
| 175 | + |
| 176 | +```bash |
| 177 | +# Validate semver constraints |
| 178 | +cd tests/unit && ../../vendor/bin/phpunit --filter testVersionConstraintsAreValid |
| 179 | +``` |
| 180 | + |
| 181 | +## One-Liner Commands (Copy & Paste) |
| 182 | + |
| 183 | +```bash |
| 184 | +# From project root - all tests with pretty output |
| 185 | +./vendor/bin/phpunit -c tests/unit/phpunit.xml.dist --testsuite Integrity --testdox |
| 186 | + |
| 187 | +# From project root - quick check |
| 188 | +./vendor/bin/phpunit -c tests/unit/phpunit.xml.dist --testsuite Integrity |
| 189 | + |
| 190 | +# From project root - specific test |
| 191 | +./vendor/bin/phpunit -c tests/unit/phpunit.xml.dist --filter testPatchesJsonStructure |
| 192 | + |
| 193 | +# From tests/unit directory - most common |
| 194 | +cd tests/unit && ../../vendor/bin/phpunit --testsuite Integrity --testdox |
| 195 | +``` |
| 196 | + |
| 197 | +## Troubleshooting |
| 198 | + |
| 199 | +### Error: "Could not find file" |
| 200 | +**Solution:** Make sure you're in the correct directory |
| 201 | +```bash |
| 202 | +cd /opt/homebrew/var/www/magento-cloud-patches/tests/unit |
| 203 | +``` |
| 204 | + |
| 205 | +### Error: "No tests executed" |
| 206 | +**Solution:** Check the testsuite name (case-sensitive) |
| 207 | +```bash |
| 208 | +../../vendor/bin/phpunit --testsuite Integrity # Correct |
| 209 | +../../vendor/bin/phpunit --testsuite integrity # Wrong |
| 210 | +``` |
| 211 | + |
| 212 | +### Error: "Class not found" |
| 213 | +**Solution:** Run composer install |
| 214 | +```bash |
| 215 | +cd /opt/homebrew/var/www/magento-cloud-patches |
| 216 | +composer install |
| 217 | +``` |
| 218 | + |
| 219 | +## Requirements |
| 220 | + |
| 221 | +- PHP 8.1 or higher |
| 222 | +- Composer dependencies installed |
| 223 | +- No Docker required |
| 224 | +- No Magento installation required |
| 225 | + |
| 226 | +## Performance |
| 227 | + |
| 228 | +**Integrity Tests:** |
| 229 | +- 17 tests total |
| 230 | +- ~0.04 seconds execution time |
| 231 | +- Minimal memory usage (~8 MB) |
| 232 | + |
| 233 | + |
| 234 | +## Quick Reference Table |
| 235 | + |
| 236 | +| Command | Purpose | Speed | |
| 237 | +|---------|---------|-------| |
| 238 | +| `--testsuite Integrity` | All integrity tests | Fast | |
| 239 | +| `--testdox` | Pretty output | Fast | |
| 240 | +| `--filter <name>` | Specific test | Very fast | |
| 241 | +| `--list-tests` | Show available tests | Very fast | |
| 242 | +| `--debug` | Verbose output | Fast | |
| 243 | +| `--stop-on-failure` | Stop on first error | Fast | |
| 244 | +| `--coverage-html` | Coverage report | Slow | |
| 245 | + |
| 246 | +## What Each Test Validates |
| 247 | + |
| 248 | +### ConfigStructureTest (4 tests) |
| 249 | +- patches.json is valid JSON |
| 250 | +- JSON has correct structure |
| 251 | +- All referenced files exist |
| 252 | +- Version constraints are valid semver |
| 253 | + |
| 254 | +### PatchFileNamingTest (2 tests) |
| 255 | +- Files follow naming conventions |
| 256 | +- No duplicate references (warning only) |
| 257 | + |
| 258 | +### PatchesDirectoryTest (4 tests) |
| 259 | +- patches/ directory exists |
| 260 | +- Directory contains patch files |
| 261 | +- All files are referenced |
| 262 | +- File quality checks (warning only) |
| 263 | + |
| 264 | +### SupportedVersionsTest (7 tests) |
| 265 | +- Covers Magento 2.4.4+ |
| 266 | +- Covers PHP 8.1+ versions |
| 267 | +- Major versions: 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.8 |
| 268 | + |
| 269 | +--- |
| 270 | + |
| 271 | +**Pro Tip:** Add this to your bash/zsh aliases for quick access: |
| 272 | + |
| 273 | +```bash |
| 274 | +# Add to ~/.bashrc or ~/.zshrc |
| 275 | +alias integrity='cd tests/unit && ../../vendor/bin/phpunit --testsuite Integrity --testdox' |
| 276 | + |
| 277 | +# Usage: |
| 278 | +cd /opt/homebrew/var/www/magento-cloud-patches |
| 279 | +integrity |
| 280 | +``` |
0 commit comments