Commit a9d8b9dc authored by Viral Solani's avatar Viral Solani

Registration Test

parent c90fdf22
......@@ -88,6 +88,7 @@ class UserRepository extends BaseRepository
*/
public function create(array $data, $provider = false)
{
$user = self::MODEL;
$user = new $user();
$user->first_name = $data['first_name'];
......@@ -117,6 +118,7 @@ class UserRepository extends BaseRepository
DB::transaction(function () use ($user) {
if ($user->save()) {
/*
* Add the default site role to the new user
*/
......
......@@ -115,6 +115,7 @@ return [
'already_confirmed' => 'Your account is already confirmed.',
'confirm' => 'Confirm your account!',
'created_confirm' => 'Your account was successfully created. We have sent you an e-mail to confirm your account.',
'created_pending' => 'Your account was successfully created and is pending approval. An e-mail will be sent when your account is approved.',
'mismatch' => 'Your confirmation code does not match.',
'not_found' => 'That confirmation code does not exist.',
'resend' => 'Your account is not confirmed. Please click the confirmation link in your e-mail, or <a href='.route('frontend.auth.account.confirm.resend', ':user_id').'>click here</a> to resend the confirmation e-mail.',
......
......@@ -2,9 +2,12 @@
namespace Tests\Feature;
use App\Events\Frontend\Auth\UserRegistered;
use Illuminate\Support\Facades\Event;
use Tests\BrowserKitTestCase;
use App\Models\Access\User\User;
use Illuminate\Support\Facades\Event;
use App\Events\Frontend\Auth\UserRegistered;
use Illuminate\Support\Facades\Notification;
use App\Notifications\Frontend\Auth\UserNeedsConfirmation;
class RegistrationTest extends BrowserKitTestCase
{
......@@ -71,4 +74,45 @@ class RegistrationTest extends BrowserKitTestCase
Event::assertDispatched(UserRegistered::class);
}
/**
* Test the registration form when account are set to be pending an approval
* ensure they are registered but not confirmed.
*/
/** @test */
public function registration_for_pending_approval()
{
Event::fake();
Notification::fake();
// Set registration to pending approval
config(['access.users.confirm_email' => false]);
config(['access.users.requires_approval' => true]);
$this->visit('/register')
->type('first name', 'first_name')
->type('last name', 'last_name')
->type('test@example.com', 'email')
->type('Viral@1234', 'password')
->type('Viral@1234', 'password_confirmation')
->check('is_term_accept')
->press('Register')
->see('Your account was successfully created and is pending approval. An e-mail will be sent when your account is approved.')
->see('Login')
->seePageIs('/')
->seeInDatabase(config('access.users_table'),
[
'email' => 'test@example.com',
'first_name' => 'first name',
'last_name' => 'last name',
'confirmed' => 0,
]);
// Get the user that was inserted into the database
$user = User::where('email', 'test@example.com')->first();
Notification::assertNotSentTo([$user], UserNeedsConfirmation::class);
Event::assertDispatched(UserRegistered::class);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment