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

Tenant-specific connections, some work to get tests running

This commit is contained in:
Samuel Štancl 2019-09-15 17:44:26 +02:00
parent e25a01a997
commit c65b6839ff
13 changed files with 162 additions and 67 deletions

View file

@ -5,8 +5,9 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Tests;
use Illuminate\Support\Facades\Redis;
use Stancl\Tenancy\StorageDrivers\DatabaseStorageDriver;
use Stancl\Tenancy\StorageDrivers\Database\DatabaseStorageDriver;
use Stancl\Tenancy\StorageDrivers\RedisStorageDriver;
use Stancl\Tenancy\Tenant;
abstract class TestCase extends \Orchestra\Testbench\TestCase
{
@ -40,19 +41,12 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
}
}
protected function tearDown(): void
public function createTenant($domains = ['test.localhost'])
{
// config(['database.default' => 'central']);
parent::tearDown();
Tenant::new()->withDomains($domains)->save();
}
public function createTenant($domain = 'localhost')
{
tenant()->create($domain);
}
public function initTenancy($domain = 'localhost')
public function initTenancy($domain = 'test.localhost')
{
return tenancy()->init($domain);
}
@ -112,13 +106,13 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
'tenancy.storage_driver' => RedisStorageDriver::class,
]);
tenancy()->storage = $app->make(RedisStorageDriver::class);
// tenancy()->storage = $app->make(RedisStorageDriver::class); // todo this shouldn't be necessary
} elseif (env('TENANCY_TEST_STORAGE_DRIVER', 'redis') === 'db') {
$app['config']->set([
'tenancy.storage_driver' => DatabaseStorageDriver::class,
]);
tenancy()->storage = $app->make(DatabaseStorageDriver::class);
// tenancy()->storage = $app->make(DatabaseStorageDriver::class); // todo this shouldn't be necessary
}
}