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

[2.x] Tenant config (#145)

* TenantConfig first draft

* Apply fixes from StyleCI

* Add unsetTenantConfig

* Fix DB storage driver bug, add regression test (tenant_data_can_be_set_during_creation)

* Add tests & config keys

* Apply fixes from StyleCI
This commit is contained in:
Samuel Štancl 2019-09-30 16:52:46 +02:00 committed by GitHub
parent d70e561106
commit 56a2bdf5af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 109 additions and 1 deletions

View file

@ -94,4 +94,15 @@ class TenantClassTest extends TestCase
$this->expectException(\BadMethodCallException::class);
$tenant->sdjigndfgnjdfgj();
}
/** @test */
public function tenant_data_can_be_set_during_creation()
{
Tenant::new()->withData(['foo' => 'bar'])->save();
$data = tenancy()->all()->first()->data;
unset($data['id']);
$this->assertSame(['foo' => 'bar'], $data);
}
}

View file

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Tests;
class TenantConfigTest extends TestCase
{
public $autoInitTenancy = false;
public $autoCreateTenant = false;
/** @test */
public function config_is_merged_and_removed()
{
$this->assertSame(null, config('services.paypal'));
config(['tenancy.storage_to_config_map' => [
'paypal_api_public' => 'services.paypal.public',
'paypal_api_private' => 'services.paypal.private',
]]);
tenancy()->create('foo.localhost', [
'paypal_api_public' => 'foo',
'paypal_api_private' => 'bar',
]);
tenancy()->init('foo.localhost');
$this->assertSame(['public' => 'foo', 'private' => 'bar'], config('services.paypal'));
tenancy()->end();
$this->assertSame([
'public' => null,
'private' => null,
], config('services.paypal'));
}
}