1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 17:54:03 +00:00
tenancy/tests/RequestOriginIdentificationTest.php
2021-03-22 16:18:17 -07:00

43 lines
984 B
PHP

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