Files
ik-codex/test/tests/Games/ProjectZomboid/Log/ProjectZomboidBurdJournalsLogTest.php
indifferentketchup 27424f6a14 Add ProjectZomboidBurdJournalsLog (BurdJournals.txt)
Per-line warnings emitted by the BurdJournals mod, format
'[time] [BurdJournals] LEVEL: message.'. Parser captures time, the
[BurdJournals] tag as the entry prefix, and the LEVEL token. Detectors:
filename match plus content signature on the literal '[BurdJournals]'
tag bracket.
2026-04-30 20:42:52 +00:00

45 lines
1.5 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\Level;
use IndifferentKetchup\Codex\Log\ProjectZomboid\ProjectZomboidBurdJournalsLog;
use PHPUnit\Framework\TestCase;
class ProjectZomboidBurdJournalsLogTest extends TestCase
{
private function fixturePath(): string
{
return __DIR__ . '/../../../../src/Games/ProjectZomboid/fixtures/burd-journals-minimal.txt';
}
public function testParsesEachLineAsAnEntry(): void
{
$log = (new ProjectZomboidBurdJournalsLog())->setLogFile(new PathLogFile($this->fixturePath()));
$log->parse();
$this->assertCount(5, $log->getEntries());
}
public function testLevelAndPrefixAreParsed(): void
{
$log = (new ProjectZomboidBurdJournalsLog())->setLogFile(new PathLogFile($this->fixturePath()));
$log->parse();
$first = $log->getEntries()[0];
$this->assertSame(Level::WARNING, $first->getLevel());
$this->assertSame('BurdJournals', $first->getPrefix());
}
public function testDetectiveDispatchesByContent(): void
{
$detective = (new Detective())
->setLogFile(new PathLogFile($this->fixturePath()))
->addPossibleLogClass(ProjectZomboidBurdJournalsLog::class);
$this->assertInstanceOf(ProjectZomboidBurdJournalsLog::class, $detective->detect());
}
}