Testing
tilttek/player-knowledgeThe 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 secrets and revelations live
in Store\InMemoryKnowledgeStore. 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.
An application tests its own KnowledgeStoreInterface against the rules of
the store: nothing for an identifier never kept, a new secret kept once, a stale one
refused on save and on delete, the version raised by one at each write, a secret erased with its revelations,
revelations kept all or none and refused twice for the same knower, and every list in the order it was kept.
The fuzz target
tests/Fuzz/knower-key.php is the fuzz target of the knower keys: any text is refused with the library's exceptions,
or gives a knower whose key is the text read and reads back to the same knower. composer fuzz runs it.
Benchmarks
tests/Benchmark/KnowledgeBench.php reads the snapshot of a character in a campaign of 2 000 secrets, half of them
revealed, as a page does at each display, and filters 1 000 entries requiring up to three secrets each with it. On
PHP 8.5 without an opcode cache, with the store of the tests: the snapshot in about 0.6 ms, the filter in about
0.35 ms.