From 3db825cfdc83f684e33df98567bbe2784b838e3a Mon Sep 17 00:00:00 2001 From: indifferentketchup Date: Thu, 30 Apr 2026 21:34:02 +0000 Subject: [PATCH] Wire ProjectZomboidServerLog default analyser --- .../ProjectZomboidServerLog.php | 10 ++- .../Analyser/ServerLogAnalysisTest.php | 61 +++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 test/tests/Games/ProjectZomboid/Analyser/ServerLogAnalysisTest.php diff --git a/src/Log/ProjectZomboid/ProjectZomboidServerLog.php b/src/Log/ProjectZomboid/ProjectZomboidServerLog.php index 617fd89..59442f9 100644 --- a/src/Log/ProjectZomboid/ProjectZomboidServerLog.php +++ b/src/Log/ProjectZomboid/ProjectZomboidServerLog.php @@ -4,6 +4,10 @@ namespace IndifferentKetchup\Codex\Log\ProjectZomboid; use IndifferentKetchup\Codex\Analyser\AnalyserInterface; use IndifferentKetchup\Codex\Analyser\PatternAnalyser; +use IndifferentKetchup\Codex\Analysis\ProjectZomboid\EngineVersionInformation; +use IndifferentKetchup\Codex\Analysis\ProjectZomboid\ModLoadInformation; +use IndifferentKetchup\Codex\Analysis\ProjectZomboid\ModMissingProblem; +use IndifferentKetchup\Codex\Analysis\ProjectZomboid\ServerExceptionProblem; use IndifferentKetchup\Codex\Detective\FilenameDetector; use IndifferentKetchup\Codex\Detective\WeightedSinglePatternDetector; use IndifferentKetchup\Codex\Parser\ParserInterface; @@ -29,7 +33,11 @@ class ProjectZomboidServerLog extends ProjectZomboidLog public static function getDefaultAnalyser(): AnalyserInterface { - return new PatternAnalyser(); + return (new PatternAnalyser()) + ->addPossibleInsightClass(EngineVersionInformation::class) + ->addPossibleInsightClass(ModLoadInformation::class) + ->addPossibleInsightClass(ModMissingProblem::class) + ->addPossibleInsightClass(ServerExceptionProblem::class); } public static function getDetectors(): array diff --git a/test/tests/Games/ProjectZomboid/Analyser/ServerLogAnalysisTest.php b/test/tests/Games/ProjectZomboid/Analyser/ServerLogAnalysisTest.php new file mode 100644 index 0000000..7da4e56 --- /dev/null +++ b/test/tests/Games/ProjectZomboid/Analyser/ServerLogAnalysisTest.php @@ -0,0 +1,61 @@ +setLogFile(new PathLogFile($this->fixturePath())); + $log->parse(); + $analysis = $log->analyse(); + + $this->assertCount(1, $analysis->getFilteredInsights(EngineVersionInformation::class)); + $this->assertCount(3, $analysis->getFilteredInsights(ModLoadInformation::class)); + $this->assertCount(1, $analysis->getFilteredInsights(ModMissingProblem::class)); + $this->assertCount(2, $analysis->getFilteredInsights(ServerExceptionProblem::class)); + } + + public function testAnalysisCarriesAttachedSolutionForMissingMod(): void + { + $log = (new ProjectZomboidServerLog())->setLogFile(new PathLogFile($this->fixturePath())); + $log->parse(); + $analysis = $log->analyse(); + + $missing = $analysis->getFilteredInsights(ModMissingProblem::class); + $this->assertCount(1, $missing); + $this->assertCount(1, $missing[0]->getSolutions()); + } + + public function testTwoDistinctExceptionsAreNotCoalesced(): void + { + $log = (new ProjectZomboidServerLog())->setLogFile(new PathLogFile($this->fixturePath())); + $log->parse(); + $analysis = $log->analyse(); + + $exceptions = $analysis->getFilteredInsights(ServerExceptionProblem::class); + $types = array_map(fn($e) => $e->getExceptionType(), $exceptions); + sort($types); + + $this->assertSame( + [ + 'java.nio.file.NoSuchFileException', + 'zombie.core.properties.IsoPropertyType$IsoPropertyTypeNotFoundException', + ], + $types + ); + } +}