- Add phpunit/phpunit ^13.2, symfony/browser-kit and symfony/css-selector
to require-dev, plus the autoload-dev mapping for App\Tests- Add phpunit.dist.xml (strict deprecation/notice/warning failures,
APP_ENV=test forced) and .env.test / bin/phpunit / tests/bootstrap.php
from the PHPUnit recipe
- Add tests/Support/TotpTestHelper providing a deterministic TOTP
fixture, frozen clock and ConfigBag/cache-pool helpers
- Add 121 unit tests covering Clock, ConfigBag, Data/Payload, Enum/Scope,
MonitorCacheKeys, PersistCache, Utilities, all five Traits and the
three Service managers (BackupCode, Domain, Login)
- Fix LoginManagerTest nonce lookups to use makeCacheKey() so the cache
key matches the one the manager actually reads/writes
- Gitignore bin/.phpunit.result.cache
- Add TestKernel that removes the kernel.reset tag from nonceCache,
rateLimitCache, sessionCache and sessionStorage pools so in-memory
state survives across requests within a single test (mirroring APCu
persistence in production)
- Add config/packages/test/ with array cache adapters and test session
config
- Set fixed TOTP secret (JBSWY3DPEHPK3PXP) and high rate limits in
phpunit.dist.xml and .env.test so functional tests can compute valid
codes and are not rate-limited
- Make Kernel non-final so TestKernel can extend it
- Fix testFailedLoginWithSpentNonceIsRejected and
testConsumedBackupCodeCannotBeReused: clear the CookieJar between
sub-requests so a session cookie set by a prior successful login does
not auto-authenticate the next request via AcceptListener before the
nonce/backup-code path is exercised
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Adds a comprehensive PHPUnit test suite to the preauth project, covering all 21 source classes with 222 tests and 469 assertions.
Test Results
What's Included
Test Infrastructure
phpunit.dist.xml— PHPUnit configuration with coverage settingstests/TestKernel.php— Test-specific kerneltests/bootstrap.php— Autoloader bootstraptests/Support/TotpTestHelper.php— Reusable TOTP fixtures (frozen clock, deterministic codes)tests/Support/ListenerTestHelper.php— Reusable listener test fixtures (Twig env, mock rate limiters)Unit Tests (per class)
Every source class has a corresponding unit test file:
Functional Tests
AuthenticationFlowTest.php— End-to-end tests through the real Symfony kernel:Edge Cases Covered
Commits
890cc22— Add PHPUnit test suite and supporting infrastructure4d314bc— Add unit tests for all listeners, the backup-codes command, and test support helpers6c5a7c9— Fix failing functional tests and add test infrastructure12ba6cd— Add unit tests for untested edge cases and code pathsHow to Run