mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-23 05:09:56 +09:00
merge from 1.5.3 (~r10943)
git-svn-id: http://xe-core.googlecode.com/svn/trunk@10951 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
7aa4798373
commit
54e3a72065
334 changed files with 13011 additions and 5561 deletions
21
tests/classes/db/db/xml_query/cubrid/data/doc_subquery.xml
Normal file
21
tests/classes/db/db/xml_query/cubrid/data/doc_subquery.xml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<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>
|
||||
|
|
@ -21,7 +21,7 @@ class MysqlInsertTest extends MysqlTest
|
|||
{
|
||||
$this->_testQuery($xml_file, $argsString, $expected, 'getInsertSql', $columnList);
|
||||
}
|
||||
|
||||
|
||||
function testInsertIntoNumericColumnConvertsValue()
|
||||
{
|
||||
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/member_insert_injection.xml";
|
||||
|
|
@ -35,5 +35,41 @@ class MysqlInsertTest extends MysqlTest
|
|||
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class MysqlSelectTest extends MysqlTest {
|
||||
|
||||
function _test($xml_file, $argsString, $expected, $columnList = null) {
|
||||
function _test($xml_file, $argsString, $expected, $columnList = NULL) {
|
||||
$this->_testQuery($xml_file, $argsString, $expected, 'getSelectSql', $columnList);
|
||||
}
|
||||
|
||||
|
|
@ -262,4 +262,71 @@ class MysqlSelectTest extends MysqlTest {
|
|||
$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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<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>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<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>
|
||||
23
tests/classes/db/db/xml_query/mysql/data/insert_select.xml
Normal file
23
tests/classes/db/db/xml_query/mysql/data/insert_select.xml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<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>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<query id="pageTypeNullCheck" action="select">
|
||||
<tables>
|
||||
<table name="modules" alias="m" />
|
||||
<table name="module_extra_vars" alias="ev" type="left join">
|
||||
<conditions>
|
||||
<condition operation="equal" column="ev.name" default="page_type" />
|
||||
<condition operation="equal" column="m.module_srl" default="ev.module_srl" pipe="and" />
|
||||
</conditions>
|
||||
</table>
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="m.module_srl" />
|
||||
<column name="m.mid" />
|
||||
<column name="ev.value" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="m.module" default="page" />
|
||||
<condition operation="notnull" column="ev.value" default="NULL" pipe="and" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<query id="pageTypeNullCheck" action="select">
|
||||
<tables>
|
||||
<table name="modules" alias="m" />
|
||||
<table name="module_extra_vars" alias="ev" type="left join">
|
||||
<conditions>
|
||||
<condition operation="equal" column="ev.name" default="page_type" />
|
||||
<condition operation="equal" column="m.module_srl" default="ev.module_srl" pipe="and" />
|
||||
</conditions>
|
||||
</table>
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="m.module_srl" />
|
||||
<column name="m.mid" />
|
||||
<column name="ev.value" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="m.module" default="page" />
|
||||
<condition operation="null" column="ev.value" default="NULL" pipe="and" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -114,6 +114,63 @@ class ValidatorTest extends PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
public function testCustomRule() {
|
||||
// regex
|
||||
$vd = new Validator();
|
||||
$customRules['regex_rule']['type'] = 'regex';
|
||||
$customRules['regex_rule']['test'] = '/^[a-z]+$/';
|
||||
$vd->addRule($customRules);
|
||||
$vd->addFilter('regex_field', array('rule' => 'regex_rule'));
|
||||
|
||||
$this->assertTrue($vd->validate(array('regex_field' => 'abc')));
|
||||
$this->assertFalse($vd->validate(array('regex_field' => 'ABC')));
|
||||
|
||||
// enum
|
||||
$vd = new Validator();
|
||||
$customRules['enum_rule']['type'] = 'enum';
|
||||
$customRules['enum_rule']['test'] = 'a,b,c';
|
||||
$vd->addRule($customRules);
|
||||
$vd->addFilter('enum_field', array('rule' => 'enum_rule'));
|
||||
|
||||
$this->assertTrue($vd->validate(array('enum_field' => 'a')));
|
||||
$this->assertFalse($vd->validate(array('enum_field' => 'd')));
|
||||
|
||||
// enum with custom delimiter
|
||||
$vd = new Validator();
|
||||
$customRules['enum_rule2']['type'] = 'enum';
|
||||
$customRules['enum_rule2']['test'] = 'a@b@c';
|
||||
$customRules['enum_rule2']['delim'] = '@';
|
||||
$vd->addRule($customRules);
|
||||
$vd->addFilter('enum_field2', array('rule' => 'enum_rule2'));
|
||||
|
||||
$this->assertTrue($vd->validate(array('enum_field2' => 'a')));
|
||||
$this->assertFalse($vd->validate(array('enum_field2' => 'd')));
|
||||
|
||||
// expr
|
||||
$vd = new Validator();
|
||||
$customRules['expr_rule']['type'] = 'expr';
|
||||
$customRules['expr_rule']['test'] = '$$ < 10';
|
||||
$vd->addRule($customRules);
|
||||
$vd->addFilter('expr_field', array('rule' => 'expr_rule'));
|
||||
|
||||
$this->assertTrue($vd->validate(array('expr_field' => '5')));
|
||||
$this->assertFalse($vd->validate(array('expr_field' => '15')));
|
||||
}
|
||||
|
||||
public function testCustomRuleXml()
|
||||
{
|
||||
$vd = new Validator(dirname(__FILE__).'/customrule.xml');
|
||||
|
||||
$this->assertTrue($vd->validate(array('regex_field' => 'abc')));
|
||||
$this->assertFalse($vd->validate(array('regex_field' => 'ABC')));
|
||||
|
||||
$this->assertTrue($vd->validate(array('enum_field' => 'a')));
|
||||
$this->assertFalse($vd->validate(array('enum_field' => 'd')));
|
||||
|
||||
$this->assertTrue($vd->validate(array('enum_field2' => 'a')));
|
||||
$this->assertFalse($vd->validate(array('enum_field2' => 'd')));
|
||||
|
||||
$this->assertTrue($vd->validate(array('expr_field' => '5')));
|
||||
$this->assertFalse($vd->validate(array('expr_field' => '15')));
|
||||
}
|
||||
|
||||
public function testCondition() {
|
||||
|
|
|
|||
15
tests/classes/validator/customrule.xml
Normal file
15
tests/classes/validator/customrule.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ruleset version="1.5.0">
|
||||
<customrules>
|
||||
<rule name="regex_rule" type="regex" test="/^[a-z]+$/" />
|
||||
<rule name="enum_rule" type="enum" test="a,b,c" />
|
||||
<rule name="enum_rule2" type="enum" test="a@b@c" delim="@" />
|
||||
<rule name="expr_rule" type="expr" test="$$ < 10" />
|
||||
</customrules>
|
||||
<fields>
|
||||
<field name="regex_field" rule="regex_rule" />
|
||||
<field name="enum_field" rule="enum_rule" />
|
||||
<field name="enum_field2" rule="enum_rule2" />
|
||||
<field name="expr_field" rule="expr_rule" />
|
||||
</fields>
|
||||
</ruleset>
|
||||
Loading…
Add table
Add a link
Reference in a new issue