mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 10:41:40 +09:00
Update to query argument naming - so that queries that have the same variable name specified in the XML will not fail.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8658 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
620b18e532
commit
cfc7d32afd
15 changed files with 209 additions and 189 deletions
|
|
@ -95,8 +95,6 @@
|
|||
$this->value = $default_value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkFilter($filter_type){
|
||||
if(isset($this->value) && $this->value != ''){
|
||||
$val = $this->value;
|
||||
|
|
|
|||
|
|
@ -49,13 +49,8 @@
|
|||
if($column_type === '') return;
|
||||
|
||||
$this->type = $column_type;
|
||||
|
||||
//if($column_type === '') $column_type = 'varchar';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
11
classes/xml/xmlquery/argument/SortArgument.class.php
Normal file
11
classes/xml/xmlquery/argument/SortArgument.class.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
class SortArgument extends Argument {
|
||||
|
||||
function getValue(){
|
||||
return $this->getUnescapedValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,80 +1,87 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
class QueryArgument {
|
||||
var $argument_name;
|
||||
var $variable_name;
|
||||
var $argument_validator;
|
||||
var $column_name;
|
||||
var $operation;
|
||||
|
||||
|
||||
static $number_of_arguments = 0;
|
||||
|
||||
function QueryArgument($tag){
|
||||
$this->argument_name = $tag->attrs->var;
|
||||
if(!$this->argument_name) $this->argument_name = $tag->attrs->name;
|
||||
if(!$this->argument_name) $this->argument_name = str_replace('.', '_',$tag->attrs->column);
|
||||
|
||||
|
||||
$this->variable_name = $this->argument_name;
|
||||
|
||||
self::$number_of_arguments++;
|
||||
$this->argument_name .= self::$number_of_arguments;
|
||||
|
||||
$name = $tag->attrs->name;
|
||||
if(!$name) $name = $tag->attrs->column;
|
||||
if(strpos($name, '.') === false) $this->column_name = $name;
|
||||
else {
|
||||
list($prefix, $name) = explode('.', $name);
|
||||
$this->column_name = $name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($tag->attrs->operation) $this->operation = $tag->attrs->operation;
|
||||
|
||||
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/validator/QueryArgumentValidator.class.php');
|
||||
$this->argument_validator = new QueryArgumentValidator($tag, $this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getArgumentName(){
|
||||
return $this->argument_name;
|
||||
}
|
||||
|
||||
|
||||
function getColumnName(){
|
||||
return $this->column_name;
|
||||
}
|
||||
|
||||
|
||||
function getValidatorString(){
|
||||
return $this->argument_validator->toString();
|
||||
}
|
||||
|
||||
|
||||
function isConditionArgument(){
|
||||
if($this->operation) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function toString(){
|
||||
if($this->isConditionArgument())
|
||||
$arg = sprintf("\n$%s_argument = new ConditionArgument('%s', %s, '%s');\n"
|
||||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
, '$args->'.$this->argument_name
|
||||
, '$args->'.$this->variable_name
|
||||
, $this->operation
|
||||
);
|
||||
|
||||
|
||||
else
|
||||
$arg = sprintf("\n$%s_argument = new Argument('%s', %s);\n"
|
||||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
, '$args->'.$this->argument_name
|
||||
, $this->ignoreValue ? 'null' : '$args->'.$this->argument_name);
|
||||
|
||||
|
||||
, '$args->'.$this->variable_name);
|
||||
|
||||
|
||||
$arg .= $this->argument_validator->toString();
|
||||
|
||||
|
||||
if($this->isConditionArgument()){
|
||||
$arg .= sprintf("$%s_argument->createConditionValue();\n"
|
||||
, $this->argument_name
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$arg .= sprintf("if(!$%s_argument->isValid()) return $%s_argument->getErrorMessage();\n"
|
||||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
);
|
||||
return $arg;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
class SortQueryArgument extends QueryArgument{
|
||||
function toString(){
|
||||
$arg = sprintf("\n$%s_argument = new SortArgument('%s', %s);\n"
|
||||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
, '$args->'.$this->variable_name);
|
||||
|
||||
|
||||
$arg .= $this->argument_validator->toString();
|
||||
|
||||
$arg .= sprintf("if(!$%s_argument->isValid()) return $%s_argument->getErrorMessage();\n"
|
||||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
);
|
||||
return $arg;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,53 +1,53 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @class ConditionTag
|
||||
* @author Corina
|
||||
* @brief Models the <condition> tag inside an XML Query file. Base class.
|
||||
* @brief Models the <condition> tag inside an XML Query file. Base class.
|
||||
*
|
||||
*/
|
||||
|
||||
class ConditionTag {
|
||||
var $operation;
|
||||
var $column_name;
|
||||
|
||||
|
||||
var $pipe;
|
||||
var $argument_name;
|
||||
var $argument;
|
||||
var $default_column;
|
||||
|
||||
|
||||
var $query;
|
||||
function ConditionTag($condition){
|
||||
$this->operation = $condition->attrs->operation;
|
||||
$this->pipe = $condition->attrs->pipe;
|
||||
$dbParser = XmlQueryParser::getDBParser();
|
||||
$this->column_name = $dbParser->parseColumnName($condition->attrs->column);
|
||||
|
||||
|
||||
$isColumnName = strpos($condition->attrs->default, '.');
|
||||
$isColumnName = $isColumnName || strpos($condition->attrs->var, '.');
|
||||
|
||||
|
||||
if($condition->node_name == 'query'){
|
||||
$this->query = new QueryTag($condition, true);
|
||||
$this->default_column = $this->query->toString();
|
||||
}
|
||||
else if(($condition->attrs->var && !$isColumnName) || $isColumnName === false){
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/QueryArgument.class.php');
|
||||
|
||||
$this->argument = new QueryArgument($condition);
|
||||
$this->argument_name = $this->argument->getArgumentName();
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/QueryArgument.class.php');
|
||||
|
||||
$this->argument = new QueryArgument($condition);
|
||||
$this->argument_name = $this->argument->getArgumentName();
|
||||
}
|
||||
else {
|
||||
if($condition->attrs->default)
|
||||
$this->default_column = "'" . $dbParser->parseColumnName($condition->attrs->default) . "'" ;
|
||||
$this->default_column = "'" . $dbParser->parseColumnName($condition->attrs->default) . "'" ;
|
||||
else
|
||||
$this->default_column = "'" . $dbParser->parseColumnName($condition->attrs->var) . "'" ;
|
||||
}
|
||||
$this->default_column = "'" . $dbParser->parseColumnName($condition->attrs->var) . "'" ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function setPipe($pipe){
|
||||
$this->pipe = $pipe;
|
||||
}
|
||||
|
||||
|
||||
function getArguments(){
|
||||
$arguments = array();
|
||||
if($this->query)
|
||||
|
|
@ -56,7 +56,7 @@
|
|||
$arguments[] = $this->argument;
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
|
||||
function getConditionString(){
|
||||
return sprintf("new Condition('%s',%s,%s%s)"
|
||||
, $this->column_name
|
||||
|
|
@ -64,6 +64,6 @@
|
|||
, '"'.$this->operation.'"'
|
||||
, $this->pipe ? ", '" . $this->pipe . "'" : ''
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,35 +1,35 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
class IndexTag {
|
||||
class IndexTag {
|
||||
var $argument_name;
|
||||
var $argument;
|
||||
var $default;
|
||||
var $sort_order;
|
||||
var $sort_order_argument;
|
||||
|
||||
|
||||
function IndexTag($index){
|
||||
$this->argument_name = $index->attrs->var;
|
||||
|
||||
|
||||
// Sort index - column by which to sort
|
||||
//$dbParser = XmlQueryParser::getDBParser();
|
||||
//$index->attrs->default = $dbParser->parseExpression($index->attrs->default);
|
||||
$this->default = $index->attrs->default;
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/QueryArgument.class.php');
|
||||
$this->argument = new QueryArgument($index);
|
||||
|
||||
$this->argument = new QueryArgument($index);
|
||||
|
||||
// Sort order - asc / desc
|
||||
$this->sort_order = $index->attrs->order;
|
||||
if(!in_array($this->sort_order, array("asc", "desc"))){
|
||||
$arg->var = $this->sort_order;
|
||||
$arg->default = '"asc"';
|
||||
$this->sort_order_argument = new QueryArgument($arg);
|
||||
$this->sort_order = "\$args->".$this->sort_order;
|
||||
$arg->attrs->var = $this->sort_order;
|
||||
$arg->attrs->default = 'asc';
|
||||
$this->sort_order_argument = new SortQueryArgument($arg);
|
||||
$this->sort_order = '$'.$this->sort_order_argument->getArgumentName().'_argument';
|
||||
}
|
||||
else $this->sort_order = '"'.$this->sort_order.'"';
|
||||
}
|
||||
|
||||
|
||||
function toString(){
|
||||
return sprintf("new OrderByColumn(\$%s_argument, %s)", $this->argument_name, $this->sort_order);
|
||||
return sprintf("new OrderByColumn(\$%s_argument, %s)", $this->argument->getArgumentName(), $this->sort_order);
|
||||
}
|
||||
|
||||
function getArguments(){
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
if($this->sort_order_argument)
|
||||
$arguments[] = $this->sort_order_argument;
|
||||
return $arguments;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
class LimitTag {
|
||||
class LimitTag {
|
||||
var $arguments;
|
||||
var $page;
|
||||
var $page_count;
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
function LimitTag($index){
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/QueryArgument.class.php');
|
||||
|
||||
|
||||
if($index->page->attrs && $index->page_count->attrs){
|
||||
$this->page = $index->page->attrs;
|
||||
$this->page_count = $index->page_count->attrs;
|
||||
|
|
@ -16,17 +16,18 @@
|
|||
$this->arguments[] = new QueryArgument($index->page_count);
|
||||
}
|
||||
|
||||
$this->list_count = $index->list_count->attrs;
|
||||
$this->arguments[] = new QueryArgument($index->list_count);
|
||||
$this->list_count = new QueryArgument($index->list_count);
|
||||
$this->arguments[] = $this->list_count;
|
||||
}
|
||||
|
||||
function toString(){
|
||||
if ($this->page)return sprintf("new Limit(\$%s_argument, \$%s_argument, \$%s_argument)",$this->list_count->var, $this->page->var, $this->page_count->var);
|
||||
else return sprintf("new Limit(\$%s_argument)", $this->list_count->var);
|
||||
$name = $this->list_count->getArgumentName();
|
||||
if ($this->page)return sprintf("new Limit(\$%s_argument, \$%s_argument, \$%s_argument)",$name, $name, $name);
|
||||
else return sprintf("new Limit(\$%s_argument)", $name);
|
||||
}
|
||||
|
||||
function getArguments(){
|
||||
return $this->arguments;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -6,30 +6,10 @@
|
|||
class QueryArgumentTest extends CubridTest {
|
||||
|
||||
var $xmlPath = "data/";
|
||||
|
||||
|
||||
function QueryArgumentTest(){
|
||||
$this->xmlPath = str_replace('QueryArgumentTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
|
||||
}
|
||||
|
||||
function testNotNullConditionArgument(){
|
||||
$xml_file = $this->xmlPath . "condition1.xml";
|
||||
$xml_obj = Helper::getXmlObject($xml_file);
|
||||
$tag = new QueryArgument($xml_obj->condition);
|
||||
|
||||
$this->assertEquals("member_srl", $tag->getArgumentName());
|
||||
$this->assertEquals("member_srl", $tag->getColumnName());
|
||||
$this->assertEquals(true, $tag->isConditionArgument());
|
||||
|
||||
$actual = Helper::cleanString($tag->toString());
|
||||
$expected = Helper::cleanString('$member_srl_argument = new ConditionArgument(\'member_srl\', $args->member_srl, \'equal\');
|
||||
$member_srl_argument->checkNotNull();
|
||||
$member_srl_argument->createConditionValue();
|
||||
if(!$member_srl_argument->isValid()) return $member_srl_argument->getErrorMessage();');
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@
|
|||
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" />
|
||||
|
|
@ -19,15 +19,16 @@ class ConditionTagTest extends CubridTest {
|
|||
$xml_file = $this->xmlPath . "condition1.xml";
|
||||
$xml_obj = Helper::getXmlObject($xml_file);
|
||||
$tag = new ConditionTag($xml_obj->condition);
|
||||
|
||||
$expected = "new Condition('\"user_id\"',\$user_id_argument,\"equal\")";
|
||||
$actual = $tag->getConditionString();
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$arguments = $tag->getArguments();
|
||||
|
||||
$expected = "new Condition('\"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" />
|
||||
|
|
@ -39,13 +40,13 @@ class ConditionTagTest extends CubridTest {
|
|||
|
||||
$expected = "new Condition('\"comments\".\"user_id\"','\"member\".\"user_id\"',\"equal\")";
|
||||
$actual = $tag->getConditionString();
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$arguments = $tag->getArguments();
|
||||
$this->assertEquals(0, count($arguments));
|
||||
}
|
||||
|
||||
|
||||
$this->assertEquals(0, count($arguments));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests a <condition> tag with pipe:
|
||||
* <condition operation="equal" column="type" var="type" notnull="notnull" pipe="and" />
|
||||
|
|
@ -54,15 +55,16 @@ class ConditionTagTest extends CubridTest {
|
|||
$xml_file = $this->xmlPath . "condition2.xml";
|
||||
$xml_obj = Helper::getXmlObject($xml_file);
|
||||
$tag = new ConditionTag($xml_obj->condition);
|
||||
|
||||
$expected = "new Condition('\"type\"',\$type_argument,\"equal\", 'and')";
|
||||
$actual = $tag->getConditionString();
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$arguments = $tag->getArguments();
|
||||
|
||||
$expected = "new Condition('\"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" />
|
||||
|
|
@ -74,11 +76,11 @@ class ConditionTagTest extends CubridTest {
|
|||
|
||||
$expected = "new Condition('\"modules\".\"module_srl\"','\"documents\".\"module_srl\"',\"equal\", 'and')";
|
||||
$actual = $tag->getConditionString();
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$arguments = $tag->getArguments();
|
||||
$this->assertEquals(0, count($arguments));
|
||||
}
|
||||
$this->assertEquals(0, count($arguments));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
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');
|
||||
|
|
@ -48,4 +49,5 @@
|
|||
require_once(_XE_PATH_.'classes/xml/xmlquery/tags/table/TableTag.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');
|
||||
?>
|
||||
|
|
@ -26,8 +26,13 @@
|
|||
}
|
||||
|
||||
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')){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
$args->site_srl = 0;
|
||||
$output = executeQuery('module.getMidInfo', $args);
|
||||
$this->assertNotNull($output);
|
||||
$this->assertNotNull($output->data, $output->message);
|
||||
$this->assertNotNull($output->data, $output->message . PHP_EOL . $output->variables["_query"]);
|
||||
$this->assertEquals($output->data->module_srl, 111);
|
||||
}
|
||||
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
$args->site_srl = 0;
|
||||
$output = executeQuery('module.getSiteInfo', $args);
|
||||
$this->assertTrue(is_a($output, 'Object'));
|
||||
$this->assertEquals(0, $output->error, $output->message);
|
||||
$this->assertEquals(0, $output->error, $output->message . PHP_EOL . $output->variables["_query"]);
|
||||
}
|
||||
|
||||
function test_document_getDocumentList_pagination(){
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
$args->member_srl = NULL;
|
||||
$output = executeQuery('document.getDocumentList', $args);
|
||||
|
||||
$this->assertTrue(is_int($output->page), $output->message);
|
||||
$this->assertTrue(is_int($output->page), $output->message . PHP_EOL . $output->variables["_query"]);
|
||||
}
|
||||
|
||||
function test_member_getMemberList(){
|
||||
|
|
@ -56,7 +56,7 @@
|
|||
$args->page_count = 10;
|
||||
|
||||
$output = executeQuery('member.getMemberList', $args);
|
||||
$this->assertEquals(0, $output->error, $output->message);
|
||||
$this->assertEquals(0, $output->error, $output->message . PHP_EOL . $output->variables["_query"]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -6,28 +6,28 @@
|
|||
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 testRquiredParameter(){
|
||||
$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);
|
||||
$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);
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
|
||||
function test_module_getDefaultModules(){
|
||||
$xml_file = _XE_PATH_ . "modules/module/queries/getDefaultModules.xml";
|
||||
$argsString = '';
|
||||
|
|
@ -36,14 +36,14 @@
|
|||
, "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
|
||||
, "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);
|
||||
}
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
function test_module_getSiteInfo(){
|
||||
$xml_file = _XE_PATH_ . "modules/module/queries/getSiteInfo.xml";
|
||||
|
|
@ -71,9 +71,9 @@
|
|||
, "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"
|
||||
, "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);
|
||||
}
|
||||
|
|
@ -81,78 +81,78 @@
|
|||
function test_addon_getAddonInfo(){
|
||||
$xml_file = _XE_PATH_ . "modules/addon/queries/getAddonInfo.xml";
|
||||
$argsString = '$args->addon = "captcha";';
|
||||
$expected = 'SELECT *
|
||||
$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 *
|
||||
$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"
|
||||
$expected = 'SELECT count(*) as "count"
|
||||
FROM "xe_comments" as "comments"';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
$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"
|
||||
$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)
|
||||
WHERE "regdate" >= \'20110411\'
|
||||
GROUP BY substr("regdate",1,8)
|
||||
ORDER BY substr("regdate",1,8) asc limit 2';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
$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\'
|
||||
, "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 = _XE_PATH_ . "modules/opage/queries/getOpageList.xml";
|
||||
$argsString = '$args->s_title = "yuhuu";
|
||||
$args->module = \'opage\';';
|
||||
$expected = 'SELECT *
|
||||
$expected = 'SELECT *
|
||||
FROM "xe_modules" as "modules"
|
||||
WHERE "module" = \'opage\' and ("browser_title" like \'%yuhuu%\')
|
||||
WHERE "module" = \'opage\' and ("browser_title" like \'%yuhuu%\')
|
||||
ORDER BY "module_srl" desc
|
||||
LIMIT 0, 20';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
|
||||
function test_syndication_getGrantedModules(){
|
||||
$xml_file = _XE_PATH_ . "modules/syndication/queries/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" >= -2
|
||||
or "group_srl" = -2
|
||||
or "group_srl" = -2)
|
||||
$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);
|
||||
}
|
||||
|
||||
$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\';
|
||||
|
|
@ -161,16 +161,16 @@
|
|||
$args->list_count = 30;
|
||||
$args->page_count = 10;
|
||||
$args->s_member_srl = 4;';
|
||||
$expected = 'select *
|
||||
from "xe_documents" as "documents"
|
||||
$expected = 'select *
|
||||
from "xe_documents" as "documents"
|
||||
where "member_srl" = 4
|
||||
order by "list_order" asc
|
||||
order by "list_order" asc
|
||||
limit 0, 30';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
|
||||
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test column list
|
||||
*/
|
||||
|
|
@ -178,25 +178,25 @@
|
|||
$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"
|
||||
|
||||
$expected = 'select "session_key", "cur_mid", "val"
|
||||
from "xe_session" as "session"
|
||||
where "session_key" = \'session_key\'';
|
||||
|
||||
$this->_test($xml_file, $argsString, $expected, $columnList);
|
||||
|
||||
$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
|
||||
$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);
|
||||
}
|
||||
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
function test_member_getMemberList(){
|
||||
$xml_file = _XE_PATH_ . "modules/member/queries/getMemberList.xml";
|
||||
$argsString = '$args->is_admin = \'\';
|
||||
|
|
@ -205,10 +205,10 @@
|
|||
$args->sort_order = \'asc\';
|
||||
$args->list_count = 40;
|
||||
$args->page_count = 10;';
|
||||
$expected = 'select * from "xe_member" as "member"
|
||||
order by "list_order" asc
|
||||
$expected = 'select * from "xe_member" as "member"
|
||||
order by "list_order" asc
|
||||
limit 0, 40';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -147,7 +147,6 @@
|
|||
|
||||
function test_module_getModuleSites(){
|
||||
$xml_file = _XE_PATH_ . "modules/module/queries/getModuleSites.xml";
|
||||
//$argsString = '$args->module_srls = array(67, 65);';
|
||||
$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)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue