# Testing — rank24.pl

## Test Infrastructure

**No automated tests exist.** There are no:
- PHPUnit configuration files (`phpunit.xml`, `phpunit.xml.dist`)
- Test directories (`tests/`, `test/`, `spec/`)
- Test class files (`*Test.php`, `*Spec.php`)
- CI/CD pipeline that runs tests

## How Testing Is Done

All testing is **manual** via the web interface:

1. **Web UI testing** — load pages in browser, exercise forms and interactions
2. **AJAX endpoints** — `ajax-check.php` used for health checks / spot validation
3. **Cron output** — `cron.php` returns JSON; check via browser or log inspection
4. **PHP error logs** — `error_reporting` is suppressed in production; errors must be caught via server logs or temporary enabling of reporting

## Debugging Aids

- **OPD debug console** — `$config['db']['debug']` enables query logging via `opd.debug.php`
- **`\S::pre()`** — utility for dumping variables (calls `var_dump` / `print_r`), used inline and commented out: `//\S::pre($results); exit;`
- **`file_put_contents('google-rank.txt', $result)`** — ad-hoc scraping debug log in `class.GoogleRank.php`
- **`$debbbb = $data`** — debug variable left in `class.S.php`

## Adding Tests (Guidance for Future)

If automated testing is introduced:
- PHPUnit is the natural choice for PHP
- Heavy global state (`$db`, `$mdb`, `$user`) makes unit testing hard without refactoring — start with integration tests against a test database
- Factory classes (`factory\*`) are the best seam for testing — they have clear input/output and centralize DB access
- Cron methods in `class.Cron.php` return `['status' => 'ok'|'empty', 'msg' => '...']` — easily assertable
