-
-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Fix tests failing on unsupported versions
1 parent
65ad357
commit 2411457
Showing
5 changed files
with
46 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/test/java/org/skriptlang/skript/test/utils/InputHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.skriptlang.skript.test.utils; | ||
|
||
import org.bukkit.Input; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.player.PlayerEvent; | ||
import org.bukkit.event.player.PlayerInputEvent; | ||
import org.easymock.EasyMock; | ||
import org.skriptlang.skript.bukkit.input.InputKey; | ||
|
||
public class InputHelper { | ||
|
||
public static PlayerEvent createPlayerInputEvent(Player player, InputKey... keys) { | ||
return new PlayerInputEvent(player, fromKeys(keys)); | ||
} | ||
|
||
public static Input fromKeys(InputKey... keys) { | ||
Input input = EasyMock.niceMock(Input.class); | ||
for (InputKey key : keys) { | ||
switch (key) { | ||
case FORWARD -> EasyMock.expect(input.isForward()).andStubReturn(true); | ||
case BACKWARD -> EasyMock.expect(input.isBackward()).andStubReturn(true); | ||
case RIGHT -> EasyMock.expect(input.isRight()).andStubReturn(true); | ||
case LEFT -> EasyMock.expect(input.isLeft()).andStubReturn(true); | ||
case JUMP -> EasyMock.expect(input.isJump()).andStubReturn(true); | ||
case SNEAK -> EasyMock.expect(input.isSneak()).andStubReturn(true); | ||
case SPRINT -> EasyMock.expect(input.isSprint()).andStubReturn(true); | ||
} | ||
} | ||
EasyMock.replay(input); | ||
return input; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters