1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 17:44:04 +00:00

Add test for tenant.creating hook

This commit is contained in:
Samuel Štancl 2019-10-29 21:49:50 +01:00
parent eecadd6d39
commit ccb68f5400

View file

@ -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);
}
}