Test structure
Running tests
Test configuration
File:phpunit.xml
- Docker:
mysql-db-testservice on port 3310 - Database:
tutorbloc_db_test - Credentials:
tester/tester_secret
Key test files
EnvTest
File:tests/Unit/EnvTest.php
Validates that all 115 required environment variables are set. Acts as a deployment safety net — if any env var is missing, this test fails.
UserTest (69 methods)
File:tests/Unit/ModelTests/UserTest.php
The most comprehensive test file. Covers:
- Role filtering — students, tutors, parents correctly filtered
- Tutor search scopes — by subject, level, exam boards
- User visibility —
isVisiblescope works correctly - Distance calculations —
withDistanceandwithinDistancescopes - Verification checks — identity, DBS, qualifications
- Payment accounts — active account detection
- Address/mobile validation — required field checks
- Lesson booking availability — holiday checks, scheduling conflicts
- Profile completeness — step-by-step completion tracking
- Language defaults — English auto-added for tutors
- OAuth integration — Zoom connection status
- Video/bio content — presence checks
- Subscription status — valid/invalid subscription states
ProfileTest
File:tests/Unit/ModelTests/ProfileTest.php
Tests teacher reference number validation.
Test coverage
Test database setup
Before running tests, ensure the test database is migrated:CI/CD testing
In the staging build pipeline (buildspec-staging.yml):
- Waits for test MySQL container to be ready (120s timeout)
- Runs migrations on test database
- Runs full PHPUnit suite
- Build fails if any test fails
Production builds skip tests entirely — they rely on staging tests having passed.