Updated unit tests - added input XML queries directly in the tests folder, instead of including them from core (for opage and syndication modules, which were removed).

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9786 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-11-01 15:43:44 +00:00
parent 3928e8ec37
commit ad7dda9b75
19 changed files with 646 additions and 113 deletions

View file

@ -1,44 +1,44 @@
<?php
/**
* Test class for Condition.
* Test class for ConditionWithArgument.
*/
class ConditionTest extends CubridTest {
class ConditionWithArgumentTest extends CubridTest {
/**
* Checks equal operation
*/
public function testConditionString_Equal_WithoutPipe_NumericValue() {
$member_srl_argument = new ConditionArgument('"member_srl"', 20, 'equal');
$tag = new Condition('"member_srl"', $member_srl_argument, '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 Condition('"member_srl"', $member_srl_argument, 'equal', 'and');
$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 Condition('"member_srl"', $member_srl_argument, 'equal', 'and');
$tag = new ConditionWithArgument('"member_srl"', $member_srl_argument, 'equal', 'and');
$this->assertEquals('', $tag->toString());
}
}
/**
* Checks "in" operation
*/
@ -46,11 +46,11 @@ class ConditionTest extends CubridTest {
$member_srl_argument = new ConditionArgument('"member_srl"', array('a', 'b', 'c'), 'in');
$member_srl_argument->createConditionValue();
$member_srl_argument->setColumnType('varchar');
$tag = new Condition('"member_srl"', $member_srl_argument, 'in');
$tag = new ConditionWithArgument('"member_srl"', $member_srl_argument, 'in');
$this->assertEquals(' "member_srl" in (\'a\',\'b\',\'c\')', $tag->toString());
}
}
}
?>

View file

