Add ProjectZomboidCmdLog (cmd.txt)
Per-line client RPC trace. Parser captures only the timestamp; analysers decompose steamid/player/command/coords via CmdPattern::FIELDS. Detectors: filename match plus content signature on the 'steamid "name" command @ x,y,z' line shape.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?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\ProjectZomboidCmdLog;
|
||||
use IndifferentKetchup\Codex\Pattern\ProjectZomboid\CmdPattern;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ProjectZomboidCmdLogTest extends TestCase
|
||||
{
|
||||
private function fixturePath(): string
|
||||
{
|
||||
return __DIR__ . '/../../../../src/Games/ProjectZomboid/fixtures/cmd-minimal.txt';
|
||||
}
|
||||
|
||||
public function testParsesEachLineAsAnEntry(): void
|
||||
{
|
||||
$log = (new ProjectZomboidCmdLog())->setLogFile(new PathLogFile($this->fixturePath()));
|
||||
$log->parse();
|
||||
|
||||
$this->assertCount(10, $log->getEntries());
|
||||
}
|
||||
|
||||
public function testFieldsRegexExtractsCommand(): void
|
||||
{
|
||||
$line = '[16-04-26 16:19:30.812] 76561198000000003 "AdminUser" admin.kickPlayer @ 1020,2020,0.';
|
||||
$this->assertSame(1, preg_match(CmdPattern::FIELDS, $line, $m));
|
||||
$this->assertSame('AdminUser', $m['player']);
|
||||
$this->assertSame('admin.kickPlayer', $m['command']);
|
||||
}
|
||||
|
||||
public function testDetectiveDispatchesByContent(): void
|
||||
{
|
||||
$detective = (new Detective())
|
||||
->setLogFile(new PathLogFile($this->fixturePath()))
|
||||
->addPossibleLogClass(ProjectZomboidCmdLog::class);
|
||||
|
||||
$this->assertInstanceOf(ProjectZomboidCmdLog::class, $detective->detect());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user