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

Allow array values for Tenant Config

Closes #412
This commit is contained in:
Samuel Štancl 2020-05-30 17:14:56 +02:00
parent a0192a941e
commit 6dad6ce49a
2 changed files with 64 additions and 8 deletions

View file

@ -15,6 +15,13 @@ use Stancl\Tenancy\Tests\TestCase;
class TenantConfigTest extends TestCase
{
public function tearDown(): void
{
TenantConfig::$storageToConfigMap = [];
parent::tearDown();
}
/** @test */
public function config_is_merged_and_removed()
{
@ -45,4 +52,43 @@ class TenantConfigTest extends TestCase
'private' => null,
], config('services.paypal'));
}
/** @test */
public function the_value_can_be_set_to_multiple_config_keys()
{
$this->assertSame(null, config('services.paypal'));
config([
'tenancy.features' => [TenantConfig::class],
'tenancy.bootstrappers' => [],
]);
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
TenantConfig::$storageToConfigMap = [
'paypal_api_public' => [
'services.paypal.public1',
'services.paypal.public2',
],
'paypal_api_private' => 'services.paypal.private',
];
$tenant = Tenant::create([
'paypal_api_public' => 'foo',
'paypal_api_private' => 'bar',
]);
tenancy()->initialize($tenant);
$this->assertSame([
'public1' => 'foo',
'public2' => 'foo',
'private' => 'bar',
], config('services.paypal'));
tenancy()->end();
$this->assertSame([
'public1' => null,
'public2' => null,
'private' => null,
], config('services.paypal'));
}
}