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

Add TestCase@initTenancy

This commit is contained in:
Samuel Štancl 2019-02-07 22:28:41 +01:00
parent 124e747aa0
commit 3857c4a27d
2 changed files with 9 additions and 4 deletions

View file

@ -12,7 +12,7 @@ class BootstrapsTenancyTest extends TestCase
public function database_connection_is_switched()
{
$old_connection_name = app(\Illuminate\Database\DatabaseManager::class)->connection()->getName();
tenancy()->init('localhost');
$this->initTenancy();
$new_connection_name = app(\Illuminate\Database\DatabaseManager::class)->connection()->getName();
$this->assertNotEquals($old_connection_name, $new_connection_name);
@ -22,7 +22,7 @@ class BootstrapsTenancyTest extends TestCase
/** @test */
public function redis_is_prefixed()
{
tenancy()->init('localhost');
$this->initTenancy();
foreach (config('tenancy.redis.prefixed_connections', ['default']) as $connection) {
$prefix = config('tenancy.redis.prefix_base') . tenant('uuid');
$client = Redis::connection($connection)->client();
@ -34,7 +34,7 @@ class BootstrapsTenancyTest extends TestCase
public function filesystem_is_suffixed()
{
$old_storage_path = storage_path();
tenancy()->init();
$this->initTenancy();
$new_storage_path = storage_path();
$this->assertEquals($old_storage_path . "/" . config('tenancy.filesystem.suffix_base') . tenant('uuid'), $new_storage_path);

View file

@ -16,7 +16,7 @@ class TestCase extends \Orchestra\Testbench\TestCase
protected function setUp()
{
parent::setUp();
Redis::connection('tenancy')->flushdb();
tenant()->create('localhost');
@ -84,4 +84,9 @@ class TestCase extends \Orchestra\Testbench\TestCase
// set one of these environment vars on their computer.
return env('CI') && env('TRAVIS') && env('CONTINUOUS_INTEGRATION');
}
public function initTenancy($domain = 'localhost')
{
tenancy()->init($domain);
}
}