From de025a6a4dc7f9bcbbd47706f7a03c72749a13be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Fri, 9 Aug 2019 23:17:10 +0200 Subject: [PATCH] Set public key on model --- src/TenancyServiceProvider.php | 4 ++++ src/Tenant.php | 2 ++ test | 2 +- tests/TenantStorageTest.php | 2 ++ tests/TestCase.php | 8 +------- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/TenancyServiceProvider.php b/src/TenancyServiceProvider.php index 087e0d47..1c174ea3 100644 --- a/src/TenancyServiceProvider.php +++ b/src/TenancyServiceProvider.php @@ -34,6 +34,10 @@ class TenancyServiceProvider extends ServiceProvider __DIR__ . '/assets/config.php' => config_path('tenancy.php'), ], 'config'); + $this->publishes([ + __DIR__ . '/assets/2019_08_08_000000_create_tenants_table.php' => database_path('migrations'), + ], 'migrations'); + $this->loadRoutesFrom(__DIR__ . '/routes.php'); Route::middlewareGroup('tenancy', [ diff --git a/src/Tenant.php b/src/Tenant.php index 5af3aa6f..a7349a26 100644 --- a/src/Tenant.php +++ b/src/Tenant.php @@ -9,6 +9,8 @@ class Tenant extends Model protected $dataColumn = 'data'; protected $specialColumns = []; protected $guarded = []; + protected $publicKey = 'uuid'; + public $incrementing = false; /** * Decoded data from the data column. diff --git a/test b/test index 0d11eef3..710b1824 100755 --- a/test +++ b/test @@ -5,7 +5,7 @@ import argparse system('docker-compose up -d') parser = argparse.ArgumentParser() -parser.add_argument("--variants", default='1,2', +parser.add_argument("--variants", default='1,2,3', help="Comma-separated values. Which test variants should be run.") args, other = parser.parse_known_args() diff --git a/tests/TenantStorageTest.php b/tests/TenantStorageTest.php index aaa4209b..5979bf57 100644 --- a/tests/TenantStorageTest.php +++ b/tests/TenantStorageTest.php @@ -109,6 +109,8 @@ class TenantStorageTest extends TestCase { $value = ['foo' => 'bar', 'abc' => 'xyz']; + dd(\Stancl\Tenancy\Tenant::find(tenant('uuid'))); + $this->assertSame($value, tenancy()->put($value)); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index f1d04c0f..27373df1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -10,13 +10,6 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase public $autoCreateTenant = true; public $autoInitTenancy = true; - private function checkRequirements(): void - { - parent::checkRequirements(); - - dd($this->getAnnotations()); - } - /** * Setup the test environment. * @@ -28,6 +21,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase Redis::connection('tenancy')->flushdb(); Redis::connection('cache')->flushdb(); + Artisan::call('migrate'); if ($this->autoCreateTenant) { $this->createTenant();