mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 19: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) {
|
array_map(function ($listener) {
|
||||||
$listener($this);
|
$listener($this);
|
||||||
}, $this->listeners['boostrapping']);
|
}, $this->listeners['bootstrapping']);
|
||||||
|
|
||||||
$this->initialized = true;
|
$this->initialized = true;
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ trait BootstrapsTenancy
|
||||||
|
|
||||||
array_map(function ($listener) {
|
array_map(function ($listener) {
|
||||||
$listener($this);
|
$listener($this);
|
||||||
}, $this->listeners['boostrapped']);
|
}, $this->listeners['bootstrapped']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function end()
|
public function end()
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ trait TenantManagerEvents
|
||||||
* @var callable[][]
|
* @var callable[][]
|
||||||
*/
|
*/
|
||||||
protected $listeners = [
|
protected $listeners = [
|
||||||
'boostrapping' => [],
|
'bootstrapping' => [],
|
||||||
'boostrapped' => [],
|
'bootstrapped' => [],
|
||||||
'ending' => [],
|
'ending' => [],
|
||||||
'ended' => [],
|
'ended' => [],
|
||||||
];
|
];
|
||||||
|
|
@ -35,7 +35,7 @@ trait TenantManagerEvents
|
||||||
* @param callable $callback
|
* @param callable $callback
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function boostrapped(callable $callback)
|
public function bootstrapped(callable $callback)
|
||||||
{
|
{
|
||||||
$this->listeners['bootstrapped'][] = $callback;
|
$this->listeners['bootstrapped'][] = $callback;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Tests;
|
namespace Stancl\Tenancy\Tests;
|
||||||
|
|
||||||
|
use Tenancy;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Stancl\Tenancy\Exceptions\CannotChangeUuidOrDomainException;
|
use Stancl\Tenancy\Exceptions\CannotChangeUuidOrDomainException;
|
||||||
|
|
@ -241,4 +242,34 @@ class TenantManagerTest extends TestCase
|
||||||
$this->expectException(CannotChangeUuidOrDomainException::class);
|
$this->expectException(CannotChangeUuidOrDomainException::class);
|
||||||
tenant()->put(['uuid' => 'foo']);
|
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