62 lines
2.4 KiB
PHP
62 lines
2.4 KiB
PHP
<?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
|
|
);
|
|
}
|
|
}
|