@ -8,8 +8,7 @@ class ArgumentTest extends CubridTest {
public function testErrorMessageIsSent_NotNullCheck(){
global $lang;
include(_XE_PATH_.'common/lang/en.lang.php');
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());
@ -18,7 +17,7 @@ class ArgumentTest extends CubridTest {
public function testErrorMessageIsSent_MinLengthCheck(){
global $lang;
include(_XE_PATH_.'common/lang/en.lang.php');
include(_TEST_PATH_ . "classes/xml/xmlquery/argument/data/en.lang.php");
$args->page = '123';
$page_argument = new Argument('page', $args->page);
@ -29,7 +28,7 @@ class ArgumentTest extends CubridTest {
public function testErrorMessageIsSent_MaxLengthCheck(){
global $lang;
include(_XE_PATH_.'common/lang/en.lang.php');
include(_TEST_PATH_ . "classes/xml/xmlquery/argument/data/en.lang.php");
$args->page = '123';
$page_argument = new Argument('page', $args->page);
@ -215,7 +214,7 @@ class ArgumentTest extends CubridTest {
$member_srl_argument = new ConditionArgument('"mid"', 'forum', 'like_prefix');
$member_srl_argument->createConditionValue();
$this->assertEquals('forum%', $member_srl_argument->getValue());
$this->assertEquals('\'forum%\'', $member_srl_argument->getValue());
}
/**
@ -225,7 +224,7 @@ class ArgumentTest extends CubridTest {
$member_srl_argument = new ConditionArgument('"mid"', 'forum', 'like_tail');
$member_srl_argument->createConditionValue();
$this->assertEquals('%forum', $member_srl_argument->getValue());
$this->assertEquals('\'%forum\'', $member_srl_argument->getValue());
}
/**
@ -235,7 +234,7 @@ class ArgumentTest extends CubridTest {
$member_srl_argument = new ConditionArgument('"mid"', 'forum', 'like');
$member_srl_argument->createConditionValue();
$this->assertEquals('%forum%', $member_srl_argument->getValue());
$this->assertEquals('\'%forum%\'', $member_srl_argument->getValue());
}

View file

@ -12,23 +12,23 @@ class ConditionArgumentTest extends CubridTest {
$document_srl_argument->createConditionValue();
if(!$document_srl_argument->isValid()) return $document_srl_argument->getErrorMessage();
$document_srl_argument->setColumnType('number');
$condition = new Condition('"extra_vars"."document_srl"',$document_srl_argument,"in", 'and');
$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 Condition('"sites"."site_srl"',$site_srl_argument,"equal");
$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().
*/

View file

@ -0,0 +1,322 @@
<?php
/**
* @file common/lang/en.lang.php
* @author NHN (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

@ -21,7 +21,7 @@ class ConditionTagTest extends CubridTest {
$tag = new ConditionTag($xml_obj->condition);
$arguments = $tag->getArguments();
$expected = "new Condition('\"user_id\"',\$" . $arguments[0]->getArgumentName() . "_argument,\"equal\")";
$expected = "new ConditionWithArgument('\"user_id\"',\$" . $arguments[0]->getArgumentName() . "_argument,\"equal\")";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
@ -38,7 +38,7 @@ class ConditionTagTest extends CubridTest {
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new ConditionTag($xml_obj->condition);
$expected = "new Condition('\"comments\".\"user_id\"','\"member\".\"user_id\"',\"equal\")";
$expected = "new ConditionWithoutArgument('\"comments\".\"user_id\"','\"member\".\"user_id\"',\"equal\")";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
@ -57,7 +57,7 @@ class ConditionTagTest extends CubridTest {
$tag = new ConditionTag($xml_obj->condition);
$arguments = $tag->getArguments();
$expected = "new Condition('\"type\"',\$" . $arguments[0]->getArgumentName() . "_argument,\"equal\", 'and')";
$expected = "new ConditionWithArgument('\"type\"',\$" . $arguments[0]->getArgumentName() . "_argument,\"equal\", 'and')";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
@ -74,7 +74,7 @@ class ConditionTagTest extends CubridTest {
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new ConditionTag($xml_obj->condition);
$expected = "new Condition('\"modules\".\"module_srl\"','\"documents\".\"module_srl\"',\"equal\", 'and')";
$expected = "new ConditionWithoutArgument('\"modules\".\"module_srl\"','\"documents\".\"module_srl\"',\"equal\", 'and')";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);

View file

@ -1,17 +1,17 @@
<?php
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
/**
* 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" />
@ -20,12 +20,12 @@
$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" />
@ -33,14 +33,14 @@
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">
@ -48,27 +48,27 @@
* <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 Condition(\'"module_categories"."module_category_srl"\',\'"modules"."module_category_srl"\',"equal")
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
@ -78,22 +78,22 @@
$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(){
function testTagWithoutTypeIsNotJoinTable(){
$xml_file = $this->xmlPath . "table_name_alias.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TableTag($xml_obj->table);
$tag = new TableTag($xml_obj->table);
$this->assertEquals(false, $tag->isJoinTable());
}
}
/**
* If no alias is specified, test that table name is used
*/
@ -101,9 +101,9 @@
$xml_file = $this->xmlPath . "table_name.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new TableTag($xml_obj->table);
$this->assertEquals("modules", $tag->getTableAlias());
$tag = new TableTag($xml_obj->table);
$this->assertEquals("modules", $tag->getTableAlias());
}
/**
@ -113,11 +113,11 @@
$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());
}
$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)
@ -126,9 +126,9 @@
$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());
}
$tag = new TableTag($xml_obj->table);
$this->assertEquals("modules", $tag->getTableName());
}
}

View file

@ -1,17 +1,17 @@
<?php
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
/**
* 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>
@ -22,13 +22,13 @@
$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>
@ -40,16 +40,16 @@
$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\"', '\"a\"')
,new Table('\"xe_member_group_member\"', '\"b\"')
)";
$actual = $tag->toString();
$this->_testCachedOutput($expected, $actual);
}
}
/**
* Tests a simple <tables> tag:
* <tables>
@ -65,16 +65,16 @@
$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 Table('\"xe_files\"', '\"files\"')
,new JoinTable('\"xe_member\"'
, '\"member\"'
, \"left join\"
, array(
new ConditionGroup(
array(
new Condition(
new ConditionWithoutArgument(
'\"files\".\"member_srl\"'
,'\"member\".\"member_srl\"'
,\"equal\"
@ -85,10 +85,10 @@
)
)";
$actual = $tag->toString();
$this->_testCachedOutput($expected, $actual);
}
}
/**
* Tests a simple <tables> tag:
* <tables>
@ -104,11 +104,11 @@
$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

@ -14,6 +14,7 @@
* 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'

View file

@ -14,6 +14,7 @@
* 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'

View file

@ -128,7 +128,7 @@
}
function test_opage_getOpageList(){
$xml_file = _XE_PATH_ . "modules/opage/queries/getOpageList.xml";
$xml_file = _TEST_PATH_ . "db/xml_query/cubrid/data/opage.getOpageList.xml";
$argsString = '$args->s_title = "yuhuu";
$args->module = \'opage\';';
$expected = 'SELECT *
@ -140,7 +140,7 @@
}
function test_syndication_getGrantedModules(){
$xml_file = _XE_PATH_ . "modules/syndication/queries/getGrantedModules.xml";
$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"
@ -219,7 +219,7 @@
* Query argument is a single value - not in (12)
*/
function test_module_getModules_Notin_Single_Value(){
$xml_file = _XE_PATH_ . "modules/syndication/queries/getModules.xml";
$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"
@ -239,7 +239,7 @@
}
function test_module_getModules_Notin_Multiple_Value_String(){
$xml_file = _XE_PATH_ . "modules/syndication/queries/getModules.xml";
$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"
@ -259,7 +259,7 @@
}
function test_module_getModules_Notin_Multiple_Value_Array(){
$xml_file = _XE_PATH_ . "modules/syndication/queries/getModules.xml";
$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"
@ -279,7 +279,7 @@
}
function test_module_getModules_In_Single_Value(){
$xml_file = _XE_PATH_ . "modules/syndication/queries/getModules.xml";
$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"
@ -299,7 +299,7 @@
}
function test_module_getModules_In_Multiple_Value_String(){
$xml_file = _XE_PATH_ . "modules/syndication/queries/getModules.xml";
$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"
@ -319,7 +319,7 @@
}
function test_module_getModules_In_Multiple_Value_Array(){
$xml_file = _XE_PATH_ . "modules/syndication/queries/getModules.xml";
$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"
@ -390,7 +390,7 @@
$argsString = '';
$expected = 'select "session_key"
from "xe_session" as "session"
where "expired" <= ' . date("YmdHis");
where "expired" <= \'' . date("YmdHis") . '\'';
$this->_test($xml_file, $argsString, $expected);
}

View file

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

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

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

@ -132,7 +132,7 @@
* in xe_modules. Maybe the developer ment "browser_title"
*/
function test_opage_getOpageList(){
$xml_file = _XE_PATH_ . "modules/opage/queries/getOpageList.xml";
$xml_file = _TEST_PATH_ . "db/xml_query/mssql/data/opage.getOpageList.xml";
$argsString = '$args->s_title = "yuhuu";
$args->module = \'opage\';';
$expected = 'SELECT TOP 20 *
@ -157,7 +157,7 @@
}
function test_syndication_getGrantedModule(){
$xml_file = _XE_PATH_ . "modules/syndication/queries/getGrantedModule.xml";
$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]

View file

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

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

@ -8,7 +8,7 @@
}
function testConditionWithVarAndColumnDefaultValue_WithoutArgument(){
$xml_file = _XE_PATH_ . "modules/resource/queries/getLatestItem.xml";
$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`
@ -45,7 +45,7 @@
}
function testConditionWithVarAndColumnDefaultValue_WithArgument(){
$xml_file = _XE_PATH_ . "modules/resource/queries/getLatestItem.xml";
$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`
@ -89,7 +89,7 @@
}
function testResource_getLatestItemList(){
$xml_file = _XE_PATH_ . "modules/resource/queries/getLatestItemList.xml";
$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`

View file

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

@ -0,0 +1,60 @@
<query id="getLatestItemList" action="select">
<tables>
<table name="resource_packages" alias="package" />
<table name="member" alias="member" />
<table name="resource_items" alias="item" />
<table name="files" alias="files" />
</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="item_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" />
<column name="files.source_filename" alias="source_filename"/>
<column name="files.sid" alias="sid"/>
</columns>
<conditions>
<condition operation="equal" column="package.module_srl" var="module_srl" filter="number" />
<condition operation="equal" column="package.status" default="accepted" pipe="and" />
<condition operation="in" column="package.category_srl" var="category_srl" filter="number" pipe="and" />
<condition operation="more" column="package.category_srl" var="idx_category_srl" pipe="and" />
<condition operation="equal" column="package.member_srl" var="member_srl" filter="number" pipe="and" />
<condition operation="equal" column="package.member_srl" default="member.member_srl" filter="number" pipe="and" />
<condition operation="equal" column="item.item_srl" default="package.latest_item_srl" filter="number" pipe="and" />
<condition operation="less" column="package.update_order" default="0" filter="number" notnull="notnull" pipe="and" />
<condition operation="equal" column="files.file_srl" default="item.file_srl" filter="number" notnull="notnull" pipe="and" />
<group pipe="and">
<condition operation="like" column="package.title" var="search_keyword" pipe="or" />
<condition operation="like" column="package.path" var="search_keyword" pipe="or" />
<condition operation="like" column="package.description" var="search_keyword" pipe="or" />
</group>
</conditions>
<navigation>
<index var="sort_index" default="package.update_order" order="order_type" />
<list_count var="list_count" default="20" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
</query>