Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/TenantTest.php
Show All 33 Lines | class TenantTest extends TestCase | ||||
*/ | */ | ||||
public function testGetConfig(): void | public function testGetConfig(): void | ||||
{ | { | ||||
// No tenant id specified | // No tenant id specified | ||||
$this->assertSame(\config('app.name'), Tenant::getConfig(null, 'app.name')); | $this->assertSame(\config('app.name'), Tenant::getConfig(null, 'app.name')); | ||||
$this->assertSame(\config('app.env'), Tenant::getConfig(null, 'app.env')); | $this->assertSame(\config('app.env'), Tenant::getConfig(null, 'app.env')); | ||||
$this->assertSame(null, Tenant::getConfig(null, 'app.unknown')); | $this->assertSame(null, Tenant::getConfig(null, 'app.unknown')); | ||||
$tenant = Tenant::whereNotIn('id', [1])->first(); | $tenant = Tenant::whereNotIn('id', [\config('app.tenant_id')])->first(); | ||||
machniak: Same here. We're testing for non-default tenant. | |||||
$tenant->setSetting('app.test', 'test'); | $tenant->setSetting('app.test', 'test'); | ||||
// Tenant specified | // Tenant specified | ||||
$this->assertSame($tenant->title, Tenant::getConfig($tenant->id, 'app.name')); | $this->assertSame($tenant->title, Tenant::getConfig($tenant->id, 'app.name')); | ||||
$this->assertSame('test', Tenant::getConfig($tenant->id, 'app.test')); | $this->assertSame('test', Tenant::getConfig($tenant->id, 'app.test')); | ||||
$this->assertSame(\config('app.env'), Tenant::getConfig($tenant->id, 'app.env')); | $this->assertSame(\config('app.env'), Tenant::getConfig($tenant->id, 'app.env')); | ||||
$this->assertSame(null, Tenant::getConfig($tenant->id, 'app.unknown')); | $this->assertSame(null, Tenant::getConfig($tenant->id, 'app.unknown')); | ||||
} | } | ||||
/** | /** | ||||
* Test Tenant::wallet() method | * Test Tenant::wallet() method | ||||
*/ | */ | ||||
public function testWallet(): void | public function testWallet(): void | ||||
{ | { | ||||
$tenant = Tenant::find(1); | $tenant = Tenant::find(\config('app.tenant_id')); | ||||
$user = \App\User::where('email', 'reseller@' . \config('app.domain'))->first(); | $user = \App\User::where('email', 'reseller@' . \config('app.domain'))->first(); | ||||
$wallet = $tenant->wallet(); | $wallet = $tenant->wallet(); | ||||
$this->assertInstanceof(\App\Wallet::class, $wallet); | $this->assertInstanceof(\App\Wallet::class, $wallet); | ||||
$this->assertSame($user->wallets->first()->id, $wallet->id); | $this->assertSame($user->wallets->first()->id, $wallet->id); | ||||
} | } | ||||
} | } |
Same here. We're testing for non-default tenant.