Add AdminTeleportedInformation insight

This commit is contained in:
2026-04-30 21:47:14 +00:00
parent 64641fa8e8
commit d15fc81f9f
3 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace IndifferentKetchup\Codex\Test\Tests\Games\ProjectZomboid\Analysis;
use IndifferentKetchup\Codex\Analysis\ProjectZomboid\AdminTeleportedInformation;
use IndifferentKetchup\Codex\Pattern\ProjectZomboid\AdminPattern;
use PHPUnit\Framework\TestCase;
class AdminTeleportedInformationTest extends TestCase
{
public function testGetPatternsReturnsEntryRegex(): void
{
$this->assertSame([AdminPattern::TELEPORTED_ENTRY], AdminTeleportedInformation::getPatterns());
}
public function testEntryRegexMatchesPositiveZ(): void
{
$line = "[16-04-26 18:38:00.225] AdminUser teleported Player1 to 1100,2200,0.";
$this->assertSame(1, preg_match(AdminPattern::TELEPORTED_ENTRY, $line, $m));
$insight = new AdminTeleportedInformation();
$insight->setMatches($m, 0);
$this->assertSame('Admin teleported', $insight->getLabel());
$this->assertSame('AdminUser teleported Player1 to 1100,2200,0', $insight->getValue());
}
public function testEntryRegexHandlesNegativeZ(): void
{
$line = "[16-04-26 18:39:15.500] AdminUser teleported Player2 to 1100,2200,-1.";
$this->assertSame(1, preg_match(AdminPattern::TELEPORTED_ENTRY, $line, $m));
$this->assertSame('-1', $m['z']);
}
}