mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 17:04:03 +00:00
Fix typos, add tests
This commit is contained in:
parent
82237bd7f3
commit
0111ed6f53
3 changed files with 36 additions and 5 deletions
|
|
@ -23,7 +23,7 @@ trait BootstrapsTenancy
|
|||
{
|
||||
array_map(function ($listener) {
|
||||
$listener($this);
|
||||
}, $this->listeners['boostrapping']);
|
||||
}, $this->listeners['bootstrapping']);
|
||||
|
||||
$this->initialized = true;
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ trait BootstrapsTenancy
|
|||
|
||||
array_map(function ($listener) {
|
||||
$listener($this);
|
||||
}, $this->listeners['boostrapped']);
|
||||
}, $this->listeners['bootstrapped']);
|
||||
}
|
||||
|
||||
public function end()
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ trait TenantManagerEvents
|
|||
* @var callable[][]
|
||||
*/
|
||||
protected $listeners = [
|
||||
'boostrapping' => [],
|
||||
'boostrapped' => [],
|
||||
'bootstrapping' => [],
|
||||
'bootstrapped' => [],
|
||||
'ending' => [],
|
||||
'ended' => [],
|
||||
];
|
||||
|
|
@ -35,7 +35,7 @@ trait TenantManagerEvents
|
|||
* @param callable $callback
|
||||
* @return self
|
||||
*/
|
||||
public function boostrapped(callable $callback)
|
||||
public function bootstrapped(callable $callback)
|
||||
{
|
||||
$this->listeners['bootstrapped'][] = $callback;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Stancl\Tenancy\Tests;
|
||||
|
||||
use Tenancy;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Stancl\Tenancy\Exceptions\CannotChangeUuidOrDomainException;
|
||||
|
|
@ -241,4 +242,34 @@ class TenantManagerTest extends TestCase
|
|||
$this->expectException(CannotChangeUuidOrDomainException::class);
|
||||
tenant()->put(['uuid' => 'foo']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function bootstrapping_event_works()
|
||||
{
|
||||
$uuid = tenant()->create('foo.localhost')['uuid'];
|
||||
|
||||
Tenancy::bootstrapping(function ($tenantManager) use ($uuid) {
|
||||
if ($tenantManager->tenant['uuid'] === $uuid) {
|
||||
config(['tenancy.foo' => 'bar']);
|
||||
}
|
||||
});
|
||||
|
||||
tenancy()->init('foo.localhost');
|
||||
$this->assertSame('bar', config('tenancy.foo'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function bootstrapped_event_works()
|
||||
{
|
||||
$uuid = tenant()->create('foo.localhost')['uuid'];
|
||||
|
||||
Tenancy::bootstrapped(function ($tenantManager) use ($uuid) {
|
||||
if ($tenantManager->tenant['uuid'] === $uuid) {
|
||||
config(['tenancy.foo' => 'bar']);
|
||||
}
|
||||
});
|
||||
|
||||
tenancy()->init('foo.localhost');
|
||||
$this->assertSame('bar', config('tenancy.foo'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue