Wire ProjectZomboidServerLog default analyser
Some checks failed
Tests / Run tests on PHP v8.4 (push) Failing after 1s
Tests / Run tests on PHP v8.5 (push) Failing after 0s

This commit is contained in:
2026-04-30 21:34:02 +00:00
parent 423c6d3963
commit 3db825cfdc
2 changed files with 70 additions and 1 deletions

View File

@@ -0,0 +1,61 @@
<?php
namespace IndifferentKetchup\Codex\Test\Tests\Games\ProjectZomboid\Analyser;
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\Log\File\PathLogFile;
use IndifferentKetchup\Codex\Log\ProjectZomboid\ProjectZomboidServerLog;
use PHPUnit\Framework\TestCase;
class ServerLogAnalysisTest extends TestCase
{
private function fixturePath(): string
{
return __DIR__ . '/../../../../src/Games/ProjectZomboid/fixtures/debug-server-minimal.txt';
}
public function testAnalyseProducesExpectedInsightSet(): void
{
$log = (new ProjectZomboidServerLog())->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
);
}
}