# Final Regression Plan — v12.2

This plan is intended for a PHP/MySQL staging environment before production deployment.

## Required order

1. Static preflight
2. PHP syntax lint
3. Fresh database import
4. Installer disposable database test
5. Admin login and route smoke test
6. Create/edit/view tests on high-risk modules
7. Permission matrix verification
8. Production configuration check
9. Package final ZIP

---

## 1. Static preflight

```bash
cd mvc
./scripts/static_preflight.sh
```

Expected: pass.

---

## 2. PHP syntax lint

```bash
find app -name '*.php' -print0 | xargs -0 -n1 php -l
php -l index.php
php -l install.php
```

Expected: no syntax errors.

---

## 3. Fresh database import

Use a disposable database:

```bash
mysql -u root -e "DROP DATABASE IF EXISTS aarjay_gdp_regression; CREATE DATABASE aarjay_gdp_regression CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
mysql -u root aarjay_gdp_regression < install.sql
```

Expected: zero SQL errors.

---

## 4. Installer test

Use another disposable database and run `/install.php` end-to-end.

Expected:

- DB connection succeeds
- schema import succeeds
- `app/config.php` is written
- `install.lock` is created
- login works

---

## 5. Route smoke test

Start the PHP dev server or use staging URL:

```bash
BASE_URL=http://127.0.0.1:8100 ./scripts/regression_smoke_test.sh
```

Expected: all routes HTTP 200 with no PHP error output.

---

## 6. High-risk create/edit/view tests

Manually test create → view → edit for:

- Recalls
- Falsified Medicines
- Defective Stock
- GDP Gap Analysis
- Training Matrix
- SOP Read & Sign
- Premises & Equipment
- Cold-chain Imports
- Accounts & Tax export pack
- Technical Agreements
- Returns
- Qualifications
- MHRA Inspections
- Account Reopening

---

## 7. Permission matrix

For a non-admin test user, verify only permitted modules are visible and directly-posted restricted routes are blocked.

---

## 8. Production configuration

Before production:

- Set production `app.url`
- Use production DB credentials
- Change admin password
- Create/keep `install.lock`
- Remove `install.sql` if not needed on server
- Confirm upload folders are writable
- Confirm `.htaccess` protection

---

## 9. Sign-off

Use `STAGING_TEST_REPORT_TEMPLATE.md` to record results.
