/** * Test the functionality of the logic token matcher */ public function testMatchLogic() { $parser = new Parser(); $tokensToTest = ['T_LOGIC_AND', 'T_LOGIC_OR', 'T_LOGIC_XOR']; // Build a token stream from the list of tokens to test $tokenStream = array_map(function ($token) { return ['token' => $token]; }, $tokensToTest); // Initialise $parser->setTokenStream($tokenStream); $parser->setTokenIndex(-1); // Try them all foreach ($tokensToTest as $token) { $this->assertEquals($token, $parser->matchLogic()['token'], "Token {$token} should match as a logic token"); } }