mirror of
https://github.com/karatektus/pl_mail.git
synced 2026-10-25 10:04:18 +00:00
MERCURE 0.5.0 / symfony/mercure 0.8.0, kept out of the earlier sweep because it carries the live-update transport and should not ride along with eighteen patch bumps. It earned that: HubInterface gained getProtocolVersion() and getCookieName(), so the two hub doubles in CalendarSyncFinishedNotificationTest stopped satisfying it — a fatal error, not a failing test. Both implement them now, returning what a real hub would rather than pretending to configuration these tests do not have. Verified where it matters: the full browser suite, including the specs that stop and restart the hub to prove the stream recovers. A DATABASE OF ITS OWN for the unit suite. Both suites run APP_ENV=test, and doctrine.yaml's `dbname_suffix: '_test%env(default::TEST_TOKEN)%'` therefore pointed both at app_test. One database, two suites — and one test in here truncates real tables, because exercising a data reset is its whole purpose. Sequentially that is safe; Postgres rolls a TRUNCATE back like anything else. Concurrently it is not: TRUNCATE takes an ACCESS EXCLUSIVE lock, so live queries from the browser suite block until the unit test's transaction ends, and specs with no connection to any of this report timeouts. It fits the transaction abort seen here once and never reproduced. TEST_TOKEN is Symfony's own mechanism for exactly this, so the fix uses it rather than inventing a second DATABASE_URL. bin/test-unit.sh sets it and does the create/migrate/seed a fresh database needs. The seeding is the part worth guarding: PageRendersTest, ListFragmentTest and others SKIP THEMSELVES when the admin user is missing, so without it a green run would quietly be ~50 tests smaller than it looks — a worse failure than a red one. Checked rather than assumed: 4047 tests either way, no skipped or incomplete markers. The assertion count moved, 11540 → 11526, and settled there across runs. That is the point of the change showing up: the unit suite was reading rows the browser stack had left behind, and now it reads only its own. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
40 lines
1.9 KiB
Bash
40 lines
1.9 KiB
Bash
#!/bin/sh
|
|
# PHPUnit against a database of its own.
|
|
#
|
|
# WHY THIS EXISTS
|
|
# ───────────────
|
|
# The unit suite and the browser stack both run APP_ENV=test, and Doctrine's
|
|
# `dbname_suffix: '_test%env(default::TEST_TOKEN)%'` therefore pointed both at
|
|
# `app_test`. One database, two suites, and one of the tests in here truncates
|
|
# real tables: ResetHandsBackRegistrationsTest exercises a data reset, which is
|
|
# the whole point of it.
|
|
#
|
|
# Sequentially that is safe — Postgres rolls a TRUNCATE back like anything else.
|
|
# Run the two at once and it is not: TRUNCATE takes an ACCESS EXCLUSIVE lock, so
|
|
# every live query the browser suite makes against those tables blocks until the
|
|
# unit test's transaction ends, and the browser suite reports timeouts in specs
|
|
# that have nothing to do with any of this. It can also go the other way, which
|
|
# fits a transaction abort seen once here and never reproduced.
|
|
#
|
|
# TEST_TOKEN is Symfony's own answer to this — the mechanism that gives each
|
|
# parallel test process its own database — so the fix is to use it rather than
|
|
# to invent a second DATABASE_URL.
|
|
#
|
|
# The cost is that a fresh database needs creating, migrating and seeding, which
|
|
# is what the rest of this does. Migrations are a no-op once they have run, so
|
|
# only the first invocation is slow.
|
|
#
|
|
# The two seeded users are not optional: PageRendersTest, ListFragmentTest and
|
|
# friends skip themselves when the admin is missing, so without these a green
|
|
# run would quietly be ~50 tests smaller than it looks.
|
|
set -e
|
|
|
|
export TEST_TOKEN=_unit
|
|
|
|
php bin/console doctrine:database:create --if-not-exists --quiet
|
|
php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration --quiet
|
|
php bin/console app:test:seed-user --quiet
|
|
php bin/console app:test:seed-user --admin --email=e2e-admin@plmail.test --password=e2e-admin-password --quiet
|
|
|
|
exec php vendor/bin/phpunit "$@"
|