setLogFile(new PathLogFile($this->fixturePath())); $log->parse(); $this->assertCount(9, $log->getEntries()); } public function testConnectionRegexExtractsAddVariant(): void { $line = '[29-04-26 18:35:41.512] Connection add index=0 guid=144118788000000001 id=null.'; $this->assertSame(1, preg_match(UserPattern::CONNECTION, $line, $m)); $this->assertSame('add', $m['action']); $this->assertSame('null', $m['id']); } public function testConnectionRegexExtractsDisconnectVariant(): void { $line = '[29-04-26 18:39:23.923] Connection disconnect index=0 guid=144118788000000001 id=76561198000000001.'; $this->assertSame(1, preg_match(UserPattern::CONNECTION, $line, $m)); $this->assertSame('disconnect', $m['action']); $this->assertSame('76561198000000001', $m['id']); } public function testPlayerEventRegexExtracts(): void { $line = '[29-04-26 18:35:42.802] 76561198000000001 "Player1" attempting to join.'; $this->assertSame(1, preg_match(UserPattern::PLAYER_EVENT, $line, $m)); $this->assertSame('Player1', $m['player']); $this->assertSame('attempting to join', $m['event']); } public function testDetectiveDispatchesByContent(): void { $detective = (new Detective()) ->setLogFile(new PathLogFile($this->fixturePath())) ->addPossibleLogClass(ProjectZomboidUserLog::class); $this->assertInstanceOf(ProjectZomboidUserLog::class, $detective->detect()); } }