当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPUnit_Extensions_Database_Operation_Insert类代码示例

本文整理汇总了PHP中PHPUnit_Extensions_Database_Operation_Insert的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Extensions_Database_Operation_Insert类的具体用法?PHP PHPUnit_Extensions_Database_Operation_Insert怎么用?PHP PHPUnit_Extensions_Database_Operation_Insert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PHPUnit_Extensions_Database_Operation_Insert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  *  Test setup for every test
  *
  *  Connect to the database, truncate the tables that will be used
  *  and redirect stdin to a temporary file
  */
 public function setUp()
 {
     //  Connect to the database
     parent::setUp();
     $this->quickCleanup(array('civicrm_address_format', 'civicrm_currency', 'civicrm_domain', 'civicrm_file', 'civicrm_financial_account', 'civicrm_financial_trxn', 'civicrm_job', 'civicrm_job_log', 'civicrm_location_type', 'civicrm_mail_settings', 'civicrm_mapping', 'civicrm_navigation', 'civicrm_option_group', 'civicrm_payment_processor', 'civicrm_payment_processor_type', 'civicrm_preferences_date', 'civicrm_worldregion', 'civicrm_component', 'civicrm_persistent', 'civicrm_prevnext_cache', 'civicrm_action_mapping', 'civicrm_acl', 'civicrm_acl_entity_role', 'civicrm_contact', 'civicrm_acl_contact_cache', 'civicrm_relationship_type', 'civicrm_saved_search', 'civicrm_contact_type', 'civicrm_mailing_component', 'civicrm_mailing_bounce_type', 'civicrm_mailing_bounce_pattern', 'civicrm_financial_type', 'civicrm_premiums', 'civicrm_product', 'civicrm_premiums_product', 'civicrm_sms_provider', 'civicrm_membership_status', 'civicrm_campaign', 'civicrm_campaign_group', 'civicrm_survey', 'civicrm_participant_status_type', 'civicrm_event_carts', 'civicrm_dedupe_rule_group', 'civicrm_dedupe_rule', 'civicrm_dedupe_exception', 'civicrm_case', 'civicrm_case_contact', 'civicrm_grant', 'civicrm_tell_friend', 'civicrm_pledge_block', 'civicrm_queue_item', 'civicrm_report_instance', 'civicrm_price_set', 'civicrm_price_set_entity', 'civicrm_pcp', 'civicrm_batch', 'civicrm_cache', 'civicrm_country', 'civicrm_custom_group', 'civicrm_custom_field', 'civicrm_dashboard', 'civicrm_email', 'civicrm_entity_batch', 'civicrm_entity_file', 'civicrm_entity_financial_trxn', 'civicrm_im', 'civicrm_log', 'civicrm_mapping_field', 'civicrm_menu', 'civicrm_note', 'civicrm_option_value', 'civicrm_phone', 'civicrm_state_province', 'civicrm_tag', 'civicrm_uf_match', 'civicrm_timezone', 'civicrm_openid', 'civicrm_discount', 'civicrm_website', 'civicrm_setting', 'civicrm_acl_cache', 'civicrm_dashboard_contact', 'civicrm_group', 'civicrm_subscription_history', 'civicrm_group_contact_cache', 'civicrm_group_nesting', 'civicrm_group_organization', 'civicrm_relationship', 'civicrm_mailing_event_subscribe', 'civicrm_mailing_event_confirm', 'civicrm_contribution_recur', 'civicrm_contribution_page', 'civicrm_contribution_widget', 'civicrm_activity', 'civicrm_activity_contact', 'civicrm_case_activity', 'civicrm_pledge', 'civicrm_price_field', 'civicrm_county', 'civicrm_entity_tag', 'civicrm_msg_template', 'civicrm_uf_group', 'civicrm_uf_field', 'civicrm_uf_join', 'civicrm_action_schedule', 'civicrm_action_log', 'civicrm_mailing', 'civicrm_mailing_group', 'civicrm_mailing_trackable_url', 'civicrm_mailing_job', 'civicrm_mailing_recipients', 'civicrm_mailing_spool', 'civicrm_mailing_event_queue', 'civicrm_mailing_event_bounce', 'civicrm_mailing_event_delivered', 'civicrm_mailing_event_forward', 'civicrm_mailing_event_opened', 'civicrm_mailing_event_reply', 'civicrm_mailing_event_trackable_url_open', 'civicrm_mailing_event_unsubscribe', 'civicrm_membership_type', 'civicrm_membership', 'civicrm_membership_block', 'civicrm_membership_log', 'civicrm_price_field_value', 'civicrm_line_item', 'civicrm_pcp_block', 'civicrm_address', 'civicrm_loc_block', 'civicrm_group_contact', 'civicrm_contribution', 'civicrm_contribution_product', 'civicrm_contribution_soft', 'civicrm_membership_payment', 'civicrm_event', 'civicrm_participant', 'civicrm_participant_payment', 'civicrm_events_in_carts', 'civicrm_pledge_payment'));
     //  Insert test data
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(dirname(__FILE__) . '/dataset/data.xml'));
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:15,代码来源:MembershipTest.php

