1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 19:14:03 +00:00

Add request origin resolver test

This commit is contained in:
Jon Erickson 2021-03-22 16:18:17 -07:00
parent be44d1baf4
commit b4182f8194

View 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);
}
}