Documentation · Chapter 16

Verify complete HTTP and browser behavior.

HTTP tests cross routing and middleware. Browser tests add rendering, keyboard behavior, hydration, navigation, and real JavaScript execution.

Every lesson starts from the problem, explains the mechanism, then gives a concrete verification.

LESSON OBJECTIVE

What you will be able to do

Verify complete HTTP contracts and reserve browser automation for behavior only a browser can prove.

Test status, headers, and body

Assert the contract: status, content type, cache/security headers, redirects, and stable JSON or HTML meaning.

phpaml — zsh
GET /health → 200 application/json
POST /admin/news without CSRF → 403
GET /missing → 404

Exercise authentication and CSRF

Cover anonymous, authenticated, forbidden, invalid CSRF, expired session, and successful actions. Security middleware deserves direct regression tests.

Keep browser tests selective

Use browser automation for interactions the lower layers cannot prove: focus, history, forms, responsive menus, View hydration, and accessibility.

CHECKPOINT

Before you continue

Do tests cover anonymous, forbidden, invalid, missing, failure, and successful responses—not only status 200?