示例2: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->quickCleanup(array('civicrm_group', 'civicrm_contact', 'civicrm_uf_group', 'civicrm_uf_field', 'civicrm_uf_join', 'civicrm_uf_match'));
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, $this->createFlatXMLDataSet(dirname(__FILE__) . '/dataset/uf_group_test.xml'));
     $this->callAPISuccess('uf_field', 'getfields', array('cache_clear' => 1));
     $this->_params = array('field_name' => 'phone', 'field_type' => 'Contact', 'visibility' => 'Public Pages and Listings', 'weight' => 1, 'label' => 'Test Phone', 'is_searchable' => 1, 'is_active' => 1, 'location_type_id' => 1, 'phone_type_id' => 1, 'uf_group_id' => $this->_ufGroupId);
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:9,代码来源:UFFieldTest.php

示例3: setUp

 protected function setUp()
 {
     parent::setUp();
     //  Truncate the tables
     $this->quickCleanup(array('civicrm_group', 'civicrm_contact', 'civicrm_uf_group', 'civicrm_uf_join', 'civicrm_uf_match'));
     $this->_apiversion = 3;
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, $this->createFlatXMLDataSet(dirname(__FILE__) . '/dataset/uf_group_test.xml'));
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:9,代码来源:UFJoinTest.php

示例4: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->_apiversion = 3;
     $this->quickCleanup(array('civicrm_group', 'civicrm_contact', 'civicrm_uf_group', 'civicrm_uf_join', 'civicrm_uf_match'));
     $this->_contactId = $this->individualCreate();
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, $this->createFlatXMLDataSet(dirname(__FILE__) . '/dataset/uf_group_test.xml'));
     $this->_params = array('contact_id' => $this->_contactId, 'uf_id' => '2', 'uf_name' => 'blahdyblah@gmail.com', 'domain_id' => 1);
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:10,代码来源:UFMatchTest.php

