From b4182f8194114c8ff296e2d8725800198ddf938a Mon Sep 17 00:00:00 2001 From: Jon Erickson Date: Mon, 22 Mar 2021 16:18:17 -0700 Subject: [PATCH] Add request origin resolver test --- tests/RequestOriginIdentificationTest.php | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/RequestOriginIdentificationTest.php diff --git a/tests/RequestOriginIdentificationTest.php b/tests/RequestOriginIdentificationTest.php new file mode 100644 index 00000000..f83ea21f --- /dev/null +++ b/tests/RequestOriginIdentificationTest.php @@ -0,0 +1,43 @@ + [ + 'localhost', + ], + ]); + + Route::middleware(InitializeTenancyByRequestOrigin::class)->get('/test', function () { + return 'Tenant id: ' . tenant('id'); + }); + } + + /** @test */ + public function origin_identification_works() + { + $tenant = Tenant::create(); + $tenant->domains()->create([ + 'domain' => 'localhost' + ]); + + $this + ->withoutExceptionHandling() + ->get('test', [ + 'Origin' => 'http://localhost', + ]) + ->assertSee($tenant->id); + } +}