3fde161f29
API CI/CD / Validate (composer + pint) (push) Successful in 3m6s
API CI/CD / Test (PHPUnit) (push) Failing after 6m55s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 50s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
3.4 KiB
3.4 KiB
PHPUnit CI Fix Plan
Goal
Fix the current PHPUnit CI failures from the latest test run by addressing the shared causes first, then the page-specific failures.
Priority Fixes
1. Fix Test Database Isolation
The feature suite is hitting SQLite lock errors.
- Stop using
database/database.sqliteas the shared CI test database. - Create a unique SQLite database per CI run or per parallel process.
- Store it under
$RUNNER_TEMPor another temporary path. - Disable parallel tests until each process has its own database.
- Add SQLite busy timeout only as a backup, not as the main fix.
2. Fix Auth and Permission Test Setup
Many tests expect 200, 201, or 422 but receive 403.
- Add shared test helpers:
actingAsAdmin()actingAsTeacher()actingAsStaff()actingAsParent()actingAsWithPermission($permission)
- Make factories create active, verified, non-suspended users by default.
- Assign required roles and permissions in every feature test.
- Do not bypass middleware unless the test is not about authorization.
3. Fix Missing or Renamed Routes
Some tests call routes that now return 404.
- Restore or replace
/api/v1/users. - Confirm canonical routes for staff, teacher pages, school-year pages, messages, and parent profile APIs.
- Update tests only after confirming the new route contract.
4. Fix Model Metadata Drift
Many model metadata tests fail after school-year changes.
- Review every model touched by
school_year. - Update
$fillable,$casts, relationships, hidden fields, and table names. - Add
school_yearonly where the model should directly store it. - Update tests to match the intended model contract.
5. Fix Factory and Schema Drift
Factories are missing required fields.
- Update
EmailTemplateFactoryto always providecode. - Update affected tests to use valid required fields.
- Confirm unique fields and required defaults are consistent across migrations, factories, and tests.
6. Fix Section Placement Finalization
Placement finalization fails when the batch record does not exist.
- Create a valid
SectionPlacementBatchin tests before finalizing. - Resolve placement batches by ID and selected
school_year. - Return controlled
404when the batch is missing.
7. Fix Validation Payloads
Some service tests now fail because validation rules changed.
- Update class progress test payloads to include required Islamic Studies units.
- Confirm whether the rule applies to all progress reports or only specific report types.
Execution Order
- Fix SQLite CI database isolation.
- Fix user factories and auth helpers.
- Fix missing routes.
- Fix model metadata tests.
- Fix factories with required fields.
- Fix section placement batch setup.
- Fix changed validation payloads.
- Re-run unit tests.
- Re-run feature tests.
- Fix remaining isolated workflow failures.
Do Not Chase Yet
These are noisy but not the main cause of the PHPUnit failure:
- Xdebug connection warnings.
mbstring is already loaded.- Action cache checkout warnings.
- Artifact upload certificate failure after tests fail.
Acceptance Criteria
- PHPUnit unit suite passes.
- PHPUnit feature suite passes.
- No
database is lockederrors. - No unexpected
403caused by missing test permissions. - No
404from expected public/internal API contracts. - All school-year-aware tests use only
school_year, notschool_year_id.