Commit a3dcc14
committed
Add wiring-level test coverage for the Octane reset listener
`PermissionServiceProvider::registerOctaneListener()` wires two listeners for `Laravel\Octane\Contracts\OperationTerminated` — resetting the permissions team ID on every request, and (opt-in via `permission.register_octane_reset_listener`) clearing the in-memory permissions collection — but neither had any test coverage. The registration code bails out early via `if ($this->app->runningInConsole() || ...)`, and since Pest/Testbench always runs under the CLI SAPI, `runningInConsole()` is always `true` in the test suite, so this code path was silently never exercised.
This PR adds real coverage without requiring a running Swoole/RoadRunner server:
- Adds `laravel/octane` as a **dev-only** dependency: it's pure PHP with no extension requirement — swoole/roadrunner are only needed to actually *serve* traffic via `octane:start`, not to use Octane's `Contracts`/`Events` classes.
- `tests/Integration/OctaneListenerTest.php` forces `Application::$isRunningInConsole` to `false` via reflection (the real, memoized gate Laravel checks (see `Illuminate\Foundation\Application::runningInConsole()`), invokes the real (protected) `registerOctaneListener()` method, and dispatches an actual `Laravel\Octane\Events\RequestTerminated` event to exercise the genuine listener wiring end-to-end.
**Coverage added:**
- Listener is not registered when `octane.listeners` is disabled.
- `PermissionRegistrar::getPermissionsTeamId()` resets to `null` on operation termination.
- The permissions collection is cleared on termination only when `permission.register_octane_reset_listener` is enabled, and left untouched when it isn't.
**Maintenance Trade-off:** the tests reach into a protected framework property (`Application::$isRunningInConsole`) and a protected provider method via reflection. If Laravel renames that property, or Octane changes `RequestTerminated`'s constructor signature, these tests could break for reasons unrelated to an actual regression here ... but we keep in sync with Laravel releases already.
**No behavior change** — this is test-only coverage plus a dev dependency.1 parent 9d4eb1e commit a3dcc14
2 files changed
Lines changed: 97 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
0 commit comments