Add AdminAddedXpInformation insight

This commit is contained in:
2026-04-30 21:45:12 +00:00
parent 0d85a05df3
commit a2faa551a1
3 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace IndifferentKetchup\Codex\Test\Tests\Games\ProjectZomboid\Analysis;
use IndifferentKetchup\Codex\Analysis\ProjectZomboid\AdminAddedXpInformation;
use IndifferentKetchup\Codex\Pattern\ProjectZomboid\AdminPattern;
use PHPUnit\Framework\TestCase;
class AdminAddedXpInformationTest extends TestCase
{
public function testGetPatternsReturnsEntryRegex(): void
{
$this->assertSame([AdminPattern::ADDED_XP_ENTRY], AdminAddedXpInformation::getPatterns());
}
public function testEntryRegexMatchesFullLine(): void
{
$line = "[16-04-26 18:34:00.500] AdminUser added 750.0 Blunt xp's to Player1.";
$this->assertSame(1, preg_match(AdminPattern::ADDED_XP_ENTRY, $line, $m));
$insight = new AdminAddedXpInformation();
$insight->setMatches($m, 0);
$this->assertSame('Admin added xp', $insight->getLabel());
$this->assertSame('AdminUser added 750.0 Blunt xp to Player1', $insight->getValue());
}
public function testEntryRegexDoesNotMatchAddedItemLine(): void
{
$line = "[16-04-26 18:33:34.289] AdminUser added item Base.ShotgunShells in Player1's inventory.";
$this->assertSame(0, preg_match(AdminPattern::ADDED_XP_ENTRY, $line));
}
}