2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for parsing of Routine parameters
6 * @package phpMyAdmin-test
10 * Needed for PMA_unQuote() and PMA_SQP_parse()
12 require_once 'libraries/common.lib.php';
13 require_once 'libraries/sqlparser.lib.php';
18 require_once 'libraries/rte/rte_routines.lib.php';
21 class PMA_RTN_parameterParser_test
extends PHPUnit_Framework_TestCase
24 * @dataProvider definer_provider
26 public function test_parseDefiner($source, $target)
29 $this->assertEquals($target, PMA_RTN_parseRoutineDefiner(PMA_SQP_parse($source)));
32 public function definer_provider()
35 array('CREATE PROCEDURE FOO() SELECT NULL', ''),
36 array('CREATE DEFINER=`root`@`localhost` PROCEDURE FOO() SELECT NULL', 'root@localhost'),
37 array('CREATE DEFINER=`root\\`@`localhost` PROCEDURE FOO() SELECT NULL', 'root\\@localhost'),
42 * @dataProvider param_provider
44 public function test_parseOneParameter($source, $target)
47 $this->assertEquals($target, PMA_RTN_parseOneParameter($source));
50 public function param_provider()
53 array('`foo` TEXT', array('', 'foo', 'TEXT', '', '')),
54 array('`foo` INT(20)', array('', 'foo', 'INT', '20', '')),
55 array('DECIMAL(5,5)', array('', '', 'DECIMAL', '5,5', '')),
56 array('IN `fo``fo` INT UNSIGNED', array('IN', 'fo`fo', 'INT', '', 'UNSIGNED')),
57 array('OUT bar VARCHAR(1) CHARSET utf8', array('OUT', 'bar', 'VARCHAR', '1', 'utf8')),
58 array('`"baz\'\'` ENUM(\'a\', \'b\') CHARSET latin1', array('', '"baz\'\'', 'ENUM', '\'a\',\'b\'', 'latin1')),
59 array('INOUT `foo` DECIMAL(5,2) UNSIGNED ZEROFILL', array('INOUT', 'foo', 'DECIMAL', '5,2', 'UNSIGNED ZEROFILL')),
60 array('`foo``s func` SET(\'test\'\'esc"\', \'more\\\'esc\')', array('', 'foo`s func', 'SET', '\'test\'\'esc"\',\'more\\\'esc\'', ''))
65 * @depends test_parseOneParameter
66 * @dataProvider query_provider
68 public function test_parseAllParameters($query, $type, $target)
71 $this->assertEquals($target, PMA_RTN_parseAllParameters(PMA_SQP_parse($query), $type));
74 public function query_provider()
78 'CREATE PROCEDURE `foo`() SET @A=0',
90 'CREATE DEFINER=`user\\`@`somehost``(` FUNCTION `foo```(`baz` INT) BEGIN SELECT NULL; END',
112 'CREATE PROCEDURE `foo`(IN `baz\\)` INT(25) zerofill unsigned) BEGIN SELECT NULL; END',
129 0 => 'UNSIGNED ZEROFILL'
134 'CREATE PROCEDURE `foo`(IN `baz\\` INT(001) zerofill, out bazz varchar(15) charset UTF8) BEGIN SELECT NULL; END',