기존 테스트 코드 제거

This commit is contained in:
bnu 2015-04-10 14:44:41 +09:00
parent fc1b891287
commit 8af24d698a
145 changed files with 0 additions and 8875 deletions

View file

@ -1,26 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
if(!defined('__DEBUG__')) define('__DEBUG__', 1);
if(!defined('__XE__')) define('__XE__', true);
if(!defined('__ZBXE__')) define('__ZBXE__', true);
if(!defined('_XE_PATH_')) define('_XE_PATH_', realpath(dirname(__FILE__).'/../').'/');
$_SERVER['SCRIPT_NAME'] = '/xe/index.php';
error_reporting(E_ALL & ~E_NOTICE);
/**
* Print out the message
**/
function _log($msg) {
$args = func_get_args();
foreach($args as $arg) {
fwrite(STDOUT, "\n");
fwrite(STDOUT, print_r($arg, true));
}
fwrite(STDOUT, "\n");
}
/* End of file Bootstrap.php */
/* Location: ./tests/Bootstrap.php */

View file

@ -1,59 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
define('__XE__', 1);
define('_XE_PATH_', realpath(dirname(__FILE__).'/../'));
require _XE_PATH_.'/config/func.inc.php';
class FuncIncTest extends PHPUnit_Framework_TestCase
{
static public function xssProvider()
{
return array(
// remove iframe
array(
'<div class="frame"><iframe src="path/to/file.html"></iframe><p><a href="#iframe">IFrame</a></p></div>',
'<div class="frame">&lt;iframe src="path/to/file.html">&lt;/iframe><p><a href="#iframe">IFrame</a></p></div>'
),
// expression
array(
'<div class="dummy" style="xss:expr/*XSS*/ession(alert(\'XSS\'))">',
'<div class="dummy">'
),
// no quotes and no semicolon - http://ha.ckers.org/xss.html
array(
'<img src=javascript:alert(\'xss\')>',
'<img>'
),
// embedded encoded tab to break up XSS - http://ha.ckers.org/xss.html
array(
'<IMG SRC="jav&#x09;ascript:alert(\'XSS\');">',
'<img>'
),
// issue 178
array(
"<img src=\"invalid\"\nonerror=\"alert(1)\" />",
'<img src="invalid" />'
),
// issue 534
array(
'<img src=\'as"df dummy=\'"1234\'" 4321\' asdf/*/>*/" onerror="console.log(\'Yet another XSS\')">',
'<img src="as&quot;df dummy=" />*/" onerror="console.log(\'Yet another XSS\')">'
),
// issue 602
array(
'<img alt="test" src="(http://static.naver.com/www/u/2010/0611/nmms_215646753.gif" onload="eval(String.fromCharCode(105,61,49,48,48,59,119,104,105,108,101, 40,105,62,48,41,97,108,101,114,116,40,40,105,45,45,41,43,39,48264,47564,32, 45908,32,53364,47533,54616,49464,50836,39,41,59));">',
'<img alt="test" src="(http://static.naver.com/www/u/2010/0611/nmms_215646753.gif">'
)
);
}
/**
* @dataProvider xssProvider
*/
public function testXSS($source, $expected)
{
$result = removeHackTag($source);
$this->assertEquals($result, $expected);
}
}

View file

@ -1,74 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
if(!defined('FOLLOW_REQUEST_SSL')) define('FOLLOW_REQUEST_SSL',0);
if(!defined('ENFORCE_SSL')) define('ENFORCE_SSL',1);
if(!defined('RELEASE_SSL')) define('RELEASE_SSL',2);
if(!defined('MOCK_CONTEXT')) define('MOCK_CONTEXT', 1);
class Context
{
public static $mock_vars = array();
private static $useCdn = 'N';
private static $requestUrl = 'http://www.test.com';
public function gets() {
$args = func_get_args();
$output = new stdClass;
foreach($args as $name) {
$output->{$name} = self::$mock_vars[$name];
}
return $output;
}
public function get($name) {
return array_key_exists($name, self::$mock_vars)?self::$mock_vars[$name]:'';
}
public function getRequestVars() {
return self::$mock_vars;
}
public function set($name, $value) {
self::$mock_vars[$name] = $value;
}
public function getLangType() {
return 'en';
}
public function getLang($str) {
return $str;
}
public function truncate() {
self::$mock_vars = array();
}
public static function setUseCdn($useCdn)
{
self::$useCdn = $useCdn != 'Y' ? 'N':'Y';
}
public static function getDBInfo() {
$dbInfo = new stdClass();
$dbInfo->use_cdn = self::$useCdn;
return $dbInfo;
}
public static function setRequestUrl($url)
{
self::$requestUrl= $url;
}
public static function getRequestUrl() {
return self::$requestUrl;
}
}
/* End of file Context.mock.php */
/* Location: ./tests/classes/context/Context.mock.php */

View file

@ -1,86 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
if(!defined('__XE__')) require dirname(__FILE__).'/../../Bootstrap.php';
require_once _XE_PATH_.'classes/context/Context.class.php';
require_once _XE_PATH_.'classes/handler/Handler.class.php';
require_once _XE_PATH_.'classes/frontendfile/FrontEndFileHandler.class.php';
class ContextTest extends PHPUnit_Framework_TestCase
{
/**
* test whether the singleton works
*/
public function testGetInstance()
{
$this->assertInstanceOf('Context', Context::getInstance());
$this->assertSame(Context::getInstance(), Context::getInstance());
}
public function testSetGetVars()
{
$this->assertSame(Context::get('var1'), null);
Context::set('var1', 'val1');
$this->assertSame(Context::get('var1'), 'val1');
Context::set('var2', 'val2');
$this->assertSame(Context::get('var2'), 'val2');
Context::set('var3', 'val3');
$data = new stdClass;
$data->var1 = 'val1';
$data->var2 = 'val2';
$this->assertEquals(Context::gets('var1','var2'), $data);
$data->var3 = 'val3';
$this->assertEquals(Context::getAll(), $data);
}
public function testAddGetBodyClass()
{
$this->assertEquals(Context::getBodyClass(), '');
Context::addBodyClass('red');
$this->assertEquals(Context::getBodyClass(), ' class="red"');
Context::addBodyClass('green');
$this->assertEquals(Context::getBodyClass(), ' class="red green"');
Context::addBodyClass('blue');
$this->assertEquals(Context::getBodyClass(), ' class="red green blue"');
// remove duplicated class
Context::addBodyClass('red');
$this->assertEquals(Context::getBodyClass(), ' class="red green blue"');
}
public function testRequsetResponseMethod()
{
$this->assertEquals(Context::getRequestMethod(), 'GET');
$_SERVER['REQUEST_METHOD'] = 'POST';
Context::setRequestMethod();
$this->assertEquals(Context::getRequestMethod(), 'POST');
$GLOBALS['HTTP_RAW_POST_DATA'] = 'abcde';
Context::setRequestMethod();
$this->assertEquals(Context::getRequestMethod(), 'XMLRPC');
$_SERVER['CONTENT_TYPE'] = 'application/json';
Context::setRequestMethod();
$this->assertEquals(Context::getRequestMethod(), 'JSON');
Context::setRequestMethod('POST');
$this->assertEquals(Context::getRequestMethod(), 'POST');
$this->assertEquals(Context::getResponseMethod(), 'HTML');
Context::setRequestMethod('JSON');
$this->assertEquals(Context::getResponseMethod(), 'JSON');
Context::setResponseMethod('WRONG_TYPE');
$this->assertEquals(Context::getResponseMethod(), 'HTML');
Context::setResponseMethod('XMLRPC');
$this->assertEquals(Context::getResponseMethod(), 'XMLRPC');
Context::setResponseMethod('HTML');
$this->assertEquals(Context::getResponseMethod(), 'HTML');
}
}
/* End of file ContextTest.php */
/* Location: ./tests/classes/context/ContextTest.php */

View file

@ -1,24 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class Helper {
static function cleanString($query){
$query = trim(preg_replace('/\s+/', ' ',$query));
$query = preg_replace('/\t+/', '',$query);
$query = str_replace(" , ", ', ', $query);
$query = str_replace(" ,", ',', $query);
$query = str_replace("( ", '(', $query);
$query = str_replace(" )", ')', $query);
$query = str_replace(array("\r", "\r\n", "\n"), '*', $query);
$query = strtolower($query);
return $query;
}
static function getXmlObject($xml_file){
$xmlParser = XmlQueryParser::getInstance();
return $xmlParser->getXmlFileContent($xml_file);
}
}
?>

View file

