Testing
tilttek/reading-quests-bundleThe bundle's tests
composer install
vendor/bin/phpunit --no-configuration tests
The unit tests run the repositories on SQLite in memory and in memory, through one contract each: a reading inserted at
version 1 and updated at its version, a stale version or a second insertion refused with nothing written, the latest
reading the highest number whatever the order it was stored in, readers and books kept apart; goals kept, replaced and
removed; books kept with their facts, replaced, removed, and damaged rows refused. A middleware stands for another
process: a locked table turns into ReadingConflict, and an UPDATE that reports no row still replaces a goal or a
book. They also cover ReadingTracker and ReaderGoals on the journal of tilttek/activity in memory — positions
stored, counted once after a conflict, events dispatched, books read again, goals read —, the tables on PostgreSQL,
MySQL and MariaDB and the schema listener, the configuration and the services, and the privacy module. The functional
test boots a small application, reads a book to its end and again, hears its events, reaches a goal, and exports and
erases a reader through the privacy bundle. In the monorepo, Infection holds the bundle at 100 % of covered mutants.
The benchmark
tests/Benchmark/ReadingTrackerBench.php measures, on SQLite in memory, a position recorded among 10 000 readings in a
book of 2 000 blocks. The figure is in The readings in the database.
Testing an application
Set store: memory in the test environment: the readings and the goals live until the kernel resets them, and no
table is needed.
when@test:
tilttek_reading_quests:
store: memory
Set tilttek_activity.store: memory too for a journal in memory. Freeze the clock service with Symfony's MockClock
to test a goal's pace at a given date.