1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 04:04:04 +00:00

Rewrite old tests

This commit is contained in:
Samuel Štancl 2020-05-12 23:22:40 +02:00
parent 64383b4c56
commit 89936187ce
71 changed files with 698 additions and 3203 deletions

View file

@ -154,6 +154,12 @@ class BootstrapperTest extends TestCase
FilesystemTenancyBootstrapper::class
]]);
$old_storage_path = storage_path();
$old_storage_facade_roots = [];
foreach (config('tenancy.filesystem.disks') as $disk) {
$old_storage_facade_roots[$disk] = config("filesystems.disks.{$disk}.root");
}
$tenant1 = Tenant::create();
$tenant2 = Tenant::create();
@ -176,6 +182,27 @@ class BootstrapperTest extends TestCase
tenancy()->initialize($tenant3);
$this->assertFalse(Storage::disk('public')->exists('foo'));
$this->assertFalse(Storage::disk('public')->exists('abc'));
// Check suffixing logic
$new_storage_path = storage_path();
$this->assertEquals($old_storage_path . '/' . config('tenancy.filesystem.suffix_base') . tenant('id'), $new_storage_path);
foreach (config('tenancy.filesystem.disks') as $disk) {
$suffix = config('tenancy.filesystem.suffix_base') . tenant('id');
$current_path_prefix = Storage::disk($disk)->getAdapter()->getPathPrefix();
if ($override = config("tenancy.filesystem.root_override.{$disk}")) {
$correct_path_prefix = str_replace('%storage_path%', storage_path(), $override);
} else {
if ($base = $old_storage_facade_roots[$disk]) {
$correct_path_prefix = $base . "/$suffix/";
} else {
$correct_path_prefix = "$suffix/";
}
}
$this->assertSame($correct_path_prefix, $current_path_prefix);
}
}
// for queues see QueueTest