merge from 1.5.2

git-svn-id: http://xe-core.googlecode.com/svn/trunk@10446 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
devjin 2012-03-20 08:03:02 +00:00
parent 6c23751ef8
commit c727926d9e
382 changed files with 6855 additions and 3603 deletions

View file

@ -1,15 +1,15 @@
<?php
class MysqlSelectTest extends MysqlTest {
class MysqlSelectTest extends MysqlTest {
function _test($xml_file, $argsString, $expected, $columnList = null){
$this->_testQuery($xml_file, $argsString, $expected, 'getSelectSql', $columnList);
}
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`
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`
@ -40,13 +40,13 @@
, `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);
}
$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`
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`
@ -77,20 +77,20 @@
, `xe_resource_items` as `item`
where `package`.`member_srl` = `member`.`member_srl`
and `item`.`item_srl` = 10';
$this->_test($xml_file, $argsString, $expected);
}
$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 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`
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`
@ -130,88 +130,90 @@
and `package`.`update_order` <= 2100000000
order by `package`.`update_order` asc
limit 0, 20';
$this->_test($xml_file, $argsString, $expected);
}
$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`
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);
}
$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 *
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);
}
$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 *
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);
}
$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 *
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);
}
$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 *
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);
}
$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`
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` in (566036,3777868)
`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`
$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`
@ -227,6 +229,37 @@
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);
}
}
$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);
}
}

View file

@ -0,0 +1,16 @@
<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

@ -0,0 +1,32 @@
<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

@ -159,8 +159,8 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase
),
// error case
array(
'<a href="{$layout_info->index_url}" cond="$layout_info->logo_image"><img src="{$layout_info->logo_image}" alt="logo" border="0" class="iePngFix" /></a>',
'<?php if($__Context->layout_info->logo_image){ ?><a href="<?php echo $__Context->layout_info->index_url ?>"><img src="<?php echo $__Context->layout_info->logo_image ?>" alt="logo" border="0" class="iePngFix" /></a><?php } ?>'
'<a href="{$layout_info->index_url}" cond="$layout_info->logo_image"><img src="{$layout_info->logo_image}" alt="logo" border="0" /></a>',
'<?php if($__Context->layout_info->logo_image){ ?><a href="<?php echo $__Context->layout_info->index_url ?>"><img src="<?php echo $__Context->layout_info->logo_image ?>" alt="logo" border="0" /></a><?php } ?>'
),
// error case - ignore stylesheets
array(
@ -175,7 +175,7 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase
// error case - inline javascript
array(
'<form onsubmit="jQuery(this).find(\'input\').each(function(){if(this.title==this.value)this.value=\'\';}); return procFilter(this, insert_comment)"></form>',
'<form onsubmit="jQuery(this).find(\'input\').each(function(){if(this.title==this.value)this.value=\'\';}); return procFilter(this, insert_comment)"><input type="hidden" name="error_return_url" value="<?php echo getRequestUriByServerEnviroment() ?>" /><input type="hidden" name="act" value="<?php echo $__Context->act ?>"><input type="hidden" name="mid" value="<?php echo $__Context->mid ?>"><input type="hidden" name="vid" value="<?php echo $__Context->vid ?>"></form>'
'<form onsubmit="jQuery(this).find(\'input\').each(function(){if(this.title==this.value)this.value=\'\';}); return procFilter(this, insert_comment)"><input type="hidden" name="error_return_url" value="<?php echo getRequestUriByServerEnviroment() ?>" /><input type="hidden" name="act" value="<?php echo $__Context->act ?>" /><input type="hidden" name="mid" value="<?php echo $__Context->mid ?>" /><input type="hidden" name="vid" value="<?php echo $__Context->vid ?>" /></form>'
),
// issue 103
array(