Skip to content

Testing

tilttek/character-retirement

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 sheets live in the store of the tests of tilttek/character-sheet, and the endings in Store\InMemoryEndingStore. 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 EndingStoreInterface against the rules of the store: nothing for an identifier never kept, a new ending kept once, a second open ending of a sheet refused, a stale one refused on save and on delete, the version raised by one at each write, and every list in the order it was first kept.

The fuzz target

tests/Fuzz/frozen-sheet.php is the fuzz target of the frozen sheets a store reads back: any JSON document is refused with the library's exceptions, or gives a frozen sheet that writes back to the same values. composer fuzz runs it.

Benchmarks

tests/Benchmark/EndingsBench.php reads the first page of the memorial of a campaign of 2 000 endings, as a member reads it, freezes a sheet of 500 items, and reads that frozen sheet back from its plain values. On PHP 8.5 without an opcode cache, with the stores of the tests: the page in about 2.4 ms, the freeze in about 0.8 ms, the read in about 0.4 ms.