1
0
mirror of https://github.com/phpmyadmin/phpmyadmin.git synced 2026-10-28 07:41:55 +03:00

add test case for SQL_Validator and SQL_parser

This commit is contained in:
adamgsoc2013
2013-07-04 22:01:53 +08:00
parent d88293632a
commit 48372c19fe
2 changed files with 70 additions and 1 deletions

View File

@@ -0,0 +1,58 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for correctness of SQL validator
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
define('PMA_MYSQL_STR_VERSION', "PMA_MYSQL_STR_VERSION");
global $cfg;
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/Message.class.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/Theme.class.php';
require_once 'libraries/sanitizing.lib.php';
require_once 'libraries/sqlvalidator.class.php';
require_once 'libraries/sqlvalidator.lib.php';
class PMA_SQLValidator_Test extends PHPUnit_Framework_TestCase
{
/**
* Prepares environment for the test.
*
* @return void
*/
public function setUp()
{
if (function_exists('mb_internal_encoding')) {
mb_internal_encoding('utf-8');
}
$_SESSION['PMA_Theme'] = new PMA_Theme();
$GLOBALS['pmaThemeImage'] = 'theme/';
$GLOBALS['cfg']['SQLValidator']['username'] = "PMA_username";
$GLOBALS['cfg']['SQLValidator']['password'] = "PMA_password";
}
public function testPMA_validateSQL()
{
$sql = "select * from PMA_test";
$GLOBALS['cfg']['SQLValidator']['use'] = false;
$this->assertEquals(
'',
PMA_validateSQL($sql)
);
$GLOBALS['cfg']['SQLValidator']['use'] = true;
$GLOBALS['sqlvalidator_error'] = true;
$this->assertContains(
'The SQL validator could not be initialized.',
PMA_validateSQL($sql)
);
}
}
?>