Wire ProjectZomboidServerLog default analyser
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user