Testing
tilttek/homebrew-hubThe 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 homebrews and the
subscriptions live in Store\InMemoryHomebrewStore and Store\InMemorySubscriptionStore, the rules of the tables in
the store in memory of tilttek/table-rules, and the time is the MockClock of symfony/clock, moved forward by each
test to the moment it needs. In the monorepo, Infection holds the package at 100 % of covered mutants.
An application tests its own stores against the rules of the stores: nothing
for an identifier never kept, a new homebrew or subscription kept once, a stale one refused, the version raised by one at
each write, a search that answers as HomebrewSearch::matches() and compare() say, and every release, origin and
endorser read back as it was kept. It tests its Contract\Transactions by an adoption whose subscription is refused:
the table's rules stay as they were.
Fuzzing
tests/Fuzz/draft-json.php is the fuzz target of Codec\DraftJson, run by composer fuzz in the monorepo: any text
gives a draft that writes back and reads back the same, or is refused with InvalidHomebrew, never another exception.
Benchmarks
tests/Benchmark/HomebrewHubBench.php searches a page of the most endorsed among 1 000 homebrews, reads the update a
table sees of a homebrew of 100 rules of 9 lines whose next release changes a third of them, and reads that homebrew as
a JSON document. On PHP 8.5 without an opcode cache: the page in about 3 ms, the store in memory sorting every
homebrew, the update in about 0.8 ms and the document in about 1.2 ms.