|
11 | 11 | use Illuminate\Support\Carbon;
|
12 | 12 | use Illuminate\Support\Facades\Event;
|
13 | 13 | use Illuminate\Support\Facades\Route;
|
| 14 | +use Orchestra\Testbench\Http\Middleware\PreventRequestsDuringMaintenance as TestbenchPreventRequestsDuringMaintenance; |
14 | 15 | use Orchestra\Testbench\TestCase;
|
15 | 16 | use Symfony\Component\HttpFoundation\Cookie;
|
16 | 17 |
|
17 | 18 | class MaintenanceModeTest extends TestCase
|
18 | 19 | {
|
| 20 | + protected function setUp(): void |
| 21 | + { |
| 22 | + parent::setUp(); |
| 23 | + |
| 24 | + $this->withoutMiddleware(TestbenchPreventRequestsDuringMaintenance::class); |
| 25 | + } |
| 26 | + |
19 | 27 | protected function tearDown(): void
|
20 | 28 | {
|
21 | 29 | @unlink(storage_path('framework/down'));
|
@@ -113,6 +121,25 @@ public function testMaintenanceModeCanBeBypassedWithValidCookie()
|
113 | 121 | $this->assertSame('Hello World', $response->original);
|
114 | 122 | }
|
115 | 123 |
|
| 124 | + public function testMaintenanceModeCanBeBypassedOnExcludedUrls() |
| 125 | + { |
| 126 | + $this->app->instance(PreventRequestsDuringMaintenance::class, new class($this->app) extends PreventRequestsDuringMaintenance |
| 127 | + { |
| 128 | + protected $except = ['/test']; |
| 129 | + }); |
| 130 | + |
| 131 | + file_put_contents(storage_path('framework/down'), json_encode([ |
| 132 | + 'retry' => 60, |
| 133 | + ])); |
| 134 | + |
| 135 | + Route::get('/test', fn () => 'Hello World')->middleware(PreventRequestsDuringMaintenance::class); |
| 136 | + |
| 137 | + $response = $this->get('/test'); |
| 138 | + |
| 139 | + $response->assertStatus(200); |
| 140 | + $this->assertSame('Hello World', $response->original); |
| 141 | + } |
| 142 | + |
116 | 143 | public function testMaintenanceModeCantBeBypassedWithInvalidCookie()
|
117 | 144 | {
|
118 | 145 | file_put_contents(storage_path('framework/down'), json_encode([
|
|
0 commit comments