mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 17:14:03 +00:00
Add request origin resolver test
This commit is contained in:
parent
be44d1baf4
commit
b4182f8194
1 changed files with 43 additions and 0 deletions
43
tests/RequestOriginIdentificationTest.php
Normal file
43
tests/RequestOriginIdentificationTest.php
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Tests;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Stancl\Tenancy\Middleware\InitializeTenancyByRequestOrigin;
|
||||||
|
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||||
|
|
||||||
|
class RequestOriginIdentificationTest extends TestCase
|
||||||
|
{
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
config([
|
||||||
|
'tenancy.central_domains' => [
|
||||||
|
'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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue