-
-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add delete changer to ExprMessage (#6828)
* Add delete changer * Update examples * use toString Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> * Add JUnit test (chat event) * Call chat event in JUnit Test * Create viewer Set differently * Add more tests (join/quit) * Remove use of components --------- Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
118 additions
and
17 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
53 changes: 53 additions & 0 deletions
53
src/test/java/org/skriptlang/skript/test/tests/syntaxes/expressions/ExprMessageTest.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,53 @@ | ||
/** | ||
* This file is part of Skript. | ||
* | ||
* Skript is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Skript is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Skript. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Copyright Peter Güttinger, SkriptLang team and contributors | ||
*/ | ||
package org.skriptlang.skript.test.tests.syntaxes.expressions; | ||
|
||
import ch.njol.skript.test.runner.SkriptJUnitTest; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.player.AsyncPlayerChatEvent; | ||
import org.bukkit.event.player.PlayerJoinEvent; | ||
import org.bukkit.event.player.PlayerQuitEvent; | ||
import org.bukkit.plugin.PluginManager; | ||
import org.easymock.EasyMock; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class ExprMessageTest extends SkriptJUnitTest { | ||
|
||
private Player testPlayer; | ||
|
||
@Before | ||
public void setup() { | ||
testPlayer = EasyMock.niceMock(Player.class); | ||
} | ||
|
||
@Test | ||
public void test() { | ||
Set<Player> viewers = new HashSet<>(); | ||
viewers.add(testPlayer); | ||
PluginManager manager = Bukkit.getServer().getPluginManager(); | ||
manager.callEvent(new AsyncPlayerChatEvent(false, testPlayer, "hi", viewers)); | ||
manager.callEvent(new PlayerJoinEvent(testPlayer, "hi")); | ||
manager.callEvent(new PlayerQuitEvent(testPlayer, "hi")); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
test "ExprMessageJUnit" when running JUnit: | ||
set {_tests::1} to "set chat message" | ||
set {_tests::2} to "clear chat message" | ||
set {_tests::3} to "set join message" | ||
set {_tests::4} to "clear join message" | ||
set {_tests::5} to "set quit message" | ||
set {_tests::6} to "clear quit message" | ||
ensure junit test "org.skriptlang.skript.test.tests.syntaxes.expressions.ExprMessageTest" completes {_tests::*} | ||
|
||
on chat: | ||
set {_test} to "org.skriptlang.skript.test.tests.syntaxes.expressions.ExprMessageTest" | ||
junit test is {_test} | ||
|
||
set chat message to "hello" | ||
if chat message is "hello": | ||
complete objective "set chat message" for {_test} | ||
|
||
clear message | ||
if message is "": | ||
complete objective "clear chat message" for {_test} | ||
|
||
on join: | ||
set {_test} to "org.skriptlang.skript.test.tests.syntaxes.expressions.ExprMessageTest" | ||
junit test is {_test} | ||
|
||
set login message to "I joined" | ||
if log in message is "I joined": | ||
complete objective "set join message" for {_test} | ||
|
||
clear join message | ||
if join message is "": | ||
complete objective "clear join message" for {_test} | ||
|
||
on quit: | ||
set {_test} to "org.skriptlang.skript.test.tests.syntaxes.expressions.ExprMessageTest" | ||
junit test is {_test} | ||
|
||
set logout message to "I left" | ||
if log out message is "I left": | ||
complete objective "set quit message" for {_test} | ||
|
||
clear quit message | ||
if leave message is "": | ||
complete objective "clear quit message" for {_test} |