示例5: setUp

 protected function setUp()
 {
     parent::setUp();
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(dirname(__FILE__) . '/dataset/uf_group_test.xml'));
     // FIXME: something NULLs $GLOBALS['_HTML_QuickForm_registered_rules'] when the tests are ran all together
     $GLOBALS['_HTML_QuickForm_registered_rules'] = array('required' => array('html_quickform_rule_required', 'HTML/QuickForm/Rule/Required.php'), 'maxlength' => array('html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php'), 'minlength' => array('html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php'), 'rangelength' => array('html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php'), 'email' => array('html_quickform_rule_email', 'HTML/QuickForm/Rule/Email.php'), 'regex' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), 'lettersonly' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), 'alphanumeric' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), 'numeric' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), 'nopunctuation' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), 'nonzero' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), 'callback' => array('html_quickform_rule_callback', 'HTML/QuickForm/Rule/Callback.php'), 'compare' => array('html_quickform_rule_compare', 'HTML/QuickForm/Rule/Compare.php'));
     // FIXME: …ditto for $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES']
     $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] = array('group' => array('HTML/QuickForm/group.php', 'HTML_QuickForm_group'), 'hidden' => array('HTML/QuickForm/hidden.php', 'HTML_QuickForm_hidden'), 'reset' => array('HTML/QuickForm/reset.php', 'HTML_QuickForm_reset'), 'checkbox' => array('HTML/QuickForm/checkbox.php', 'HTML_QuickForm_checkbox'), 'file' => array('HTML/QuickForm/file.php', 'HTML_QuickForm_file'), 'image' => array('HTML/QuickForm/image.php', 'HTML_QuickForm_image'), 'password' => array('HTML/QuickForm/password.php', 'HTML_QuickForm_password'), 'radio' => array('HTML/QuickForm/radio.php', 'HTML_QuickForm_radio'), 'button' => array('HTML/QuickForm/button.php', 'HTML_QuickForm_button'), 'submit' => array('HTML/QuickForm/submit.php', 'HTML_QuickForm_submit'), 'select' => array('HTML/QuickForm/select.php', 'HTML_QuickForm_select'), 'hiddenselect' => array('HTML/QuickForm/hiddenselect.php', 'HTML_QuickForm_hiddenselect'), 'text' => array('HTML/QuickForm/text.php', 'HTML_QuickForm_text'), 'textarea' => array('HTML/QuickForm/textarea.php', 'HTML_QuickForm_textarea'), 'fckeditor' => array('HTML/QuickForm/fckeditor.php', 'HTML_QuickForm_FCKEditor'), 'tinymce' => array('HTML/QuickForm/tinymce.php', 'HTML_QuickForm_TinyMCE'), 'dojoeditor' => array('HTML/QuickForm/dojoeditor.php', 'HTML_QuickForm_dojoeditor'), 'link' => array('HTML/QuickForm/link.php', 'HTML_QuickForm_link'), 'advcheckbox' => array('HTML/QuickForm/advcheckbox.php', 'HTML_QuickForm_advcheckbox'), 'date' => array('HTML/QuickForm/date.php', 'HTML_QuickForm_date'), 'static' => array('HTML/QuickForm/static.php', 'HTML_QuickForm_static'), 'header' => array('HTML/QuickForm/header.php', 'HTML_QuickForm_header'), 'html' => array('HTML/QuickForm/html.php', 'HTML_QuickForm_html'), 'hierselect' => array('HTML/QuickForm/hierselect.php', 'HTML_QuickForm_hierselect'), 'autocomplete' => array('HTML/QuickForm/autocomplete.php', 'HTML_QuickForm_autocomplete'), 'xbutton' => array('HTML/QuickForm/xbutton.php', 'HTML_QuickForm_xbutton'), 'advmultiselect' => array('HTML/QuickForm/advmultiselect.php', 'HTML_QuickForm_advmultiselect'));
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:10,代码来源:UFGroupTest.php

示例6: testCheckParamsWithDuplicateContact2

 /**
  *  Test civicrm_contact_check_params with a duplicate.
  *  and request the error in array format
  */
 public function testCheckParamsWithDuplicateContact2()
 {
     //  Insert a row in civicrm_contact creating individual contact
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, $this->createXMLDataSet(dirname(__FILE__) . '/../../api/v3/dataset/contact_17.xml'));
     $op->execute($this->_dbconn, $this->createXMLDataSet(dirname(__FILE__) . '/../../api/v3/dataset/email_contact_17.xml'));
     $params = array('first_name' => 'Test', 'last_name' => 'Contact', 'email' => 'TestContact@example.com', 'contact_type' => 'Individual');
     $contact = _civicrm_api3_deprecated_contact_check_params($params, TRUE, TRUE);
     $this->assertEquals(1, $contact['is_error']);
     $this->assertRegexp("/matching contacts.*17/s", $contact['error_message']['message']);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:15,代码来源:DeprecatedUtilsTest.php

