From 32eb3ad339999c6150ff88ed201f38404813e463 Mon Sep 17 00:00:00 2001 From: George Bishop Date: Fri, 19 Aug 2022 11:36:05 +0100 Subject: [PATCH] test: ensure nested tenant values are mapped --- tests/Features/TenantConfigTest.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/Features/TenantConfigTest.php b/tests/Features/TenantConfigTest.php index 37e26198..904e420b 100644 --- a/tests/Features/TenantConfigTest.php +++ b/tests/Features/TenantConfigTest.php @@ -22,6 +22,30 @@ class TenantConfigTest extends TestCase parent::tearDown(); } + /** @test */ + public function nested_tenant_values_are_merged() + { + $this->assertSame(null, config('whitelabel.theme')); + config([ + 'tenancy.features' => [TenantConfig::class], + 'tenancy.bootstrappers' => [], + ]); + Event::listen(TenancyInitialized::class, BootstrapTenancy::class); + Event::listen(TenancyEnded::class, RevertToCentralContext::class); + + TenantConfig::$storageToConfigMap = [ + 'whitelabel.config.theme' => 'whitelabel.theme', + ]; + + $tenant = Tenant::create([ + 'whitelabel' => ['config' => ['theme' => 'dark']], + ]); + + tenancy()->initialize($tenant); + $this->assertSame('dark', config('whitelabel.theme')); + tenancy()->end(); + } + /** @test */ public function config_is_merged_and_removed() {