Files
ik-codex/test/tests/Games/ProjectZomboid/Analyser/UserLogAnalysisTest.php
indifferentketchup 73e9ca6181 Add ConnectionFailureAnalyser
First custom Analyser subclass in this game tree. PatternAnalyser
operates per-entry without cross-entry state, so pairing
'attempting to join' with 'allowed to join' per Steam ID requires a
bespoke pass over the log. The analyser counts attempts and allowed
events per Steam ID and emits a ConnectionFailureProblem for each
player whose attempt count exceeds their allowed count. Unmatched
'attempting to join used queue' rows are surfaced as failures in v1
because a long queue wait is indistinguishable from a real failure
without timing context.
2026-04-30 22:39:13 +00:00

44 lines
1.5 KiB
PHP

<?php
namespace IndifferentKetchup\Codex\Test\Tests\Games\ProjectZomboid\Analyser;
use IndifferentKetchup\Codex\Analysis\ProjectZomboid\ConnectionFailureProblem;
use IndifferentKetchup\Codex\Log\File\PathLogFile;
use IndifferentKetchup\Codex\Log\ProjectZomboid\ProjectZomboidUserLog;
use PHPUnit\Framework\TestCase;
class UserLogAnalysisTest extends TestCase
{
private function fixturePath(): string
{
return __DIR__ . '/../../../../src/Games/ProjectZomboid/fixtures/user-minimal.txt';
}
public function testFlagsPlayerWithUnmatchedAttempts(): void
{
$log = (new ProjectZomboidUserLog())->setLogFile(new PathLogFile($this->fixturePath()));
$log->parse();
$analysis = $log->analyse();
$problems = $analysis->getFilteredInsights(ConnectionFailureProblem::class);
$this->assertCount(1, $problems);
$problem = $problems[0];
$this->assertSame('76561198000000001', $problem->getSteamId());
$this->assertSame('Player1', $problem->getPlayer());
$this->assertSame(1, $problem->getUnmatchedAttempts());
}
public function testDoesNotFlagPlayerWithMatchedAttempts(): void
{
$log = (new ProjectZomboidUserLog())->setLogFile(new PathLogFile($this->fixturePath()));
$log->parse();
$analysis = $log->analyse();
$problems = $analysis->getFilteredInsights(ConnectionFailureProblem::class);
foreach ($problems as $problem) {
$this->assertNotSame('76561198000000002', $problem->getSteamId());
}
}
}