mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-06 19:24:04 +00:00
Extract cleanup in test file
This commit is contained in:
parent
fa075ef187
commit
c5683d8e00
1 changed files with 14 additions and 25 deletions
|
|
@ -12,13 +12,9 @@ use Stancl\Tenancy\Bootstrappers\LogTenancyBootstrapper;
|
||||||
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
|
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
beforeEach(function () {
|
$cleanup = function () {
|
||||||
config([
|
LogTenancyBootstrapper::$channelOverrides = [];
|
||||||
'tenancy.bootstrappers' => [
|
LogTenancyBootstrapper::$storagePathChannels = ['single', 'daily'];
|
||||||
// FilesystemTenancyBootstrapper needed for LogTenancyBootstrapper to work with storage path channels BY DEFAULT (note that this can be completely overridden)
|
|
||||||
LogTenancyBootstrapper::class,
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$logFiles = array_merge(
|
$logFiles = array_merge(
|
||||||
glob(storage_path('logs/*.log')) ?: [],
|
glob(storage_path('logs/*.log')) ?: [],
|
||||||
|
|
@ -30,30 +26,23 @@ beforeEach(function () {
|
||||||
foreach ($logFiles as $path) {
|
foreach ($logFiles as $path) {
|
||||||
@unlink($path);
|
@unlink($path);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Reset static properties
|
beforeEach(function () use ($cleanup) {
|
||||||
LogTenancyBootstrapper::$channelOverrides = [];
|
config([
|
||||||
LogTenancyBootstrapper::$storagePathChannels = ['single', 'daily'];
|
'tenancy.bootstrappers' => [
|
||||||
|
// FilesystemTenancyBootstrapper needed for LogTenancyBootstrapper to work with storage path channels BY DEFAULT
|
||||||
|
LogTenancyBootstrapper::class,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$cleanup();
|
||||||
|
|
||||||
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
|
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
|
||||||
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
|
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach($cleanup);
|
||||||
LogTenancyBootstrapper::$channelOverrides = [];
|
|
||||||
LogTenancyBootstrapper::$storagePathChannels = ['single', 'daily'];
|
|
||||||
|
|
||||||
$logFiles = array_merge(
|
|
||||||
glob(storage_path('logs/*.log')) ?: [],
|
|
||||||
glob(storage_path('logs/*/*.log')) ?: [],
|
|
||||||
glob(storage_path('tenant*/logs/*.log')) ?: [],
|
|
||||||
glob(storage_path('tenant*/logs/*/*.log')) ?: []
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($logFiles as $path) {
|
|
||||||
@unlink($path);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test('storage path channels get tenant-specific paths by default', function () {
|
test('storage path channels get tenant-specific paths by default', function () {
|
||||||
// Note that for LogTenancyBootstrapper to change the paths correctly by default,
|
// Note that for LogTenancyBootstrapper to change the paths correctly by default,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue