From ccb68f54007c3647b08591d5125989479dd577df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Tue, 29 Oct 2019 21:49:50 +0100 Subject: [PATCH] Add test for tenant.creating hook --- tests/TenantManagerTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/TenantManagerTest.php b/tests/TenantManagerTest.php index 9506f9fd..c3df859c 100644 --- a/tests/TenantManagerTest.php +++ b/tests/TenantManagerTest.php @@ -330,4 +330,19 @@ class TenantManagerTest extends TestCase Tenant::new()->withData(['foo' => 'bar'])->save(); } + + /** @test */ + public function tenant_creating_hook_can_be_used_to_modify_tenants_data() + { + tenancy()->hook('tenant.creating', function ($tm, Tenant $tenant) { + $tenant->put([ + 'foo' => 'bar', + 'abc123' => 'def456', + ]); + }); + $tenant = Tenant::new()->save(); + + $this->assertArrayHasKey('foo', $tenant->data); + $this->assertArrayHasKey('abc123', $tenant->data); + } }