mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 20:34:03 +00:00
singleton regis in TestCase
This commit is contained in:
parent
fafe7cf278
commit
48ed21313c
2 changed files with 17 additions and 11 deletions
|
|
@ -11,8 +11,6 @@ use Stancl\Tenancy\Listeners\RevertToCentralContext;
|
||||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$this->app->singleton(BatchTenancyBootstrapper::class);
|
|
||||||
|
|
||||||
config([
|
config([
|
||||||
'tenancy.bootstrappers' => [
|
'tenancy.bootstrappers' => [
|
||||||
DatabaseTenancyBootstrapper::class,
|
DatabaseTenancyBootstrapper::class,
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,15 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Tests;
|
namespace Stancl\Tenancy\Tests;
|
||||||
|
|
||||||
|
use Dotenv\Dotenv;
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Support\Facades\Redis;
|
use Illuminate\Support\Facades\Redis;
|
||||||
use PDO;
|
use PDO;
|
||||||
|
use Stancl\Tenancy\Bootstrappers\BatchTenancyBootstrapper;
|
||||||
|
use Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper;
|
||||||
|
use Stancl\Tenancy\Facades\GlobalCache;
|
||||||
|
use Stancl\Tenancy\Facades\Tenancy;
|
||||||
|
use Stancl\Tenancy\TenancyServiceProvider;
|
||||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||||
|
|
||||||
abstract class TestCase extends \Orchestra\Testbench\TestCase
|
abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
|
|
@ -42,13 +49,13 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
/**
|
/**
|
||||||
* Define environment setup.
|
* Define environment setup.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Foundation\Application $app
|
* @param Application $app
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function getEnvironmentSetUp($app)
|
protected function getEnvironmentSetUp($app)
|
||||||
{
|
{
|
||||||
if (file_exists(__DIR__ . '/../.env')) {
|
if (file_exists(__DIR__ . '/../.env')) {
|
||||||
\Dotenv\Dotenv::createImmutable(__DIR__ . '/..')->load();
|
Dotenv::createImmutable(__DIR__ . '/..')->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
$app['config']->set([
|
$app['config']->set([
|
||||||
|
|
@ -96,7 +103,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
'--realpath' => true,
|
'--realpath' => true,
|
||||||
'--force' => true,
|
'--force' => true,
|
||||||
],
|
],
|
||||||
'tenancy.bootstrappers.redis' => \Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper::class,
|
'tenancy.bootstrappers.redis' => RedisTenancyBootstrapper::class,
|
||||||
'queue.connections.central' => [
|
'queue.connections.central' => [
|
||||||
'driver' => 'sync',
|
'driver' => 'sync',
|
||||||
'central' => true,
|
'central' => true,
|
||||||
|
|
@ -105,28 +112,29 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
'tenancy.tenant_model' => Tenant::class, // Use test tenant w/ DBs & domains
|
'tenancy.tenant_model' => Tenant::class, // Use test tenant w/ DBs & domains
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$app->singleton(\Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper::class);
|
$app->singleton(RedisTenancyBootstrapper::class);
|
||||||
|
$app->singleton(BatchTenancyBootstrapper::class); // todo (Samuel) use proper approach eg config for singleton registration
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getPackageProviders($app)
|
protected function getPackageProviders($app)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
\Stancl\Tenancy\TenancyServiceProvider::class,
|
TenancyServiceProvider::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getPackageAliases($app)
|
protected function getPackageAliases($app)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'Tenancy' => \Stancl\Tenancy\Facades\Tenancy::class,
|
'Tenancy' => Tenancy::class,
|
||||||
'GlobalCache' => \Stancl\Tenancy\Facades\GlobalCache::class,
|
'GlobalCache' => GlobalCache::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve application HTTP Kernel implementation.
|
* Resolve application HTTP Kernel implementation.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Foundation\Application $app
|
* @param Application $app
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function resolveApplicationHttpKernel($app)
|
protected function resolveApplicationHttpKernel($app)
|
||||||
|
|
@ -137,7 +145,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
/**
|
/**
|
||||||
* Resolve application Console Kernel implementation.
|
* Resolve application Console Kernel implementation.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Foundation\Application $app
|
* @param Application $app
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function resolveApplicationConsoleKernel($app)
|
protected function resolveApplicationConsoleKernel($app)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue