Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/UserTest.php
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | public function testCreate(): void | ||||
$this->assertSame(User::STATUS_NEW | User::STATUS_ACTIVE, $result->status); | $this->assertSame(User::STATUS_NEW | User::STATUS_ACTIVE, $result->status); | ||||
} | } | ||||
/** | /** | ||||
* Verify user creation process | * Verify user creation process | ||||
*/ | */ | ||||
public function testCreateJobs(): void | public function testCreateJobs(): void | ||||
{ | { | ||||
// Fake the queue, assert that no jobs were pushed... | |||||
Queue::fake(); | Queue::fake(); | ||||
Queue::assertNothingPushed(); | |||||
$user = User::create([ | $user = User::create([ | ||||
'email' => 'user-test@' . \config('app.domain') | 'email' => 'user-test@' . \config('app.domain') | ||||
]); | ]); | ||||
Queue::assertPushed(\App\Jobs\User\CreateJob::class, 1); | Queue::assertPushed(\App\Jobs\User\CreateJob::class, 1); | ||||
Queue::assertPushed(\App\Jobs\PGP\KeyCreateJob::class, 0); | |||||
Queue::assertPushed( | Queue::assertPushed( | ||||
\App\Jobs\User\CreateJob::class, | \App\Jobs\User\CreateJob::class, | ||||
function ($job) use ($user) { | function ($job) use ($user) { | ||||
$userEmail = TestCase::getObjectProperty($job, 'userEmail'); | $userEmail = TestCase::getObjectProperty($job, 'userEmail'); | ||||
$userId = TestCase::getObjectProperty($job, 'userId'); | $userId = TestCase::getObjectProperty($job, 'userId'); | ||||
return $userEmail === $user->email | return $userEmail === $user->email | ||||
Show All 20 Lines | /* | ||||
return $userEmail === $user->email | return $userEmail === $user->email | ||||
&& $userId === $user->id; | && $userId === $user->id; | ||||
}); | }); | ||||
*/ | */ | ||||
} | } | ||||
/** | /** | ||||
* Verify user creation process invokes the PGP keys creation job (if configured) | |||||
*/ | |||||
public function testCreatePGPJob(): void | |||||
{ | |||||
Queue::fake(); | |||||
\config(['pgp.enable' => true]); | |||||
$user = User::create([ | |||||
'email' => 'user-test@' . \config('app.domain') | |||||
]); | |||||
Queue::assertPushed(\App\Jobs\PGP\KeyCreateJob::class, 1); | |||||
Queue::assertPushed( | |||||
\App\Jobs\PGP\KeyCreateJob::class, | |||||
function ($job) use ($user) { | |||||
$userEmail = TestCase::getObjectProperty($job, 'userEmail'); | |||||
$userId = TestCase::getObjectProperty($job, 'userId'); | |||||
return $userEmail === $user->email | |||||
&& $userId === $user->id; | |||||
} | |||||
); | |||||
\config(['pgp.enable' => false]); | |||||
} | |||||
/** | |||||
* Tests for User::domains() | * Tests for User::domains() | ||||
*/ | */ | ||||
public function testDomains(): void | 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) { | ||||
▲ Show 20 Lines • Show All 531 Lines • Show Last 20 Lines |