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:
10
test/src/Games/ProjectZomboid/fixtures/cmd-minimal.txt
Normal file
10
test/src/Games/ProjectZomboid/fixtures/cmd-minimal.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
[16-04-26 16:17:50.114] 76561198000000001 "Player1" ISLogSystem.writeLog @ 1000,2000,0.
|
||||
[16-04-26 16:17:50.115] 76561198000000001 "Player1" ISLogSystem.writeLog @ 1000,2000,0.
|
||||
[16-04-26 16:17:50.120] 76561198000000001 "Player1" example.RelayRequestDataController @ 1000,2000,0.
|
||||
[16-04-26 16:17:59.081] 76561198000000001 "Player1" example.syncPartAnimation @ 1001,2001,0.
|
||||
[16-04-26 16:17:59.315] 76561198000000001 "Player1" example.savePartsCondition @ 1001,2001,0.
|
||||
[16-04-26 16:18:10.220] 76561198000000002 "Player2" ISLogSystem.writeLog @ 1010,2010,0.
|
||||
[16-04-26 16:18:10.230] 76561198000000002 "Player2" example.syncPartAnimation @ 1010,2010,0.
|
||||
[16-04-26 16:19:02.500] 76561198000000003 "AdminUser" admin.broadcastMessage @ 1020,2020,0.
|
||||
[16-04-26 16:19:30.812] 76561198000000003 "AdminUser" admin.kickPlayer @ 1020,2020,0.
|
||||
[16-04-26 16:20:00.014] 76561198000000001 "Player1" ISLogSystem.writeLog @ 1002,2002,0.
|
||||
@@ -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