Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/UserTest.php
Show First 20 Lines • Show All 253 Lines • ▼ Show 20 Lines | public function testDelete(): void | ||||
$this->assertTrue($userB->fresh()->trashed()); | $this->assertTrue($userB->fresh()->trashed()); | ||||
$this->assertTrue($domain->fresh()->trashed()); | $this->assertTrue($domain->fresh()->trashed()); | ||||
$this->assertFalse($userA->isDeleted()); | $this->assertFalse($userA->isDeleted()); | ||||
$this->assertFalse($userB->isDeleted()); | $this->assertFalse($userB->isDeleted()); | ||||
$this->assertFalse($domain->isDeleted()); | $this->assertFalse($domain->isDeleted()); | ||||
} | } | ||||
/** | /** | ||||
* Tests for User::emailExists() | |||||
*/ | |||||
public function testEmailExists(): void | |||||
{ | |||||
$this->markTestIncomplete(); | |||||
} | |||||
/** | |||||
* Tests for User::findByEmail() | * Tests for User::findByEmail() | ||||
*/ | */ | ||||
public function testFindByEmail(): void | public function testFindByEmail(): void | ||||
{ | { | ||||
$user = $this->getTestUser('john@kolab.org'); | $user = $this->getTestUser('john@kolab.org'); | ||||
$result = User::findByEmail('john'); | $result = User::findByEmail('john'); | ||||
$this->assertNull($result); | $this->assertNull($result); | ||||
$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); | ||||
// Use an alias | // Use an alias | ||||
$result = User::findByEmail('john.doe@kolab.org'); | $result = User::findByEmail('john.doe@kolab.org'); | ||||
$this->assertInstanceOf(User::class, $result); | $this->assertInstanceOf(User::class, $result); | ||||
$this->assertSame($user->id, $result->id); | $this->assertSame($user->id, $result->id); | ||||
// A case where two users have the same alias | |||||
$ned = $this->getTestUser('ned@kolab.org'); | |||||
$ned->setAliases(['joe.monster@kolabnow.com']); | |||||
$result = User::findByEmail('joe.monster@kolabnow.com'); | |||||
$this->assertNull($result); | |||||
$ned->setAliases([]); | |||||
// TODO: searching by external email (setting) | // TODO: searching by external email (setting) | ||||
$this->markTestIncomplete(); | $this->markTestIncomplete(); | ||||
} | } | ||||
/** | /** | ||||
* Test User::name() | * Test User::name() | ||||
*/ | */ | ||||
public function testName(): void | public function testName(): void | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | public function testSetAliases(): void | ||||
$this->assertSame('useralias1@useraccount.com', $aliases[0]['alias']); | $this->assertSame('useralias1@useraccount.com', $aliases[0]['alias']); | ||||
// Remove all aliases | // Remove all aliases | ||||
$user->setAliases([]); | $user->setAliases([]); | ||||
Queue::assertPushed(\App\Jobs\UserUpdate::class, 4); | Queue::assertPushed(\App\Jobs\UserUpdate::class, 4); | ||||
$this->assertCount(0, $user->aliases()->get()); | $this->assertCount(0, $user->aliases()->get()); | ||||
// Test sanity checks in UserAliasObserver | |||||
Queue::fake(); | |||||
// Existing user | |||||
$user->setAliases(['john@kolab.org']); | |||||
$this->assertCount(0, $user->aliases()->get()); | |||||
// Existing alias (in another account) | |||||
$user->setAliases(['john.doe@kolab.org']); | |||||
$this->assertCount(0, $user->aliases()->get()); | |||||
Queue::assertNothingPushed(); | |||||
// Existing user (in the same group account) | |||||
$ned = $this->getTestUser('ned@kolab.org'); | |||||
$ned->setAliases(['john@kolab.org']); | |||||
$this->assertCount(0, $ned->aliases()->get()); | |||||
// Existing alias (in the same group account) | |||||
$ned = $this->getTestUser('ned@kolab.org'); | |||||
$ned->setAliases(['john.doe@kolab.org']); | |||||
$this->assertSame('john.doe@kolab.org', $ned->aliases()->first()->alias); | |||||
// cleanup | |||||
$ned->setAliases([]); | |||||
} | } | ||||
/** | /** | ||||
* Tests for UserSettingsTrait::setSettings() and getSetting() | * Tests for UserSettingsTrait::setSettings() and getSetting() | ||||
*/ | */ | ||||
public function testUserSettings(): void | public function testUserSettings(): void | ||||
{ | { | ||||
Queue::fake(); | Queue::fake(); | ||||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |