expectOutputString($error); $parsed_sql = PMA_SQP_parse($sql); $this->assertEquals('', PMA_SQP_getErrorString()); $this->assertEquals($expected, $parsed_sql); } public function testPMA_SQP_isKeyWord() { PMA_SQP_resetError(); $this->assertEquals(true, PMA_SQP_isKeyWord("ACCESSIBLE")); $this->assertEquals(true, PMA_SQP_isKeyWord("accessible")); $this->assertEquals(true, PMA_SQP_isKeyWord("ASC")); $this->assertEquals(false, PMA_SQP_isKeyWord("hello")); } /** * Data provider for parser testing * * @return array with test data */ public function parserData() { return array( array( 'SELECT 1;', array( 'raw' => 'SELECT 1;', 0 => array( 'type' => 'alpha_reservedWord', 'data' => 'SELECT', 'pos' => 6, 'forbidden' => true, ), 1 => array( 'type' => 'digit_integer', 'data' => '1', 'pos' => 8, ), 2 => array( 'type' => 'punct_queryend', 'data' => ';', 'pos' => 0, ), 'len' => 3, ) ), array( 'SELECT * from aaa;', array( 'raw' => 'SELECT * from aaa;', 0 => array( 'type' => 'alpha_reservedWord', 'data' => 'SELECT', 'pos' => 6, 'forbidden' => true, ), 1 => array( 'type' => 'punct', 'data' => '*', 'pos' => 0, ), 2 => array( 'type' => 'alpha_reservedWord', 'data' => 'from', 'pos' => 13, 'forbidden' => true, ), 3 => array( 'type' => 'alpha_identifier', 'data' => 'aaa', 'pos' => 17, 'forbidden' => false, ), 4 => array( 'type' => 'punct_queryend', 'data' => ';', 'pos' => 0, ), 'len' => 5, ) ), array( 'SELECT * from `aaa`;', array( 'raw' => 'SELECT * from `aaa`;', 0 => array( 'type' => 'alpha_reservedWord', 'data' => 'SELECT', 'pos' => 6, 'forbidden' => true, ), 1 => array( 'type' => 'punct', 'data' => '*', 'pos' => 0, ), 2 => array( 'type' => 'alpha_reservedWord', 'data' => 'from', 'pos' => 13, 'forbidden' => true, ), 3 => array( 'type' => 'quote_backtick', 'data' => '`aaa`', 'pos' => 0, ), 4 => array( 'type' => 'punct_queryend', 'data' => ';', 'pos' => 0, ), 'len' => 5, ) ), array( 'SELECT * from `aaa;', array( 'raw' => 'SELECT * from `aaa`;', 0 => array ( 'type' => 'alpha_reservedWord', 'data' => 'SELECT', 'pos' => 6, 'forbidden' => true, ), 1 => array( 'type' => 'punct', 'data' => '*', 'pos' => 0, ), 2 => array( 'type' => 'alpha_reservedWord', 'data' => 'from', 'pos' => 13, 'forbidden' => true, ), 3 => array( 'type' => 'quote_backtick', 'data' => '`aaa`', 'pos' => 0, ), 4 => array( 'type' => 'punct_queryend', 'data' => ';', 'pos' => 0, ), 'len' => 5, ), '
Automatically appended backtick to the end of query!