@ -1,321 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
// Only supports queries inside modules for now
class QueryTester {
function QueryTester(){
}
function getQueryPath($type, $name, $query_name){
return _XE_PATH_ . $type ."/".$name."/queries/" . $query_name . ".xml";
}
function getNewParserOutput($xml_file){
$newXmlQueryParser = new XmlQueryParser();
$xml_obj = $newXmlQueryParser->getXmlFileContent($xml_file);
$parser = new QueryParser($xml_obj->query);
return $parser->toString();
}
function getOldParserOutput($query_id, $xml_file){
$cache_file = _TEST_PATH_ . "cache/".$query_id.'.cache.php';
$parser = new OldXmlQueryParser();
$parser->parse($query_id, $xml_file, $cache_file);
$buff = FileHandler::readFile($cache_file);
return $buff;
}
function cleanOutputAndAddArgs($outputString, $argsString = ''){
$outputString = str_replace("<?php if(!defined('__ZBXE__')) exit();", "", $outputString);
$outputString = str_replace("?>", "", $outputString);
$outputString = $argsString . $outputString;
return $outputString;
}
function getXmlFileContent($xml_file){
return FileHandler::readFile($xml_file);
}
function printOutput($output){
if(is_object($output)) {
var_dump($output); return;
}
$output = htmlspecialchars($output, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
$output = preg_replace('/select/i', 'SELECT', $output);
$output = preg_replace('/from/i', '<br/>FROM', $output);
$output = preg_replace('/where/i', '<br/>WHERE', $output);
$output = preg_replace('/group by/i', '<br/>GROUP BY', $output);
$output = preg_replace('/order by/i', '<br/>ORDER BY', $output);
$output = str_replace("\n", "<br/>", $output);
echo '<pre class=prettyprint>'
.$output
.'</pre>';
}
function getNewParserOutputString($xml_file, $argsString){
$outputString = '';
$outputString = $this->getNewParserOutput($xml_file);
$outputString = $this->cleanOutputAndAddArgs($outputString, $argsString);
return $outputString;
}
function getNewParserQuery($outputString){
//echo $outputString;
//exit(0);
$output = eval($outputString);
if(is_a($output, 'Object'))
if(!$output->toBool()) return("Date incorecte! Query-ul nu a putut fi executat.");
$db = new DBCubrid();
if($output->getAction() == 'select')
return $db->getSelectSql($output);
else if($output->getAction() == 'insert')
return $db->getInsertSql($output);
else if($output->getAction() == 'update')
return $db->getUpdateSql($output);
else if($output->getAction() == 'delete')
return $db->getDeleteSql($output);
}
function testNewParser($xml_file, $escape_char, $argsString, $show_output_string){
$outputString = $this->getNewParserOutputString($xml_file, $escape_char, $argsString);
$query = $this->getNewParserQuery($outputString);
echo '<tr>';
if($show_output_string){
echo '<td>';
$this->printOutput($outputString);
echo '</td>';
}
echo '<td>';
$this->printOutput($query);
echo '</td>';
echo '</tr>';
}
function getOldParserOutputString($query_id, $xml_file, $argsString){
$outputString = $this->getOldParserOutput($query_id, $xml_file);
$outputString = $this->cleanOutputAndAddArgs($outputString, $argsString);
return $outputString;
}
function getOldParserQuery($outputString){
$output = eval($outputString);
if(is_a($output, 'Object'))
if(!$output->toBool()) exit("Date incorecte! Query-ul nu a putut fi executat.");
/* SQL Server
*
$db = new DBMssql(false);
if($output->action == "select")
return $db->_executeSelectAct($output);
else if($output->action == "insert")
return $db->_executeInsertAct($output);
else if($output->action == "delete")
return $db->_executeDeleteAct($output);
else if($output->action == "update")
return $db->_executeUpdateAct($output);
*/
/*
* Mysql
*/
$db = new DBMysql(false);
if($output->action == "select")
$db->_executeSelectAct($output);
else if($output->action == "insert")
$db->_executeInsertAct($output);
else if($output->action == "delete")
$db->_executeDeleteAct($output);
else if($output->action == "update")
$db->_executeUpdateAct($output);
return $db->getLatestQuery();
}
function testOldParser($query_id, $xml_file, $argsString, $show_output_string){
$outputString = $this->getOldParserOutputString($query_id, $xml_file, $argsString);
$query = $this->getOldParserQuery($outputString);
echo '<tr>';
if($show_output_string){
echo '<td>';
$this->printOutput($outputString);
echo '</td>';
}
echo '<td>';
$this->printOutput($query);
echo '</td>';
echo '</tr>';
}
function showXmlInputFile($xml_file){
echo '<tr colspan=2>';
echo '<td>';
$xml_file_content = $this->getXmlFileContent($xml_file);
$this->printOutput($xml_file_content);
echo '</td></tr>';
}
function test($query_id, $xml_file, $argsString, $show_output_string, $escape_char = '"'){
echo "<h3>$query_id</h3>";
echo '<table border=1 cellpadding=5 cellspacing=0 width=50%>';
$this->showXmlInputFile($xml_file);
$this->testNewParser($xml_file, $escape_char, $argsString, $show_output_string);
//$this->testOldParser($query_id, $xml_file, $argsString, $show_output_string);
echo '</table>';
}
function test_addon_getAddonInfo($show_output_string = false){
$argsString = '$args->addon = "captcha";';
$this->test("modules.addon.getAddonInfo"
, $this->getQueryPath("modules", "addon", "getAddonInfo")
, $argsString
, $show_output_string);
}
function test_addon_getAddons($show_output_string = false){
$argsString = '';
$this->test("modules.addon.getAddons"
, $this->getQueryPath("modules", "addon", "getAddons")
, $argsString
, $show_output_string);
}
function test_admin_getCommentCount($show_output_string = false){
$argsString = '';
$this->test("modules.admin.getCommentCount"
, $this->getQueryPath("modules", "admin", "getCommentCount")
, $argsString
, $show_output_string);
}
function test_admin_getCommentDeclaredStatus($show_output_string = false){
$argsString = '$args->date = "20110411";';
$this->test("modules.admin.getCommentDeclaredStatus"
, $this->getQueryPath("modules", "admin", "getCommentDeclaredStatus")
, $argsString
, $show_output_string);
}
function test_module_getDefaultModules($show_output_string = false){
$argsString = '';
$this->test("modules.module.getDefaultModules"
, $this->getQueryPath("modules", "module", "getDefaultModules")
, $argsString
, $show_output_string);
}
function test_module_getModuleCategories($show_output_string = false){
$argsString = '';
$this->test("modules.module.getModuleCategories"
, $this->getQueryPath("modules", "module", "getModuleCategories")
, $argsString
, $show_output_string);
}
function test_module_getNonuniqueDomains($show_output_string = false){
$argsString = '';
$this->test("modules.module.getNonuniqueDomains"
, $this->getQueryPath("modules", "module", "getNonuniqueDomains")
, $argsString
, $show_output_string);
}
function test_module_getAdminId($show_output_string = false){
$argsString = '$args->module_srl = 23;';
$this->test("modules.module.getAdminId"
, $this->getQueryPath("modules", "module", "getAdminId")
, $argsString
, $show_output_string);
}
function test_module_getSiteInfo($show_output_string = false){
$argsString = '$args->site_srl = 0;';
$this->test("modules.module.getSiteInfo"
, $this->getQueryPath("modules", "module", "getSiteInfo")
, $argsString
, $show_output_string);
}
function test_module_insertModule($show_output_string = false){
$argsString = ' $args->module_category_srl = 0;
$args->browser_title = "test";
$args->layout_srl = 0;
$args->mlayout_srl = 0;
$args->module = "page";
$args->mid = "test";
$args->site_srl = 0;
$args->module_srl = 47374;';
$this->test("modules.module.insertModule"
, $this->getQueryPath("modules", "module", "insertModule")
, $argsString
, $show_output_string);
}
function test_module_updateModule($show_output_string = false){
$argsString = ' $args->module_category_srl = 0;
$args->browser_title = "test";
$args->layout_srl = 0;
$args->mlayout_srl = 0;
$args->module = "page";
$args->mid = "test";
$args->use_mobile = "";
$args->site_srl = 0;
$args->module_srl = 47374;';
$this->test("modules.module.updateModule"
, $this->getQueryPath("modules", "module", "updateModule")
, $argsString
, $show_output_string);
}
function test_admin_deleteActionForward($show_output_string = false){
$argsString = '$args->module = "page";
$args->type = "page";
$args->act = "tata";';
$this->test("modules.admin.deleteActionForward"
, $this->getQueryPath("modules", "module", "deleteActionForward")
, $argsString
, $show_output_string);
}
function test_member_getAutologin($show_output_string = false){
$argsString = '$args->autologin_key = 10;';
$this->test("modules.member.getAutologin"
, $this->getQueryPath("modules", "member", "getAutologin")
, $argsString
, $show_output_string);
}
function test_opage_getOpageList($show_output_string = false){
$argsString = '$args->s_title = "yuhuu";
$args->module = 12;';
$this->test("modules.opage.getOpageList"
, $this->getQueryPath("modules", "opage", "getOpageList")
, $argsString
, $show_output_string);
}
function test_getPageList($show_output_string = false){
$argsString = '$args->sort_index = "module_srl";
$args->page_count = 10;
$args->s_module_category_srl = 0;
$args->s_mid = "test";
$args->s_browser_title = "caca";';
$this->test("modules.page.getPageList"
, $this->getQueryPath("modules", "page", "getPageList")
, $argsString
, $show_output_string);
}
}
?>

View file

@ -1,93 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Test class for ConditionWithArgument.
*/
class ConditionWithArgumentTest extends CubridTest {
/**
* Checks equal operation
*/
public function testConditionString_Equal_WithoutPipe_NumericValue() {
$member_srl_argument = new ConditionArgument('"member_srl"', 20, 'equal');
$tag = new ConditionWithArgument('"member_srl"', $member_srl_argument, 'equal', null);
$this->assertEquals(' "member_srl" = 20', $tag->toString());
}
/**
* Checks equal operation
*/
public function testConditionString_Equal_WithPipe_NumericValue() {
$member_srl_argument = new ConditionArgument('"member_srl"', 20, 'equal');
$tag = new ConditionWithArgument('"member_srl"', $member_srl_argument, 'equal', 'and');
$this->assertEquals('and "member_srl" = 20', $tag->toString());
}
/**
* Checks condition returns nothing when argument is not valid
*/
public function testConditionString_InvalidArgument() {
$member_srl_argument = new ConditionArgument('"member_srl"', null, 'equal');
$member_srl_argument->checkNotNull();
$tag = new ConditionWithArgument('"member_srl"', $member_srl_argument, 'equal', 'and');
$this->assertEquals('', $tag->toString());
}
/**
* Checks "in" operation
*/
public function testConditionString_In_VarcharArray() {
$member_srl_argument = new ConditionArgument('"member_srl"', array('a', 'b', 'c'), 'in');
$member_srl_argument->createConditionValue();
$member_srl_argument->setColumnType('varchar');
$tag = new ConditionWithArgument('"member_srl"', $member_srl_argument, 'in');
$this->assertEquals(' "member_srl" in (\'a\',\'b\',\'c\')', $tag->toString());
}
/**
* Checks and operation
*/
public function testConditionString_And() {
$tag = new ConditionWithoutArgument('"member_srl"', "20", 'and', null);
$this->assertEquals(' "member_srl" & 20', $tag->toString());
}
/**
* Checks or operation
*/
public function testConditionString_Or() {
$tag = new ConditionWithoutArgument('"member_srl"', "20", 'or', null);
$this->assertEquals(' "member_srl" | 20', $tag->toString());
}
/**
* Checks xor operation
*/
public function testConditionString_Xor() {
$tag = new ConditionWithoutArgument('"member_srl"', "20", 'xor', null);
$this->assertEquals(' "member_srl" ^ 20', $tag->toString());
}
/**
* Checks not operation
*/
public function testConditionString_Not() {
$tag = new ConditionWithoutArgument('"member_srl"', "20", 'not', null);
$this->assertEquals(' "member_srl" ~ 20', $tag->toString());
}
}
?>

View file

@ -1,43 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Test class for Table.
*/
class TableTest extends CubridTest
{
/**
* @var Table
*/
protected $object;
protected function setUp()
{
$this->object = new Table('"xe_member"', '"m"');
}
protected function tearDown()
{
}
public function testToString()
{
$this->assertEquals('"xe_member" as "m"', $this->object->toString());
}
public function testGetName()
{
$this->assertEquals('"xe_member"', $this->object->getName());
}
public function testGetAlias()
{
$this->assertEquals('"m"', $this->object->getAlias());
}
public function testIsJoinTable()
{
$this->assertEquals(false, $this->object->isJoinTable());
}
}
?>

View file

@ -1,281 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Test class for Argument.
* Generated by PHPUnit on 2011-07-07 at 16:51:29.
*/
class ArgumentTest extends CubridTest {
public function testErrorMessageIsSent_NotNullCheck(){
global $lang;
include(_TEST_PATH_ . "classes/xml/xmlquery/argument/data/en.lang.php");
$page_argument = new Argument('page', $args->page);
$page_argument->checkNotNull();
$this->assertFalse($page_argument->isValid());
$this->assertEquals("Please input a value for page", $page_argument->getErrorMessage()->message);
}
public function testErrorMessageIsSent_MinLengthCheck(){
global $lang;
include(_TEST_PATH_ . "classes/xml/xmlquery/argument/data/en.lang.php");
$args->page = '123';
$page_argument = new Argument('page', $args->page);
$page_argument->checkMinLength(6);
$this->assertFalse($page_argument->isValid());
$this->assertEquals("Please align the text length of page", $page_argument->getErrorMessage()->message);
}
public function testErrorMessageIsSent_MaxLengthCheck(){
global $lang;
include(_TEST_PATH_ . "classes/xml/xmlquery/argument/data/en.lang.php");
$args->page = '123';
$page_argument = new Argument('page', $args->page);
$page_argument->checkMaxLength(2);
$this->assertFalse($page_argument->isValid());
$this->assertEquals("Please align the text length of page", $page_argument->getErrorMessage()->message);
}
/**
* @todo Implement testGetType().
*/
public function testGetType() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testSetColumnType().
*/
public function testSetColumnType() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testGetName().
*/
public function testGetName() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testGetValue().
*/
public function testGetValue() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testGetUnescapedValue().
*/
public function testGetUnescapedValue() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testToString().
*/
public function testToString() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testEscapeValue().
*/
public function testEscapeValue() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testIsValid().
*/
public function testIsValid() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testGetErrorMessage().
*/
public function testGetErrorMessage() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testEnsureDefaultValue().
*/
public function testEnsureDefaultValue() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testCheckFilter().
*/
public function testCheckFilter() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testCheckMaxLength().
*/
public function testCheckMaxLength() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testCheckMinLength().
*/
public function testCheckMinLength() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* Checks that argument is valid after a notnull check when value is not null
*/
public function testCheckNotNullWhenNotNull() {
$member_srl_argument = new ConditionArgument('member_srl', 20, 'equal');
$member_srl_argument->checkNotNull();
$this->assertEquals(true, $member_srl_argument->isValid());
}
/**
* Checks that argument becomes invalid after a notnull check when value is null
*/
public function testCheckNotNullWhenNull() {
$member_srl_argument = new ConditionArgument('member_srl', null, 'equal');
$member_srl_argument->checkNotNull();
$this->assertEquals(false, $member_srl_argument->isValid());
}
/**
* Checks that argument value stays the same when both user value and default value are given
*/
public function testCheckDefaultValueWhenNotNull() {
$member_srl_argument = new ConditionArgument('member_srl', 20, 'equal');
$member_srl_argument->ensureDefaultValue(25);
$this->assertEquals(20, $member_srl_argument->getValue());
}
/**
* Checks that argument value gets set when user value is null and default value is specified
*/
public function testCheckDefaultValueWhenNull() {
$member_srl_argument = new ConditionArgument('member_srl', null, 'equal');
$member_srl_argument->ensureDefaultValue(25);
$this->assertEquals(25, $member_srl_argument->getValue());
}
/**
* Checks like prefix operation
*/
public function testCreateConditionValue_LikePrefix() {
$member_srl_argument = new ConditionArgument('"mid"', 'forum', 'like_prefix');
$member_srl_argument->createConditionValue();
$this->assertEquals('\'forum%\'', $member_srl_argument->getValue());
}
/**
* Checks like tail operation
*/
public function testCreateConditionValue_LikeTail() {
$member_srl_argument = new ConditionArgument('"mid"', 'forum', 'like_tail');
$member_srl_argument->createConditionValue();
$this->assertEquals('\'%forum\'', $member_srl_argument->getValue());
}
/**
* Checks like operation
*/
public function testCreateConditionValue_Like() {
$member_srl_argument = new ConditionArgument('"mid"', 'forum', 'like');
$member_srl_argument->createConditionValue();
$this->assertEquals('\'%forum%\'', $member_srl_argument->getValue());
}
/**
* Checks in operation
*/
public function testCreateConditionValue_In_StringValues() {
$member_srl_argument = new ConditionArgument('"mid"', array('forum', 'board'), 'in');
$member_srl_argument->createConditionValue();
$member_srl_argument->setColumnType('varchar');
$this->assertEquals('(\'forum\',\'board\')', $member_srl_argument->getValue());
}
/**
* Checks in operation
*/
public function testCreateConditionValue_In_NumericValues() {
$member_srl_argument = new ConditionArgument('"module_srl"', array(3, 21), 'in');
$member_srl_argument->setColumnType('number');
$member_srl_argument->createConditionValue();
$this->assertEquals('(3,21)', $member_srl_argument->getValue());
}
public function testEnsureDefaultValueWithEmptyString(){
$homepage_argument = new Argument('homepage', '');
$homepage_argument->ensureDefaultValue('');
$homepage_argument->checkFilter('homepage');
if(!$homepage_argument->isValid()) return $homepage_argument->getErrorMessage();
$homepage_argument->setColumnType('varchar');
$this->assertEquals('\'\'', $homepage_argument->getValue());
}
public function testDefaultValue() {
$default = new DefaultValue("var", '');
$this->assertEquals('\'\'', $default->toString());
}
}
?>

View file

@ -1,65 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Test class for ConditionArgument.
*/
class ConditionArgumentTest extends CubridTest {
function testIn(){
$args->document_srl = 1234;
$document_srl_argument = new ConditionArgument('document_srl', $args->document_srl, 'in');
$document_srl_argument->checkNotNull();
$document_srl_argument->createConditionValue();
if(!$document_srl_argument->isValid()) return $document_srl_argument->getErrorMessage();
$document_srl_argument->setColumnType('number');
$condition = new ConditionWithArgument('"extra_vars"."document_srl"',$document_srl_argument,"in", 'and');
$this->assertEquals('and "extra_vars"."document_srl" in (1234)', $condition->toString());
}
function testZeroValue(){
$args->site_srl = 0;
$site_srl_argument = new ConditionArgument('site_srl', $args->site_srl, 'equal');
$site_srl_argument->checkNotNull();
$site_srl_argument->createConditionValue();
if(!$site_srl_argument->isValid()) return $site_srl_argument->getErrorMessage();
$site_srl_argument->setColumnType('number');
$condition = new ConditionWithArgument('"sites"."site_srl"',$site_srl_argument,"equal");
$this->assertEquals(' "sites"."site_srl" = 0', $condition->toString());
}
/**
* @todo Implement testCreateConditionValue().
*/
public function testCreateConditionValue() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testGetType().
*/
public function testGetType() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testSetColumnType().
*/
public function testSetColumnType() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}
?>

View file

@ -1,323 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* @file common/lang/en.lang.php
* @author NAVER (developers@xpressengine.com)
* @brief English Language Pack (Only basic words are included here)
**/
// words for action, which is basically used
$lang->cmd_write = 'Write';
$lang->cmd_reply = 'Reply';
$lang->cmd_delete = 'Delete';
$lang->cmd_modify = 'Modify';
$lang->cmd_edit = 'Edit';
$lang->cmd_view = 'View';
$lang->cmd_view_all = 'View All';
$lang->cmd_list = 'List';
$lang->cmd_prev = 'Prev';
$lang->cmd_next = 'Next';
$lang->cmd_send_trackback = 'Send Trackback';
$lang->cmd_registration = $lang->cmd_submit = 'Submit';
$lang->cmd_comment_registration = 'Add Comment';
$lang->cmd_insert = 'Insert';
$lang->cmd_save = 'Save';
$lang->cmd_load = 'Load';
$lang->cmd_input = 'Input';
$lang->cmd_search = 'Search';
$lang->cmd_find = 'Find';
$lang->cmd_replace = 'Replace';
$lang->cmd_confirm = 'Confirm';
$lang->cmd_cancel = 'Cancel';
$lang->cmd_back = 'Go Back';
$lang->cmd_vote = 'Recommend';
$lang->cmd_vote_down = 'Criticize';
$lang->cmd_declare = 'Accuse';
$lang->cmd_cancel_declare = 'Cancel Accuse';
$lang->cmd_declared_list = 'Accusations List';
$lang->cmd_copy = 'Copy';
$lang->cmd_move = 'Move';
$lang->cmd_move_up = 'Up';
$lang->cmd_move_down = 'Down';
$lang->cmd_add_indent = 'Indent';
$lang->cmd_remove_indent = 'Outdent';
$lang->cmd_management = 'Manage';
$lang->cmd_make = 'Create';
$lang->cmd_select = 'Select';
$lang->cmd_select_all = 'Select All';
$lang->cmd_unselect_all = 'Deselect All';
$lang->cmd_reverse_all = 'Reverse';
$lang->cmd_close_all = 'Close All';
$lang->cmd_open_all = 'Open All';
$lang->cmd_reload = 'Reload';
$lang->cmd_close = 'Close';
$lang->cmd_open = 'Open';
$lang->cmd_setup = 'Configure';
$lang->cmd_addition_setup = 'Additional Setup';
$lang->cmd_option = 'Option';
$lang->cmd_apply = 'Apply';
$lang->cmd_open_calendar = 'Select a Date';
$lang->cmd_send = 'Send';
$lang->cmd_print = 'Print';
$lang->cmd_scrap = 'Scrap';
$lang->cmd_preview = 'Preview';
$lang->cmd_reset = 'Reset';
$lang->cmd_remake_cache = "Re-create cache file";
$lang->cmd_publish = "Publish";
$lang->cmd_layout_setup = 'Configure layout';
$lang->cmd_layout_edit = 'Edit layout';
$lang->cmd_search_by_ipaddress = 'Search by IP Address';
$lang->cmd_add_ip_to_spamfilter = 'Add IP to spamfilter';
$lang->enable = 'Enable';
$lang->disable = 'Disable';
// Essential Words
$lang->menu = 'Menu';
$lang->no = 'No.';
$lang->notice = 'Notice';
$lang->secret = 'Secret';
$lang->category = $lang->category_srl = 'Category';
$lang->none_category = 'None category';
$lang->none_image = 'Image does not exist';
$lang->document_srl = 'Doc. No.';
$lang->user_id = 'User ID';
$lang->author = 'Developer';
$lang->password = 'Password';
$lang->password1 = 'Password';
$lang->password2 = 'Retype Password';
$lang->admin_id = 'Admin ID';
$lang->writer = 'Author';
$lang->user_name = 'User Name';
$lang->nick_name = 'Nick Name';
$lang->email_address = 'Email';
$lang->homepage = 'Homepage';
$lang->blog = 'Blog';
$lang->birthday = 'Birthday';
$lang->browser_title = 'Browser Title';
$lang->title = 'Subject';
$lang->title_content = 'Subject+Content';
$lang->topic = 'Topic';
$lang->replies = 'Reply';
$lang->content = 'Content';
$lang->document = 'Article';
$lang->comment = 'Comment';
$lang->description = 'Description';
$lang->trackback = 'Trackback';
$lang->tag = 'Tag';
$lang->allow_comment = 'Allow Comments';
$lang->lock_comment = 'Block Comments';
$lang->allow_trackback = 'Allow Trackbacks';
$lang->uploaded_file = 'Attachment';
$lang->grant = 'Permission';
$lang->target = 'Target';
$lang->total = 'Total';
$lang->total_count = 'Count Total';
$lang->ipaddress = 'IP Address';
$lang->path = 'Path';
$lang->cart = 'Selected Item';
$lang->friend = 'Friends';
$lang->notify = 'Notification';
$lang->order_target = 'Align Target';
$lang->order_type = 'Sorting Type';
$lang->order_asc = 'ascend';
$lang->order_desc = 'descend';
$lang->file = 'file';
$lang->mid = 'Module Name';
$lang->sid = 'Site Name';
$lang->layout = 'Layout';
$lang->mobile_layout = 'Mobile Layout';
$lang->widget = 'Widget';
$lang->module = 'Module';
$lang->skin = 'Theme';
$lang->mobile_skin = 'Mobile Theme';
$lang->colorset = 'Colorset';
$lang->extra_vars = 'Extra Vars';
$lang->domain = "Domain Name";
$lang->url = "URL";
$lang->document_url = 'Article URL';
$lang->trackback_url = 'Trackback URL';
$lang->blog_name = 'Blog Title';
$lang->excerpt = 'Quotation';
$lang->document_count = 'Total Articles';
$lang->page_count = 'Page Count';
$lang->list_count = 'List Count';
$lang->search_list_count = 'Search List Count';
$lang->readed_count = 'Views';
$lang->voted_count = 'Votes';
$lang->comment_count = 'Comments';
$lang->member_count = 'Member Count';
$lang->date = 'Date';
$lang->regdate = 'Registered Date';
$lang->last_update = 'Last Update';
$lang->last_post = 'Last Post';
$lang->signup_date = 'Sign up Date';
$lang->last_login = 'Last Sign in';
$lang->first_page = 'First Page';
$lang->last_page = 'Last Page';
$lang->search_target = 'Target for Search';
$lang->search_keyword = 'Keyword';
$lang->is_default = 'Default';
$lang->no_documents = 'No Articles';
$lang->board_manager = 'Board Settings';
$lang->member_manager = 'Member Settings';
$lang->layout_manager = 'Layout Settings';
$lang->use = 'Use';
$lang->notuse = 'Not use';
$lang->not_exists = "Doesn't exist";
$lang->public = 'public';
$lang->private = 'private';
$lang->unit_sec = 'sec';
$lang->unit_min = 'min';
$lang->unit_hour = 'hr';
$lang->unit_day = 'th';
$lang->unit_month = 'month';
$lang->unit_year = 'year';
$lang->unit_week = array(
'Monday' => 'Monday',
'Tuesday' => 'Tuesday',
'Wednesday' => 'Wednesday',
'Thursday' => 'Thursday',
'Friday' => 'Friday',
'Saturday' => 'Saturday',
'Sunday' => 'Sunday',
);
$lang->unit_meridiem = array(
'am' => 'am',
'pm' => 'pm',
'AM' => 'AM',
'PM' => 'PM',
);
$lang->time_gap = array(
'min' => '%d minute ago',
'mins' => '%d minutes ago',
'hour' => '%d hour ago',
'hours' => '%d hours ago',
);
// Descriptions
$lang->about_tag = 'You may submit multiple tags by inserting commas(,) between each tag';
$lang->about_layout = 'Layouts decorate the appearance of your modules. you can configure them from Layout menu on the top';
// Messages
$lang->msg_call_server = 'Requesting to the server, please wait';
$lang->msg_db_not_setted = 'DB configuration has not been set';
$lang->msg_dbconnect_failed = "Error has occurred while connecting DB.\nPlease check DB information again";
$lang->msg_invalid_queryid = 'Specified query ID value is invalid';
$lang->msg_not_permitted = 'You do not have permission to access';
$lang->msg_input_password = 'Please input the password';
$lang->msg_invalid_document = 'Invalid Article Number';
$lang->msg_invalid_request = 'Invalid Request';
$lang->msg_invalid_password = 'Invalid Password';
$lang->msg_error_occured = 'An error has occured';
$lang->msg_not_founded = 'Target could not be found';
$lang->msg_no_result = 'Nothing found';
$lang->msg_fail_to_request_open = 'Fail to open your request';
$lang->msg_invalid_format = 'Invalid Format';
$lang->msg_not_permitted_act = 'You do not have permission to execute requested action';
$lang->msg_module_does_not_exist = "Couldn't find the requested module.\nPlease contact the administrator.";
$lang->msg_module_is_not_standalone = 'Requested module cannot be executed independently';
$lang->msg_default_url_is_not_defined = 'Default URL is not defined';
$lang->success_registed = 'Registered successfully';
$lang->success_declared = 'Accused successfully';
$lang->success_updated = 'Updated successfully';
$lang->success_deleted = 'Deleted successfully';
$lang->success_voted = 'Recommended successfully';
$lang->success_blamed = 'Blamed successfully';
$lang->success_moved = 'Moved successfully';
$lang->success_sended = 'Sent successfully';
$lang->success_reset = 'Reset successfully';
$lang->success_leaved = 'All member data have been deleted completely.';
$lang->success_saved = 'Saved successfully';
$lang->fail_to_delete = 'Could not be deleted';
$lang->fail_to_move = 'Could not be moved';
$lang->failed_voted = 'Could not recommend';
$lang->failed_blamed = 'Could not blame';
$lang->failed_declared = 'Could not accuse';
$lang->fail_to_delete_have_children = 'Please try again after removing replies first';
$lang->confirm_submit = 'Are you sure to submit?';
$lang->confirm_logout = 'Are you sure to logout?';
$lang->confirm_vote = 'Are you sure to recommend?';
$lang->confirm_delete = 'Are you sure to delete?';
$lang->confirm_move = 'Are you sure to move?';
$lang->confirm_reset = 'Are you sure to reset?';
$lang->confirm_leave = 'Are you sure to leave?';
$lang->confirm_update = 'Are you sure to update?';
$lang->column_type = 'Column Type';
$lang->column_type_list['text'] = 'one-line text';
$lang->column_type_list['homepage'] = 'url';
$lang->column_type_list['email_address'] = 'email';
$lang->column_type_list['tel'] = 'phone number';
$lang->column_type_list['textarea'] = 'multi-line textarea';
$lang->column_type_list['checkbox'] = 'checkbox (multiple selection)';
$lang->column_type_list['select'] = 'select box (single selection)';
$lang->column_type_list['radio'] = 'radio button (radio)';
$lang->column_type_list['kr_zip'] = 'zip code (Korean)';
$lang->column_type_list['date'] = 'date (yyyy/mm/dd)';
//$lang->column_type_list['jp_zip'] = 'zip code (Japanese)';
$lang->column_name = 'Column Name';
$lang->column_title = 'Column Title';
$lang->default_value = 'Default Value';
$lang->is_active = 'Active';
$lang->is_required = 'Required Field';
$lang->eid = 'Name of extra variable';
// ftp-related
$lang->ftp_form_title = 'FTP Account Information';
$lang->ftp = 'FTP';
$lang->ftp_host = 'FTP hostname';
$lang->ftp_port = 'FTP port';
$lang->about_ftp_password = 'FTP password will not be stored';
$lang->cmd_check_ftp_connect = 'Check FTP Connection';
$lang->about_ftp_info = "
FTP account information can be used in following cases. <br />
1. If safe_mode setting of PHP is on, XE will be installed using FTP. <br />
2. Automatic updates might use FTP information. <br />
This account info will be stored in files/config/ftp.config.php <br />
After installation, you can modify or delete the account info at the administration page. <br />
";
$lang->msg_safe_mode_ftp_needed = "If safe_mode setting of PHP is on, you should input FTP account information to install XE.";
$lang->msg_ftp_not_connected = "Connection to localhost via FTP failed. Please check the port number and if FTP service is available.";
$lang->msg_ftp_invalid_auth_info = "Authentication failed. Please check the username and password.";
$lang->msg_ftp_mkdir_fail = "Directory creation failed. Please check the permission of FTP account.";
$lang->msg_ftp_chmod_fail = "Chmod failed. Please check the permission and configuration of FTP server.";
$lang->msg_ftp_connect_success = "Connection and authentication to the FTP server succeeded.";
$lang->ftp_path_title = 'FTP Path Information';
$lang->msg_ftp_installed_realpath = 'Absolute Path of XE';
$lang->msg_ftp_installed_ftp_realpath = 'Absolute FTP Path of XE';
// Alert messages for Javascript using by XML filter
$lang->filter->isnull = 'Please input a value for %s';
$lang->filter->outofrange = 'Please align the text length of %s';
$lang->filter->equalto = "The value of %s is invalid";
$lang->filter->invalid_email = "The format of %s is invalid. ex) developers@xpressengine.com";
$lang->filter->invalid_user_id = $lang->filter->invalid_userid = "The format of %s is invalid.\\nAll values should consist of alphabets, numbers or underscore(_) and the first letter should be alphabet";
$lang->filter->invalid_homepage = "The format of %s is invalid. ex) http://xpressengine.com/";
$lang->filter->invalid_korean = "The format of %s is invalid. Please input Korean only";
$lang->filter->invalid_korean_number = "The format of %s is invalid. Please input Korean or numbers";
$lang->filter->invalid_alpha = "The format of %s is invalid. Please input alphabets only";
$lang->filter->invalid_alpha_number = "The format of %s is invalid. Please input alphabets or numbers";
$lang->filter->invalid_number = "The format of %s is invalid. Please input numbers only";
$lang->security_warning_embed = "Due to security concern, administrators are not allowed to view embedded items.<BR /> To view them, please use another non-administrator ID.";
$lang->msg_pc_to_mobile = '이 페이지는 모바일 보기가 있습니다. 모바일 보기로 이동하시겠습니까?';
?>

View file

@ -1,16 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Test class for QueryArgument.
*/
class QueryArgumentTest extends CubridTest {
var $xmlPath = "data/";
function QueryArgumentTest(){
$this->xmlPath = str_replace('QueryArgumentTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
}
}
?>

View file

@ -1 +0,0 @@
<condition operation="equal" column="member_srl" var="member_srl" notnull="notnull" />

View file

@ -1 +0,0 @@
<index var="sort_index" default="list_order" order="order_type" />

View file

@ -1,88 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Test class for ConditionTag.
*/
class ConditionTagTest extends CubridTest {
var $xmlPath = "data/";
function ConditionTagTest(){
$this->xmlPath = str_replace('ConditionTagTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
}
/**
* Tests a simple <condition> tag:
* <condition operation="equal" column="user_id" var="user_id" />
*/
function testConditionStringWithArgument(){
$xml_file = $this->xmlPath . "condition1.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new ConditionTag($xml_obj->condition);
$arguments = $tag->getArguments();
$expected = "new ConditionWithArgument('\"user_id\"',\$" . $arguments[0]->getArgumentName() . "_argument,\"equal\")";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
$this->assertEquals(1, count($arguments));
}
/**
* Tests a condition tag for joins - that uses no argument
* <condition operation="equal" column="comments.user_id" default="member.user_id" filter="userid" />
*/
function testConditionStringWithoutArgument(){
$xml_file = $this->xmlPath . "condition3.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new ConditionTag($xml_obj->condition);
$expected = "new ConditionWithoutArgument('\"comments\".\"user_id\"','\"member\".\"user_id\"',\"equal\")";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
$arguments = $tag->getArguments();
$this->assertEquals(0, count($arguments));
}
/**
* Tests a <condition> tag with pipe:
* <condition operation="equal" column="type" var="type" notnull="notnull" pipe="and" />
*/
function testConditionStringWithPipe(){
$xml_file = $this->xmlPath . "condition2.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new ConditionTag($xml_obj->condition);
$arguments = $tag->getArguments();
$expected = "new ConditionWithArgument('\"type\"',\$" . $arguments[0]->getArgumentName() . "_argument,\"equal\", 'and')";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
$this->assertEquals(1, count($arguments));
}
/**
* Tests that even if the column name is given in the var attribute, it knows it's just a name and not an argument
* <condition operation="equal" column="modules.module_srl" var="documents.module_srl" pipe="and" />
*/
function testConditionStringWithoutArgumentAndDefaultValueInsideVar(){
$xml_file = $this->xmlPath . "condition4.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new ConditionTag($xml_obj->condition);
$expected = "new ConditionWithoutArgument('\"modules\".\"module_srl\"','\"documents\".\"module_srl\"',\"equal\", 'and')";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
$arguments = $tag->getArguments();
$this->assertEquals(0, count($arguments));
}
}
?>

View file

@ -1 +0,0 @@
<condition operation="equal" column="user_id" var="user_id" />

View file

@ -1 +0,0 @@
<condition operation="equal" column="type" var="type" notnull="notnull" pipe="and" />

View file

@ -1 +0,0 @@
<condition operation="equal" column="comments.user_id" default="member.user_id" filter="userid" />

View file

@ -1 +0,0 @@
<condition operation="equal" column="modules.module_srl" var="documents.module_srl" pipe="and" />

View file

@ -1,133 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Test class for TableTag.
*/
class TableTagTest extends CubridTest {
var $xmlPath = "data/";
function TableTagTest(){
$this->xmlPath = str_replace('TableTagTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
}
/**
* Tests a simple <table> tag:
* <table name="modules" />
*/
function testTableTagWithName(){
$xml_file = $this->xmlPath . "table_name.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TableTag($xml_obj->table);
$expected = "new Table('\"xe_modules\"', '\"modules\"')";
$actual = $tag->getTableString();
$this->assertEquals($expected, $actual);
}
/**
* Tests a <table> tag with name and alias
* <table name="modules" alias="mod" />
*/
function testTableTagWithNameAndAlias(){
$xml_file = $this->xmlPath . "table_name_alias.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TableTag($xml_obj->table);
$expected = "new Table('\"xe_modules\"', '\"mod\"')";
$actual = $tag->getTableString();
$this->assertEquals($expected, $actual);
}
/**
* Tests a <table> tag used for joins
* <table name="module_categories" alias="module_categories" type="left join">
* <conditions>
* <condition operation="equal" column="module_categories.module_category_srl" default="modules.module_category_srl" />
* </conditions>
* </table>
*
*/
function testTableTagWithJoinCondition(){
$xml_file = $this->xmlPath . "table_name_alias_type.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TableTag($xml_obj->table);
$actual = $tag->getTableString();
$expected = 'new JoinTable(\'"xe_module_categories"\', \'"module_categories"\', "left join", array(
new ConditionGroup(array(
new ConditionWithoutArgument(\'"module_categories"."module_category_srl"\',\'"modules"."module_category_srl"\',"equal")
))
))';
$actual = Helper::cleanString($actual);
$expected = Helper::cleanString($expected);
$this->assertEquals($expected, $actual);
}
/**
* If a table tag has the type attribute and condition children
* it means it is meant to be used inside a join
*/
function testTagWithTypeIsJoinTable(){
$xml_file = $this->xmlPath . "table_name_alias_type.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TableTag($xml_obj->table);
$this->assertEquals(true, $tag->isJoinTable());
}
/**
* Tests that a simple table tag is not a join table
*/
function testTagWithoutTypeIsNotJoinTable(){
$xml_file = $this->xmlPath . "table_name_alias.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TableTag($xml_obj->table);
$this->assertEquals(false, $tag->isJoinTable());
}
/**
* If no alias is specified, test that table name is used
*/
function testTableAliasWhenAliasNotSpecified(){
$xml_file = $this->xmlPath . "table_name.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TableTag($xml_obj->table);
$this->assertEquals("modules", $tag->getTableAlias());
}
/**
* If alias is specified, test that it is used
*/
function testTableAliasWhenAliasSpecified(){
$xml_file = $this->xmlPath . "table_name_alias.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TableTag($xml_obj->table);
$this->assertEquals("mod", $tag->getTableAlias());
}
/**
* Table name propery should returned unescaped and unprefixed table name
* (The one in the XML file)
*/
function testTableName(){
$xml_file = $this->xmlPath . "table_name_alias.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TableTag($xml_obj->table);
$this->assertEquals("modules", $tag->getTableName());
}
}

View file

@ -1,113 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Test class for TablesTag.
*/
class TablesTagTest extends CubridTest {
var $xmlPath = "data/";
function TablesTagTest(){
$this->xmlPath = str_replace('TablesTagTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
}
/**
* Tests a simple <tables> tag:
* <tables>
* <table name="member" />
* </tables>
*/
function testTablesTagWithOneTable(){
$xml_file = $this->xmlPath . "tables_one_table.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TablesTag($xml_obj->tables);
$expected = "array(new Table('\"xe_member\"', '\"member\"'))";
$actual = $tag->toString();
$this->_testCachedOutput($expected, $actual);
}
/**
* Tests a simple <tables> tag:
* <tables>
* <table name="member_group" alias="a" />
* <table name="member_group_member" alias="b" />
* </tables>
*/
function testTablesTagWithTwoTablesNoJoin(){
$xml_file = $this->xmlPath . "tables_two_tables_no_join.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TablesTag($xml_obj->tables);
$expected = "array(
new Table('\"xe_member_group\"', '\"a\"')
,new Table('\"xe_member_group_member\"', '\"b\"')
)";
$actual = $tag->toString();
$this->_testCachedOutput($expected, $actual);
}
/**
* Tests a simple <tables> tag:
* <tables>
* <table name="files" alias="files" />
* <table name="member" alias="member" type="left join">
* <conditions>
* <condition operation="equal" column="files.member_srl" default="member.member_srl" />
* </conditions>
* </table>
* </tables>
*/
function testTablesTagWithTwoTablesWithJoin(){
$xml_file = $this->xmlPath . "tables_two_tables_with_join.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TablesTag($xml_obj->tables);
$expected = "array(
new Table('\"xe_files\"', '\"files\"')
,new JoinTable('\"xe_member\"'
, '\"member\"'
, \"left join\"
, array(
new ConditionGroup(
array(
new ConditionWithoutArgument(
'\"files\".\"member_srl\"'
,'\"member\".\"member_srl\"'
,\"equal\"
)
)
)
)
)
)";
$actual = $tag->toString();
$this->_testCachedOutput($expected, $actual);
}
/**
* Tests a simple <tables> tag:
* <tables>
* <table name="files" alias="files" />
* <table name="member" alias="member" type="left join">
* <conditions>
* <condition operation="equal" column="files.member_srl" default="member.member_srl" />
* </conditions>
* </table>
* </tables>
*/
function testGetTables(){
$xml_file = $this->xmlPath . "tables_two_tables_with_join.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TablesTag($xml_obj->tables);
$tables = $tag->getTables();
$this->assertEquals(2, count($tables));
$this->assertTrue(is_a($tables[0], 'TableTag'));
$this->assertTrue(is_a($tables[1], 'TableTag'));
}
}

View file

@ -1 +0,0 @@
<table name="modules" />

View file

@ -1 +0,0 @@
<table name="modules" alias="mod" />

View file

@ -1,5 +0,0 @@
<table name="module_categories" alias="module_categories" type="left join">
<conditions>
<condition operation="equal" column="module_categories.module_category_srl" default="modules.module_category_srl" />
</conditions>
</table>

View file

@ -1,3 +0,0 @@
<tables>
<table name="member" />
</tables>

View file

@ -1,4 +0,0 @@
<tables>
<table name="member_group" alias="a" />
<table name="member_group_member" alias="b" />
</tables>

View file

@ -1,8 +0,0 @@
<tables>
<table name="files" alias="files" />
<table name="member" alias="member" type="left join">
<conditions>
<condition operation="equal" column="files.member_srl" default="member.member_srl" />
</conditions>
</table>
</tables>

View file

@ -1,64 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
error_reporting(E_ALL ^ E_NOTICE);
define('_XE_PATH_', str_replace('tests/classes/db/config/config.inc.php', '', str_replace('\\', '/', __FILE__)));
define('_TEST_PATH_', _XE_PATH_ . 'tests/classes/db/');
if(!defined('__DEBUG__')) define('__DEBUG__', 4);
define('__ZBXE__', true);
define('__XE__', true);
require_once(_TEST_PATH_.'Helper.class.php');
require_once(_TEST_PATH_.'QueryTester.class.php');
require_once(_TEST_PATH_.'db/DBTest.php');
require_once(_TEST_PATH_.'db/CubridTest.php');
require_once(_TEST_PATH_.'db/CubridOnlineTest.php');
require_once(_TEST_PATH_.'db/MssqlTest.php');
require_once(_TEST_PATH_.'db/MssqlOnlineTest.php');
require_once(_TEST_PATH_.'db/MysqlTest.php');
require_once(_TEST_PATH_.'db/SqliteTest.php');
require_once(_XE_PATH_.'config/config.inc.php');
require_once(_XE_PATH_.'classes/xml/XmlQueryParser.class.php');
require_once(_XE_PATH_.'classes/db/DB.class.php');
require_once(_XE_PATH_.'classes/db/DBCubrid.class.php');
require_once(_XE_PATH_.'classes/db/DBMssql.class.php');
require_once(_XE_PATH_.'classes/db/DBMysql.class.php');
require_once(_TEST_PATH_.'db/MockDb.php');
require_once(_XE_PATH_.'classes/xml/xmlquery/DBParser.class.php');
require_once(_XE_PATH_.'classes/xml/xmlquery/argument/Argument.class.php');
require_once(_XE_PATH_.'classes/xml/xmlquery/argument/SortArgument.class.php');
require_once(_XE_PATH_.'classes/xml/xmlquery/argument/ConditionArgument.class.php');
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/DefaultValue.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/expression/Expression.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/expression/SelectExpression.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/expression/InsertExpression.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpression.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/expression/ClickCountExpression.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/table/Table.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/table/JoinTable.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/table/CubridTableWithHint.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/table/MysqlTableWithHint.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/table/MssqlTableWithHint.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/table/IndexHint.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/condition/ConditionGroup.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/condition/Condition.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/condition/ConditionWithArgument.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/condition/ConditionWithoutArgument.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/condition/ConditionSubquery.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/expression/StarExpression.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/order/OrderByColumn.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/limit/Limit.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/Query.class.php');
require_once(_XE_PATH_.'classes/db/queryparts/Subquery.class.php');
require_once(_XE_PATH_.'classes/xml/xmlquery/tags/table/TableTag.class.php');
require_once(_XE_PATH_.'classes/xml/xmlquery/tags/table/HintTableTag.class.php');
require_once(_XE_PATH_.'classes/xml/xmlquery/tags/condition/ConditionTag.class.php');
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/QueryArgument.class.php');
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/SortQueryArgument.class.php');

View file

@ -1,50 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Base class for tests for CUBRID SQL syntax
*/
class CubridOnlineTest extends PHPUnit_Framework_TestCase {
protected $backupGlobals = FALSE;
protected $backupStaticAttributes = FALSE;
protected $preserveGlobalState = FALSE;
/**
* Prepare runtime context - tell DB class that current DB is CUBRID
*/
protected function setUp() {
$this->markTestSkipped();
$oContext = &Context::getInstance();
$db_info->master_db = array('db_type' => 'cubrid'
,'db_port' => '33000'
,'db_hostname' => '10.0.0.206'
,'db_userid' => 'dba'
,'db_password' => 'arniarules'
,'db_database' => 'xe15QA'
,'db_table_prefix' => 'xe_');
$db_info->slave_db = array(array('db_type' => 'cubrid'
,'db_port' => '33000'
,'db_hostname' => '10.0.0.206'
,'db_userid' => 'dba'
,'db_password' => 'arniarules'
,'db_database' => 'xe15QA'
,'db_table_prefix' => 'xe_'));
$oContext->setDbInfo($db_info);
// remove cache dir
FileHandler::removeDir( _XE_PATH_ . 'files/cache');
DB::getParser(true);
}
/**
* Free resources - reset static DB and QueryParser
*/
protected function tearDown() {
unset($GLOBALS['__DB__']);
}
}
?>

View file

@ -1,32 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Base class for tests for CUBRID SQL syntax
*/
class CubridTest extends DBTest {
/**
* Prepare runtime context - tell DB class that current DB is CUBRID
*/
protected function setUp() {
$oContext = &Context::getInstance();
$db_info->master_db = array('db_type' => 'cubrid','db_table_prefix' => 'xe_');
$db_info->slave_db = array(array('db_type' => 'cubrid','db_table_prefix' => 'xe_'));
$oContext->setDbInfo($db_info);
$db = new MockDb();
$db->getParser(true);
}
/**
* Free resources - reset static DB and QueryParser
*/
protected function tearDown() {
unset($GLOBALS['__DB__']);
}
}
?>

View file

@ -1,75 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class DBTest extends PHPUnit_Framework_TestCase {
function _testQuery($xml_file, $argsString, $expected, $methodName, $columnList = null){
echo PHP_EOL . ' ----------------------------------- ' .PHP_EOL;
echo $xml_file;
echo PHP_EOL . ' ----------------------------------- ' .PHP_EOL;
$tester = new QueryTester();
$outputString = $tester->getNewParserOutputString($xml_file, $argsString);
echo $outputString;
$output = eval($outputString);
if(!is_a($output, 'Query')){
if(!$output->toBool()) $querySql = "Date incorecte! Query-ul nu a putut fi executat.";
}else {
$db = &DB::getInstance();
if($columnList) $output->setColumnList($columnList);
$querySql = $db->{$methodName}($output);
// Remove whitespaces, tabs and all
if(is_a($querySql, 'Object'))
{
$querySql = $querySql->getMessage();
}
$querySql = Helper::cleanString($querySql);
$expected = Helper::cleanString($expected);
}
$this->assertEquals($expected, $querySql);
}
function _testPreparedQuery($xml_file, $argsString, $expected, $methodName, $expectedArgs = NULL){
echo PHP_EOL . ' ----------------------------------- ' .PHP_EOL;
echo $xml_file;
echo PHP_EOL . ' ----------------------------------- ' .PHP_EOL;
$tester = new QueryTester();
$outputString = $tester->getNewParserOutputString($xml_file, $argsString);
echo $outputString;
$output = eval($outputString);
if(!is_a($output, 'Query')){
if(!$output->toBool()) $querySql = "Date incorecte! Query-ul nu a putut fi executat.";
}else {
$db = &DB::getInstance();
$querySql = $db->{$methodName}($output, false);
$queryArguments = $output->getArguments();
// Remove whitespaces, tabs and all
$querySql = Helper::cleanString($querySql);
$expected = Helper::cleanString($expected);
}
// Test
$this->assertEquals($expected, $querySql);
// Test query arguments
$argCount = count($expectedArgs);
for($i = 0; $i < $argCount; $i++){
$this->assertEquals($expectedArgs[$i], $queryArguments[$i]->getEscapedValue());
}
}
function _testCachedOutput($expected, $actual){
$expected = Helper::cleanString($expected);
$actual = Helper::cleanString($actual);
$this->assertEquals($expected, $actual);
}
}
?>

View file

@ -1,110 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class ExpressionParserTest extends PHPUnit_Framework_TestCase {
/* Escape char for:
* CUBRID ""
* MySql ``
* SqlServer []
*/
var $dbLeftEscapeChar = '[';
var $dbRightEscapeChar = ']';
function _test($column_name, $alias, $expected){
$expressionParser = new DBParser($this->dbLeftEscapeChar,$this->dbRightEscapeChar);
$actual = $expressionParser->parseExpression($column_name);
if($alias) $actual .= " as $alias";
$this->assertEquals($expected, $actual);
}
function testStarExpressionIsNotEscaped(){
$this->_test("*", NULL, '*');
}
function testSimpleColumnNameGetsEscaped(){
$this->_test("member_srl", NULL
, $this->dbLeftEscapeChar.'member_srl'.$this->dbRightEscapeChar );
}
function testUnqualifiedAliasedColumnNameGetsEscaped(){
$this->_test("member_srl", "id"
, $this->dbLeftEscapeChar.'member_srl'.$this->dbRightEscapeChar.' as id');
}
function testQualifiedColumnNameGetsEscaped(){
$this->_test("xe_members.member_srl", NULL
, $this->dbLeftEscapeChar.'xe_members'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'member_srl'.$this->dbRightEscapeChar);
}
function testQualifiedAliasedColumnNameGetsEscaped(){
$this->_test("xe_members.member_srl","id"
,$this->dbLeftEscapeChar.'xe_members'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'member_srl'.$this->dbRightEscapeChar.' as id');
}
function testCountDoesntGetEscaped(){
$this->_test("count(*)", NULL, 'count(*)');
}
function testAliasedCountDoesntGetEscaped(){
$this->_test("count(*)", "count", 'count(*) as count');
}
function testUnqualifiedColumnExpressionWithOneParameterLessFunction(){
$this->_test("substring(regdate)", NULL
, 'substring('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.')');
}
function testAliasedUnqualifiedColumnExpressionWithOneParameterLessFunction(){
$this->_test("substring(regdate)", "regdate"
, 'substring('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.') as regdate');
}
function testQualifiedColumnExpressionWithOneParameterLessFunction(){
$this->_test("substring(xe_member.regdate)", NULL
, 'substring('.$this->dbLeftEscapeChar.'xe_member'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.')');
}
function testAliasedQualifiedColumnExpressionWithOneParameterLessFunction(){
$this->_test("substring(xe_member.regdate)", "regdate"
, 'substring('.$this->dbLeftEscapeChar.'xe_member'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.') as regdate');
}
function testUnqualifiedColumnExpressionWithTwoParameterLessFunctions(){
$this->_test("lpad(rpad(regdate))", NULL
, 'lpad(rpad('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.'))');
}
function testAliasedUnqualifiedColumnExpressionWithTwoParameterLessFunctions(){
$this->_test("lpad(rpad(regdate))", "regdate"
, 'lpad(rpad('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.')) as regdate');
}
function testQualifiedColumnExpressionWithTwoParameterLessFunctions(){
$this->_test("lpad(rpad(xe_member.regdate))", NULL
, 'lpad(rpad('.$this->dbLeftEscapeChar.'xe_member'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.'))');
}
function testAliasedQualifiedColumnExpressionWithTwoParameterLessFunctions(){
$this->_test("lpad(rpad(xe_member.regdate))", "regdate"
, 'lpad(rpad('.$this->dbLeftEscapeChar.'xe_member'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.')) as regdate');
}
function testColumnAddition(){
$this->_test("score1 + score2", "total"
, $this->dbLeftEscapeChar.'score1'.$this->dbRightEscapeChar.' + '.$this->dbLeftEscapeChar.'score2'.$this->dbRightEscapeChar.' as total');
}
function testMultipleParameterFunction(){
$this->_test("substring(regdate, 1, 8)", NULL
, 'substring('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.', 1, 8)');
$this->_test("substring(regdate, 1, 8)", "regdate"
, 'substring('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.', 1, 8) as regdate');
$this->_test("substring(xe_member.regdate, 1, 8)", NULL
, 'substring('.$this->dbLeftEscapeChar.'xe_member'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.', 1, 8)');
}
function testFunctionAddition(){
$this->_test("abs(score) + abs(totalscore)", NULL
, 'abs('.$this->dbLeftEscapeChar.'score'.$this->dbRightEscapeChar.') + abs('.$this->dbLeftEscapeChar.'totalscore'.$this->dbRightEscapeChar.')');
}
}

View file

@ -1,82 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* @brief Mock database base class
*
* Used to load mock classes instead of actual ones,
* so that connect methods can be skipped
*/
class MockDb extends DB {
function &getParser($force = false){
static $dbParser = null;
if(!$dbParser || $force) {
$oDB = &MockDb::getInstance();
$dbParser = $oDB->getParser();
DB::getParser(true);
}
return $dbParser;
}
function &getInstance(){
$db_type = Context::getDBType();
if(!isset($GLOBALS['__DB__'])) $GLOBALS['__DB__'] = array();
if(!isset($GLOBALS['__DB__'][$db_type])) {
switch($db_type){
case 'mssql' :
$GLOBALS['__DB__'][$db_type] = new MockDBMssql; break;
case 'mysql' :
$GLOBALS['__DB__'][$db_type] = new MockDBMysql; break;
case 'cubrid' :
$GLOBALS['__DB__'][$db_type] = new MockDBCubrid; break;
}
}
return $GLOBALS['__DB__'][$db_type];
}
}
/**
* @brief Mock up for MS SQL class
*
* Overrides default constructor in order to skip connect method
*/
class MockDBMssql extends DBMssql {
function MockDBMssql(){
$this->_setDBInfo();
}
}
/**
* @brief Mock up for CUBRID class
*
* Overrides default constructor in order to skip connect method
*/
class MockDBCubrid extends DBCubrid {
function MockDBCubrid(){
$this->_setDBInfo();
}
}
/**
* @brief Mock up for Mysql class
*
* Overri des default constructor in order to skip connect method.
*/
class MockDBMysql extends DBMysql {
function MockDBMysql(){
$this->_setDBInfo();
}
/**
* Overrides mysql_real_escape_string, that returns null when no connection is present
*/
function addQuotes($string){
return $string;
}
}
?>

View file

@ -1,50 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Base class for tests for MSSQL SQL syntax
*/
class MssqlOnlineTest extends PHPUnit_Framework_TestCase {
protected $backupGlobals = FALSE;
protected $backupStaticAttributes = FALSE;
protected $preserveGlobalState = FALSE;
/**
* Prepare runtime context - tell DB class that current DB is MSSQL
*/
protected function setUp() {
$this->markTestSkipped();
$oContext = &Context::getInstance();
$db_info->master_db = array('db_type' => 'mssql'
,'db_port' => '3306'
,'db_hostname' => 'PHENOMII\SQL2008EXPRESS'
,'db_userid' => 'dba'
,'db_password' => 'arniarules'
,'db_database' => 'xe-15-db'
,'db_table_prefix' => 'xe_');
$db_info->slave_db = array(array('db_type' => 'mssql'
,'db_port' => '3306'
,'db_hostname' => 'PHENOMII\SQL2008EXPRESS'
,'db_userid' => 'dba'
,'db_password' => 'arniarules'
,'db_database' => 'xe-15-db'
,'db_table_prefix' => 'xe_'));
$oContext->setDbInfo($db_info);
// remove cache dir
FileHandler::removeDir( _XE_PATH_ . 'files/cache');
DB::getParser(true);
}
/**
* Free resources - reset static DB and QueryParser
*/
protected function tearDown() {
unset($GLOBALS['__DB__']);
}
}
?>

View file

@ -1,27 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class MssqlTest extends DBTest {
protected function setUp() {
$oContext = &Context::getInstance();
$db_info->master_db = array('db_type' => 'mssql','db_table_prefix' => 'xe_');
$db_info->slave_db = array(array('db_type' => 'mssql','db_table_prefix' => 'xe_'));
$oContext->setDbInfo($db_info);
$db = new MockDb();
$db->getParser(true);
}
protected function tearDown() {
unset($GLOBALS['__DB__']);
}
}
?>

View file

@ -1,32 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Base class for tests for Mysql SQL syntax
*/
class MysqlTest extends DBTest {
/**
* Prepare runtime context - tell DB class that current DB is CUBRID
*/
protected function setUp() {
$oContext = &Context::getInstance();
$db_info->master_db = array('db_type' => 'mysql','db_table_prefix' => 'xe_');
$db_info->slave_db = array(array('db_type' => 'mysql','db_table_prefix' => 'xe_'));
$oContext->setDbInfo($db_info);
$db = new MockDb();
$db->getParser(true);
}
/**
* Free resources - reset static DB and QueryParser
*/
protected function tearDown() {
unset($GLOBALS['__DB__']);
}
}
?>

View file

@ -1,33 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Base class for tests for Sqlite SQL syntax
*
* See syntax reference:
* http://www.sqlite.org/lang.html
*/
class SqliteTest extends DBTest {
/**
* Prepare runtime context - tell DB class that current DB is CUBRID
*/
protected function setUp() {
$oContext = &Context::getInstance();
$db_info->master_db = array('db_type' => 'sqlite3_pdo','db_table_prefix' => 'xe_');
$db_info->slave_db = array(array('db_type' => 'sqlite3_pdo','db_table_prefix' => 'xe_'));
$oContext->setDbInfo($db_info);
DB::getParser(true);
}
/**
* Free resources - reset static DB and QueryParser
*/
protected function tearDown() {
unset($GLOBALS['__DB__']);
}
}
?>

View file

@ -1,21 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class CubridDeleteTest extends CubridTest {
function _test($xml_file, $argsString, $expected){
$this->_testQuery($xml_file, $argsString, $expected, 'getDeleteSql');
}
function test_module_deleteActionForward(){
$xml_file = _XE_PATH_ . "modules/module/queries/deleteActionForward.xml";
$argsString = '$args->module = "page";
$args->type = "page";
$args->act = "tata";';
$expected = 'delete "action_forward" from "xe_action_forward" as "action_forward"
where "module" = \'page\'
and "type" = \'page\'
and "act" = \'tata\'';
$this->_test($xml_file, $argsString, $expected);
}
}

View file

@ -1,86 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class CubridIndexHintTest extends CubridTest {
var $xmlPath = 'data/';
function CubridIndexHintTest(){
$this->xmlPath = str_replace('CubridIndexHintTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
}
function _test($xml_file, $argsString, $expected){
var_dump($xml_file);
$this->_testQuery($xml_file, $argsString, $expected, 'getSelectSql');
}
function testOneUseIndexHintAndOneTable(){
$xml_file = $this->xmlPath . "one_index_hint_one_table.xml";
$argsString = '';
$expected = 'select * from "xe_member" as "member" using index "member"."xe_idx_member_list_order"';
$this->_test($xml_file, $argsString, $expected);
}
function testTwoUseIndexHintsAndOneTable(){
$xml_file = $this->xmlPath . "two_index_hints_one_table.xml";
$argsString = '';
$expected = 'select * from "xe_member" as "member" using index "member"."xe_idx_member_list_order", "member"."xe_idx_member_srl"';
$this->_test($xml_file, $argsString, $expected);
}
function testThreeUseIndexHintsAndTwoTables(){
$xml_file = $this->xmlPath . "three_index_hints_two_tables.xml";
$argsString = '';
$expected = 'select * from "xe_member" as "member", "xe_document" as "document"
using index "member"."xe_idx_member_list_order", "member"."xe_idx_member_srl", "document"."xe_idx_document_srl"';
$this->_test($xml_file, $argsString, $expected);
}
function testThreeUseIndexHintsAndTwoTablesCombined(){
$xml_file = $this->xmlPath . "three_index_hints_two_tables_combined.xml";
$argsString = '';
$expected = 'select * from "xe_member" as "member", "xe_document" as "document"
using index "member"."xe_idx_member_list_order", "member"."xe_idx_member_srl"(+), "document"."xe_idx_document_srl"';
$this->_test($xml_file, $argsString, $expected);
}
function testIgnoreIndexHintIsSkipped(){
$xml_file = $this->xmlPath . "ignore_index_hint.xml";
$argsString = '';
$expected = 'select * from "xe_member" as "member"';
$this->_test($xml_file, $argsString, $expected);
}
function testMysqlIndexHintIsSkipped(){
$xml_file = $this->xmlPath . "mysql_index_hint.xml";
$argsString = '';
$expected = 'select * from "xe_member" as "member"';
$this->_test($xml_file, $argsString, $expected);
}
/**
* If CUBRID database is used, indexes are created with prefix.
*
* e.g.: xe_indx_list_order
*/
function testPrefixIsAddedToIndexName(){
$xml_file = $this->xmlPath . "one_index_hint_one_table.xml";
$argsString = '';
$expected = 'select * from "xe_member" as "member" using index "member"."xe_idx_member_list_order"';
$this->_test($xml_file, $argsString, $expected);
}
/**
* Tests that index is added if "for" attribute is "ALL"
*
* example: <index_hint for="ALL"> ... </index_hint>
*/
function testIndexHintForAll(){
$xml_file = $this->xmlPath . "index_hint_for_all.xml";
$argsString = '';
$expected = 'select * from "xe_member" as "member" using index "member"."xe_idx_member_list_order"';
$this->_test($xml_file, $argsString, $expected);
}
}
?>

View file

@ -1,86 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class CubridInsertOnlineTest extends CubridOnlineTest {
/**
* Note: this test can fail when comaparing regdate from the $args with
* regdate from the expected string - a few seconds difference
*/
function test_module_insertModule_escapeContent(){
$xml_file = _XE_PATH_ . "modules/module/queries/insertModule.xml";
$args->module_category_srl = 0;
$args->browser_title = "test";
$args->layout_srl = 0;
$args->mlayout_srl = 0;
$args->module = "page";
$args->mid = "test";
$args->site_srl = 0;
$args->module_srl = 47374;
$args->content = "hello \' moto";
$output = executeQuery('module.insertModule', $args);
$this->assertTrue(!$output->error, $output->message);
}
function test_document_insertDocument_defaultVarcharValue(){
$args->module_srl = 102;
$args->content = '<p>yuhuuuuu</p>';
$args->document_srl = 9200;
$args->is_secret = 'N';
$args->allow_comment = 'N';
$args->lock_comment = 'N';
$args->allow_trackback = 'N';
$args->notify_message = 'N';
$args->ipaddress = '127.0.0.1';
$args->extra_vars = 'N;';
$args->readed_count = 0;
$args->list_order = -9201;
$args->update_order = -9201;
$args->member_srl = 4;
$args->user_id = 'admin';
$args->user_name = 'admin';
$args->nick_name = 'admin';
$args->email_address = 'admin@admin.admin';
$args->homepage = '';
$args->title = 'yuhuu';
$args->lang_code;
$output = executeQuery('document.insertDocument', $args);
$this->assertNotEquals(-225, $output->error);
$this->assertNotEquals('Missing value for attribute "homepage" with the NOT NULL constraint.', $output->message);
}
function test_communication_addFriendGroup(){
$args->member_srl = 202;
$args->title = "Grup";
$output = executeQuery("communication.addFriendGroup", $args);
$this->assertEquals(0, $output->error, $output->message);
}
function test_communication_addFriendGroup_NullId(){
$args->member_srl = 202;
$args->title = "Grup";
$args->friend_group_srl = trim(null);
$output = executeQuery("communication.addFriendGroup", $args);
$this->assertEquals(0, $output->error, $output->message);
}
protected function tearDown() {
$db = &DB::getInstance();
$db->_query("DELETE FROM xe_modules WHERE module_srl = 47374");
$db->_query("DELETE FROM xe_documents WHERE document_srl = 9200");
$db->_query("DELETE FROM xe_member_friend_group WHERE member_srl = 202");
$db->close();
parent::tearDown();
}
}

View file

@ -1,128 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class CubridInsertTest extends CubridTest {
function _test($xml_file, $argsString, $expected){
$this->_testQuery($xml_file, $argsString, $expected, 'getInsertSql');
}
/**
* Note: this test can fail when comaparing regdate from the $args with
* regdate from the expected string - a few seconds difference
*/
function test_module_insertModule(){
$xml_file = _XE_PATH_ . "modules/module/queries/insertModule.xml";
$argsString = ' $args->module_category_srl = 0;
$args->browser_title = "test";
$args->layout_srl = 0;
$args->mlayout_srl = 0;
$args->module = "page";
$args->mid = "test";
$args->site_srl = 0;
$args->module_srl = 47374;';
$expected = 'insert into "xe_modules"
("site_srl"
, "module_srl"
, "module_category_srl"
, "mid"
, "browser_title"
, "layout_srl"
, "module"
, "is_default"
, "open_rss"
, "regdate"
, "mlayout_srl"
, "use_mobile")
values
(0
, 47374
, 0
, \'test\'
, \'test\'
, 0
, \'page\'
, \'n\'
, \'y\'
, \''.date("YmdHis").'\'
, 0
, \'n\')';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_insertSiteTodayStatus(){
//\''.date("YmdHis").'\'
$xml_file = _XE_PATH_ . "modules/counter/queries/insertTodayStatus.xml";
$argsString = ' $args->regdate = 0;
$args->unique_visitor = 0;
$args->pageview = 0;';
$expected = 'insert into "xe_counter_status"
("regdate"
, "unique_visitor"
, "pageview")
values
('.date("YmdHis").'
, 0
, 0)';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_insertCounterLog(){
$xml_file = _XE_PATH_ . "modules/counter/queries/insertCounterLog.xml";
$argsString = ' $args->site_srl = 0;
$args->regdate = "20110607120619";
$args->ipaddress = "127.0.0.1";
$args->user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.77 Safari/534.24";';
$expected = 'insert into "xe_counter_log"
("site_srl", "regdate", "ipaddress", "user_agent")
VALUES (0, \'20110607120619\', \'127.0.0.1\', \'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.77 Safari/534.24\')
';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_insertMember(){
$xml_file = _XE_PATH_ . "modules/member/queries/insertMember.xml";
$argsString = ' $args->member_srl = 203;
$args->user_id = "cacao";
$args->email_address = "teta@ar.ro";
$args->password = "23e5484cb88f3c07bcce2920a5e6a2a7";
$args->email_id = "teta";
$args->email_host = "ar.ro";
$args->user_name = "trident";
$args->nick_name = "aloha";
$args->homepage = "http://jkgjfk./ww";
$args->allow_mailing = "Y";
$args->allow_message = "Y";
$args->denied = "N";
$args->regdate = "20110607121952";
$args->change_password_date = "20110607121952";
$args->last_login = "20110607121952";
$args->is_admin = "N";
$args->extra_vars = "O:8:\"stdClass\":2:{s:4:\"body\";s:0:\"\";s:7:\"_filter\";s:6:\"insert\";}";
$args->list_order = -203;
';
$expected = 'INSERT INTO "xe_member"
("member_srl", "user_id", "email_address", "password", "email_id", "email_host", "user_name", "nick_name",
"homepage", "allow_mailing", "allow_message", "denied", "regdate", "change_password_date",
"last_login", "is_admin", "extra_vars", "list_order")
VALUES (203, \'cacao\', \'teta@ar.ro\', \'23e5484cb88f3c07bcce2920a5e6a2a7\', \'teta\', \'ar.ro\', \'trident\',
\'aloha\', \'http://jkgjfk./ww\', \'Y\', \'Y\', \'N\', \'20110607121952\', \'20110607121952\',
\'20110607121952\', \'N\', \'O:8:"stdClass":2:{s:4:"body";s:0:"";s:7:"_filter";s:6:"insert";}\', -203)';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_insertModuleExtraVars(){
$xml_file = _XE_PATH_ . "modules/module/queries/insertModuleExtraVars.xml";
$argsString = ' $args->module_srl = 202;
$args->name = "_filter";
$args->value = "insert_page";
';
$expected = 'INSERT INTO "xe_module_extra_vars"
("module_srl", "name", "value")
VALUES (202, \'_filter\', \'insert_page\')
';
$this->_test($xml_file, $argsString, $expected);
}
}

View file

@ -1,77 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class CubridSelectOnlineTest extends CubridOnlineTest {
function test_get_module_by_mid(){
$args->mid = 'test_4l8ci4vv0n';
$args->site_srl = 0;
$output = executeQuery('module.getMidInfo', $args);
$this->assertNotNull($output);
$this->assertNotNull($output->data, $output->message . PHP_EOL . $output->variables["_query"]);
$this->assertEquals($output->data->module_srl, 111);
}
/**
* Tests that when a column list is given, the query only selects those columns from the database
* insetad of retrieving all table columns (as specified in the xml query file)
*/
function test_get_module_by_mid_columnList(){
$args->mid = 'test_4l8ci4vv0n';
$args->site_srl = 0;
$output = executeQuery('module.getMidInfo', $args, array('module_srl'));
$this->assertNotNull($output);
$this->assertNotNull($output->data, $output->message . PHP_EOL . $output->variables["_query"]);
$this->assertEquals($output->data->module_srl, 111);
$this->assertEquals($output->data->module, null);
}
function test_module_getInfo(){
$args->site_srl = 0;
$output = executeQuery('module.getSiteInfo', $args);
$this->assertTrue(is_a($output, 'Object'));
$this->assertEquals(0, $output->error, $output->message . PHP_EOL . $output->variables["_query"]);
}
function test_document_getDocumentList_pagination(){
$args->sort_index = 'list_order';
$args->order_type = 'asc';
$args->page = 1;
$args->list_count = 30;
$args->page_count = 10;
$args->s_member_srl = 4;
$output = executeQuery('document.getDocumentList', $args);
$this->assertEquals(0, $output->error, $output->message . PHP_EOL . $output->variables["_query"]);
}
function test_syndication_getDocumentList(){
$args->module_srl = NULL;
$args->exclude_module_srl = NULL;
$args->category_srl = NULL;
$args->sort_index = 'list_order';
$args->order_type = 'asc';
$args->page = 5;
$args->list_count = 30;
$args->page_count = 10;
$args->start_date = NULL;
$args->end_date = NULL;
$args->member_srl = NULL;
$output = executeQuery('document.getDocumentList', $args);
$this->assertTrue(is_int($output->page), $output->message . PHP_EOL . $output->variables["_query"]);
}
function test_member_getMemberList(){
$args->is_admin = '';
$args->is_denied = '';
$args->sort_index = "list_order";
$args->sort_order = 'asc';
$args->list_count = 40;
$args->page_count = 10;
$output = executeQuery('member.getMemberList', $args);
$this->assertEquals(0, $output->error, $output->message . PHP_EOL . $output->variables["_query"]);
}
}
?>

View file

@ -1,456 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class CubridSelectTest extends CubridTest {
function _test($xml_file, $argsString, $expected, $columnList = null){
$this->_testQuery($xml_file, $argsString, $expected, 'getSelectSql', $columnList);
}
function testSelectStar(){
$xml_file = _XE_PATH_ . "modules/module/queries/getAdminId.xml";
$argsString = '$args->module_srl = 10;';
$expected = 'SELECT * FROM "xe_module_admins" as "module_admins" , "xe_member" as "member" WHERE "module_srl" = 10 and "member"."member_srl" = "module_admins"."member_srl"';
$this->_test($xml_file, $argsString, $expected);
}
function testRequiredParameter(){
$xml_file = _XE_PATH_ . "modules/module/queries/getAdminId.xml";
$argsString = '';
$expected = 'Date incorecte! Query-ul nu a putut fi executat.';
$this->_test($xml_file, $argsString, $expected);
}
function testWithoutCategoriesTag(){
$xml_file = _XE_PATH_ . "modules/module/queries/getModuleCategories.xml";
$argsString = '';
$expected = 'SELECT * FROM "xe_module_categories" as "module_categories" ORDER BY "title" asc';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_getDefaultModules(){
$xml_file = _XE_PATH_ . "modules/module/queries/getDefaultModules.xml";
$argsString = '$args->site_srl = 0;';
$expected = 'SELECT "modules"."site_srl"
, "modules"."module"
, "modules"."mid"
, "modules"."browser_title"
, "module_categories"."title" as "category"
, "modules"."module_srl"
FROM "xe_modules" as "modules"
left join "xe_module_categories" as "module_categories"
on "module_categories"."module_category_srl" = "modules"."module_category_srl"
WHERE "modules"."site_srl" = 0
ORDER BY "modules"."module" asc, "module_categories"."title" asc, "modules"."mid" asc';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_getSiteInfo(){
$xml_file = _XE_PATH_ . "modules/module/queries/getSiteInfo.xml";
$argsString = '$args->site_srl = 0;';
$expected = 'SELECT "modules"."site_srl" as "module_site_srl"
, "modules"."module_srl" as "module_srl"
, "modules"."module" as "module"
, "modules"."module_category_srl" as "module_category_srl"
, "modules"."layout_srl" as "layout_srl"
, "modules"."mlayout_srl" as "mlayout_srl"
, "modules"."use_mobile" as "use_mobile"
, "modules"."menu_srl" as "menu_srl"
, "modules"."mid" as "mid"
, "modules"."skin" as "skin"
, "modules"."mskin" as "mskin"
, "modules"."browser_title" as "browser_title"
, "modules"."description" as "description"
, "modules"."is_default" as "is_default"
, "modules"."content" as "content"
, "modules"."mcontent" as "mcontent"
, "modules"."open_rss" as "open_rss"
, "modules"."header_text" as "header_text"
, "modules"."footer_text" as "footer_text"
, "modules"."regdate" as "regdate"
, "sites"."site_srl" as "site_srl"
, "sites"."domain" as "domain"
, "sites"."index_module_srl" as "index_module_srl"
, "sites"."default_language" as "default_language"
FROM "xe_sites" as "sites"
left join "xe_modules" as "modules" on "modules"."module_srl" = "sites"."index_module_srl"
WHERE "sites"."site_srl" = 0 ';
$this->_test($xml_file, $argsString, $expected);
}
function test_addon_getAddonInfo(){
$xml_file = _XE_PATH_ . "modules/addon/queries/getAddonInfo.xml";
$argsString = '$args->addon = "captcha";';
$expected = 'SELECT *
FROM "xe_addons" as "addons"
WHERE "addon" = \'captcha\' ';
$this->_test($xml_file, $argsString, $expected);
}
function test_addon_getAddons(){
$xml_file = _XE_PATH_ . "modules/addon/queries/getAddons.xml";
$argsString = '';
$expected = 'SELECT *
FROM "xe_addons" as "addons"
ORDER BY "addon" asc';
$this->_test($xml_file, $argsString, $expected);
}
function test_admin_getCommentCount(){
$xml_file = _XE_PATH_ . "modules/admin/queries/getCommentCount.xml";
$argsString = '';
$expected = 'SELECT count(*) as "count"
FROM "xe_comments" as "comments"';
$this->_test($xml_file, $argsString, $expected);
}
function test_admin_getCommentDeclaredStatus(){
$xml_file = _XE_PATH_ . "modules/admin/queries/getCommentDeclaredStatus.xml";
$argsString = '$args->date = "20110411";';
$expected = 'SELECT substr("regdate",1,8) as "date", count(*) as "count"
FROM "xe_comment_declared_log" as "comment_declared_log"
WHERE "regdate" >= \'20110411\'
GROUP BY substr("regdate",1,8)
ORDER BY substr("regdate",1,8) asc limit 2';
$this->_test($xml_file, $argsString, $expected);
}
function test_member_getAutoLogin(){
$xml_file = _XE_PATH_ . "modules/member/queries/getAutoLogin.xml";
$argsString = '$args->autologin_key = 10;';
$expected = 'SELECT "member"."user_id" as "user_id"
, "member"."password" as "password"
, "member_autologin"."autologin_key" as "autologin_key"
FROM "xe_member" as "member" , "xe_member_autologin" as "member_autologin"
WHERE "member_autologin"."autologin_key" = \'10\'
and "member"."member_srl" = "member_autologin"."member_srl"';
$this->_test($xml_file, $argsString, $expected);
}
function test_opage_getOpageList(){
$xml_file = _TEST_PATH_ . "db/xml_query/cubrid/data/opage.getOpageList.xml";
$argsString = '$args->s_title = "yuhuu";
$args->module = \'opage\';';
$expected = 'SELECT *
FROM "xe_modules" as "modules"
WHERE "module" = \'opage\' and ("title" like \'%yuhuu%\')
ORDER BY "module_srl" desc
LIMIT 0, 20';
$this->_test($xml_file, $argsString, $expected);
}
function test_syndication_getGrantedModules(){
$xml_file = _TEST_PATH_ . "db/xml_query/cubrid/data/syndication.getGrantedModules.xml";
$argsString = '$args->module_srl = 12;
$args->name = array(\'access\',\'view\',\'list\');';
$expected = 'select "module_srl"
from "xe_module_grants" as "module_grants"
where "name" in (\'access\',\'view\',\'list\')
and ("group_srl" >= 1
or "group_srl" = -1
or "group_srl" = -2)
group by "module_srl"';
$this->_test($xml_file, $argsString, $expected);
}
function test_document_getDocumentList(){
$xml_file = _XE_PATH_ . "modules/document/queries/getDocumentList.xml";
$argsString = '$args->sort_index = \'list_order\';
$args->order_type = \'asc\';
$args->page = 1;
$args->list_count = 30;
$args->page_count = 10;
$args->s_member_srl = 4;';
$expected = 'select *
from "xe_documents" as "documents"
where ("member_srl" = 4)
and "list_order" <= 2100000000
order by "list_order" asc
limit 0, 30';
$this->_test($xml_file, $argsString, $expected);
}
/**
* Test column list
*/
function test_session_getSession(){
$xml_file = _XE_PATH_ . "modules/session/queries/getSession.xml";
$argsString = '$args->session_key = \'session_key\';';
$columnList = array('session_key', 'cur_mid', 'val');
$expected = 'select "session_key", "cur_mid", "val"
from "xe_session" as "session"
where "session_key" = \'session_key\'';
$this->_test($xml_file, $argsString, $expected, $columnList);
}
function test_module_getModuleInfoByDocument(){
$xml_file = _XE_PATH_ . "modules/module/queries/getModuleInfoByDocument.xml";
$argsString = '$args->document_srl = 10;';
$expected = 'SELECT "modules".*
FROM "xe_modules" as "modules"
, "xe_documents" as "documents"
WHERE "documents"."document_srl" = 10
and "modules"."module_srl" = "documents"."module_srl"';
$this->_test($xml_file, $argsString, $expected);
}
function test_member_getMemberList(){
$xml_file = _XE_PATH_ . "modules/member/queries/getMemberList.xml";
$argsString = '$args->is_admin = \'\';
$args->is_denied = \'\';
$args->sort_index = "list_order";
$args->sort_order = \'asc\';
$args->list_count = 40;
$args->page_count = 10;';
$expected = 'select *
from "xe_member" as "member"
where "list_order" <= 2100000000
order by "list_order" asc
limit 0, 40';
$this->_test($xml_file, $argsString, $expected);
}
/**
* Tests "not in" query condition
* Query argument is a single value - not in (12)
*/
function test_module_getModules_Notin_Single_Value(){
$xml_file = _TEST_PATH_ . "db/xml_query/cubrid/data/syndication.getModules.xml";
$argsString = '$args->except_module_srls = 12;';
$expected = 'select "modules"."site_srl" as "site_srl"
, "modules"."module_srl" as "module_srl"
, "sites"."domain" as "domain"
, "modules"."mid" as "mid"
, "modules"."module" as "module"
, "modules"."browser_title" as "browser_title"
, "modules"."description" as "description"
from "xe_sites" as "sites"
, "xe_modules" as "modules"
left join "xe_syndication_except_modules" as "except_modules"
on "modules"."module_srl" = "except_modules"."module_srl"
where "modules"."module_srl" not in (12)
and "sites"."site_srl" = "modules"."site_srl"
and "except_modules"."module_srl" is null';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_getModules_Notin_Multiple_Value_String(){
$xml_file = _TEST_PATH_ . "db/xml_query/cubrid/data/syndication.getModules.xml";
$argsString = '$args->except_module_srls = "12, 13, 14";';
$expected = 'select "modules"."site_srl" as "site_srl"
, "modules"."module_srl" as "module_srl"
, "sites"."domain" as "domain"
, "modules"."mid" as "mid"
, "modules"."module" as "module"
, "modules"."browser_title" as "browser_title"
, "modules"."description" as "description"
from "xe_sites" as "sites"
, "xe_modules" as "modules"
left join "xe_syndication_except_modules" as "except_modules"
on "modules"."module_srl" = "except_modules"."module_srl"
where "modules"."module_srl" not in (12,13,14)
and "sites"."site_srl" = "modules"."site_srl"
and "except_modules"."module_srl" is null';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_getModules_Notin_Multiple_Value_Array(){
$xml_file = _TEST_PATH_ . "db/xml_query/cubrid/data/syndication.getModules.xml";
$argsString = '$args->except_module_srls = array(12, 13, 14);';
$expected = 'select "modules"."site_srl" as "site_srl"
, "modules"."module_srl" as "module_srl"
, "sites"."domain" as "domain"
, "modules"."mid" as "mid"
, "modules"."module" as "module"
, "modules"."browser_title" as "browser_title"
, "modules"."description" as "description"
from "xe_sites" as "sites"
, "xe_modules" as "modules"
left join "xe_syndication_except_modules" as "except_modules"
on "modules"."module_srl" = "except_modules"."module_srl"
where "modules"."module_srl" not in (12,13,14)
and "sites"."site_srl" = "modules"."site_srl"
and "except_modules"."module_srl" is null';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_getModules_In_Single_Value(){
$xml_file = _TEST_PATH_ . "db/xml_query/cubrid/data/syndication.getModules.xml";
$argsString = '$args->module_srls = 12;';
$expected = 'select "modules"."site_srl" as "site_srl"
, "modules"."module_srl" as "module_srl"
, "sites"."domain" as "domain"
, "modules"."mid" as "mid"
, "modules"."module" as "module"
, "modules"."browser_title" as "browser_title"
, "modules"."description" as "description"
from "xe_sites" as "sites"
, "xe_modules" as "modules"
left join "xe_syndication_except_modules" as "except_modules"
on "modules"."module_srl" = "except_modules"."module_srl"
where "modules"."module_srl" in (12)
and "sites"."site_srl" = "modules"."site_srl"
and "except_modules"."module_srl" is null';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_getModules_In_Multiple_Value_String(){
$xml_file = _TEST_PATH_ . "db/xml_query/cubrid/data/syndication.getModules.xml";
$argsString = '$args->module_srls = "12, 13, 14";';
$expected = 'select "modules"."site_srl" as "site_srl"
, "modules"."module_srl" as "module_srl"
, "sites"."domain" as "domain"
, "modules"."mid" as "mid"
, "modules"."module" as "module"
, "modules"."browser_title" as "browser_title"
, "modules"."description" as "description"
from "xe_sites" as "sites"
, "xe_modules" as "modules"
left join "xe_syndication_except_modules" as "except_modules"
on "modules"."module_srl" = "except_modules"."module_srl"
where "modules"."module_srl" in (12,13,14)
and "sites"."site_srl" = "modules"."site_srl"
and "except_modules"."module_srl" is null';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_getModules_In_Multiple_Value_Array(){
$xml_file = _TEST_PATH_ . "db/xml_query/cubrid/data/syndication.getModules.xml";
$argsString = '$args->module_srls = array(12, 13, 14);';
$expected = 'select "modules"."site_srl" as "site_srl"
, "modules"."module_srl" as "module_srl"
, "sites"."domain" as "domain"
, "modules"."mid" as "mid"
, "modules"."module" as "module"
, "modules"."browser_title" as "browser_title"
, "modules"."description" as "description"
from "xe_sites" as "sites"
, "xe_modules" as "modules"
left join "xe_syndication_except_modules" as "except_modules"
on "modules"."module_srl" = "except_modules"."module_srl"
where "modules"."module_srl" in (12,13,14)
and "sites"."site_srl" = "modules"."site_srl"
and "except_modules"."module_srl" is null';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_getModuleSrlByMid_In_Multiple_Value_Array_Strings(){
$xml_file = _XE_PATH_ . "modules/module/queries/getModuleSrlByMid.xml";
$argsString = '$args->mid = "\'mid1\', \'mid2\'";';
$expected = 'select "module_srl" from "xe_modules" as "modules" where "mid" in (\'mid1\',\'mid2\')';
$this->_test($xml_file, $argsString, $expected);
}
function test_file_getFileList_In_Empty_Array_Value(){
$xml_file = _XE_PATH_ . "modules/file/queries/getFileList.xml";
$argsString = '$args->exclude_module_srl = 12; $args->s_module_srl = array(); ';
$expected = 'select "files".*
from "xe_files" as "files"
left join "xe_member" as "member" on "files"."member_srl" = "member"."member_srl"
where "files"."module_srl" not in (12)
order by "files"."file_srl" desc
limit 0, 20';
$this->_test($xml_file, $argsString, $expected);
}
function test_file_getFileList_Not_In_Empty_String_Value(){
$xml_file = _XE_PATH_ . "modules/file/queries/getFileList.xml";
$argsString = '$args->exclude_module_srl = ""; $args->s_module_srl = array(12); ';
$expected = 'select "files".*
from "xe_files" as "files"
left join "xe_member" as "member" on "files"."member_srl" = "member"."member_srl"
where "files"."module_srl" in (12)
order by "files"."file_srl" desc
limit 0, 20';
$this->_test($xml_file, $argsString, $expected);
}
function test_document_getDeclaredList_In_Query(){
$xml_file = _XE_PATH_ . "modules/document/queries/getDeclaredList.xml";
$argsString = "\$args->list_count = 30;
\$args->page_count = 10;
\$args->sort_index = 'document_declared.declared_count';
\$args->order_type = 'desc';";
$expected = 'select * from "xe_documents" as "documents"
, "xe_document_declared" as "document_declared"
where "documents"."document_srl"
in ("document_declared"."document_srl")
order by "document_declared"."declared_count" desc
limit 0, 30';
$this->_test($xml_file, $argsString, $expected);
}
function test_getExpiredSession_curdate(){
$xml_file = _XE_PATH_ . "modules/session/queries/getExpiredSessions.xml";
$argsString = '';
$expected = 'select "session_key"
from "xe_session" as "session"
where "expired" <= \'' . date("YmdHis") . '\'';
$this->_test($xml_file, $argsString, $expected);
}
function test_rlike_1(){
$xml_file = _TEST_PATH_ . "db/xml_query/cubrid/data/rlike1.xml";
$argsString = '$args->title = "aaa";';
$expected = 'select * from "xe_modules" as "modules" where "title" rlike \'aaa\'';
define('__CUBRID_VERSION__', '8.4.1');
$this->_test($xml_file, $argsString, $expected);
}
function test_resource_getLatestItem(){
$xml_file = _TEST_PATH_ . "db/xml_query/cubrid/data/resource.getLatestItem.xml";
$expected = 'SELECT "package"."module_srl" as "module_srl"
, "package"."status" as "status"
, "package"."category_srl" as "category_srl"
, "package"."member_srl" as "member_srl"
, "package"."package_srl" as "package_srl"
, "package"."path" as "path"
, "package"."license" as "license"
, "package"."title" as "title"
, "package"."homepage" as "homepage"
, "package"."description" as "package_description"
, "package"."voter" as "package_voter"
, "package"."voted" as "package_voted"
, "package"."downloaded" as "package_downloaded"
, "package"."regdate" as "package_regdate"
, "package"."last_update" as "package_last_update"
, "member"."nick_name" as "nick_name"
, "member"."user_id" as "user_id"
, "item"."item_srl" as "item_srl"
, "item"."document_srl" as "document_srl"
, "item"."file_srl" as "item_file_srl"
, "item"."screenshot_url" as "item_screenshot_url"
, "item"."version" as "item_version"
, "item"."voter" as "item_voter"
, "item"."voted" as "item_voted"
, "item"."downloaded" as "item_downloaded"
, "item"."regdate" as "item_regdate"
FROM "xe_resource_packages" as "package"
, "xe_member" as "member"
, "xe_resource_items" as "item"
WHERE "package"."package_srl" = ?
and "package"."member_srl" = "member"."member_srl"
and "item"."item_srl" = "package"."latest_item_srl"';
$argsString = '$args->package_srl = 18325662;';
$expectedArgs = array(18325662);
$this->_testPreparedQuery($xml_file, $argsString, $expected, 'getSelectSql', $expectedArgs);
}
/**
* Issue 1431 - xml click count error
*/
function testClickCount()
{
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/click_count.xml";
$argsString = '$args->incr_expose_count = true;';
$expected = 'select INCR("expose_count") from "xe_modules" as "modules"';
$this->_test($xml_file, $argsString, $expected);
}
}

View file

@ -1,192 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class CubridSubqueryTest extends CubridTest {
var $xmlPath = 'data/';
function CubridSubqueryTest(){
$this->xmlPath = str_replace('CubridSubqueryTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
}
function _test($xml_file, $argsString, $expected){
$this->_testQuery($xml_file, $argsString, $expected, 'getSelectSql');
}
function testSelectUncorrelated1(){
$xml_file = $this->xmlPath . "select_uncorrelated1.xml";
$argsString = '$args->user_id = 4;
';
$expected = 'select "column_a" as "value_a"
, (select max("column_b") as "count"
from "xe_table_b" as "table_b"
) as "value_b"
from "xe_table_a" as "table_a"
where "column_a" = 4';
$this->_test($xml_file, $argsString, $expected);
}
function testSelectUncorrelated2(){
$xml_file = $this->xmlPath . "select_uncorrelated2.xml";
$argsString = '$args->user_id = 4;
$args->user_name = 7;
';
$expected = 'SELECT "column_a" as "value_a"
, "column_b" as "value_b"
, "column_c" as "value_c"
, (SELECT max("column_b") as "count"
FROM "xe_table_b" as "table_b"
WHERE "column_ab" = 7) as "value_b"
FROM "xe_table_a" as "table_a"
WHERE "column_a" = 4';
$this->_test($xml_file, $argsString, $expected);
}
function testFromUncorrelated1(){
$xml_file = $this->xmlPath . "from_uncorrelated1.xml";
$argsString = '$args->user_id = 4;
$args->user_name = 7;
';
$expected = 'select max("documentcountbymember"."count") as "maxcount"
from (
select "member_srl" as "member_srl"
, count(*) as "count"
from "xe_documents" as "documents"
group by "member_srl"
) as "documentcountbymember"';
$this->_test($xml_file, $argsString, $expected);
}
// function testFromUncorrelated2(){
// $xml_file = $this->xmlPath . "from_uncorrelated1.xml";
// $argsString = '$args->user_id = 4;
// $args->user_name = 7;
// ';
// $expected = 'select max("documentcountbymember"."count") as "maxcount"
// from (
// select "member_srl" as "member_srl"
// , count(*) as "count"
// from "xe_documents" as "documents"
// group by "member_srl"
// ) as "documentcountbymember"';
// $this->_test($xml_file, $argsString, $expected);
// }
function testFromUncorrelated2(){
$xml_file = $this->xmlPath . "from_uncorrelated2.xml";
$argsString = '$args->member_srl = 4;
$args->module_srl = 7;
';
$expected = 'select max("documentcountbymember"."count") as "maxcount"
from (
select "member_srl" as "member_srl"
, count(*) as "count"
from "xe_documents" as "documents"
where "module_srl" = 7
group by "member_srl"
) as "documentcountbymember"
where "member_srl" = 4
';
$this->_test($xml_file, $argsString, $expected);
}
function testSelectCorrelated1(){
$xml_file = $this->xmlPath . "select_correlated1.xml";
$argsString = '$args->user_id = 7;';
$expected = 'select *,
(select count(*) as "count"
from "xe_documents" as "documents"
where "documents"."user_id" = "member"."user_id"
) as "totaldocumentcount"
from "xe_member" as "member"
where "user_id" = \'7\'';
$this->_test($xml_file, $argsString, $expected);
}
function testSelectCorrelated2(){
$xml_file = $this->xmlPath . "select_correlated2.xml";
$argsString = '$args->user_id = 7;
$args->module_srl = 17;
';
$expected = 'select *,
(select count(*) as "count"
from "xe_documents" as "documents"
where "documents"."user_id" = "member"."user_id"
and "module_srl" = 17
) as "totaldocumentcount"
from "xe_member" as "member"
where "user_id" = \'7\'';
$this->_test($xml_file, $argsString, $expected);
}
function testWhereCorrelated1(){
$xml_file = $this->xmlPath . "where_correlated1.xml";
$argsString = '';
$expected = 'select *
from "xe_member" as "member"
where "regdate" = (
select max("regdate") as "maxregdate"
from "xe_documents" as "documents"
where "documents"."user_id" = "member"."user_id"
)';
$this->_test($xml_file, $argsString, $expected);
}
function testWhereCorrelated2(){
$xml_file = $this->xmlPath . "where_correlated2.xml";
$argsString = '$args->module_srl = 12; $args->member_srl = 19;';
$expected = 'select *
from "xe_member" as "member"
where "member_srl" = 19
and "regdate" = (
select max("regdate") as "maxregdate"
from "xe_documents" as "documents"
where "documents"."user_id" = "member"."user_id"
and "module_srl" = 12
)
';
$this->_test($xml_file, $argsString, $expected);
}
function testFromCorrelated1(){
$xml_file = $this->xmlPath . "from_correlated1.xml";
$argsString = '';
$expected = 'select "m"."member_srl"
, "m"."nickname"
, "m"."regdate"
, "a"."count"
from (
select "member_srl" as "member_srl"
, count(*) as "count"
from "xe_documents" as "documents"
group by "member_srl"
) as "a"
left join "xe_member" as "m" on "m"."member" = "a"."member_srl"';
$this->_test($xml_file, $argsString, $expected);
}
function testFromCorrelated2(){
$xml_file = $this->xmlPath . "from_correlated2.xml";
$argsString = '$args->module_srl = 12; $args->count = 20;';
$expected = 'select "m"."member_srl"
, "m"."nickname"
, "m"."regdate"
, "a"."count"
from (
select "member_srl" as "member_srl"
, count(*) as "count"
from "xe_documents" as "documents"
where "module_srl" = 12
group by "member_srl"
) as "a"
left join "xe_member" as "m" on "m"."member" = "a"."member_srl"
where "a"."count" >= 20
';
$this->_test($xml_file, $argsString, $expected);
}
}
?>

View file

@ -1,98 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class CubridUpdateTest extends CubridTest {
function _test($xml_file, $argsString, $expected){
$this->_testQuery($xml_file, $argsString, $expected, 'getUpdateSql');
}
function test_module_updateModule(){
$xml_file = _XE_PATH_ . "modules/module/queries/updateModule.xml";
$argsString = ' $args->module_category_srl = 0;
$args->browser_title = "test";
$args->layout_srl = 0;
$args->mlayout_srl = 0;
$args->module = "page";
$args->mid = "test";
$args->use_mobile = "";
$args->site_srl = 0;
$args->module_srl = 47374;';
$expected = 'update "xe_modules" as "modules"
set "module" = \'page\'
, "module_category_srl" = 0
, "layout_srl" = 0
, "mid" = \'test\'
, "browser_title" = \'test\'
, "description" = \'\'
, "is_default" = \'n\'
, "open_rss" = \'y\'
, "header_text" = \'\'
, "footer_text" = \'\'
, "mlayout_srl" = 0
, "use_mobile" = \'n\'
where "site_srl" = 0 and "module_srl" = 47374';
// $expected = 'UPDATE "xe_modules" as "modules"
// SET "module" = \'page\'
// , "mid" = \'test\'
// , "browser_title" = \'test\'
// , "description" = \'\'
// , "is_default" = \'N\'
// , "open_rss" = \'Y\'
// , "header_text" = \'\'
// , "footer_text" = \'\'
// , "use_mobile" = \'n\'
// WHERE "site_srl" = 0
// AND "module_srl" = 47374';
$this->_test($xml_file, $argsString, $expected);
}
function test_member_updateLastLogin(){
$xml_file = _XE_PATH_ . "modules/member/queries/updateLastLogin.xml";
$argsString = ' $args->member_srl = 4;
$args->last_login = "20110607120549";';
$expected = 'UPDATE "xe_member" as "member" SET "member_srl" = 4, "last_login" = \'20110607120549\' WHERE "member_srl" = 4';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_updatePoint(){
$xml_file = _XE_PATH_ . "modules/point/queries/updatePoint.xml";
$argsString = ' $args->member_srl = 4;
$args->point = 105;';
$expected = 'UPDATE "xe_point" as "point" SET "point" = 105 WHERE "member_srl" = 4';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_updateCounterUnique(){
$xml_file = _XE_PATH_ . "modules/counter/queries/updateCounterUnique.xml";
$argsString = '$args->regdate = 20110607;
';
$expected = 'UPDATE "xe_counter_status" as "counter_status" SET "unique_visitor" = "unique_visitor" + 1,
"pageview" = "pageview" + 1 WHERE "regdate" = 20110607 ';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_updateMenu(){
$xml_file = _XE_PATH_ . "modules/menu/queries/updateMenu.xml";
$argsString = '$args->menu_srl = 204;
$args->title = "test_menu";
';
$expected = 'UPDATE "xe_menu" as "menu" SET "title" = \'test_menu\' WHERE "menu_srl" = 204';
$this->_test($xml_file, $argsString, $expected);
}
function test_menu_updateMenuItemNode(){
$xml_file = _XE_PATH_ . "modules/menu/queries/updateMenuItemNode.xml";
$argsString = '$args->parent_srl = 0;
$args->menu_srl = 237423;
$args->listorder = -8;
$args->menu_item_srl = 237431;';
$expected = 'UPDATE "xe_menu_item" as "menu_item" SET "parent_srl" = 0, "listorder" = -8 WHERE "menu_item_srl" = 237431';
$this->_test($xml_file, $argsString, $expected);
}
// $queryTester->test_admin_deleteActionForward();
// $queryTester->test_module_insertModule();
}

View file

@ -1,8 +0,0 @@
<query id="getNewestDocuments" action="select">
<tables>
<table name="modules" />
</tables>
<columns>
<column name="expose_count" click_count="incr_expose_count"/>
</columns>
</query>

View file

@ -1,21 +0,0 @@
<query id="getMemberInfo" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<query operation="equal" column="regdate" notnull="notnull" alias="documentMaxRegdate">
<tables>
<table name="documents" alias="documents" />
</tables>
<columns>
<column name="max(regdate)" alias="maxregdate" />
</columns>
<conditions>
<condition operation="equal" column="documents.user_id" var="member.user_id" notnull="notnull" />
</conditions>
</query>
</conditions>
</query>

View file

@ -1,27 +0,0 @@
<query id="getMemberInfo" action="select">
<tables>
<table query="true" alias="a">
<tables>
<table name="documents" alias="documents" />
</tables>
<columns>
<column name="member_srl" alias="member_srl" />
<column name="count(*)" alias="count" />
</columns>
<groups>
<group column="member_srl" />
</groups>
</table>
<table name="member" alias="m" type="left join">
<conditions>
<condition operation="equal" column="m.member" default="a.member_srl" />
</conditions>
</table>
</tables>
<columns>
<column name="m.member_srl" />
<column name="m.nickname" />
<column name="m.regdate" />
<column name="a.count" />
</columns>
</query>

View file

@ -1,33 +0,0 @@
<query id="getMemberInfo" action="select">
<tables>
<table query="true" alias="a">
<tables>
<table name="documents" alias="documents" />
</tables>
<columns>
<column name="member_srl" alias="member_srl" />
<column name="count(*)" alias="count" />
</columns>
<conditions>
<condition operation="equal" column="module_srl" var="module_srl" notnull="notnull" />
</conditions>
<groups>
<group column="member_srl" />
</groups>
</table>
<table name="member" alias="m" type="left join">
<conditions>
<condition operation="equal" column="m.member" default="a.member_srl" />
</conditions>
</table>
</tables>
<columns>
<column name="m.member_srl" />
<column name="m.nickname" />
<column name="m.regdate" />
<column name="a.count" />
</columns>
<conditions>
<condition operation="more" column="a.count" var="count" notnull="notnull" />
</conditions>
</query>

View file

@ -1,19 +0,0 @@
<query id="getMemberInfo" action="select">
<tables>
<table query="true" alias="documentCountByMember">
<tables>
<table name="documents" alias="documents" />
</tables>
<columns>
<column name="member_srl" alias="member_srl" />
<column name="count(*)" alias="count" />
</columns>
<groups>
<group column="member_srl" />
</groups>
</table>
</tables>
<columns>
<column name="MAX(documentCountByMember.count)" alias="maxCount" />
</columns>
</query>

View file

@ -1,25 +0,0 @@
<query id="getMemberInfo" action="select">
<tables>
<table query="true" alias="documentCountByMember">
<tables>
<table name="documents" alias="documents" />
</tables>
<columns>
<column name="member_srl" alias="member_srl" />
<column name="count(*)" alias="count" />
</columns>
<conditions>
<condition operation="equal" column="module_srl" var="module_srl" notnull="notnull" />
</conditions>
<groups>
<group column="member_srl" />
</groups>
</table>
</tables>
<columns>
<column name="MAX(documentCountByMember.count)" alias="maxCount" />
</columns>
<conditions>
<condition operation="equal" column="member_srl" var="member_srl" notnull="notnull" />
</conditions>
</query>

View file

@ -1,11 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="CUBRID">
<index table="member" name="idx_member_list_order" type="IGNORE" />
</index_hint>
</query>

View file

@ -1,11 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="ALL">
<index table="member" name="idx_member_list_order" type="USE" />
</index_hint>
</query>

View file

@ -1,11 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="MYSQL">
<index table="member" name="idx_member_list_order" type="IGNORE" />
</index_hint>
</query>

View file

@ -1,11 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="CUBRID">
<index table="member" name="idx_member_list_order" type="USE" />
</index_hint>
</query>

View file

@ -1,24 +0,0 @@
<query id="getOpageList" action="select">
<tables>
<table name="modules" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="module" default="opage" />
<group pipe="and">
<condition operation="like" column="mid" var="s_mid" pipe="or" />
<condition operation="like" column="title" var="s_title" pipe="or" />
<condition operation="like" column="comment" var="s_comment" pipe="or" />
<condition operation="equal" column="module" var="s_module" pipe="or" />
<condition operation="equal" column="module_category_srl" var="s_module_category_srl" pipe="or" />
</group>
</conditions>
<navigation>
<index var="sort_index" default="module_srl" order="desc" />
<list_count var="list_count" default="20" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
</query>

View file

@ -1,40 +0,0 @@
<query id="getLatestItem" action="select">
<tables>
<table name="resource_packages" alias="package" />
<table name="member" alias="member" />
<table name="resource_items" alias="item" />
</tables>
<columns>
<column name="package.module_srl" alias="module_srl"/>
<column name="package.status" alias="status"/>
<column name="package.category_srl" alias="category_srl"/>
<column name="package.member_srl" alias="member_srl"/>
<column name="package.package_srl" alias="package_srl"/>
<column name="package.path" alias="path"/>
<column name="package.license" alias="license"/>
<column name="package.title" alias="title"/>
<column name="package.homepage" alias="homepage"/>
<column name="package.description" alias="package_description"/>
<column name="package.voter" alias="package_voter"/>
<column name="package.voted" alias="package_voted"/>
<column name="package.downloaded" alias="package_downloaded"/>
<column name="package.regdate" alias="package_regdate"/>
<column name="package.last_update" alias="package_last_update"/>
<column name="member.nick_name" alias="nick_name" />
<column name="member.user_id" alias="user_id" />
<column name="item.item_srl" alias="item_srl" />
<column name="item.document_srl" alias="document_srl" />
<column name="item.file_srl" alias="item_file_srl" />
<column name="item.screenshot_url" alias="item_screenshot_url" />
<column name="item.version" alias="item_version" />
<column name="item.voter" alias="item_voter" />
<column name="item.voted" alias="item_voted" />
<column name="item.downloaded" alias="item_downloaded" />
<column name="item.regdate" alias="item_regdate" />
</columns>
<conditions>
<condition operation="equal" column="package.package_srl" var="package_srl" filter="number" />
<condition operation="equal" column="package.member_srl" default="member.member_srl" filter="number" pipe="and" />
<condition operation="equal" column="item.item_srl" var="item_srl" default="package.latest_item_srl" filter="number" pipe="and" />
</conditions>
</query>

View file

@ -1,11 +0,0 @@
<query id="testRlike1" action="select">
<tables>
<table name="modules" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="like" column="title" var="title" />
</conditions>
</query>

View file

@ -1,22 +0,0 @@
<query id="getStatistics" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
<query id="getMemberDocumentCount" alias="totalDocumentCount">
<tables>
<table name="documents" alias="documents" />
</tables>
<columns>
<column name="count(*)" alias="count" />
</columns>
<conditions>
<condition operation="equal" column="documents.user_id" default="member.user_id" />
</conditions>
</query>
</columns>
<conditions>
<condition operation="equal" column="user_id" var="user_id" notnull="notnull" />
</conditions>
</query>

View file

@ -1,23 +0,0 @@
<query id="getStatistics" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
<query id="getMemberDocumentCount" alias="totalDocumentCount">
<tables>
<table name="documents" alias="documents" />
</tables>
<columns>
<column name="count(*)" alias="count" />
</columns>
<conditions>
<condition operation="equal" column="documents.user_id" default="member.user_id" />
<condition operation="equal" column="module_srl" var="module_srl" notnull="notnull" pipe="and" />
</conditions>
</query>
</columns>
<conditions>
<condition operation="equal" column="user_id" var="user_id" notnull="notnull" />
</conditions>
</query>

View file

@ -1,19 +0,0 @@
<query id="select_uncorrelated" action="select">
<tables>
<table name="table_a" />
</tables>
<columns>
<column name="column_a" alias="value_a" />
<query alias="value_b">
<tables>
<table name="table_b" />
</tables>
<columns>
<column name="max(column_b)" alias="count" />
</columns>
</query>
</columns>
<conditions>
<condition operation="equal" column="column_a" var="user_id" notnull="notnull" />
</conditions>
</query>

View file

@ -1,24 +0,0 @@
<query id="select_uncorrelated" action="select">
<tables>
<table name="table_a" />
</tables>
<columns>
<column name="column_a" alias="value_a" />
<column name="column_b" alias="value_b" />
<query alias="value_b">
<tables>
<table name="table_b" />
</tables>
<columns>
<column name="max(column_b)" alias="count" />
</columns>
<conditions>
<condition operation="equal" column="column_ab" var="user_name" notnull="notnull" />
</conditions>
</query>
<column name="column_c" alias="value_c" />
</columns>
<conditions>
<condition operation="equal" column="column_a" var="user_id" notnull="notnull" />
</conditions>
</query>

View file

@ -1,19 +0,0 @@
<query id="getGrantedModules" action="select">
<tables>
<table name="module_grants" />
</tables>
<columns>
<column name="module_srl" />
</columns>
<conditions>
<condition operation="in" column="name" default="'access','view','list'" notnull="notnull" />
<group pipe="and">
<condition operation="more" column="group_srl" default="1" notnull="notnull" />
<condition operation="equal" column="group_srl" default="-1" notnull="notnull" pipe="or" />
<condition operation="equal" column="group_srl" default="-2" notnull="notnull" pipe="or" />
</group>
</conditions>
<groups>
<group column="module_srl" />
</groups>
</query>

View file

@ -1,26 +0,0 @@
<query id="getModules" action="select">
<tables>
<table name="sites" />
<table name="modules" />
<table name="syndication_except_modules" alias="except_modules" type="left join">
<conditions>
<condition operation="equal" column="modules.module_srl" default="except_modules.module_srl" />
</conditions>
</table>
</tables>
<columns>
<column name="modules.site_srl" alias="site_srl" />
<column name="modules.module_srl" alias="module_srl" />
<column name="sites.domain" alias="domain" />
<column name="modules.mid" alias="mid" />
<column name="modules.module" alias="module" />
<column name="modules.browser_title" alias="browser_title" />
<column name="modules.description" alias="description" />
</columns>
<conditions>
<condition operation="in" column="modules.module_srl" var="module_srls" />
<condition operation="notin" column="modules.module_srl" var="except_module_srls" pipe="and" />
<condition operation="equal" column="sites.site_srl" default="modules.site_srl" notnull="notnull" pipe="and" />
<condition operation="null" column="except_modules.module_srl" default="1" pipe="and" />
</conditions>
</query>

View file

@ -1,14 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
<table name="document" alias="document" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="CUBRID">
<index table="member" name="idx_member_list_order" type="USE" />
<index table="member" name="idx_member_srl" type="USE" />
<index table="document" name="idx_document_srl" type="USE" />
</index_hint>
</query>

View file

@ -1,14 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
<table name="document" alias="document" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="CUBRID">
<index table="member" name="idx_member_list_order" type="USE" />
<index table="member" name="idx_member_srl" type="FORCE" />
<index table="document" name="idx_document_srl" type="USE" />
</index_hint>
</query>

View file

@ -1,12 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="CUBRID">
<index table="member" name="idx_member_list_order" type="USE" />
<index table="member" name="idx_member_srl" type="USE" />
</index_hint>
</query>

View file

@ -1,21 +0,0 @@
<query id="getMemberInfo" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<query alias="documentMaxRegdate" operation="equal" column="regdate" notnull="notnull">
<tables>
<table name="documents" alias="documents" />
</tables>
<columns>
<column name="max(regdate)" alias="maxregdate" />
</columns>
<conditions>
<condition operation="equal" column="documents.user_id" default="member.user_id" notnull="notnull" />
</conditions>
</query>
</conditions>
</query>

View file

@ -1,23 +0,0 @@
<query id="getMemberInfo" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="member_srl" var="member_srl" notnull="notnull"/>
<query alias="documentMaxRegdate" operation="equal" column="regdate" notnull="notnull" pipe="and" >
<tables>
<table name="documents" alias="documents" />
</tables>
<columns>
<column name="max(regdate)" alias="maxregdate" />
</columns>
<conditions>
<condition operation="equal" column="documents.user_id" default="member.user_id" notnull="notnull" />
<condition operation="equal" column="module_srl" var="module_srl" notnull="notnull" pipe="and" />
</conditions>
</query>
</conditions>
</query>

View file

@ -1,18 +0,0 @@
<query id="getMemberInfo" action="select">
<tables>
<table name="member" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<query operation="equal" column="regdate" alias="documentMaxRegdate">
<tables>
<table name="documents" />
</tables>
<columns>
<column name="max(regdate)" alias="maxregdate" />
</columns>
</query>
</conditions>
</query>

View file

@ -1,65 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class MssqlIndexHintTest extends MssqlTest {
var $xmlPath = 'data/';
function MssqlIndexHintTest(){
$this->xmlPath = str_replace('MssqlIndexHintTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
}
function _test($xml_file, $argsString, $expected){
$this->_testQuery($xml_file, $argsString, $expected, 'getSelectSql');
}
function testOneUseIndexHintAndOneTable(){
$xml_file = $this->xmlPath . "one_index_hint_one_table.xml";
$argsString = '';
$expected = 'select * from [xe_member] as [member] with(index([idx_member_list_order]))';
$this->_test($xml_file, $argsString, $expected);
}
function testTwoUseIndexHintsAndOneTable(){
$xml_file = $this->xmlPath . "two_index_hints_one_table.xml";
$argsString = '';
$expected = 'select * from [xe_member] as [member] with(index([idx_member_list_order]), index([idx_member_srl]))';
$this->_test($xml_file, $argsString, $expected);
}
function testThreeUseIndexHintsAndTwoTables(){
$xml_file = $this->xmlPath . "three_index_hints_two_tables.xml";
$argsString = '';
$expected = 'select * from [xe_member] as [member] with(index([idx_member_list_order]), index([idx_member_srl]))
, [xe_document] as [document] with(index([idx_document_srl]))';
$this->_test($xml_file, $argsString, $expected);
}
/**
* Tests that index is added if "for" attribute is "ALL"
*
* example: <index_hint for="ALL"> ... </index_hint>
*/
function testIndexHintForAll(){
$xml_file = $this->xmlPath . "index_hint_for_all.xml";
$argsString = '';
$expected = 'select * from [xe_member] as [member] with(index([idx_member_list_order]))';
$this->_test($xml_file, $argsString, $expected);
}
function testIgnoreIndexHintIsSkipped(){
$xml_file = $this->xmlPath . "ignore_index_hint.xml";
$argsString = '';
$expected = 'select * from [xe_member] as [member]';
$this->_test($xml_file, $argsString, $expected);
}
function testMysqlIndexHintIsSkipped(){
$xml_file = $this->xmlPath . "mysql_index_hint.xml";
$argsString = '';
$expected = 'select * from [xe_member] as [member]';
$this->_test($xml_file, $argsString, $expected);
}
}
?>

View file

@ -1,12 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class MssqlSelectOnlineTest extends MssqlOnlineTest {
function test_syndication_getGrantedModule(){
$args->module_srl = 67;
$output = executeQuery("syndication.getGrantedModule", $args);
$this->assertEquals(0, $output->error, $output->error + ' ' + $output->message);
}
}
?>

View file

@ -1,171 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class MssqlSelectTest extends MssqlTest {
function _test($xml_file, $argsString, $expected, $expectedArgs = NULL){
$this->_testPreparedQuery($xml_file, $argsString, $expected, 'getSelectSql', $expectedArgs);
}
function testSelectStar(){
$xml_file = _XE_PATH_ . "modules/module/queries/getAdminId.xml";
$argsString = '$args->module_srl = 10;';
$expected = 'SELECT * FROM [xe_module_admins] as [module_admins] , [xe_member] as [member] WHERE [module_srl] = ? and [member].[member_srl] = [module_admins].[member_srl]';
$this->_test($xml_file, $argsString, $expected, array(10));
}
function testRequiredParameter(){
$xml_file = _XE_PATH_ . "modules/module/queries/getAdminId.xml";
$argsString = '';
$expected = 'Date incorecte! Query-ul nu a putut fi executat.';
$this->_test($xml_file, $argsString, $expected);
}
function testWithoutCategoriesTag(){
$xml_file = _XE_PATH_ . "modules/module/queries/getModuleCategories.xml";
$argsString = '';
$expected = 'SELECT * FROM [xe_module_categories] as [module_categories] ORDER BY [title] asc';
$this->_test($xml_file, $argsString, $expected);
}
function test_module_getDefaultModules(){
$xml_file = _XE_PATH_ . "modules/module/queries/getDefaultModules.xml";
$argsString = '$args->site_srl = 0;';
$expected = 'SELECT [modules].[site_srl]
, [modules].[module]
, [modules].[mid]
, [modules].[browser_title]
, [module_categories].[title] as [category]
, [modules].[module_srl]
FROM [xe_modules] as [modules]
left join [xe_module_categories] as [module_categories]
on [module_categories].[module_category_srl] = [modules].[module_category_srl]
WHERE [modules].[site_srl] = ?
ORDER BY [modules].[module] asc, [module_categories].[title] asc, [modules].[mid] asc';
$this->_test($xml_file, $argsString, $expected, array(0));
}
function test_module_getSiteInfo(){
$xml_file = _XE_PATH_ . "modules/module/queries/getSiteInfo.xml";
$argsString = '$args->site_srl = 0;';
$expected = 'SELECT [modules].[site_srl] as [module_site_srl]
, [modules].[module_srl] as [module_srl]
, [modules].[module] as [module]
, [modules].[module_category_srl] as [module_category_srl]
, [modules].[layout_srl] as [layout_srl]
, [modules].[mlayout_srl] as [mlayout_srl]
, [modules].[use_mobile] as [use_mobile]
, [modules].[menu_srl] as [menu_srl]
, [modules].[mid] as [mid]
, [modules].[skin] as [skin]
, [modules].[mskin] as [mskin]
, [modules].[browser_title] as [browser_title]
, [modules].[description] as [description]
, [modules].[is_default] as [is_default]
, [modules].[content] as [content]
, [modules].[mcontent] as [mcontent]
, [modules].[open_rss] as [open_rss]
, [modules].[header_text] as [header_text]
, [modules].[footer_text] as [footer_text]
, [modules].[regdate] as [regdate]
, [sites].[site_srl] as [site_srl]
, [sites].[domain] as [domain]
, [sites].[index_module_srl] as [index_module_srl]
, [sites].[default_language] as [default_language]
FROM [xe_sites] as [sites]
left join [xe_modules] as [modules] on [modules].[module_srl] = [sites].[index_module_srl]
WHERE [sites].[site_srl] = ? ';
$this->_test($xml_file, $argsString, $expected, array(0));
}
function test_addon_getAddonInfo(){
$xml_file = _XE_PATH_ . "modules/addon/queries/getAddonInfo.xml";
$argsString = '$args->addon = "captcha";';
$expected = 'SELECT *
FROM [xe_addons] as [addons]
WHERE [addon] = ? ';
$this->_test($xml_file, $argsString, $expected, array("'captcha'"));
}
function test_addon_getAddons(){
$xml_file = _XE_PATH_ . "modules/addon/queries/getAddons.xml";
$argsString = '';
$expected = 'SELECT *
FROM [xe_addons] as [addons]
ORDER BY [addon] asc';
$this->_test($xml_file, $argsString, $expected);
}
function test_admin_getCommentCount(){
$xml_file = _XE_PATH_ . "modules/admin/queries/getCommentCount.xml";
$argsString = '';
$expected = 'SELECT count(*) as [count]
FROM [xe_comments] as [comments]';
$this->_test($xml_file, $argsString, $expected);
}
function test_admin_getCommentDeclaredStatus(){
$xml_file = _XE_PATH_ . "modules/admin/queries/getCommentDeclaredStatus.xml";
$argsString = '$args->date = "20110411";';
$expected = 'SELECT TOP 2 substr([regdate],1,8) as [date], count(*) as [count]
FROM [xe_comment_declared_log] as [comment_declared_log]
WHERE [regdate] >= ?
GROUP BY substr([regdate],1,8)
ORDER BY substr([regdate],1,8) asc';
$this->_test($xml_file, $argsString, $expected, array("'20110411'"));
}
function test_member_getAutoLogin(){
$xml_file = _XE_PATH_ . "modules/member/queries/getAutoLogin.xml";
$argsString = '$args->autologin_key = 10;';
$expected = 'SELECT [member].[user_id] as [user_id]
, [member].[password] as [password]
, [member_autologin].[autologin_key] as [autologin_key]
FROM [xe_member] as [member] , [xe_member_autologin] as [member_autologin]
WHERE [member_autologin].[autologin_key] = ?
and [member].[member_srl] = [member_autologin].[member_srl]';
$this->_test($xml_file, $argsString, $expected, array("'10'"));
}
/**
* Query fails because XML is wrong - title column does not exist
* in xe_modules. Maybe the developer ment "browser_title"
*/
function test_opage_getOpageList(){
$xml_file = _TEST_PATH_ . "db/xml_query/mssql/data/opage.getOpageList.xml";
$argsString = '$args->s_title = "yuhuu";
$args->module = \'opage\';';
$expected = 'SELECT TOP 20 *
FROM [xe_modules] as [modules]
WHERE [module] = \'opage\' and ([title] like ?)
ORDER BY [module_srl] desc';
$this->_test($xml_file, $argsString, $expected, array("'%yuhuu%'"));
}
function test_module_getExtraVars(){
$xml_file = _XE_PATH_ . "modules/module/queries/getModuleExtraVars.xml";
$argsString = '$args->module_srl = 25;';
$expected = 'SELECT * FROM [xe_module_extra_vars] as [module_extra_vars] WHERE [module_srl] in (?)';
$this->_test($xml_file, $argsString, $expected, array(array(25)));
}
function test_module_getModuleSites(){
$xml_file = _XE_PATH_ . "modules/module/queries/getModuleSites.xml";
$argsString = '$args->module_srls = "67, 65";';
$expected = 'SELECT [modules].[module_srl] as [module_srl], [sites].[domain] as [domain] FROM [xe_modules] as [modules] , [xe_sites] as [sites] WHERE [modules].[module_srl] in (?,?) and [sites].[site_srl] = [modules].[site_srl]';
$this->_test($xml_file, $argsString, $expected, array(array(67, 65)));
}
function test_syndication_getGrantedModule(){
$xml_file = _TEST_PATH_ . "db/xml_query/mssql/data/syndication.getGrantedModule.xml";
$argsString = '$args->module_srl = 67;';
$expected = 'select count(*) as [count]
from [xe_module_grants] as [module_grants]
where [module_srl] = ?
and [name] in (\'access\',\'view\',\'list\')
and ([group_srl] >= 1
or [group_srl] = -1
or [group_srl] = -2)';
$this->_test($xml_file, $argsString, $expected, array(67));
}
}

View file

@ -1,13 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class MssqlUpdateOnlineTest extends MssqlOnlineTest {
function test_counter_updateCounterUnique(){
$args->regdate = 20110211;
$output = executeQuery("counter.updateCounterUnique", $args);
$this->assertEquals(0, $output->error, $output->error + ' ' + $output->message);
}
}
?>

View file

@ -1,23 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class MssqlUpdateTest extends MssqlTest {
function _test($xml_file, $argsString, $expected, $expectedArgs = NULL) {
$this->_testPreparedQuery($xml_file, $argsString, $expected, 'getUpdateSql', $expectedArgs = NULL);
}
function test_counter_updateCounterUnique() {
$xml_file = _XE_PATH_ . "modules/counter/queries/updateCounterUnique.xml";
$argsString = '$args->regdate = 25;';
$expected = 'UPDATE [counter_status]
SET [unique_visitor] = [unique_visitor] + ?
, [pageview] = [pageview] + ?
FROM [xe_counter_status] as [counter_status]
WHERE [regdate] = ?';
$this->_test($xml_file, $argsString, $expected, array("25", 1, 1));
}
}
?>

View file

@ -1,11 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="MSSQL">
<index table="member" name="idx_member_list_order" type="IGNORE" />
</index_hint>
</query>

View file

@ -1,11 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="ALL">
<index table="member" name="idx_member_list_order" type="USE" />
</index_hint>
</query>

View file

@ -1,11 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="MYSQL">
<index table="member" name="idx_member_list_order" type="IGNORE" />
</index_hint>
</query>

View file

@ -1,11 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="MSSQL">
<index table="member" name="idx_member_list_order" type="USE" />
</index_hint>
</query>

View file

@ -1,24 +0,0 @@
<query id="getOpageList" action="select">
<tables>
<table name="modules" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="module" default="opage" />
<group pipe="and">
<condition operation="like" column="mid" var="s_mid" pipe="or" />
<condition operation="like" column="title" var="s_title" pipe="or" />
<condition operation="like" column="comment" var="s_comment" pipe="or" />
<condition operation="equal" column="module" var="s_module" pipe="or" />
<condition operation="equal" column="module_category_srl" var="s_module_category_srl" pipe="or" />
</group>
</conditions>
<navigation>
<index var="sort_index" default="module_srl" order="desc" />
<list_count var="list_count" default="20" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
</query>

View file

@ -1,17 +0,0 @@
<query id="getGrantedModule" action="select">
<tables>
<table name="module_grants" />
</tables>
<columns>
<column name="count(*)" alias="count" />
</columns>
<conditions>
<condition operation="equal" column="module_srl" var="module_srl" filter="number" notnull="notnull" />
<condition operation="in" column="name" default="'access','view','list'" notnull="notnull" pipe="and" />
<group pipe="and">
<condition operation="more" column="group_srl" default="1" notnull="notnull" />
<condition operation="equal" column="group_srl" default="-1" notnull="notnull" pipe="or" />
<condition operation="equal" column="group_srl" default="-2" notnull="notnull" pipe="or" />
</group>
</conditions>
</query>

View file

@ -1,14 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
<table name="document" alias="document" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="MSSQL">
<index table="member" name="idx_member_list_order" type="USE" />
<index table="member" name="idx_member_srl" type="USE" />
<index table="document" name="idx_document_srl" type="USE" />
</index_hint>
</query>

View file

@ -1,12 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="MSSQL">
<index table="member" name="idx_member_list_order" type="USE" />
<index table="member" name="idx_member_srl" type="USE" />
</index_hint>
</query>

View file

@ -1,59 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class MysqlIndexHintTest extends MysqlTest {
var $xmlPath = 'data/';
function MysqlIndexHintTest(){
$this->xmlPath = str_replace('MysqlIndexHintTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
}
function _test($xml_file, $argsString, $expected){
$this->_testQuery($xml_file, $argsString, $expected, 'getSelectSql');
}
function testOneUseIndexHintAndOneTable(){
$xml_file = $this->xmlPath . "one_index_hint_one_table.xml";
$argsString = '';
$expected = 'select * from `xe_member` as `member` use index (`idx_member_list_order`)';
$this->_test($xml_file, $argsString, $expected);
}
function testTwoUseIndexHintsAndOneTable(){
$xml_file = $this->xmlPath . "two_index_hints_one_table.xml";
$argsString = '';
$expected = 'select * from `xe_member` as `member` use index (`idx_member_list_order`, `idx_member_srl`)';
$this->_test($xml_file, $argsString, $expected);
}
function testThreeUseIndexHintsAndTwoTables(){
$xml_file = $this->xmlPath . "three_index_hints_two_tables.xml";
$argsString = '';
$expected = 'select * from `xe_member` as `member` use index (`idx_member_list_order`, `idx_member_srl`)
, `xe_document` as `document` use index (`idx_document_srl`)';
$this->_test($xml_file, $argsString, $expected);
}
function testThreeIndexHintsAndTwoTables_ForceAndIgnore(){
$xml_file = $this->xmlPath . "three_index_hints_two_tables_combined.xml";
$argsString = '';
$expected = 'select * from `xe_member` as `member` force index (`idx_member_list_order`, `idx_member_srl`)
, `xe_document` as `document` ignore index (`idx_document_srl`)';
$this->_test($xml_file, $argsString, $expected);
}
/**
* Tests that index is added if "for" attribute is "ALL"
*
* example: <index_hint for="ALL"> ... </index_hint>
*/
function testIndexHintForAll(){
$xml_file = $this->xmlPath . "index_hint_for_all.xml";
$argsString = '';
$expected = 'select * from `xe_member` as `member` use index (`idx_member_list_order`)';
$this->_test($xml_file, $argsString, $expected);
}
}
?>

View file

@ -1,76 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* @class MysqlInsertTest
* @brief Constains all test method for insert statements, using Mysql SQL syntax
* @developer Corina Udrescu (xe_dev@arnia.ro)
*/
class MysqlInsertTest extends MysqlTest
{
/**
* @brief _test - local helper method
* @developer Corina Udrescu (xe_dev@arnia.ro)
* @access private
* @param $xml_file string - Path to XML file containing the query to be tested
* @param $argsString string - String containing PHP code that initializez the arguments that the query receives
* @param $expected string - Expected SQL query as string
* @param $columnList array - Array containing the column names that will be retrieved, in case only a part of the ones in the query file are needed
* @return void
*/
function _test($xml_file, $argsString, $expected, $columnList = NULL)
{
$this->_testQuery($xml_file, $argsString, $expected, 'getInsertSql', $columnList);
}
function testInsertIntoNumericColumnConvertsValue()
{
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/member_insert_injection.xml";
$argsString = '$args->member_srl = 7;
$args->find_account_question = "1\'";
';
$expected = 'insert into `xe_member` (`member_srl`, `find_account_question`) values (7, 1)';
$this->_test($xml_file, $argsString, $expected);
}
}
/* End of file MysqlInsertTest.php */
/* Location: ./tests/classes/db/db/xml_query/mysql/MysqlInsertTest.php */
/**
* @brief testInsertSelectStatement - checks that when query action is 'insert-selct' an 'INSERT INTO .. SELECT ...' statement is properly generated
* @developer Corina Udrescu (xe_dev@arnia.ro)
* @access public
* @return void
*/
function testInsertSelectStatement()
{
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/insert_select.xml";
$argsString = '$args->condition_value = 7;';
$expected = 'insert into `xe_table1` (`column1`, `column2`, `column3`)
select `column4`, `column5`, `column6`
from `xe_table2` as `table2`
where `column4` >= 7';
$this->_test($xml_file, $argsString, $expected);
}
function testInsertSelectStatement2()
{
$xml_file = _XE_PATH_ . "modules/wiki/queries/insertLinkedDocuments.xml";
$argsString = '$args->document_srl = 7;
$args->module_srl = 10;
$args->alias_list = array("unu", "doi");
';
$expected = 'insert into `xe_wiki_links`
(`cur_doc_srl`, `link_doc_srl`)
select 7, `document_srl`
from `xe_document_aliases` as `document_aliases`
where `module_srl` = 10
and `alias_title` in (\'unu\',\'doi\')';
$this->_test($xml_file, $argsString, $expected);
}
}
/* End of file MysqlInsertTest.php */
/* Location: ./tests/classes/db/db/xml_query/mysql/MysqlInsertTest.php */

View file

@ -1,417 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class MysqlSelectTest extends MysqlTest {
function _test($xml_file, $argsString, $expected, $columnList = NULL) {
$this->_testQuery($xml_file, $argsString, $expected, 'getSelectSql', $columnList);
}
function testConditionWithVarAndColumnDefaultValue_WithoutArgument() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/resource.getLatestItem.xml";
$argsString = '$args->item_srl = "";';
$expected = 'select `package`.`module_srl` as `module_srl`
, `package`.`status` as `status`
, `package`.`category_srl` as `category_srl`
, `package`.`member_srl` as `member_srl`
, `package`.`package_srl` as `package_srl`
, `package`.`path` as `path`
, `package`.`license` as `license`
, `package`.`title` as `title`
, `package`.`homepage` as `homepage`
, `package`.`description` as `package_description`
, `package`.`voter` as `package_voter`
, `package`.`voted` as `package_voted`
, `package`.`downloaded` as `package_downloaded`
, `package`.`regdate` as `package_regdate`
, `package`.`last_update` as `package_last_update`
, `member`.`nick_name` as `nick_name`
, `member`.`user_id` as `user_id`
, `item`.`item_srl` as `item_srl`
, `item`.`document_srl` as `document_srl`
, `item`.`file_srl` as `item_file_srl`
, `item`.`screenshot_url` as `item_screenshot_url`
, `item`.`version` as `item_version`
, `item`.`voter` as `item_voter`
, `item`.`voted` as `item_voted`
, `item`.`downloaded` as `item_downloaded`
, `item`.`regdate` as `item_regdate`
from `xe_resource_packages` as `package`
, `xe_member` as `member`
, `xe_resource_items` as `item`
where `package`.`member_srl` = `member`.`member_srl`
and `item`.`item_srl` = `package`.`latest_item_srl`';
$this->_test($xml_file, $argsString, $expected);
}
function testConditionWithVarAndColumnDefaultValue_WithArgument() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/resource.getLatestItem.xml";
$argsString = '$args->item_srl = "10";';
$expected = 'select `package`.`module_srl` as `module_srl`
, `package`.`status` as `status`
, `package`.`category_srl` as `category_srl`
, `package`.`member_srl` as `member_srl`
, `package`.`package_srl` as `package_srl`
, `package`.`path` as `path`
, `package`.`license` as `license`
, `package`.`title` as `title`
, `package`.`homepage` as `homepage`
, `package`.`description` as `package_description`
, `package`.`voter` as `package_voter`
, `package`.`voted` as `package_voted`
, `package`.`downloaded` as `package_downloaded`
, `package`.`regdate` as `package_regdate`
, `package`.`last_update` as `package_last_update`
, `member`.`nick_name` as `nick_name`
, `member`.`user_id` as `user_id`
, `item`.`item_srl` as `item_srl`
, `item`.`document_srl` as `document_srl`
, `item`.`file_srl` as `item_file_srl`
, `item`.`screenshot_url` as `item_screenshot_url`
, `item`.`version` as `item_version`
, `item`.`voter` as `item_voter`
, `item`.`voted` as `item_voted`
, `item`.`downloaded` as `item_downloaded`
, `item`.`regdate` as `item_regdate`
from `xe_resource_packages` as `package`
, `xe_member` as `member`
, `xe_resource_items` as `item`
where `package`.`member_srl` = `member`.`member_srl`
and `item`.`item_srl` = 10';
$this->_test($xml_file, $argsString, $expected);
}
function testSubstring() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/substring.xml";
$argsString = '$args->var_start_mmdd = "1102"; ';
$expected = 'select * from `xe_member` as `member` where substr(`extra_vars_t1`.`value`,5,4) >= 1102';
$this->_test($xml_file, $argsString, $expected);
}
function testResource_getLatestItemList() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/resource.getLatestItemList.xml";
$argsString = '';
$expected = 'select `package`.`module_srl` as `module_srl`
, `package`.`status` as `status`
, `package`.`category_srl` as `category_srl`
, `package`.`member_srl` as `member_srl`
, `package`.`package_srl` as `package_srl`
, `package`.`path` as `path`
, `package`.`license` as `license`
, `package`.`title` as `title`
, `package`.`homepage` as `homepage`
, `package`.`description` as `package_description`
, `package`.`voter` as `package_voter`
, `package`.`voted` as `package_voted`
, `package`.`downloaded` as `package_downloaded`
, `package`.`regdate` as `package_regdate`
, `package`.`last_update` as `package_last_update`
, `member`.`nick_name` as `nick_name`
, `member`.`user_id` as `user_id`
, `item`.`item_srl` as `item_srl`
, `item`.`document_srl` as `item_document_srl`
, `item`.`file_srl` as `item_file_srl`
, `item`.`screenshot_url` as `item_screenshot_url`
, `item`.`version` as `item_version`
, `item`.`voter` as `item_voter`
, `item`.`voted` as `item_voted`
, `item`.`downloaded` as `item_downloaded`
, `item`.`regdate` as `item_regdate`
, `files`.`source_filename` as `source_filename`
, `files`.`sid` as `sid`
from `xe_resource_packages` as `package`
, `xe_member` as `member`
, `xe_resource_items` as `item`
, `xe_files` as `files`
where (`package`.`status` = \'accepted\'
and `package`.`member_srl` = `member`.`member_srl`
and `item`.`item_srl` = `package`.`latest_item_srl`
and `package`.`update_order` <= 0
and `files`.`file_srl` = `item`.`file_srl`)
and `package`.`update_order` <= 2100000000
order by `package`.`update_order` asc
limit 0, 20';
$this->_test($xml_file, $argsString, $expected);
}
function test_Syndication_getGrantedModules() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/syndication.getGrantedModules.xml";
$argsString = '';
$expected = 'select `module_srl`
from `xe_module_grants` as `module_grants`
where `name` in (\'access\',\'view\',\'list\')
and (`group_srl` >= 1 or `group_srl` = -1 or `group_srl` = -2) group by `module_srl`';
$this->_test($xml_file, $argsString, $expected);
}
function test_Like_Clause() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/opage.getOpageList.like.xml";
$argsString = '$args->s_mid = "test";';
$expected = 'select *
from `xe_modules` as `modules`
where `module` = \'opage\'
and (`mid` like \'%test%\')
order by `module_srl` desc
limit 0, 20';
$this->_test($xml_file, $argsString, $expected);
}
function test_NotLike_Clause() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/opage.getOpageList.notlike.xml";
$argsString = '$args->s_mid = "test";';
$expected = 'select *
from `xe_modules` as `modules`
where `module` = \'opage\'
and (`mid` not like \'%test%\')
order by `module_srl` desc
limit 0, 20';
$this->_test($xml_file, $argsString, $expected);
}
function test_NotLikeTail_Clause() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/opage.getOpageList.notliketail.xml";
$argsString = '$args->s_mid = "test";';
$expected = 'select *
from `xe_modules` as `modules`
where `module` = \'opage\'
and (`mid` not like \'%test\')
order by `module_srl` desc
limit 0, 20';
$this->_test($xml_file, $argsString, $expected);
}
function test_NotLikePrefix_Clause() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/opage.getOpageList.notlikeprefix.xml";
$argsString = '$args->s_mid = "test";';
$expected = 'select *
from `xe_modules` as `modules`
where `module` = \'opage\'
and (`mid` not like \'test%\')
order by `module_srl` desc
limit 0, 20';
$this->_test($xml_file, $argsString, $expected);
}
function test_WidgetsNewestDocument_getNewestDocuments() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/widgets.newest_document.getNewestDocuments.xml";
$argsString = '$args->module_srl = "566036,3777868";';
$expected = 'select `modules`.`site_srl` as `site_srl`
, `modules`.`mid` as `mid`
, `documents`.*
from `xe_modules` as `modules`
, `xe_documents` as `documents`
where (
`documents`.`module_srl` not in (0)
and `documents`.`module_srl` in (566036,3777868)
and `modules`.`module_srl` = `documents`.`module_srl`)
and `documents`.`list_order` <= 2100000000
order by `documents`.`list_order` asc
limit 20';
$this->_test($xml_file, $argsString, $expected);
}
function test_homepage_getNewestComments() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/homepage.getNewestComments.xml";
$argsString = ';';
$expected = 'select `sites`.`domain` as `domain`
, `comments`.*
from `xe_homepages` as `homepages`
, `xe_sites` as `sites`
, `xe_comments` as `comments`
, `xe_modules` as `modules`
left join `xe_module_grants` as `module_grants`
on `module_grants`.`module_srl` = `modules`.`module_srl`
and `module_grants`.`name` = \'access\'
and `module_grants`.`group_srl` not in (0,-1)
where (`homepages`.`site_srl` = `sites`.`site_srl`
and `homepages`.`site_srl` = `modules`.`site_srl`
and `comments`.`module_srl` = `modules`.`module_srl`
and `module_grants`.`group_srl` is null)
and `comments`.`list_order` <= 2100000000
order by `comments`.`list_order` asc limit 0, 5';
$this->_test($xml_file, $argsString, $expected);
}
function test_distinct_outer_join() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/distinct_outer_join.xml";
$argsString = '$args->site_srl = 0;';
$expected = 'select distinct `modules`.`module_srl` as `module_site_srl`
from `xe_sites` as `sites`
left join `xe_modules` as `modules` on `modules`.`module_srl` = `sites`.`index_module_srl`
where `sites`.`site_srl` = 0';
$this->_test($xml_file, $argsString, $expected);
}
function test_getDocumentListWithinComment() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/document.getDocumentListWithinComment.xml";
$argsString = '$args->module_srl = 19778968;
$args->s_comment = "dfsds";
$args->statusList = "PUBLIC, SECRET";
';
$expected = 'select `documents`.`document_srl`, `documents`.`list_order`
from `xe_documents` as `documents`
, `xe_comments` as `comments`
where (`documents`.`module_srl` in (19778968)
and `documents`.`document_srl` = `comments`.`document_srl`
and `documents`.`status` in (\'public\',\'secret\')
and `comments`.`content` like \'%dfsds%\')
and `comments`.`list_order` <= 2100000000
group by `documents`.`document_srl`
order by `comments`.`list_order` asc
limit 0, 20';
$this->_test($xml_file, $argsString, $expected);
}
/**
* Issue 2064
* Queries should support both notin and not_in as valid operations
*/
function test_not_in() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/document.getNewestDocuments.xml";
$argsString = '$args->module_srl = "345709,345710,345711,345728,345707,345670,345667,49113,16551,345679,50394,350665,345680,381846,381852,381917,345708,349028,345666,17173,49117,345671,345714,345665,349893,345696,345713,351967,330919,345685,16754,349027,348787,345672,350239,345697,345674,291882,345678,345729,345675,345721,345676,381867,294605,381864,345673,355113,353624,345681,345683,345668,345677,12424,158716,47498,101835,273679,142558,13818,12311,8723,78670,18919,365075,13833,14293,15891,27823,14291,177818,81000,11788,18918,13859,14102,14136,255783,134367,385619,317170,330312";
$args->sort_index = "documents.list_order";
$args->order_type = "asc";
$args->list_count = 10;
';
$expected = 'select `modules`.`site_srl` as `site_srl`, `modules`.`mid` as `mid`, `documents`.* from `xe_modules` as `modules`, `xe_documents` as `documents` where (`documents`.`module_srl` not in (0) and `documents`.`module_srl` in (345709,345710,345711,345728,345707,345670,345667,49113,16551,345679,50394,350665,345680,381846,381852,381917,345708,349028,345666,17173,49117,345671,345714,345665,349893,345696,345713,351967,330919,345685,16754,349027,348787,345672,350239,345697,345674,291882,345678,345729,345675,345721,345676,381867,294605,381864,345673,355113,353624,345681,345683,345668,345677,12424,158716,47498,101835,273679,142558,13818,12311,8723,78670,18919,365075,13833,14293,15891,27823,14291,177818,81000,11788,18918,13859,14102,14136,255783,134367,385619,317170,330312) and `modules`.`module_srl` = `documents`.`module_srl`) and `documents`.`list_order` <= 2100000000 order by `documents`.`list_order` asc limit 10';
$this->_test($xml_file, $argsString, $expected);
}
/**
* Issue 2064
* Query condition should be ignored if operation is invalid
*/
function test_invalid_condition_operation() {
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/document.getNewestDocumentsInvalid.xml";
$argsString = '$args->module_srl = "345709,345710,345711,345728,345707,345670,345667,49113,16551,345679,50394,350665,345680,381846,381852,381917,345708,349028,345666,17173,49117,345671,345714,345665,349893,345696,345713,351967,330919,345685,16754,349027,348787,345672,350239,345697,345674,291882,345678,345729,345675,345721,345676,381867,294605,381864,345673,355113,353624,345681,345683,345668,345677,12424,158716,47498,101835,273679,142558,13818,12311,8723,78670,18919,365075,13833,14293,15891,27823,14291,177818,81000,11788,18918,13859,14102,14136,255783,134367,385619,317170,330312";
$args->sort_index = "documents.list_order";
$args->order_type = "asc";
$args->list_count = 10;
';
$expected = 'select `modules`.`site_srl` as `site_srl`, `modules`.`mid` as `mid`, `documents`.* from `xe_modules` as `modules`, `xe_documents` as `documents` where (`documents`.`module_srl` in (345709,345710,345711,345728,345707,345670,345667,49113,16551,345679,50394,350665,345680,381846,381852,381917,345708,349028,345666,17173,49117,345671,345714,345665,349893,345696,345713,351967,330919,345685,16754,349027,348787,345672,350239,345697,345674,291882,345678,345729,345675,345721,345676,381867,294605,381864,345673,355113,353624,345681,345683,345668,345677,12424,158716,47498,101835,273679,142558,13818,12311,8723,78670,18919,365075,13833,14293,15891,27823,14291,177818,81000,11788,18918,13859,14102,14136,255783,134367,385619,317170,330312) and `modules`.`module_srl` = `documents`.`module_srl`) and `documents`.`list_order` <= 2100000000 order by `documents`.`list_order` asc limit 10';
$this->_test($xml_file, $argsString, $expected);
}
/**
* Issue 2114
* 'Null' operation is ignored
*/
function test_null()
{
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/page.pageTypeNullCheck.xml";
$argsString = ' ';
$expected = 'select `m`.`module_srl`, `m`.`mid`, `ev`.`value`
from `xe_modules` as `m`
left join `xe_module_extra_vars` as `ev`
on `ev`.`name` = \'page_type\'
and `m`.`module_srl` = `ev`.`module_srl`
where `m`.`module` = \'page\'
and `ev`.`value` is null
';
$this->_test($xml_file, $argsString, $expected);
}
/**
* Issue 2114
* 'Notnull' operation is ignored
*/
function test_notnull()
{
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/page.pageTypeNotNullCheck.xml";
$argsString = ' ';
$expected = 'select `m`.`module_srl`, `m`.`mid`, `ev`.`value`
from `xe_modules` as `m`
left join `xe_module_extra_vars` as `ev`
on `ev`.`name` = \'page_type\'
and `m`.`module_srl` = `ev`.`module_srl`
where `m`.`module` = \'page\'
and `ev`.`value` is not null
';
$this->_test($xml_file, $argsString, $expected);
}
function testLikeWithDot()
{
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/likewithdot.xml";
$argsString = '';
$expected = 'select *
from `xe_layouts` as `layouts`
where `site_srl` = 0
and `layout_type` = \'p\'
and `layout` like \'%.%\'';
$this->_test($xml_file, $argsString, $expected);
}
function testFromSubquery()
{
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/from_subquery.xml";
$argsString = '
';
$expected = 'SELECT `A`.`member_srl` as `member_srl`, COUNT(`A`.`cnt`) as `count`
FROM (
SELECT `member_srl` as `member_srl`, count(*) AS `cnt`
FROM `xe_documents` as `documents`
GROUP BY `member_srl`
) AS `A`';
$this->_test($xml_file, $argsString, $expected);
}
/**
* Like with image extension
*/
function testLikeImageExtension()
{
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/like_image_extension.xml";
$argsString = '';
$expected = "select `files`.`upload_target_srl` as `document_srl`
from `xe_files` as `files`
, `xe_documents` as `documents`
where (
`files`.`upload_target_srl` = `documents`.`document_srl`
and (`files`.`source_filename` like '%.jpg'
or `files`.`source_filename` like '%.gif'
or `files`.`source_filename` like '%.png'))
and `documents`.`list_order` <= 2100000000
group by `files`.`upload_target_srl`
order by `documents`.`list_order` asc
limit 5";
$this->_test($xml_file, $argsString, $expected);
}
/**
* Add support for CAST / CONVERT function
*/
function testCast()
{
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/cast.xml";
$argsString = '';
$expected = "select cast(`document_srl` as unsigned integer) from `xe_documents` as `documents`";
$this->_test($xml_file, $argsString, $expected);
}
/**
* Add support for CAST / CONVERT function
*/
function testConvert()
{
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/convert.xml";
$argsString = '';
$expected = "select convert(`document_srl`, unsigned integer) from `xe_documents` as `documents`";
$this->_test($xml_file, $argsString, $expected);
}
/**
* Issue 1431 - xml click count error
*/
function testClickCount()
{
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/click_count.xml";
$argsString = '$args->incr_expose_count = true;';
$expected = "select `expose_count` from `xe_modules` as `modules`";
$this->_test($xml_file, $argsString, $expected);
}
}

View file

@ -1,76 +0,0 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
class MysqlUpdateTest extends MysqlTest {
function _test($xml_file, $argsString, $expected, $columnList = null){
$this->_testQuery($xml_file, $argsString, $expected, 'getUpdateSql', $columnList);
}
function test_document_updateDocumentStatus(){
$xml_file = _XE_PATH_ . "modules/document/queries/updateDocumentStatus.xml";
$argsString = '$args->is_secret = \'Y\';
$args->status = \'SECRET\';
';
$expected = 'update `xe_documents` as `documents` set `status` = \'secret\' where `is_secret` = \'y\'';
$this->_test($xml_file, $argsString, $expected);
}
/**
* Issue 388 - Query cache error related table alias
* http://code.google.com/p/xe-core/issues/detail?id=388
*/
function test_importer_updateDocumentSync(){
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/importer.updateDocumentSync.xml";
$argsString = '';
$expected = 'UPDATE `xe_documents` as `documents`, `xe_member` as `member`
SET `documents`.`member_srl` = `member`.`member_srl`
WHERE `documents`.`user_id` = `member`.`user_id`
';
$this->_test($xml_file, $argsString, $expected);
}
function test_document_updateItemDownloadedCount(){
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/document.updateItemDownloadedCount.xml";
$argsString = '$args->module_srl = 10; $args->package_srl = 11; $args->item_srl = 12;';
$expected = 'update `xe_resource_items` as `resource_items`
set `downloaded` = `downloaded` + 1
where `module_srl` = 10
and `package_srl` = 11
and `item_srl` = 12
';
$this->_test($xml_file, $argsString, $expected);
}
function test_menu_updateMenuItemListorder(){
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/menu.updateMenuItemListorder.xml";
$argsString = '$args->menu_srl = 10; $args->parent_srl = 11; $args->listorder = 12;';
$expected = 'update `xe_menu_item` as `menu_item`
set `listorder` = `listorder` - 1
where `menu_srl` = 10
and `parent_srl` = 11
and `listorder` <= 12';
$this->_test($xml_file, $argsString, $expected);
}
function test_communication_setMessageReaded(){
$xml_file = _XE_PATH_ . "modules/communication/queries/setMessageReaded.xml";
$argsString = '$args->message_srl = 339321; $args->related_srl = 339321;';
$expected = 'update `xe_member_message` as `member_message`
set `readed` = \'y\'
, `readed_date` = \'' . date("YmdHis") . '\'
where `message_srl` = 339321 or `related_srl` = 339321';
$this->_test($xml_file, $argsString, $expected);
}
function test_session_updateSession(){
$xml_file = _XE_PATH_ . "modules/session/queries/updateSession.xml";
$argsString = '$args->session_key = 339321; $args->val = "yuhuu";';
$expected = 'update `xe_session` as `session`
set `member_srl` = 0, `val` = \'yuhuu\'
, `ipaddress` = \''. $_SERVER['REMOTE_ADDR'] .'\'
, `last_update` = \'' . date("YmdHis") . '\'
where `session_key` = \'339321\'';
$this->_test($xml_file, $argsString, $expected);
}
}

View file

@ -1,8 +0,0 @@
<query id="getDocumentListWithinComment" action="select">
<tables>
<table name="documents" alias="documents" />
</tables>
<columns>
<column name="CAST(document_srl as UNSIGNED INTEGER)" />
</columns>
</query>

View file

@ -1,8 +0,0 @@
<query id="getNewestDocuments" action="select">
<tables>
<table name="modules" />
</tables>
<columns>
<column name="expose_count" click_count="incr_expose_count"/>
</columns>
</query>

View file

@ -1,8 +0,0 @@
<query id="getDocumentListWithinComment" action="select">
<tables>
<table name="documents" alias="documents" />
</tables>
<columns>
<column name="CONVERT(document_srl, UNSIGNED INTEGER)" />
</columns>
</query>

View file

@ -1,16 +0,0 @@
<query id="getSiteInfo" action="select">
<tables>
<table name="sites" alias="sites" />
<table name="modules" alias="modules" type="left join">
<conditions>
<condition operation="equal" column="modules.module_srl" default="sites.index_module_srl" notnull="notnull" pipe="and" />
</conditions>
</table>
</tables>
<columns>
<column name="DISTINCT modules.module_srl" alias="module_site_srl" />
</columns>
<conditions>
<condition operation="equal" column="sites.site_srl" var="site_srl" notnull="notnull" />
</conditions>
</query>

View file

@ -1,32 +0,0 @@
<query id="getDocumentListWithinComment" action="select">
<tables>
<table name="documents" alias="documents" />
<table name="comments" alias="comments" />
</tables>
<columns>
<column name="documents.document_srl" />
<column name="documents.list_order" />
</columns>
<conditions>
<condition operation="in" column="documents.module_srl" var="module_srl" filter="number" />
<condition operation="notin" column="documents.module_srl" var="exclude_module_srl" filter="number" pipe="and" />
<condition operation="equal" column="documents.category_srl" var="category_srl" pipe="and" />
<condition operation="equal" column="documents.document_srl" default="comments.document_srl" notnull="notnull" pipe="and" />
<condition operation="equal" column="documents.member_srl" var="member_srl" filter="number" pipe="and" />
<condition operation="in" column="documents.status" var="statusList" pipe="and" />
<group pipe="and">
<condition operation="more" column="documents.list_order" var="division" pipe="and" />
<condition operation="below" column="documents.list_order" var="last_division" pipe="and" />
</group>
<condition operation="like" column="comments.content" var="s_comment" notnull="notnull" pipe="and" />
</conditions>
<navigation>
<index var="sort_index" default="comments.list_order" order="asc" />
<list_count var="list_count" default="20" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
<groups>
<group column="documents.document_srl" />
</groups>
</query>

View file

@ -1,21 +0,0 @@
<query id="getNewestDocuments" action="select">
<tables>
<table name="modules" />
<table name="documents" />
</tables>
<columns>
<column name="modules.site_srl" alias="site_srl"/>
<column name="modules.mid" alias="mid"/>
<column name="documents.*" />
</columns>
<conditions>
<condition operation="equal" column="modules.site_srl" var="site_srl" />
<condition operation="not_in" column="documents.module_srl" default="0" pipe="and" />
<condition operation="in" column="documents.module_srl" var="module_srl" filter="number" pipe="and" />
<condition operation="equal" column="modules.module_srl" default="documents.module_srl" filter="number" pipe="and" />
</conditions>
<navigation>
<index var="sort_index" default="documents.list_order" order="order_type" />
<list_count var="list_count" default="20" />
</navigation>
</query>

View file

@ -1,21 +0,0 @@
<query id="getNewestDocuments" action="select">
<tables>
<table name="modules" />
<table name="documents" />
</tables>
<columns>
<column name="modules.site_srl" alias="site_srl"/>
<column name="modules.mid" alias="mid"/>
<column name="documents.*" />
</columns>
<conditions>
<condition operation="equal" column="modules.site_srl" var="site_srl" />
<condition operation="random_stuff" column="documents.module_srl" default="0" pipe="and" />
<condition operation="in" column="documents.module_srl" var="module_srl" filter="number" pipe="and" />
<condition operation="equal" column="modules.module_srl" default="documents.module_srl" filter="number" pipe="and" />
</conditions>
<navigation>
<index var="sort_index" default="documents.list_order" order="order_type" />
<list_count var="list_count" default="20" />
</navigation>
</query>

View file

@ -1,13 +0,0 @@
<query id="updateItemDownloadedCount" action="update">
<tables>
<table name="resource_items" />
</tables>
<columns>
<column name="downloaded" default="plus(1)" notnull="notnull" />
</columns>
<conditions>
<condition operation="equal" column="module_srl" var="module_srl" filter="number" notnull="notnull" />
<condition operation="equal" column="package_srl" var="package_srl" filter="number" notnull="notnull" pipe="and" />
<condition operation="equal" column="item_srl" var="item_srl" filter="number" notnull="notnull" pipe="and" />
</conditions>
</query>

View file

@ -1,20 +0,0 @@
<query id="getMemberInfo" action="select">
<tables>
<table query="true" alias="A">
<tables>
<table name="documents" alias="documents" />
</tables>
<columns>
<column name="member_srl" alias="member_srl" />
<column name="count(*)" alias="cnt" />
</columns>
<groups>
<group column="member_srl" />
</groups>
</table>
</tables>
<columns>
<column name="A.member_srl" alias="member_srl" />
<column name="count(A.cnt)" alias="count" />
</columns>
</query>

View file

@ -1,31 +0,0 @@
<query id="getNewestComments" action="select">
<tables>
<table name="homepages" />
<table name="sites" />
<table name="comments" />
<table name="modules" />
<table name="module_grants" alias="module_grants" type="left join">
<conditions>
<condition operation="equal" column="module_grants.module_srl" default="modules.module_srl" />
<condition operation="equal" column="module_grants.name" default="access" pipe="and" />
<condition operation="notin" column="module_grants.group_srl" default="0,-1" pipe="and" />
</conditions>
</table>
</tables>
<columns>
<column name="sites.domain" alias="domain" />
<column name="comments.*" />
</columns>
<conditions>
<condition operation="equal" column="homepages.site_srl" default="sites.site_srl" notnull="notnull" />
<condition operation="equal" column="homepages.site_srl" default="modules.site_srl" notnull="notnull" pipe="and" />
<condition operation="equal" column="comments.module_srl" default="modules.module_srl" notnull="notnull" pipe="and" />
<condition operation="null" column="module_grants.group_srl" pipe="and" />
</conditions>
<navigation>
<index var="sort_index" default="comments.list_order" order="asc" />
<list_count var="list_count" default="5" />
<page_count var="page_count" default="5" />
<page var="page" default="1" />
</navigation>
</query>

View file

@ -1,12 +0,0 @@
<query id="updateDocumentSync" action="update">
<tables>
<table name="documents" alias="documents" />
<table name="member" alias="member" />
</tables>
<columns>
<column name="documents.member_srl" default="member.member_srl" filter="number" />
</columns>
<conditions>
<condition operation="equal" column="documents.user_id" default="member.user_id" />
</conditions>
</query>

View file

@ -1,11 +0,0 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="ALL">
<index table="member" name="idx_member_list_order" type="USE" />
</index_hint>
</query>

View file

@ -1,23 +0,0 @@
<query id="QUERY_ID" action="insert-select">
<tables>
<table name="table1" />
</tables>
<columns>
<column name="column1" />
<column name="column2" />
<column name="column3" />
</columns>
<query>
<tables>
<table name="table2" />
</tables>
<columns>
<column name="column4" />
<column name="column5" />
<column name="column6" />
</columns>
<conditions>
<condition operation="more" column="column4" default="100" var="condition_value" />
</conditions>
</query>
</query>

Some files were not shown because too many files have changed in this diff Show more