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

Fix db_name_is_prefixed test

This commit is contained in:
Samuel Štancl 2019-09-21 19:37:19 +02:00
parent a4ab7ac080
commit 8dae2dcc6f
3 changed files with 9 additions and 3 deletions

View file

@ -71,7 +71,7 @@ return [
// Their responsibility is making Laravel features tenant-aware. // Their responsibility is making Laravel features tenant-aware.
'database' => 'Stancl\Tenancy\TenancyBootstrappers\DatabaseTenancyBootstrapper', 'database' => 'Stancl\Tenancy\TenancyBootstrappers\DatabaseTenancyBootstrapper',
'cache' => 'Stancl\Tenancy\TenancyBootstrappers\CacheTenancyBootstrapper', 'cache' => 'Stancl\Tenancy\TenancyBootstrappers\CacheTenancyBootstrapper',
// 'filesystem' => 'Stancl\Tenancy\TenancyBootstrappers\FilesystemTenancyBootstrapper', 'filesystem' => 'Stancl\Tenancy\TenancyBootstrappers\FilesystemTenancyBootstrapper',
'redis' => 'Stancl\Tenancy\TenancyBootstrappers\RedisTenancyBootstrapper', 'redis' => 'Stancl\Tenancy\TenancyBootstrappers\RedisTenancyBootstrapper',
'queue' => 'Stancl\Tenancy\TenancyBootstrappers\QueueTenancyBootstrapper', 'queue' => 'Stancl\Tenancy\TenancyBootstrappers\QueueTenancyBootstrapper',
], ],

View file

@ -25,8 +25,7 @@ class DatabaseManagerTest extends TestCase
/** @test */ /** @test */
public function db_name_is_prefixed_with_db_path_when_sqlite_is_used() public function db_name_is_prefixed_with_db_path_when_sqlite_is_used()
{ {
// make `tenant` not sqlite so that it has to detect sqlite from fooconn config(['database.connections.fooconn.driver' => 'sqlite']);
config(['database.connections.tenant.driver' => 'mysql']);
app(DatabaseManager::class)->createTenantConnection('foodb', 'fooconn'); app(DatabaseManager::class)->createTenantConnection('foodb', 'fooconn');
$this->assertSame(config('database.connections.fooconn.database'), database_path('foodb')); $this->assertSame(config('database.connections.fooconn.database'), database_path('foodb'));

View file

@ -5,9 +5,13 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Tests; namespace Stancl\Tenancy\Tests;
use Route; use Route;
use Stancl\Tenancy\Tenant;
class TenantRedirectMacroTest extends TestCase class TenantRedirectMacroTest extends TestCase
{ {
public $autoCreateTenant = false;
public $autoInitTenancy = false;
/** @test */ /** @test */
public function tenant_redirect_macro_replaces_only_the_hostname() public function tenant_redirect_macro_replaces_only_the_hostname()
{ {
@ -19,6 +23,9 @@ class TenantRedirectMacroTest extends TestCase
return redirect()->route('home')->tenant('abcd'); return redirect()->route('home')->tenant('abcd');
}); });
Tenant::create('foo.localhost');
tenancy()->init('foo.localhost');
$this->get('/redirect') $this->get('/redirect')
->assertRedirect('http://abcd/foobar'); ->assertRedirect('http://abcd/foobar');
} }