<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
*/
class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase {
- /*
- * Function to test csv import for each component.
- *
- * @params string $component component name ( Event, Contribution, Membership, Activity etc)
- * @params array $headers csv data headers
- * @params array $rows csv data rows
- * @params string $contactType contact type
- * @params string $mode import mode
- * @params array $fieldMapper select mapper fields while import
- * @params array $other other parameters
- * useMappingName : to reuse mapping
-
- * dateFormat : date format of data
- * checkMapperHeaders : to override default check mapper headers
- * saveMapping : save current mapping?
- * saveMappingName : to override mapping name
- *
- */
/**
- * @param $component
- * @param $headers
- * @param $rows
+ * Test csv import for each component.
+ *
+ * @param string $component
+ * Component name ( Event, Contribution, Membership, Activity etc).
+ * @param array $headers
+ * Csv data headers.
+ * @param array $rows
+ * Csv data rows.
* @param string $contactType
+ * Contact type.
* @param string $mode
+ * Import mode.
* @param array $fieldMapper
+ * Select mapper fields while import.
* @param array $other
+ * Other parameters.
+ * useMappingName : to reuse mapping
+
+ * dateFormat : date format of data
+ * checkMapperHeaders : to override default check mapper headers
+ * saveMapping : save current mapping?
+ * saveMappingName : to override mapping name
*/
- function importCSVComponent($component,
+ function importCSVComponent(
+ $component,
$headers,
$rows,
$contactType = 'Individual',
- $mode = 'Skip',
+ $mode = 'Skip',
$fieldMapper = array(),
- $other = array()
+ $other = array()
) {
// Go to contact import page.
}
}
- /*
- * Function to test contact import.
- *
- * @params array $headers csv data headers
- * @params array $rows csv data rows
- * @params string $contactType contact type
- * @params string $mode import mode
- * @params array $fieldMapper select mapper fields while import
- * @params array $other other parameters
- * contactSubtype : import for selected Contact Subtype
-
- * useMappingName : to reuse mapping
- * dateFormat : date format of data
- * checkMapperHeaders : to override default check mapper headers
- * saveMapping : save current mapping?
- * saveMappingName : to override mapping name
- * createGroup : create new group?
- * createGroupName : to override new Group name
- * createTag : create new tag?
- * createTagName : to override new Tag name
- * selectGroup : select existing group for contacts
- * selectTag : select existing tag for contacts
- * callbackImportSummary : function to override default import summary assertions
- *
- * @params string $type import type (csv/sql)
- * @todo:currently only supports csv, need to work on sql import
-
- */
/**
- * @param $headers
- * @param $rows
+ * Test contact import.
+ *
+ * @param array $headers
+ * Csv data headers.
+ * @param array $rows
+ * Csv data rows.
* @param string $contactType
+ * Contact type.
* @param string $mode
+ * Import mode.
* @param array $fieldMapper
+ * Select mapper fields while import.
* @param array $other
+ * Other parameters.
+ * contactSubtype : import for selected Contact Subtype
+
+ * useMappingName : to reuse mapping
+ * dateFormat : date format of data
+ * checkMapperHeaders : to override default check mapper headers
+ * saveMapping : save current mapping?
+ * saveMappingName : to override mapping name
+ * createGroup : create new group?
+ * createGroupName : to override new Group name
+ * createTag : create new tag?
+ * createTagName : to override new Tag name
+ * selectGroup : select existing group for contacts
+ * selectTag : select existing tag for contacts
+ * callbackImportSummary : function to override default import summary assertions
+ *
* @param string $type
+ * Import type (csv/sql).
+ * @todo:currently only supports csv, need to work on sql import
*/
- function importContacts($headers, $rows, $contactType = 'Individual', $mode = 'Skip', $fieldMapper = array(), $other = array(), $type = 'csv') {
+ public function importContacts($headers, $rows, $contactType = 'Individual', $mode = 'Skip', $fieldMapper = array(), $other = array(), $type = 'csv') {
// Go to contact import page.
$this->openCiviPage("import/contact", "reset=1", "uploadFile");
// Select contact subtype
if (isset($other['contactSubtype'])) {
- $this->waitForElementPresent("css=#subType option[value={$other['contactSubtype']}]");
+ $this->waitForElementPresent("xpath=//div[@id='common-form-controls']/table/tbody/tr[1]/td[2]/span");
$this->select('subType', $other['contactSubtype']);
}
$this->waitForPageToLoad($this->getTimeoutMsec());
// Check confirmation alert.
- $this->assertTrue((bool)preg_match("/^Are you sure you want to Import now[\s\S]$/", $this->getConfirmation()));
+ $this->assertTrue((bool) preg_match("/^Are you sure you want to Import now[\s\S]$/", $this->getConfirmation()));
$this->chooseOkOnNextConfirmation();
$this->waitForPageToLoad($this->getTimeoutMsec());
}
}
- /*
- * Helper function to get the import url of the component.
- *
- * @params string $component component name
- *
- * @return string import url
-
- */
/**
- * @param $component
+ * Helper function to get the import url of the component.
+ * @param string $component
+ * Component name.
*
- * @return mixed
+ * @return string
+ * import url
*/
private function _getImportComponentUrl($component) {
$importComponentUrl = array(
return $importComponentUrl[$component];
}
- /*
- * Helper function to get the import url of the component.
- *
- * @params string $component component name
- *
- * @return string import url
-
- */
/**
* @param $component
* @param $contactType
*
- * @return mixed
+ * @return string
*/
- function _getImportComponentContactType($component, $contactType) {
+ public function _getImportComponentContactType($component, $contactType) {
$importComponentMode = array(
- 'Event' => array('Individual' => 'CIVICRM_QFID_1_8',
+ 'Event' => array(
+ 'Individual' => 'CIVICRM_QFID_1_8',
'Household' => 'CIVICRM_QFID_2_10',
'Organization' => 'CIVICRM_QFID_4_12',
),
return $importComponentMode[$component][$contactType];
}
- /*
- * Helper function to check import mapping fields.
- *
- * @params array $headers field headers
- * @params array $rows field rows
- * @params array $checkMapperHeaders override default mapper headers
- */
/**
- * @param $headers
- * @param $rows
+ * Helper function to check import mapping fields.
+ * @param array $headers
+ * @param array $rows
* @param null $existingMapping
* @param array $checkMapperHeaders
* @param string $headerSelector
*/
- function _checkImportMapperData($headers, $rows, $existingMapping = NULL, $checkMapperHeaders = array(
- ), $headerSelector = 'th') {
+ public function _checkImportMapperData($headers, $rows, $existingMapping = NULL, $checkMapperHeaders = array(), $headerSelector = 'th') {
if (empty($checkMapperHeaders)) {
$checkMapperHeaders = array(
}
}
- /*
- * Helper function to get imported contact ids.
- *
- * @params array $rows fields rows
- * @params string $contactType contact type
-
- *
- * @return array $contactIds imported contact ids
- */
/**
- * @param $rows
+ * Helper function to get imported contact ids.
+ *
+ * @param array $rows
* @param string $contactType
*
* @return array
+ * imported contact ids
*/
- function _getImportedContactIds($rows, $contactType = 'Individual') {
+ public function _getImportedContactIds($rows, $contactType = 'Individual') {
$contactIds = array();
foreach ($rows as $row) {
return $contactIds;
}
- /*
- * Helper function to format headers and rows for contact relationship data.
- *
- * @params array $headers data headers
- * @params string $rows data rows
- */
/**
- * @param $headers
- * @param $rows
+ * Helper function to format headers and rows for contact relationship data.
+ *
+ * @param array $headers
+ * @param array $rows
*/
- function _formatContactCSVdata(&$headers, &$rows) {
+ public function _formatContactCSVdata(&$headers, &$rows) {
if (!isset($headers['contact_relationships'])) {
return;
}
}
}
}
-