示例7: testAllIMs

 /**
  * AllIMs() method - get all IMs for our contact, with primary IM first
  */
 public function testAllIMs()
 {
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, $this->createFlatXMLDataSet(dirname(__FILE__) . '/dataset/im_test.xml'));
     $contactId = 69;
     $IMs = CRM_Core_BAO_IM::allIMs($contactId);
     $this->assertEquals(count($IMs), 3, 'Checking number of returned IMs.');
     $firstIMValue = array_slice($IMs, 0, 1);
     $this->assertEquals('alan1.smith1', $firstIMValue[0]['name'], 'Confirm primary IM value.');
     $this->assertEquals(1, $firstIMValue[0]['is_primary'], 'Confirm first IM is primary.');
     $this->contactDelete($contactId);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:15,代码来源:IMTest.php

示例8: setUp

 /**
  *  Test setup for every test
  *
  *  Connect to the database, truncate the tables that will be used
  *  and redirect stdin to a temporary file
  */
 public function setUp()
 {
     $this->_entity = 'case';
     parent::setUp();
     // CRM-9404 - set-up is a bit cumbersome but had to put something in place to set up activity types & case types
     //. Using XML was causing breakage as id numbers were changing over time
     // & was really hard to troubleshoot as involved truncating option_value table to mitigate this & not leaving DB in a
     // state where tests could run afterwards without re-loading.
     $this->caseStatusGroup = $this->callAPISuccess('option_group', 'get', array('name' => 'case_status', 'format.only_id' => 1));
     $this->caseTypeGroup = $this->callAPISuccess('option_group', 'get', array('name' => 'case_type', 'format.only_id' => 1));
     $caseTypes = $this->callAPISuccess('option_value', 'Create', array('option_group_id' => $this->caseTypeGroup, 'name' => 'housing_support', 'label' => "Housing Support", 'sequential' => 1, 'description' => 'Help homeless individuals obtain temporary and long-term housing'));
     $this->caseTypeId = $caseTypes['values'][0]['value'];
     $this->optionValues[] = $caseTypes['id'];
     $optionValues = array('Medical evaluation' => 'Medical evaluation', 'Mental health evaluation' => "Mental health evaluation", 'Secure temporary housing' => 'Secure temporary housing', 'Long-term housing plan' => 'Long-term housing plan', 'ADC referral' => 'ADC referral', 'Income and benefits stabilization' => 'Income and benefits stabilization');
     foreach ($optionValues as $name => $label) {
         $activityTypes = $this->callAPISuccess('option_value', 'Create', array('option_group_id' => 2, 'name' => $name, 'label' => $label, 'component_id' => 7));
         // store for cleanup
         $this->optionValues[] = $activityTypes['id'];
     }
     $tablesToTruncate = array('civicrm_activity', 'civicrm_contact', 'civicrm_custom_group', 'civicrm_custom_field', 'civicrm_case', 'civicrm_case_contact', 'civicrm_case_activity', 'civicrm_activity_contact', 'civicrm_relationship', 'civicrm_relationship_type');
     $this->quickCleanup($tablesToTruncate);
     $activityTypes = $this->callAPISuccess('option_value', 'get', array('option_group_id' => 2, 'name' => 'Follow Up', 'label' => 'Follow Up', 'sequential' => 1));
     $this->followup_activity_type_value = $activityTypes['values'][0]['value'];
     //  Insert a row in civicrm_contact creating contact 17
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_XMLDataSet(dirname(__FILE__) . '/dataset/contact_17.xml'));
     //Create relationship types
     $relTypeParams = array('name_a_b' => 'Case Coordinator is', 'label_a_b' => 'Case Coordinator is', 'name_b_a' => 'Case Coordinator', 'label_b_a' => 'Case Coordinator', 'description' => 'Case Coordinator', 'contact_type_a' => 'Individual', 'contact_type_b' => 'Individual', 'is_reserved' => 0, 'is_active' => 1);
     $this->relationshipTypeCreate($relTypeParams);
     $relTypeParams = array('name_a_b' => 'Homeless Services Coordinator is', 'label_a_b' => 'Homeless Services Coordinator is', 'name_b_a' => 'Homeless Services Coordinator', 'label_b_a' => 'Homeless Services Coordinator', 'description' => 'Homeless Services Coordinator', 'contact_type_a' => 'Individual', 'contact_type_b' => 'Individual', 'is_reserved' => 0, 'is_active' => 1);
     $this->relationshipTypeCreate($relTypeParams);
     $relTypeParams = array('name_a_b' => 'Health Services Coordinator is', 'label_a_b' => 'Health Services Coordinator is', 'name_b_a' => 'Health Services Coordinator', 'label_b_a' => 'Health Services Coordinator', 'description' => 'Health Services Coordinator', 'contact_type_a' => 'Individual', 'contact_type_b' => 'Individual', 'is_reserved' => 0, 'is_active' => 1);
     $this->relationshipTypeCreate($relTypeParams);
     $relTypeParams = array('name_a_b' => 'Senior Services Coordinator is', 'label_a_b' => 'Senior Services Coordinator is', 'name_b_a' => 'Senior Services Coordinator', 'label_b_a' => 'Senior Services Coordinator', 'description' => 'Senior Services Coordinator', 'contact_type_a' => 'Individual', 'contact_type_b' => 'Individual', 'is_reserved' => 0, 'is_active' => 1);
     $this->relationshipTypeCreate($relTypeParams);
     $relTypeParams = array('name_a_b' => 'Benefits Specialist is', 'label_a_b' => 'Benefits Specialist is', 'name_b_a' => 'Benefits Specialist', 'label_b_a' => 'Benefits Specialist', 'description' => 'Benefits Specialist', 'contact_type_a' => 'Individual', 'contact_type_b' => 'Individual', 'is_reserved' => 0, 'is_active' => 1);
     $this->relationshipTypeCreate($relTypeParams);
     // enable the default custom templates for the case type xml files
     $this->customDirectories(array('template_path' => TRUE));
     // case is not enabled by default
     $enableResult = CRM_Core_BAO_ConfigSetting::enableComponent('CiviCase');
     $this->assertTrue($enableResult, 'Cannot enable CiviCase in line ' . __LINE__);
     $this->_params = array('case_type_id' => $this->caseTypeId, 'subject' => 'Test case', 'contact_id' => 17);
     // create a logged in USER since the code references it for source_contact_id
     $this->createLoggedInUser();
     $session = CRM_Core_Session::singleton();
     $this->_loggedInUser = $session->get('userID');
     /// note that activityType options are cached by the FULL set of options you pass in
     // ie. because Activity api includes campaign in it's call cache is not flushed unless
     // included in this call. Also note flush function doesn't work on this property as it sets to null not empty array
     CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name', TRUE);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:58,代码来源:CaseTest.php

