Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/UserTest.php
Show First 20 Lines • Show All 328 Lines • ▼ Show 20 Line(s) | |||||
{ | { | ||||
$user = $this->getTestUser('john@kolab.org'); | $user = $this->getTestUser('john@kolab.org'); | ||||
$domain = $this->getTestDomain('useraccount.com', [ | $domain = $this->getTestDomain('useraccount.com', [ | ||||
'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE, | 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE, | ||||
'type' => Domain::TYPE_PUBLIC, | 'type' => Domain::TYPE_PUBLIC, | ||||
]); | ]); | ||||
$domains = collect($user->domains())->pluck('namespace')->all(); | $domains = $user->domains()->pluck('namespace')->all(); | ||||
$this->assertContains($domain->namespace, $domains); | $this->assertContains($domain->namespace, $domains); | ||||
$this->assertContains('kolab.org', $domains); | $this->assertContains('kolab.org', $domains); | ||||
// Jack is not the wallet controller, so for him the list should not | // Jack is not the wallet controller, so for him the list should not | ||||
// include John's domains, kolab.org specifically | // include John's domains, kolab.org specifically | ||||
$user = $this->getTestUser('jack@kolab.org'); | $user = $this->getTestUser('jack@kolab.org'); | ||||
$domains = collect($user->domains())->pluck('namespace')->all(); | $domains = $user->domains()->pluck('namespace')->all(); | ||||
$this->assertContains($domain->namespace, $domains); | $this->assertContains($domain->namespace, $domains); | ||||
$this->assertNotContains('kolab.org', $domains); | $this->assertNotContains('kolab.org', $domains); | ||||
// Public domains of other tenants should not be returned | // Public domains of other tenants should not be returned | ||||
$tenant = \App\Tenant::where('id', '!=', \config('app.tenant_id'))->first(); | $tenant = \App\Tenant::where('id', '!=', \config('app.tenant_id'))->first(); | ||||
$domain->tenant_id = $tenant->id; | $domain->tenant_id = $tenant->id; | ||||
$domain->save(); | $domain->save(); | ||||
$domains = collect($user->domains())->pluck('namespace')->all(); | $domains = $user->domains()->pluck('namespace')->all(); | ||||
$this->assertNotContains($domain->namespace, $domains); | $this->assertNotContains($domain->namespace, $domains); | ||||
} | } | ||||
/** | /** | ||||
* Test User::getConfig() and setConfig() methods | * Test User::getConfig() and setConfig() methods | ||||
*/ | */ | ||||
public function testConfigTrait(): void | public function testConfigTrait(): void | ||||
▲ Show 20 Lines • Show All 693 Lines • ▼ Show 20 Line(s) | |||||
$users = $john->users()->orderBy('email')->get(); | $users = $john->users()->orderBy('email')->get(); | ||||
$this->assertCount(4, $users); | $this->assertCount(4, $users); | ||||
$this->assertEquals($jack->id, $users[0]->id); | $this->assertEquals($jack->id, $users[0]->id); | ||||
$this->assertEquals($joe->id, $users[1]->id); | $this->assertEquals($joe->id, $users[1]->id); | ||||
$this->assertEquals($john->id, $users[2]->id); | $this->assertEquals($john->id, $users[2]->id); | ||||
$this->assertEquals($ned->id, $users[3]->id); | $this->assertEquals($ned->id, $users[3]->id); | ||||
$this->assertSame($wallet->id, $users[0]->wallet_id); | |||||
$this->assertSame($wallet->id, $users[1]->wallet_id); | |||||
$this->assertSame($wallet->id, $users[2]->wallet_id); | |||||
$this->assertSame($wallet->id, $users[3]->wallet_id); | |||||
$users = $jack->users()->orderBy('email')->get(); | $users = $jack->users()->orderBy('email')->get(); | ||||
$this->assertCount(0, $users); | $this->assertCount(0, $users); | ||||
$users = $ned->users()->orderBy('email')->get(); | $users = $ned->users()->orderBy('email')->get(); | ||||
$this->assertCount(4, $users); | $this->assertCount(4, $users); | ||||
} | } | ||||
public function testWallets(): void | public function testWallets(): void | ||||
{ | { | ||||
$this->markTestIncomplete(); | $this->markTestIncomplete(); | ||||
} | } | ||||
} | } |