create(); $action = new PurgeUser(); $action->execute($user); $this->assertDatabaseMissing('users', ['id' => $user->id]); Event::assertDispatched(UserWasPurged::class); }); test('it cannot purge an admin', function () { Role::create(['name' => RoleType::ADMIN->value, 'guard_name' => 'web']); $user = User::factory()->create(); $user->assignRole(RoleType::ADMIN->value); $action = new PurgeUser(); $this->expectException(Exception::class); $this->expectExceptionMessage(__('domains/identity/messages.exceptions.user_cannot_be_purged')); $action->execute($user); });