Documentation · Chapter 16

Test logic and infrastructure at the right level.

Unit tests isolate decisions. Integration tests prove adapters such as database, filesystem, cache, and external protocol behavior.

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

LESSON OBJECTIVE

What you will be able to do

Choose unit or integration scope deliberately and test supported databases with their real engines.

Unit tests own business rules

Pure services can be tested without network or database. Give inputs, call behavior, and assert outputs or explicit exceptions.

phpaml — zsh
aml test
# then run the declared MySQL, MariaDB, and PostgreSQL matrix

Integration tests use real adapters

A repository or migration test is credible only against the real engine it claims to support. Maintain SQLite plus the declared server matrix.

Control time and randomness

Inject a clock and deterministic generator when expiration, IDs, tokens, or random choices affect the result.

CHECKPOINT

Before you continue

Would a fake adapter hide the very driver, locking, transaction, or filesystem behavior this test claims to prove?