public function testPermanentlyDeleteUser() { // Make sure our events are fired Event::fake(); $this->actingAs($this->admin)->delete('/admin/access/user/' . $this->user->id)->notSeeInDatabase('users', ['id' => $this->user->id, 'deleted_at' => null])->visit('/admin/access/user/' . $this->user->id . '/delete')->seePageIs('/admin/access/user/deleted')->see('The user was deleted permanently.')->notSeeInDatabase('users', ['id' => $this->user->id]); Event::assertFired(UserPermanentlyDeleted::class); }
/** * Test the logout button redirects the user back to home and the login button is again visible */ public function testLogoutRoute() { // Make sure our events are fired Event::fake(); $this->actingAs($this->user)->visit('/logout')->see('Login')->see('Register'); Event::assertFired(UserLoggedOut::class); }
/** * Create an unconfirmed user and assure the user gets * confirmed when hitting the confirmation route */ public function testConfirmAccountRoute() { Event::fake(); // Create default user to test with $unconfirmed = factory(User::class)->states('unconfirmed')->create(); $unconfirmed->attachRole(3); //User $this->visit('/account/confirm/' . $unconfirmed->confirmation_code)->seePageIs('/login')->see('Your account has been successfully confirmed!')->seeInDatabase(config('access.users_table'), ['email' => $unconfirmed->email, 'confirmed' => 1]); Event::assertFired(UserConfirmed::class); }
/** * Test that the user is logged in and redirected to the dashboard * Test that the admin is logged in and redirected to the backend */ public function testLoginForm() { // Make sure our events are fired Event::fake(); Auth::logout(); //User Test $this->visit('/login')->type($this->user->email, 'email')->type('1234', 'password')->press('Login')->seePageIs('/dashboard')->see($this->user->email); Auth::logout(); //Admin Test $this->visit('/login')->type($this->admin->email, 'email')->type('1234', 'password')->press('Login')->seePageIs('/admin/dashboard')->see($this->admin->name)->see('Access Management'); Event::assertFired(UserLoggedIn::class); }
public function testDeleteRoleWithPermissions() { // Make sure our events are fired Event::fake(); // Remove users from role first because it will error on that first DB::table('role_user')->where('role_id', 2)->delete(); $this->actingAs($this->admin)->visit('/admin/access/role')->delete('/admin/access/role/2')->assertRedirectedTo('/admin/access/role')->notSeeInDatabase('roles', ['id' => 2])->notSeeInDatabase('permission_role', ['permission_id' => 1, 'role_id' => 2])->notSeeInDatabase('permission_role', ['permission_id' => 2, 'role_id' => 2])->seeInSession(['flash_success' => 'The role was successfully deleted.']); Event::assertFired(RoleDeleted::class); }
public function testChangeUserPasswordForm() { // Make sure our events are fired Event::fake(); $password = '******'; $this->actingAs($this->admin)->visit('/admin/access/user/' . $this->user->id . '/password/change')->see('Change Password for ' . $this->user->name)->type($password, 'password')->type($password, 'password_confirmation')->press('Update')->seePageIs('/admin/access/user')->see('The user\'s password was successfully updated.'); Event::assertFired(UserPasswordChanged::class); }