Overview
A repository can pass unit tests while containing invalid SQL, incorrect joins or assumptions about database types. Integration tests exercise the actual PDO driver and database engine.
Use an isolated database
Create a dedicated test database or disposable database service. Never point automated tests at production data. Apply the same schema migrations used by the application before running repository tests.
Control test data
Use explicit fixtures with unique identifiers. Clean up reliably, or wrap tests in transactions where the behavior under test permits it. Some operations such as DDL may implicitly commit, so transaction rollback is not a universal cleanup strategy.
Test meaningful behavior
Cover inserts, updates, missing records, uniqueness constraints, null values, ordering and pagination. Include the database engine and version in CI where engine-specific behavior matters.
Keep boundaries clear
These are integration tests: they should verify the repository and database together, not mock PDO and accidentally test only the mock setup.