From 91b787d76f02ca2a2936ca9e7b67d12eb2f52156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Sun, 27 Oct 2019 20:45:12 +0100 Subject: [PATCH] Event listener arguments test --- src/TenantManager.php | 2 +- tests/TenantManagerTest.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/TenantManager.php b/src/TenantManager.php index b11a758b..dae6ce59 100644 --- a/src/TenantManager.php +++ b/src/TenantManager.php @@ -426,7 +426,7 @@ class TenantManager } /** - * Execute event listeners. + * Trigger an event and execute event listeners. * * @param string $name * @param mixed ...$args diff --git a/tests/TenantManagerTest.php b/tests/TenantManagerTest.php index f469972a..9506f9fd 100644 --- a/tests/TenantManagerTest.php +++ b/tests/TenantManagerTest.php @@ -320,4 +320,14 @@ class TenantManagerTest extends TestCase $this->expectException(TenantDoesNotExistException::class); tenancy()->find('gjnfdgf'); } + + /** @test */ + public function event_listeners_can_accept_arguments() + { + tenancy()->hook('tenant.creating', function ($tenantManager, $tenant) { + $this->assertSame('bar', $tenant->foo); + }); + + Tenant::new()->withData(['foo' => 'bar'])->save(); + } }