Skip to content

Commit 9b18a85

Browse files
authored
Merge pull request #152 from BentoBoxWorld/copilot/sub-pr-151
Add test coverage for nether world border filtering
2 parents 5dc6bc2 + c38c376 commit 9b18a85

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/test/java/world/bentobox/border/listeners/ShowVirtualWorldBorderTest.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import static org.junit.jupiter.api.Assertions.assertNotNull;
44
import static org.mockito.ArgumentMatchers.any;
5+
import static org.mockito.Mockito.never;
56
import static org.mockito.Mockito.verify;
67
import static org.mockito.Mockito.when;
78

89
import org.bukkit.Bukkit;
10+
import org.bukkit.World.Environment;
911
import org.bukkit.WorldBorder;
1012
import org.bukkit.entity.Player;
1113
import org.bukkit.util.Vector;
@@ -123,4 +125,39 @@ public void testHideBorder() {
123125
verify(mockPlayer).setWorldBorder(null);
124126
}
125127

128+
/**
129+
* Test method for {@link world.bentobox.border.listeners.ShowVirtualWorldBorder#showBorder(org.bukkit.entity.Player, world.bentobox.bentobox.database.objects.Island)}.
130+
* Tests that border is shown when player is in an island nether world.
131+
*/
132+
@Test
133+
public void testShowBorderInIslandNetherWorld() {
134+
// Setup: Player is in a nether environment that IS an island nether world
135+
when(world.getEnvironment()).thenReturn(Environment.NETHER);
136+
when(iwm.isIslandNether(world)).thenReturn(true);
137+
when(addon.getPlugin()).thenReturn(plugin);
138+
139+
svwb.showBorder(mockPlayer, island);
140+
141+
// Verify that the border was set (border should show in island nether worlds)
142+
verify(mockPlayer).setWorldBorder(wb);
143+
verify(wb).setSize(200.0D);
144+
}
145+
146+
/**
147+
* Test method for {@link world.bentobox.border.listeners.ShowVirtualWorldBorder#showBorder(org.bukkit.entity.Player, world.bentobox.bentobox.database.objects.Island)}.
148+
* Tests that border is NOT shown when player is in a non-island nether world.
149+
*/
150+
@Test
151+
public void testShowBorderInNonIslandNetherWorld() {
152+
// Setup: Player is in a nether environment that is NOT an island nether world
153+
when(world.getEnvironment()).thenReturn(Environment.NETHER);
154+
when(iwm.isIslandNether(world)).thenReturn(false);
155+
when(addon.getPlugin()).thenReturn(plugin);
156+
157+
svwb.showBorder(mockPlayer, island);
158+
159+
// Verify that the border was NOT set (border should not show in non-island nether worlds)
160+
verify(mockPlayer, never()).setWorldBorder(any());
161+
}
162+
126163
}

0 commit comments

Comments
 (0)