Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/SignupTest.php
Show First 20 Lines • Show All 475 Lines • ▼ Show 20 Lines | public function testSignupValidInput(array $result) | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$this->assertSame('success', $json['status']); | $this->assertSame('success', $json['status']); | ||||
$this->assertSame('bearer', $json['token_type']); | $this->assertSame('bearer', $json['token_type']); | ||||
$this->assertTrue(!empty($json['expires_in']) && is_int($json['expires_in']) && $json['expires_in'] > 0); | $this->assertTrue(!empty($json['expires_in']) && is_int($json['expires_in']) && $json['expires_in'] > 0); | ||||
$this->assertNotEmpty($json['access_token']); | $this->assertNotEmpty($json['access_token']); | ||||
$this->assertSame($identity, $json['email']); | $this->assertSame($identity, $json['email']); | ||||
Queue::assertPushed(\App\Jobs\UserCreate::class, 1); | Queue::assertPushed(\App\Jobs\User\CreateJob::class, 1); | ||||
Queue::assertPushed(\App\Jobs\UserCreate::class, function ($job) use ($data) { | |||||
$job_user = TestCase::getObjectProperty($job, 'user'); | |||||
return $job_user->email === \strtolower($data['login'] . '@' . $data['domain']); | Queue::assertPushed( | ||||
}); | \App\Jobs\User\CreateJob::class, | ||||
function ($job) use ($data) { | |||||
$userEmail = TestCase::getObjectProperty($job, 'userEmail'); | |||||
return $userEmail === \strtolower($data['login'] . '@' . $data['domain']); | |||||
} | |||||
); | |||||
// Check if the code has been removed | // Check if the code has been removed | ||||
$this->assertNull(SignupCode::where('code', $result['code'])->first()); | $this->assertNull(SignupCode::where('code', $result['code'])->first()); | ||||
// Check if the user has been created | // Check if the user has been created | ||||
$user = User::where('email', $identity)->first(); | $user = User::where('email', $identity)->first(); | ||||
$this->assertNotEmpty($user); | $this->assertNotEmpty($user); | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | public function testSignupGroupAccount() | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$this->assertSame('success', $result['status']); | $this->assertSame('success', $result['status']); | ||||
$this->assertSame('bearer', $result['token_type']); | $this->assertSame('bearer', $result['token_type']); | ||||
$this->assertTrue(!empty($result['expires_in']) && is_int($result['expires_in']) && $result['expires_in'] > 0); | $this->assertTrue(!empty($result['expires_in']) && is_int($result['expires_in']) && $result['expires_in'] > 0); | ||||
$this->assertNotEmpty($result['access_token']); | $this->assertNotEmpty($result['access_token']); | ||||
$this->assertSame("$login@$domain", $result['email']); | $this->assertSame("$login@$domain", $result['email']); | ||||
Queue::assertPushed(\App\Jobs\DomainCreate::class, 1); | Queue::assertPushed(\App\Jobs\Domain\CreateJob::class, 1); | ||||
Queue::assertPushed(\App\Jobs\DomainCreate::class, function ($job) use ($domain) { | |||||
$job_domain = TestCase::getObjectProperty($job, 'domain'); | |||||
return $job_domain->namespace === $domain; | Queue::assertPushed( | ||||
}); | \App\Jobs\Domain\CreateJob::class, | ||||
function ($job) use ($domain) { | |||||
$domainNamespace = TestCase::getObjectProperty($job, 'domainNamespace'); | |||||
return $domainNamespace === $domain; | |||||
} | |||||
); | |||||
Queue::assertPushed(\App\Jobs\UserCreate::class, 1); | Queue::assertPushed(\App\Jobs\User\CreateJob::class, 1); | ||||
Queue::assertPushed(\App\Jobs\UserCreate::class, function ($job) use ($data) { | |||||
$job_user = TestCase::getObjectProperty($job, 'user'); | |||||
return $job_user->email === $data['login'] . '@' . $data['domain']; | Queue::assertPushed( | ||||
}); | \App\Jobs\User\CreateJob::class, | ||||
function ($job) use ($data) { | |||||
$userEmail = TestCase::getObjectProperty($job, 'userEmail'); | |||||
return $userEmail === $data['login'] . '@' . $data['domain']; | |||||
} | |||||
); | |||||
// Check if the code has been removed | // Check if the code has been removed | ||||
$this->assertNull(SignupCode::find($code->id)); | $this->assertNull(SignupCode::find($code->id)); | ||||
// Check if the user has been created | // Check if the user has been created | ||||
$user = User::where('email', $login . '@' . $domain)->first(); | $user = User::where('email', $login . '@' . $domain)->first(); | ||||
$this->assertNotEmpty($user); | $this->assertNotEmpty($user); | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |