1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 09:54:05 +00:00

wip: add persistent queue bootstrapper, minor testcase refactor

This commit is contained in:
Samuel Štancl 2025-01-09 16:39:54 +01:00
parent 78698b0119
commit 279909f855
5 changed files with 222 additions and 33 deletions

View file

@ -22,6 +22,7 @@ use Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper;
use Stancl\Tenancy\Bootstrappers\UrlGeneratorBootstrapper;
use Stancl\Tenancy\Bootstrappers\BroadcastingConfigBootstrapper;
use Stancl\Tenancy\Bootstrappers\BroadcastChannelPrefixBootstrapper;
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
abstract class TestCase extends \Orchestra\Testbench\TestCase
{
@ -85,11 +86,8 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
'--realpath' => true,
]);
// Laravel 6.x support todo@refactor clean up
$testResponse = class_exists('Illuminate\Testing\TestResponse') ? 'Illuminate\Testing\TestResponse' : 'Illuminate\Foundation\Testing\TestResponse';
$testResponse::macro('assertContent', function ($content) {
$assertClass = class_exists('Illuminate\Testing\Assert') ? 'Illuminate\Testing\Assert' : 'Illuminate\Foundation\Testing\Assert';
$assertClass::assertSame($content, $this->baseResponse->getContent());
\Illuminate\Testing\TestResponse::macro('assertContent', function ($content) {
\Illuminate\Testing\Assert::assertSame($content, $this->baseResponse->getContent());
return $this;
});
@ -175,18 +173,25 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
'tenancy.models.tenant' => Tenant::class, // Use test tenant w/ DBs & domains
]);
$app->singleton(RedisTenancyBootstrapper::class); // todo@samuel use proper approach eg config for singleton registration
$app->singleton(CacheTenancyBootstrapper::class); // todo@samuel use proper approach eg config for singleton registration
// Since we run the TSP with no bootstrappers enabled, we need
// to manually register bootstrappers as singletons here.
$app->singleton(RedisTenancyBootstrapper::class);
$app->singleton(CacheTenancyBootstrapper::class);
$app->singleton(BroadcastingConfigBootstrapper::class);
$app->singleton(BroadcastChannelPrefixBootstrapper::class);
$app->singleton(PostgresRLSBootstrapper::class);
$app->singleton(MailConfigBootstrapper::class);
$app->singleton(RootUrlBootstrapper::class);
$app->singleton(UrlGeneratorBootstrapper::class);
$app->singleton(FilesystemTenancyBootstrapper::class);
}
protected function getPackageProviders($app)
{
TenancyServiceProvider::$configure = function () {
config(['tenancy.bootstrappers' => []]);
};
return [
TenancyServiceProvider::class,
];