/** * Notifications should be dispatched about a new order. * * @slowThreshold 1300 */ public function testNewOrderStaffNotification() { // Given a staff user exists; $this->staffUser(); // When a customer makes an order; Notification::fake(); $this->completeOrder($this); // Then the staff user should have been notified about it. Notification::assertSentTo($this->staffUser(), NewOrderNotification::class, function (NewOrderNotification $notification) { return $notification->order->id === $this->orders[0]->id; }); }
public function test_confirmed_registration() { // Fake notifications Notification::fake(); // Set settings and get user instance $this->setSettings(['registration-enabled' => 'true', 'registration-confirmation' => 'true']); $user = factory(\BookStack\User::class)->make(); // Go through registration process $this->visit('/register')->see('Sign Up')->type($user->name, '#name')->type($user->email, '#email')->type($user->password, '#password')->press('Create Account')->seePageIs('/register/confirm')->seeInDatabase('users', ['name' => $user->name, 'email' => $user->email, 'email_confirmed' => false]); // Ensure notification sent $dbUser = \BookStack\User::where('email', '=', $user->email)->first(); Notification::assertSentTo($dbUser, ConfirmEmail::class); // Test access and resend confirmation email $this->login($user->email, $user->password)->seePageIs('/register/confirm/awaiting')->see('Resend')->visit('/books')->seePageIs('/register/confirm/awaiting')->press('Resend Confirmation Email'); // Get confirmation and confirm notification matches $emailConfirmation = DB::table('email_confirmations')->where('user_id', '=', $dbUser->id)->first(); Notification::assertSentTo($dbUser, ConfirmEmail::class, function ($notification, $channels) use($emailConfirmation) { return $notification->token === $emailConfirmation->token; }); // Check confirmation email confirmation activation. $this->visit('/register/confirm/' . $emailConfirmation->token)->seePageIs('/')->see($user->name)->notSeeInDatabase('email_confirmations', ['token' => $emailConfirmation->token])->seeInDatabase('users', ['name' => $dbUser->name, 'email' => $dbUser->email, 'email_confirmed' => true]); }
/** * Test that the forgot password form sends the user the notification and places the * row in the password_resets table */ public function testForgotPasswordForm() { Notification::fake(); $this->visit('password/reset')->type($this->user->email, 'email')->press('Send Password Reset Link')->seePageIs('password/reset')->see('We have e-mailed your password reset link!')->seeInDatabase('password_resets', ['email' => $this->user->email]); Notification::assertSentTo([$this->user], UserNeedsPasswordReset::class); }
/** * Assure the user gets resent a confirmation email * after hitting the resend confirmation route */ public function testResendConfirmAccountRoute() { Notification::fake(); $this->visit('/account/confirm/resend/' . $this->user->id)->seePageIs('/login')->see('A new confirmation e-mail has been sent to the address on file.'); Notification::assertSentTo([$this->user], UserNeedsConfirmation::class); }
public function testCreateUserUnconfirmedForm() { // Make sure our events are fired Event::fake(); // Make sure our notifications are sent Notification::fake(); // Create any needed resources $faker = Faker\Factory::create(); $name = $faker->name; $email = $faker->safeEmail; $password = $faker->password(8); $this->actingAs($this->admin)->visit('/admin/access/user/create')->type($name, 'name')->type($email, 'email')->type($password, 'password')->type($password, 'password_confirmation')->seeIsChecked('status')->uncheck('confirmed')->check('confirmation_email')->check('assignees_roles[2]')->check('assignees_roles[3]')->press('Create')->seePageIs('/admin/access/user')->see('The user was successfully created.')->seeInDatabase('users', ['name' => $name, 'email' => $email, 'status' => 1, 'confirmed' => 0])->seeInDatabase('role_user', ['user_id' => 4, 'role_id' => 2])->seeInDatabase('role_user', ['user_id' => 4, 'role_id' => 3]); // Get the user that was inserted into the database $user = User::where('email', $email)->first(); // Check that the user was sent the confirmation email Notification::assertSentTo([$user], UserNeedsConfirmation::class); Event::assertFired(UserCreated::class); }