mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-16 19:53:52 +00:00
150 - Registering with a Valid Invitation
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Tests\Feature;
|
||||
use App\User;
|
||||
use App\Invitation;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
@@ -49,4 +50,30 @@ class AcceptInvitationTest extends TestCase
|
||||
|
||||
$response->assertStatus(404);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function registering_with_a_valid_invitation_code()
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
|
||||
$invitation = factory(Invitation::class)->create([
|
||||
'user_id' => null,
|
||||
'code' => 'TESTCODE1234',
|
||||
]);
|
||||
|
||||
$response = $this->post('/register', [
|
||||
'email' => 'john@example.com',
|
||||
'password' => 'secret',
|
||||
'invitation_code' => 'TESTCODE1234',
|
||||
]);
|
||||
|
||||
$response->assertRedirect('/backstage/concerts');
|
||||
|
||||
$this->assertEquals(1, User::count());
|
||||
$user = User::first();
|
||||
$this->assertAuthenticatedAs($user);
|
||||
$this->assertEquals('john@example.com', $user->email);
|
||||
$this->assertTrue(Hash::check('secret', $user->password));
|
||||
$this->assertTrue($invitation->fresh()->user->is($user));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user