Skip to content

Testing

tilttek/reading-quests

The package's tests

composer install
vendor/bin/phpunit --no-configuration tests

The unit suite, under tests/Unit, runs without a kernel, a database or a network: the documents are built in code, the journal is the one in memory of tilttek/activity and the clock is the MockClock of symfony/clock. The tests take each bound at its last allowed value and at the first refused one. In the monorepo, Infection holds the package at 100 % of covered mutants.

Testing code that reads the quests

Build the recorder on a Journal over an InMemoryActivityLog, record positions, then read the journal's totals, the quests' status or a goal's progress. A MockClock moves the even pace of a goal through the year.

The fuzz target

tests/Fuzz/book-shelf.php is the fuzz target of the shelf read from plain values: any JSON text gives a shelf or InvalidReadingQuest, never another error, and every book read is found again under its identifier. composer fuzz runs it.

The benchmark

tests/Benchmark/ReadingBench.php measures one position of reading for the largest document, 20 000 blocks: finding the book on a shelf of 100 000 books, recording the position, and building the activities it gives, in pages and in minutes. composer bench runs it.