mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 18:04:03 +00:00
Fix event tests
This commit is contained in:
parent
a9c37d1535
commit
7e645a3312
3 changed files with 20 additions and 34 deletions
|
|
@ -82,6 +82,7 @@ class DatabaseManager
|
|||
|
||||
public function switchConnection($connection)
|
||||
{
|
||||
$this->app['config']['database.default'] = $connection;
|
||||
$this->database->purge();
|
||||
$this->database->reconnect($connection);
|
||||
$this->database->setDefaultConnection($connection);
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@ class TenantManager
|
|||
protected $storage;
|
||||
|
||||
/** @var DatabaseManager */
|
||||
protected $database;
|
||||
public $database;
|
||||
|
||||
/** @var callable[][] Event listeners */
|
||||
protected $listeners = [];
|
||||
/** @var callable[][] */
|
||||
protected $eventListeners = [];
|
||||
|
||||
/** @var bool Has tenancy been initialized. */
|
||||
public $initialized;
|
||||
public $initialized = false;
|
||||
|
||||
public function __construct(Application $app, ConsoleKernel $artisan, Contracts\StorageDriver $storage, DatabaseManager $database)
|
||||
{
|
||||
|
|
@ -153,8 +153,8 @@ class TenantManager
|
|||
|
||||
public function initializeTenancy(Tenant $tenant): self
|
||||
{
|
||||
$this->bootstrapTenancy($tenant);
|
||||
$this->setTenant($tenant);
|
||||
$this->bootstrapTenancy($tenant);
|
||||
$this->initialized = true;
|
||||
|
||||
return $this;
|
||||
|
|
@ -245,7 +245,7 @@ class TenantManager
|
|||
*/
|
||||
public function tenancyBootstrappers($except = []): array
|
||||
{
|
||||
return array_diff_key($this->app['config']['tenancy.bootstrappers'], $except);
|
||||
return array_diff_key($this->app['config']['tenancy.bootstrappers'], array_flip($except));
|
||||
}
|
||||
|
||||
public function shouldMigrateAfterCreation(): bool
|
||||
|
|
@ -276,7 +276,7 @@ class TenantManager
|
|||
*/
|
||||
protected function event(string $name): array
|
||||
{
|
||||
return array_reduce($this->eventCalbacks[$name] ?? [], function ($prevented, $listener) {
|
||||
return array_reduce($this->eventListeners[$name] ?? [], function ($prevented, $listener) {
|
||||
$prevented = array_merge($prevented, $listener($this) ?? []);
|
||||
|
||||
return $prevented;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue