From 11efa66494739eda24e32ab1882d10c80300f513 Mon Sep 17 00:00:00 2001 From: indifferentketchup Date: Thu, 30 Apr 2026 21:31:01 +0000 Subject: [PATCH] Add EngineVersionInformation insight --- .../EngineVersionInformation.php | 27 ++++++++++++++++++ .../Analysis/EngineVersionInformationTest.php | 28 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/Analysis/ProjectZomboid/EngineVersionInformation.php create mode 100644 test/tests/Games/ProjectZomboid/Analysis/EngineVersionInformationTest.php diff --git a/src/Analysis/ProjectZomboid/EngineVersionInformation.php b/src/Analysis/ProjectZomboid/EngineVersionInformation.php new file mode 100644 index 0000000..ac65299 --- /dev/null +++ b/src/Analysis/ProjectZomboid/EngineVersionInformation.php @@ -0,0 +1,27 @@ +setLabel('Engine version'); + $this->setValue(sprintf( + '%s (build %s, %s %s)', + $matches['version'], + $matches['hash'], + $matches['date'], + $matches['time'] + )); + } +} diff --git a/test/tests/Games/ProjectZomboid/Analysis/EngineVersionInformationTest.php b/test/tests/Games/ProjectZomboid/Analysis/EngineVersionInformationTest.php new file mode 100644 index 0000000..6cea246 --- /dev/null +++ b/test/tests/Games/ProjectZomboid/Analysis/EngineVersionInformationTest.php @@ -0,0 +1,28 @@ +assertSame([DebugServerPattern::VERSION], EngineVersionInformation::getPatterns()); + } + + public function testSetMatchesPopulatesLabelAndValue(): void + { + $line = '[16-04-26 00:00:42.407] LOG : General f:0, t:1776297642406, st:48,648,157,584> version=42.16.3 0000000000000000000000000000000000000000 2026-04-08 11:54:01 (ZB) demo=false.'; + $this->assertSame(1, preg_match(DebugServerPattern::VERSION, $line, $matches)); + + $insight = new EngineVersionInformation(); + $insight->setMatches($matches, 0); + + $this->assertSame('Engine version', $insight->getLabel()); + $this->assertSame('42.16.3 (build 0000000000000000000000000000000000000000, 2026-04-08 11:54:01)', $insight->getValue()); + $this->assertSame('Engine version: 42.16.3 (build 0000000000000000000000000000000000000000, 2026-04-08 11:54:01)', $insight->getMessage()); + } +}