示例9: testSearch

 /**
  *  Test CRM_Contact_BAO_Query::searchQuery()
  *  @dataProvider dataProvider
  */
 function testSearch($fv, $count, $ids, $full)
 {
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(dirname(__FILE__) . '/queryDataset.xml'));
     $params = CRM_Contact_BAO_Query::convertFormValues($fv);
     $obj = new CRM_Contact_BAO_Query($params);
     $obj->_useGroupBy = TRUE;
     $dao = $obj->searchQuery();
     $contacts = array();
     while ($dao->fetch()) {
         $contacts[] = $dao->contact_id;
     }
     sort($contacts, SORT_NUMERIC);
     $this->assertEquals($ids, $contacts, 'In line ' . __LINE__);
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:19,代码来源:QueryTest.php

示例10: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     parent::setUp();
     //  Insert a row in civicrm_group creating option group
     //  from_email_address group
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_XMLDataSet(dirname(__FILE__) . '/dataset/group_admins.xml'));
     //  Insert a row in civicrm_group creating option group
     //  from_email_address group
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_XMLDataSet(dirname(__FILE__) . '/dataset/group_subscribers.xml'));
     //  Insert a row in civicrm_group creating option group
     //  from_email_address group
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_XMLDataSet(dirname(__FILE__) . '/dataset/group_nesting.xml'));
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:22,代码来源:GroupNestingTest.php

