Skip to content

Testing

tilttek/journal-bundle

The bundle's tests

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

The unit tests run DbalJournalStore on SQLite in memory: entries kept and read back as they were given, every field and block included, a publication time in UTC, a change at its version with its blocks written again, a change at another version, in another journal or of an unknown entry refused with nothing kept, a second new entry of the same identifier refused, a writer that meets a database another writer locked refused, a journal read in the order its entries were first kept, a deletion at its version, the library's Journal on the store, the pages of an author's entries, an author erased with or without a pseudonym, and rows out of their shape refused. They also cover the tables on PostgreSQL, MySQL and MariaDB and the schema listener, the configuration and the services, the observer, and the privacy module, its erasure checked in the raw rows with AssertsRawErasure of phil/privacy-bundle. The functional test boots a small application, writes, publishes, withdraws and exports entries, hears their events, and exports and erases a member through the privacy bundle. In the monorepo, Infection holds the bundle at 100 % of covered mutants.

The benchmark

tests/Benchmark/DbalJournalStoreBench.php measures, on SQLite in memory, a campaign of 1 000 entries of 20 blocks: one entry read, the whole journal read, and a change saved. The figures are in The entries in the database.

Testing an application

Set store: memory in the test environment: the entries live as long as the container, and no table is needed.

when@test:
    tilttek_journal:
        store: memory
        knowledge_store: Tilttek\PlayerKnowledge\Store\InMemoryKnowledgeStore

Register Tilttek\PlayerKnowledge\Store\InMemoryKnowledgeStore as a service of the test environment for the last line. A listener of the events, or a test double of JournalObserverInterface aliased in the test environment, sees what the journal told.