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

Merge branch '2.x' into laravel-7-support

This commit is contained in:
Samuel Štancl 2020-03-17 16:40:15 +01:00
commit febca87dfc
5 changed files with 135 additions and 4 deletions

View file

@ -21,7 +21,7 @@ class CachedResolverTest extends TestCase
$this->markTestSkipped('This test is only relevant for the DB storage driver.');
}
config(['tenancy.storage_drivers.db.cache_store' => null]); // default driver
config(['tenancy.storage_drivers.db.cache_store' => config('cache.default')]);
}
/** @test */

View file

@ -0,0 +1,62 @@
<?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);
}
}