From 13ea04e7f5e1e8a73d83cdfe257acc59e5cf7f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Mon, 30 Sep 2019 16:37:02 +0200 Subject: [PATCH] Add tests & config keys --- assets/config.php | 4 ++++ tests/TenantConfigTest.php | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/TenantConfigTest.php diff --git a/assets/config.php b/assets/config.php index 538759ec..dac5f2e0 100644 --- a/assets/config.php +++ b/assets/config.php @@ -79,9 +79,13 @@ return [ // Features are classes that provide additional functionality // not needed for tenancy to be bootstrapped. They are run // regardless of whether tenancy has been initialized. + Stancl\Tenancy\Features\TenantConfig::class, Stancl\Tenancy\Features\TelescopeTags::class, Stancl\Tenancy\Features\TenantRedirect::class, ], + 'storage_to_config_map' => [ + // 'paypal_api_key' => 'services.paypal.api_key', + ], 'home_url' => '/app', 'migrate_after_creation' => false, // run migrations after creating a tenant 'delete_database_after_tenant_deletion' => false, // delete the tenant's database after deleting the tenant diff --git a/tests/TenantConfigTest.php b/tests/TenantConfigTest.php new file mode 100644 index 00000000..b97c7e7b --- /dev/null +++ b/tests/TenantConfigTest.php @@ -0,0 +1,35 @@ +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')); + } +} \ No newline at end of file