Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/UserTest.php
Show First 20 Lines • Show All 573 Lines • ▼ Show 20 Lines | public function testDeleteWithPositiveBalance(): void | ||||
$reseller_wallet->save(); | $reseller_wallet->save(); | ||||
$user->delete(); | $user->delete(); | ||||
$this->assertSame(0, $reseller_wallet->fresh()->balance); | $this->assertSame(0, $reseller_wallet->fresh()->balance); | ||||
} | } | ||||
/** | /** | ||||
* Test user deletion with PGP/WOAT enabled | |||||
*/ | |||||
public function testDeleteWithPGP(): void | |||||
{ | |||||
Queue::fake(); | |||||
// Test with PGP disabled | |||||
$user = $this->getTestUser('user-test@' . \config('app.domain')); | |||||
$user->tenant->setSetting('pgp.enable', 0); | |||||
$user->delete(); | |||||
Queue::assertPushed(\App\Jobs\PGP\KeyDeleteJob::class, 0); | |||||
// Test with PGP enabled | |||||
$this->deleteTestUser('user-test@' . \config('app.domain')); | |||||
$user = $this->getTestUser('user-test@' . \config('app.domain')); | |||||
$user->tenant->setSetting('pgp.enable', 1); | |||||
$user->delete(); | |||||
$user->tenant->setSetting('pgp.enable', 0); | |||||
Queue::assertPushed(\App\Jobs\PGP\KeyDeleteJob::class, 1); | |||||
Queue::assertPushed( | |||||
\App\Jobs\PGP\KeyDeleteJob::class, | |||||
function ($job) use ($user) { | |||||
$userId = TestCase::getObjectProperty($job, 'userId'); | |||||
$userEmail = TestCase::getObjectProperty($job, 'userEmail'); | |||||
return $userId == $user->id && $userEmail === $user->email; | |||||
} | |||||
); | |||||
} | |||||
/** | |||||
* Tests for User::aliasExists() | * Tests for User::aliasExists() | ||||
*/ | */ | ||||
public function testAliasExists(): void | public function testAliasExists(): void | ||||
{ | { | ||||
$this->assertTrue(User::aliasExists('jack.daniels@kolab.org')); | $this->assertTrue(User::aliasExists('jack.daniels@kolab.org')); | ||||
$this->assertFalse(User::aliasExists('j.daniels@kolab.org')); | $this->assertFalse(User::aliasExists('j.daniels@kolab.org')); | ||||
$this->assertFalse(User::aliasExists('john@kolab.org')); | $this->assertFalse(User::aliasExists('john@kolab.org')); | ||||
▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | public function testSetAliases(): void | ||||
$user->tenant->setSetting('pgp.enable', 1); | $user->tenant->setSetting('pgp.enable', 1); | ||||
// Remove an alias | // Remove an alias | ||||
$user->setAliases(['UserAlias1@UserAccount.com']); | $user->setAliases(['UserAlias1@UserAccount.com']); | ||||
$user->tenant->setSetting('pgp.enable', 0); | $user->tenant->setSetting('pgp.enable', 0); | ||||
Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 3); | Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 3); | ||||
Queue::assertPushed(\App\Jobs\PGP\KeyUnregisterJob::class, 1); | Queue::assertPushed(\App\Jobs\PGP\KeyDeleteJob::class, 1); | ||||
Queue::assertPushed( | |||||
\App\Jobs\PGP\KeyDeleteJob::class, | |||||
function ($job) use ($user) { | |||||
$userId = TestCase::getObjectProperty($job, 'userId'); | |||||
$userEmail = TestCase::getObjectProperty($job, 'userEmail'); | |||||
return $userId == $user->id && $userEmail === 'useralias2@useraccount.com'; | |||||
} | |||||
); | |||||
$aliases = $user->aliases()->get(); | $aliases = $user->aliases()->get(); | ||||
$this->assertCount(1, $aliases); | $this->assertCount(1, $aliases); | ||||
$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([]); | ||||
▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines |