/**
* Tests for onAction.
*/
@Test
public void testOnAction() {
final WhoAction pq = new WhoAction();
final RPAction action = new RPAction();
action.put(Actions.TYPE, "who");
final Player player = PlayerTestHelper.createPlayer("player");
pq.onAction(player, action);
assertThat(player.events().get(0).get("text"), equalTo("0 Players online: "));
player.clearEvents();
MockStendhalRPRuleProcessor.get().addPlayer(player);
pq.onAction(player, action);
assertThat(player.events().get(0).get("text"), equalTo("1 Players online: player(0) "));
player.clearEvents();
player.setAdminLevel(AdministrationAction.getLevelForCommand("ghostmode") - 1);
player.setGhost(true);
pq.onAction(player, action);
assertThat(player.events().get(0).get("text"), equalTo("0 Players online: "));
player.clearEvents();
player.setAdminLevel(AdministrationAction.getLevelForCommand("ghostmode"));
player.setGhost(true);
pq.onAction(player, action);
assertThat(player.events().get(0).get("text"), equalTo("1 Players online: player(!0) "));
player.clearEvents();
player.setAdminLevel(AdministrationAction.getLevelForCommand("ghostmode") + 1);
player.setGhost(true);
pq.onAction(player, action);
assertThat(player.events().get(0).get("text"), equalTo("1 Players online: player(!0) "));
}