Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/UserTest.php
Show All 23 Lines | public function tearDown(): void | ||||
$this->deleteTestUser('UserAccountA@UserAccount.com'); | $this->deleteTestUser('UserAccountA@UserAccount.com'); | ||||
$this->deleteTestUser('UserAccountB@UserAccount.com'); | $this->deleteTestUser('UserAccountB@UserAccount.com'); | ||||
$this->deleteTestUser('userdeletejob@kolabnow.com'); | $this->deleteTestUser('userdeletejob@kolabnow.com'); | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Tests for User::assignPackage() | |||||
*/ | |||||
public function testAssignPackage(): void | |||||
{ | |||||
$this->markTestIncomplete(); | |||||
} | |||||
/** | |||||
* Tests for User::assignPlan() | |||||
*/ | |||||
public function testAssignPlan(): void | |||||
{ | |||||
$this->markTestIncomplete(); | |||||
} | |||||
/** | |||||
* Verify user creation process | * Verify user creation process | ||||
*/ | */ | ||||
public function testUserCreateJob(): void | public function testUserCreateJob(): void | ||||
{ | { | ||||
// Fake the queue, assert that no jobs were pushed... | // Fake the queue, assert that no jobs were pushed... | ||||
Queue::fake(); | Queue::fake(); | ||||
Queue::assertNothingPushed(); | Queue::assertNothingPushed(); | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | public function testListUserAccounts(): void | ||||
function ($wallet) use ($userB) { | function ($wallet) use ($userB) { | ||||
$wallet->addController($userB); | $wallet->addController($userB); | ||||
} | } | ||||
); | ); | ||||
$this->assertTrue($userB->accounts()->get()[0]->id === $userA->wallets()->get()[0]->id); | $this->assertTrue($userB->accounts()->get()[0]->id === $userA->wallets()->get()[0]->id); | ||||
} | } | ||||
public function testUserDomains(): void | /** | ||||
* Tests for User::controller() | |||||
*/ | |||||
public function testController(): void | |||||
{ | |||||
$john = $this->getTestUser('john@kolab.org'); | |||||
$this->assertSame($john->id, $john->controller()->id); | |||||
$jack = $this->getTestUser('jack@kolab.org'); | |||||
$this->assertSame($john->id, $jack->controller()->id); | |||||
} | |||||
/** | |||||
* Tests for User::domains() | |||||
*/ | |||||
public function testDomains(): void | |||||
{ | { | ||||
$user = $this->getTestUser('john@kolab.org'); | $user = $this->getTestUser('john@kolab.org'); | ||||
$domains = []; | $domains = []; | ||||
foreach ($user->domains() as $domain) { | foreach ($user->domains() as $domain) { | ||||
$domains[] = $domain->namespace; | $domains[] = $domain->namespace; | ||||
} | } | ||||
$this->assertContains('kolabnow.com', $domains); | $this->assertContains(\config('app.domain'), $domains); | ||||
$this->assertContains('kolab.org', $domains); | $this->assertContains('kolab.org', $domains); | ||||
// Jack is not the wallet controller, so for him the list should not | |||||
// include John's domains, kolab.org specifically | |||||
$user = $this->getTestUser('jack@kolab.org'); | |||||
$domains = []; | |||||
foreach ($user->domains() as $domain) { | |||||
$domains[] = $domain->namespace; | |||||
} | |||||
$this->assertContains(\config('app.domain'), $domains); | |||||
$this->assertNotContains('kolab.org', $domains); | |||||
} | } | ||||
public function testUserQuota(): void | public function testUserQuota(): void | ||||
{ | { | ||||
$user = $this->getTestUser('john@kolab.org'); | $user = $this->getTestUser('john@kolab.org'); | ||||
$storage_sku = \App\Sku::where('title', 'storage')->first(); | $storage_sku = \App\Sku::where('title', 'storage')->first(); | ||||
$count = 0; | $count = 0; | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | public function testFindByEmail(): void | ||||
$result = User::findByEmail('non-existing@email.com'); | $result = User::findByEmail('non-existing@email.com'); | ||||
$this->assertNull($result); | $this->assertNull($result); | ||||
$result = User::findByEmail('john@kolab.org'); | $result = User::findByEmail('john@kolab.org'); | ||||
$this->assertInstanceOf(User::class, $result); | $this->assertInstanceOf(User::class, $result); | ||||
$this->assertSame($user->id, $result->id); | $this->assertSame($user->id, $result->id); | ||||
// TODO: Make sure searching is case-insensitive | // Use an alias | ||||
// TODO: Alias, eternal email | $result = User::findByEmail('john.doe@kolab.org'); | ||||
$this->assertInstanceOf(User::class, $result); | |||||
$this->assertSame($user->id, $result->id); | |||||
// TODO: searching by external email (setting) | |||||
$this->markTestIncomplete(); | |||||
} | |||||
/** | |||||
* Tests for UserAliasesTrait::setAliases() | |||||
*/ | |||||
public function testSetAliases(): void | |||||
{ | |||||
Queue::fake(); | |||||
$user = $this->getTestUser('UserAccountA@UserAccount.com'); | |||||
$this->assertCount(0, $user->aliases->all()); | |||||
// Add an alias | |||||
$user->setAliases(['UserAlias1@UserAccount.com']); | |||||
$aliases = $user->aliases()->get(); | |||||
$this->assertCount(1, $aliases); | |||||
$this->assertSame('useralias1@useraccount.com', $aliases[0]['alias']); | |||||
// Add another alias | |||||
$user->setAliases(['UserAlias1@UserAccount.com', 'UserAlias2@UserAccount.com']); | |||||
$aliases = $user->aliases()->orderBy('alias')->get(); | |||||
$this->assertCount(2, $aliases); | |||||
$this->assertSame('useralias1@useraccount.com', $aliases[0]->alias); | |||||
$this->assertSame('useralias2@useraccount.com', $aliases[1]->alias); | |||||
vanmeeuwen: This ordering doesn't seem to work, or doesn't seem to work every time.
Would it be better to… | |||||
// Remove an alias | |||||
$user->setAliases(['UserAlias1@UserAccount.com']); | |||||
$aliases = $user->aliases()->get(); | |||||
$this->assertCount(1, $aliases); | |||||
$this->assertSame('useralias1@useraccount.com', $aliases[0]['alias']); | |||||
// Remove all aliases | |||||
$user->setAliases([]); | |||||
$this->assertCount(0, $user->aliases()->get()); | |||||
// TODO: Test that the changes are propagated to ldap | |||||
} | |||||
/** | |||||
* Tests for UserSettingsTrait::setSettings() | |||||
*/ | |||||
public function testSetSettings(): void | |||||
{ | |||||
$this->markTestIncomplete(); | |||||
} | } | ||||
} | } |
This ordering doesn't seem to work, or doesn't seem to work every time.
Would it be better to test useralias1 and useralias2?