示例11: testSearch

 /**
  *  Test CRM_Contact_BAO_Query::searchQuery()
  * @dataProvider dataProvider
  * @param $fv
  * @param $count
  * @param $ids
  * @param $full
  */
 public function testSearch($fv, $count, $ids, $full)
 {
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, $this->createFlatXMLDataSet(dirname(__FILE__) . '/queryDataset.xml'));
     $params = CRM_Contact_BAO_Query::convertFormValues($fv);
     $obj = new CRM_Contact_BAO_Query($params);
     // let's set useGroupBy=true since we are listing contacts here who might belong to
     // more than one group / tag / notes etc.
     $obj->_useGroupBy = TRUE;
     $dao = $obj->searchQuery();
     $contacts = array();
     while ($dao->fetch()) {
         $contacts[] = $dao->contact_id;
     }
     sort($contacts, SORT_NUMERIC);
     $this->assertEquals($ids, $contacts);
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:25,代码来源:QueryTest.php

示例12: execute

 /**
  * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection
  * @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet
  */
 public function execute(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
 {
     $insertOperation = new PHPUnit_Extensions_Database_Operation_Insert();
     $updateOperation = new PHPUnit_Extensions_Database_Operation_Update();
     $databaseDataSet = $connection->createDataSet();
     foreach ($dataSet as $table) {
         /* @var $table PHPUnit_Extensions_Database_DataSet_ITable */
         $databaseTableMetaData = $databaseDataSet->getTableMetaData($table->getTableMetaData()->getTableName());
         $insertQuery = $insertOperation->buildOperationQuery($databaseTableMetaData, $table, $connection);
         $updateQuery = $updateOperation->buildOperationQuery($databaseTableMetaData, $table, $connection);
         $selectQuery = $this->buildOperationQuery($databaseTableMetaData, $table, $connection);
         $insertStatement = $connection->getConnection()->prepare($insertQuery);
         $updateStatement = $connection->getConnection()->prepare($updateQuery);
         $selectStatement = $connection->getConnection()->prepare($selectQuery);
         $rowCount = $table->getRowCount();
         for ($i = 0; $i < $rowCount; $i++) {
             $selectArgs = $this->buildOperationArguments($databaseTableMetaData, $table, $i);
             $query = $selectQuery;
             $args = $selectArgs;
             try {
                 $selectStatement->execute($selectArgs);
                 if ($selectStatement->fetchColumn(0) > 0) {
                     $updateArgs = $updateOperation->buildOperationArguments($databaseTableMetaData, $table, $i);
                     $query = $updateQuery;
                     $args = $updateArgs;
                     $updateStatement->execute($updateArgs);
                 } else {
                     $insertArgs = $insertOperation->buildOperationArguments($databaseTableMetaData, $table, $i);
                     $query = $insertQuery;
                     $args = $insertArgs;
                     $insertStatement->execute($insertArgs);
                 }
             } catch (Exception $e) {
                 throw new PHPUnit_Extensions_Database_Operation_Exception($this->operationName, $query, $args, $table, $e->getMessage());
             }
         }
     }
 }
开发者ID:qcodo,项目名称:qcodo,代码行数:42,代码来源:Replace.php

示例13: setUp

 public function setUp()
 {
     //  Connect to the database
     parent::setUp();
     //  Truncate the tables
     $op = new PHPUnit_Extensions_Database_Operation_Truncate();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(dirname(__FILE__) . '/../../CiviTest/truncate-option.xml'));
     //  Insert a row in civicrm_contact creating contact 17
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_XMLDataSet(dirname(__FILE__) . '/dataset/contact_17.xml'));
     //  Insert a row in civicrm_option_group creating option group
     //  activity_type
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(dirname(__FILE__) . '/dataset/option_group_activity_type.xml'));
     //  Insert a row in civicrm_option_value creating
     //  activity_type 5
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_XMLDataSet(dirname(__FILE__) . '/dataset/option_value_activity_5.xml'));
     //  Insert rows in civicrm_activity creating activities 4 and
     //  13
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_XMLDataSet(dirname(__FILE__) . '/dataset/activity_4_13.xml'));
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:23,代码来源:ActivityContactTest.php

