Ejemplo n.º 1
0
 /**
  *  Test the functionality of the operator token matcher
  */
 public function testMatchOperator()
 {
     $parser = new Parser();
     $tokensToTest = ['T_OP_NEQ', 'T_OP_LTE', 'T_OP_LT', 'T_OP_GTE', 'T_OP_GT', 'T_OP_EQ', 'T_OP_IN'];
     // 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->matchOperator()['token'], "Token {$token} should match as an operator");
     }
 }