Hey there,
The test suite passes sometimes but not others. I'm at a loss as to why this occurs randomly.
Using sqlite, :memory: local env.
/** @test
*
* @throws Illuminate\Session\TokenMismatchException
*/
public function registering_with_a_valid_invitation_code()
{
$this->withoutExceptionHandling();
// dd(env('APP_ENV'));
$shelley = factory(User::class)->create([
'firstname' => 'Shelley',
'email' => '[email protected]',
]);
$this->assertEquals(1, User::count());
$invitation = factory(Invitation::class)->create([
'inviter_user_id' => $shelley->id,
'invitation_code' => 'TESTCODE1234',
]);
$this->assertDatabaseHas('users', [
'email' => '[email protected]',
]);
$response = $this->from('/invitations/TESTCODE1234')->post('/invitations/register', [
'firstname' => 'John',
'lastname' => 'Smith',
'email' => '[email protected]',
'password' => 'secretsecret',
'password_confirmation' => 'secretsecret',
'invitation_code' => 'TESTCODE1234',
]);
$response->assertRedirect('/email/verify');
$this->assertEquals(2, User::count());
$inviterShelley = User::first();
$john = User::find(2);
$this->actingAs($john);
$this->assertEquals('[email protected]', $inviterShelley->email);
$this->assertEquals('[email protected]', $john->email);
$this->assertTrue(Hash::check('secretsecret', $john->password));
// dd($invitation);
// dd($invitation->fresh()->invitedUser);
$this->assertTrue($invitation->fresh()->invitedUser->is($john));
$this->assertDatabaseHas('users', [
'email' => '[email protected]',
]);
$this->assertDatabaseHas('invitations', [
'user_id' => $john->id,
]);
}