Files
ik-codex/test/tests/Games/ProjectZomboid/Log/ProjectZomboidClientActionLogTest.php
indifferentketchup e74c105625 Add ProjectZomboidClientActionLog (ClientActionLog.txt)
Strict 5-field bracketed format. Parser captures only the timestamp;
analysers that want steamid/action/player/coords/param decompose the
Line text via ClientActionPattern::FIELDS. Detectors: filename match
plus content signature on the IS{Enter,Exit}Vehicle / ISWalkToTimedAction
action tokens.
2026-04-30 20:35:40 +00:00

45 lines
1.6 KiB
PHP

<?php
namespace IndifferentKetchup\Codex\Test\Tests\Games\ProjectZomboid\Log;
use IndifferentKetchup\Codex\Detective\Detective;
use IndifferentKetchup\Codex\Log\File\PathLogFile;
use IndifferentKetchup\Codex\Log\ProjectZomboid\ProjectZomboidClientActionLog;
use IndifferentKetchup\Codex\Pattern\ProjectZomboid\ClientActionPattern;
use PHPUnit\Framework\TestCase;
class ProjectZomboidClientActionLogTest extends TestCase
{
private function fixturePath(): string
{
return __DIR__ . '/../../../../src/Games/ProjectZomboid/fixtures/client-action-minimal.txt';
}
public function testParsesEachLineAsAnEntry(): void
{
$log = (new ProjectZomboidClientActionLog())->setLogFile(new PathLogFile($this->fixturePath()));
$log->parse();
$this->assertCount(10, $log->getEntries());
}
public function testFieldsRegexExtractsStructuredData(): void
{
$line = "[29-04-26 21:41:25.084] [76561198000000001][ISEnterVehicle][Player1][1000,2000,0][Van_LectroMax].";
$this->assertSame(1, preg_match(ClientActionPattern::FIELDS, $line, $m));
$this->assertSame('76561198000000001', $m['steamid']);
$this->assertSame('ISEnterVehicle', $m['action']);
$this->assertSame('Player1', $m['player']);
$this->assertSame('Van_LectroMax', $m['param']);
}
public function testDetectiveDispatchesByContent(): void
{
$detective = (new Detective())
->setLogFile(new PathLogFile($this->fixturePath()))
->addPossibleLogClass(ProjectZomboidClientActionLog::class);
$this->assertInstanceOf(ProjectZomboidClientActionLog::class, $detective->detect());
}
}