From 7a96ff1e66888fb3148b5c94c38ea19188e3ced7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Tue, 30 Jul 2019 20:28:40 +0200 Subject: [PATCH] wip --- composer.json | 3 ++- src/GlobalCacheFacade.php | 13 +++++++++++++ src/TenancyServiceProvider.php | 5 +++++ tests/GlobalCacheTest.php | 27 +++++++++++++++++++++++++++ tests/TestCase.php | 3 ++- 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 src/GlobalCacheFacade.php create mode 100644 tests/GlobalCacheTest.php diff --git a/composer.json b/composer.json index e6fc6818..6e55ab95 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,8 @@ "Stancl\\Tenancy\\TenancyServiceProvider" ], "aliases": { - "Tenancy": "Stancl\\Tenancy\\TenancyFacade" + "Tenancy": "Stancl\\Tenancy\\TenancyFacade", + "GlobalCache": "Stancl\\Tenancy\\GlobalCacheFacade" } } }, diff --git a/src/GlobalCacheFacade.php b/src/GlobalCacheFacade.php new file mode 100644 index 00000000..ba2f8fad --- /dev/null +++ b/src/GlobalCacheFacade.php @@ -0,0 +1,13 @@ +app->singleton(Seed::class, function ($app) { return new Seed($app['db'], $app[DatabaseManager::class]); }); + + $this->app->bind('globalCache', function ($app) { + return new CacheManager($app); + }); } } diff --git a/tests/GlobalCacheTest.php b/tests/GlobalCacheTest.php new file mode 100644 index 00000000..d6cd85d7 --- /dev/null +++ b/tests/GlobalCacheTest.php @@ -0,0 +1,27 @@ +assertSame(null, cache('foo')); + cache(['foo' => 'bar'], 1); + $this->assertSame('bar', cache('foo')); + // $this->assertSame('bar', GlobalCache::get('foo')); + // GlobalCache::put('foo', 'bar'); + dd(GlobalCache::get('foo')); + + tenant()->create('foo.localhost'); + tenancy()->init('foo.localhost'); + } +} \ No newline at end of file diff --git a/tests/TestCase.php b/tests/TestCase.php index fc250f6d..b9b9c20b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -98,7 +98,8 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase protected function getPackageAliases($app) { return [ - 'Tenancy' => \Stancl\Tenancy\TenancyFacade::class + 'Tenancy' => \Stancl\Tenancy\TenancyFacade::class, + 'GlobalCache' => \Stancl\Tenancy\GlobalCacheFacade::class, ]; }