From 4be6ebac10b5c89821cbbf813ddf091dd76d22fb Mon Sep 17 00:00:00 2001 From: indifferentketchup Date: Thu, 30 Apr 2026 21:31:33 +0000 Subject: [PATCH] Add ModLoadInformation insight --- .../ProjectZomboid/ModLoadInformation.php | 21 +++++++++ .../Analysis/ModLoadInformationTest.php | 44 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/Analysis/ProjectZomboid/ModLoadInformation.php create mode 100644 test/tests/Games/ProjectZomboid/Analysis/ModLoadInformationTest.php diff --git a/src/Analysis/ProjectZomboid/ModLoadInformation.php b/src/Analysis/ProjectZomboid/ModLoadInformation.php new file mode 100644 index 0000000..4bc19c9 --- /dev/null +++ b/src/Analysis/ProjectZomboid/ModLoadInformation.php @@ -0,0 +1,21 @@ +setLabel('Mod loaded'); + $this->setValue($matches['mod']); + } +} diff --git a/test/tests/Games/ProjectZomboid/Analysis/ModLoadInformationTest.php b/test/tests/Games/ProjectZomboid/Analysis/ModLoadInformationTest.php new file mode 100644 index 0000000..ce06498 --- /dev/null +++ b/test/tests/Games/ProjectZomboid/Analysis/ModLoadInformationTest.php @@ -0,0 +1,44 @@ +assertSame([DebugServerPattern::MOD_LOAD], ModLoadInformation::getPatterns()); + } + + public function testSetMatchesExtractsModName(): void + { + $line = '[16-04-26 00:01:19.131] LOG : Mod f:0, t:1776297679131, st:48,648,194,309> loading example_mod_alpha.'; + $this->assertSame(1, preg_match(DebugServerPattern::MOD_LOAD, $line, $matches)); + + $insight = new ModLoadInformation(); + $insight->setMatches($matches, 0); + + $this->assertSame('Mod loaded', $insight->getLabel()); + $this->assertSame('example_mod_alpha', $insight->getValue()); + } + + public function testIsEqualCoalescesSameMod(): void + { + $a = $this->insightFor('example_mod_alpha'); + $b = $this->insightFor('example_mod_alpha'); + $c = $this->insightFor('example_mod_beta'); + + $this->assertTrue($a->isEqual($b)); + $this->assertFalse($a->isEqual($c)); + } + + private function insightFor(string $modName): ModLoadInformation + { + $insight = new ModLoadInformation(); + $insight->setMatches(['mod' => $modName], 0); + return $insight; + } +}