[13.x] Fix order-dependent tests

Merged
JA
25d ago
+246-10

While working through the test suite, I noticed "test pollution" when certain sub-suites are run directly. CI runs the full suite in a fixed order, so it's not always noticed. But if you shuffle it with --order-by=random, run a file on its own, or change a test filename unrelated tests start failing.

This PR improves resetting state where it leaks, mostly in setUp and tearDown, and gives tests that were quietly borrowing another test's app or connection their own. A few had worse side effects: SupportFacadesHttpTest made a real request to laravel.com when run alone, and FoundationHelpersTest left hot, mix-manifest.json and a mix/ directory in tests/Foundation whenever an assertion failed partway.

Most of the fixes are one-liners, but two are worth knowing about.

  1. Orchestra Testbench disables Laravel's putenv adapter when it creates an app and only restores it on terminate, so a Testbench test that just flushes its app breaks putenv for later tests. LoadEnvironmentVariablesTest re-enables it; Testbench tests use #[WithEnv] instead of putenv().
  2. Vite::flush() only clears the font manifest cache through an instance the app may never have created.