本文整理汇总了PHP中Illuminate\Support\Facades\Event::fake方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::fake方法的具体用法?PHP Event::fake怎么用?PHP Event::fake使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Event
的用法示例。
在下文中一共展示了Event::fake方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPermanentlyDeleteUser
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);
}
示例2: testLogoutRoute
/**
* 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);
}
示例3: testDeleteRoleWithPermissions
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);
}
示例4: testConfirmAccountRoute
/**
* 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);
}
示例5: testLoginForm
/**
* 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);
}
示例6: testChangeUserPasswordForm
public function testChangeUserPasswordForm()
{
// Make sure our events are fired
Event::fake();
$password = '87654321';
$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);
}