1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 01:14:04 +00:00

Rewrite old tests

This commit is contained in:
Samuel Štancl 2020-05-12 23:22:40 +02:00
parent 64383b4c56
commit 89936187ce
71 changed files with 698 additions and 3203 deletions

View file

@ -1,62 +0,0 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Tests;
use Illuminate\Support\Facades\Route;
use Stancl\Tenancy\Middleware\InitializeTenancyByRequestData;
use Stancl\Tenancy\Tenant;
class RequestDataIdentificationTest extends TestCase
{
public $autoCreateTenant = false;
public $autoInitTenancy = false;
public function setUp(): void
{
parent::setUp();
config([
'tenancy.exempt_domains' => [
'localhost',
],
]);
Route::middleware(InitializeTenancyByRequestData::class)->get('/test', function () {
return 'Tenant id: ' . tenant('id');
});
}
/** @test */
public function header_identification_works()
{
$this->app->bind(InitializeTenancyByRequestData::class, function () {
return new InitializeTenancyByRequestData('X-Tenant');
});
$tenant = Tenant::new()->save();
$tenant2 = Tenant::new()->save();
$this
->withoutExceptionHandling()
->get('test', [
'X-Tenant' => $tenant->id,
])
->assertSee($tenant->id);
}
/** @test */
public function query_parameter_identification_works()
{
$this->app->bind(InitializeTenancyByRequestData::class, function () {
return new InitializeTenancyByRequestData(null, 'tenant');
});
$tenant = Tenant::new()->save();
$tenant2 = Tenant::new()->save();
$this
->withoutExceptionHandling()
->get('test?tenant=' . $tenant->id)
->assertSee($tenant->id);
}
}