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

Add more tests, fix bugs

This commit is contained in:
Samuel Štancl 2019-02-08 17:54:53 +01:00
parent d14aa0b642
commit 3f650d887d
4 changed files with 65 additions and 8 deletions

View file

@ -0,0 +1,45 @@
<?php
namespace Stancl\Tenancy\Tests;
class ReidentificationTest extends TestCase
{
public $autoInitTenancy = false;
/**
* These tests are run when a tenant is identified after another tenant has already been identified.
*/
/** @test */
public function storage_facade_roots_are_correct()
{
$originals = [];
foreach (config('tenancy.filesystem.disks') as $disk) {
$originals[$disk] = config("filesystems.disks.{$disk}.root");
}
tenancy()->init('localhost');
tenant()->create('second.localhost');
tenancy()->init('second.localhost');
foreach (config('tenancy.filesystem.disks') as $disk) {
$suffix = config('tenancy.filesystem.suffix_base') . tenant('uuid');
$current_path_prefix = \Storage::disk($disk)->getAdapter()->getPathPrefix();
$this->assertSame($originals[$disk] . "/$suffix/", $current_path_prefix);
}
}
/** @test */
public function storage_path_is_correct()
{
$original = storage_path();
tenancy()->init('localhost');
tenant()->create('second.localhost');
tenancy()->init('second.localhost');
$suffix = config('tenancy.filesystem.suffix_base') . tenant('uuid');
$this->assertSame($original . "/$suffix", storage_path());
}
}