summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorYehonal <yehonal.azeroth@gmail.com>2025-09-27 13:36:14 +0200
committerGitHub <noreply@github.com>2025-09-27 13:36:14 +0200
commitb950c610d4e41ee6bbfc9476020546548c20100d (patch)
tree172f74f8e19655119fd4c5b0d3979380423fb79c /src/test
parent815d99250aba4fbedf39eecd1c5c32ce1493a0e2 (diff)
feat(bash): test command in dashboard + fix tests (#23030)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/mocks/WorldMock.h2
-rw-r--r--src/test/server/game/Battlegrounds/ArenaSeason/ArenaSeasonRewardDistributorTest.cpp16
-rw-r--r--src/test/server/game/Battlegrounds/ArenaSeason/ArenaTeamFilterTest.cpp12
3 files changed, 29 insertions, 1 deletions
diff --git a/src/test/mocks/WorldMock.h b/src/test/mocks/WorldMock.h
index 75e8438e4e..db9ca51942 100644
--- a/src/test/mocks/WorldMock.h
+++ b/src/test/mocks/WorldMock.h
@@ -26,7 +26,7 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
-void AddScripts() {}
+inline void AddScripts() {}
class WorldMock: public IWorld
{
diff --git a/src/test/server/game/Battlegrounds/ArenaSeason/ArenaSeasonRewardDistributorTest.cpp b/src/test/server/game/Battlegrounds/ArenaSeason/ArenaSeasonRewardDistributorTest.cpp
index 300cfc4e07..82f68e8634 100644
--- a/src/test/server/game/Battlegrounds/ArenaSeason/ArenaSeasonRewardDistributorTest.cpp
+++ b/src/test/server/game/Battlegrounds/ArenaSeason/ArenaSeasonRewardDistributorTest.cpp
@@ -19,6 +19,8 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "ArenaSeasonRewardsDistributor.h"
+#include "WorldMock.h"
+#include <memory>
class MockArenaSeasonTeamRewarder : public ArenaSeasonTeamRewarder
{
@@ -31,12 +33,26 @@ class ArenaSeasonRewardDistributorTest : public ::testing::Test
protected:
void SetUp() override
{
+ _previousWorld = std::move(sWorld);
+ _worldMock = new ::testing::NiceMock<WorldMock>();
+ ON_CALL(*_worldMock, getIntConfig(::testing::_)).WillByDefault(::testing::Return(0));
+ ON_CALL(*_worldMock, getIntConfig(CONFIG_LEGACY_ARENA_START_RATING)).WillByDefault(::testing::Return(1500));
+ ON_CALL(*_worldMock, getIntConfig(CONFIG_ARENA_START_RATING)).WillByDefault(::testing::Return(0));
+ sWorld.reset(_worldMock);
+
_mockRewarder = std::make_unique<MockArenaSeasonTeamRewarder>();
_distributor = std::make_unique<ArenaSeasonRewardDistributor>(_mockRewarder.get());
}
+ void TearDown() override
+ {
+ sWorld = std::move(_previousWorld);
+ }
+
std::unique_ptr<MockArenaSeasonTeamRewarder> _mockRewarder;
std::unique_ptr<ArenaSeasonRewardDistributor> _distributor;
+ std::unique_ptr<IWorld> _previousWorld;
+ ::testing::NiceMock<WorldMock>* _worldMock = nullptr;
};
ArenaTeam ArenaTeamWithRating(int rating, int gamesPlayed)
diff --git a/src/test/server/game/Battlegrounds/ArenaSeason/ArenaTeamFilterTest.cpp b/src/test/server/game/Battlegrounds/ArenaSeason/ArenaTeamFilterTest.cpp
index 9db54f2000..7863f56002 100644
--- a/src/test/server/game/Battlegrounds/ArenaSeason/ArenaTeamFilterTest.cpp
+++ b/src/test/server/game/Battlegrounds/ArenaSeason/ArenaTeamFilterTest.cpp
@@ -22,6 +22,7 @@
#include "ArenaTeamMgr.h"
#include "ArenaTeam.h"
#include <memory>
+#include "WorldMock.h"
// Used to expose Type property.
class ArenaTeamTest : public ArenaTeam
@@ -46,6 +47,13 @@ class ArenaTeamFilterTest : public ::testing::Test
protected:
void SetUp() override
{
+ _previousWorld = std::move(sWorld);
+ _worldMock = new ::testing::NiceMock<WorldMock>();
+ ON_CALL(*_worldMock, getIntConfig(::testing::_)).WillByDefault(::testing::Return(0));
+ ON_CALL(*_worldMock, getIntConfig(CONFIG_LEGACY_ARENA_START_RATING)).WillByDefault(::testing::Return(1500));
+ ON_CALL(*_worldMock, getIntConfig(CONFIG_ARENA_START_RATING)).WillByDefault(::testing::Return(0));
+ sWorld.reset(_worldMock);
+
team1 = ArenaTeamWithType(2); // 2v2
team2 = ArenaTeamWithType(3); // 3v3
team3 = ArenaTeamWithType(5); // 5v5
@@ -60,12 +68,16 @@ protected:
delete team1;
delete team2;
delete team3;
+
+ sWorld = std::move(_previousWorld);
}
ArenaTeamMgr::ArenaTeamContainer arenaTeams;
ArenaTeam* team1;
ArenaTeam* team2;
ArenaTeam* team3;
+ std::unique_ptr<IWorld> _previousWorld;
+ ::testing::NiceMock<WorldMock>* _worldMock = nullptr;
};
// Test for ArenaTeamFilterAllTeams: it should return all teams without filtering