Testing
tilttek/journalThe 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 entries live in
Store\InMemoryJournalStore, the secrets in the store in memory of tilttek/player-knowledge, and the directory and
the source of events are fixtures of the suite. The tests take each bound at its last allowed value and at the first
refused one.
An application tests its own JournalStoreInterface against the rules of the store:
nothing for an identifier never kept, a new entry kept once, a stale one refused on save and on delete, an entry never
moved to another journal, and every list in the order it was kept.
The fuzz target
tests/Fuzz/mentions.php is the fuzz target of the mentions: any text is refused with the library's exceptions, when
it is not UTF-8, or cut into pieces that join back to the text, no two plain pieces in a row and none empty, each
mention with a name and a text. composer fuzz runs it.
Benchmarks
tests/Benchmark/JournalBench.php builds a journal of 1 000 published entries of 20 blocks, each block mentioning five
pages, one block in four behind a secret, then reads one entry and the timeline of one character — 500 entries — as a
player who knows half the secrets, and assembles the draft of a session of 200 events. On PHP 8.5 without an opcode
cache, with the store of the tests: the entry in about 0.1 ms, the timeline in about 45 ms, the draft in about 1.4 ms.