示例14: _createContactWithActivity

 /**
  * @return array
  */
 function _createContactWithActivity()
 {
     // @TODO: Create profile with custom fields
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, $this->createFlatXMLDataSet(dirname(__FILE__) . '/dataset/uf_group_contact_activity_26.xml'));
     // hack: xml data set do not accept  (CRM_Core_DAO::VALUE_SEPARATOR)
     CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', '26', 'group_type', 'Individual,Contact,Activity' . CRM_Core_DAO::VALUE_SEPARATOR . 'ActivityType:1');
     $sourceContactId = $this->individualCreate();
     $contactParams = array('first_name' => 'abc1', 'last_name' => 'xyz1', 'contact_type' => 'Individual', 'email' => 'abc1.xyz1@yahoo.com', 'api.address.create' => array('location_type_id' => 1, 'is_primary' => 1, 'name' => 'Saint Helier St', 'county' => 'Marin', 'country' => 'United States', 'state_province' => 'Michigan', 'supplemental_address_1' => 'Hallmark Ct', 'supplemental_address_2' => 'Jersey Village'));
     $contact = $this->callAPISuccess('contact', 'create', $contactParams);
     $keys = array_keys($contact['values']);
     $contactId = array_pop($keys);
     $this->assertEquals(0, $contact['values'][$contactId]['api.address.create']['is_error'], "In line " . __LINE__ . " error message: " . CRM_Utils_Array::value('error_message', $contact['values'][$contactId]['api.address.create']));
     $activityParams = array('source_contact_id' => $sourceContactId, 'assignee_contact_id' => $contactId, 'activity_type_id' => '1', 'subject' => 'Make-it-Happen Meeting', 'activity_date_time' => '20110316', 'duration' => '120', 'location' => 'Pensulvania', 'details' => 'a test activity', 'status_id' => '1', 'priority_id' => '1');
     $activity = $this->callAPISuccess('activity', 'create', $activityParams);
     $activityValues = array_pop($activity['values']);
     // valid parameters for above profile
     $profileParams = array('profile_id' => 26, 'contact_id' => $contactId, 'activity_id' => $activityValues['id']);
     // expected result of above created profile
     $expected = array('first_name' => 'abc1', 'last_name' => 'xyz1', 'email-Primary' => 'abc1.xyz1@yahoo.com', 'activity_subject' => 'Make-it-Happen Meeting', 'activity_details' => 'a test activity', 'activity_duration' => '120', 'activity_date_time_time' => '12:00AM', 'activity_date_time' => '03/16/2011', 'activity_status_id' => '1');
     return array($profileParams, $expected);
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:25,代码来源:ProfileTest.php

示例15: testInsert

 public function testInsert()
 {
     $insertOperation = new PHPUnit_Extensions_Database_Operation_Insert();
     $insertOperation->execute($this->getConnection(), new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet(dirname(__FILE__) . '/../_files/XmlDataSets/InsertOperationTest.xml'));
     $this->assertDataSetsEqual(new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet(dirname(__FILE__) . '/../_files/XmlDataSets/InsertOperationResult.xml'), $this->getConnection()->createDataSet());
 }
开发者ID:humansky,项目名称:qframe,代码行数:6,代码来源:OperationsTest.php


注:本文中的PHPUnit_Extensions_Database_Operation_Insert类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。