Merge pull request #5077 from eileenmcnaughton/comment-full-stops
[civicrm-core.git] / tests / phpunit / WebTest / Import / MatchExternalIdTest.php
index 9d904e231a580cfdce99703f913c2b62cc965191..91343b88c021011a02bb6db8645959f818a642e4 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -22,7 +22,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
 
@@ -35,10 +35,10 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase {
     parent::setUp();
   }
 
-  /*
-     *  Test participant import for Individuals matching on external identifier.
-     */
-  function testContributionImport() {
+  /**
+   *  Test participant import for Individuals matching on external identifier.
+   */
+  public function testContributionImport() {
     $this->webtestLogin();
 
     // Get sample import data.
@@ -48,10 +48,10 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase {
     $this->importCSVComponent('Contribution', $headers, $rows, 'Individual', 'Insert new contributions', $fieldMapper);
   }
 
-  /*
-     *  Test membership import for Individuals matching on external identifier.
-     */
-  function testMemberImportIndividual() {
+  /**
+   *  Test membership import for Individuals matching on external identifier.
+   */
+  public function testMemberImportIndividual() {
     $this->webtestLogin();
 
     // Get membership import data for Individuals.
@@ -61,10 +61,10 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase {
     $this->importCSVComponent('Membership', $headers, $rows, 'Individual', 'Skip', $fieldMapper);
   }
 
-  /*
-     *  Test participant import for Individuals matching on external identifier.
-     */
-  function testParticipantImportIndividual() {
+  /**
+   *  Test participant import for Individuals matching on external identifier.
+   */
+  public function testParticipantImportIndividual() {
     // Log in using webtestLogin() method
     $this->webtestLogin();
 
@@ -75,21 +75,20 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase {
     $this->importCSVComponent('Event', $headers, $rows, 'Individual', 'Skip', $fieldMapper);
   }
 
-  /*
-      *  Helper function to provide data for contribution  import for Individual.
-      */
   /**
+   * Helper function to provide data for contribution  import for Individual.
+   *
    * @return array
    */
-  function _contributionIndividualCSVData() {
-    $firstName1  = substr(sha1(rand()), 0, 7);
-    $lastName1   = substr(sha1(rand()), 0, 7);
+  public function _contributionIndividualCSVData() {
+    $firstName1 = substr(sha1(rand()), 0, 7);
+    $lastName1 = substr(sha1(rand()), 0, 7);
     $externalId1 = substr(sha1(rand()), 0, 4);
 
     $this->_addContact($firstName1, $lastName1, $externalId1);
 
-    $firstName2  = substr(sha1(rand()), 0, 7);
-    $lastName2   = substr(sha1(rand()), 0, 7);
+    $firstName2 = substr(sha1(rand()), 0, 7);
+    $lastName2 = substr(sha1(rand()), 0, 7);
     $externalId2 = substr(sha1(rand()), 0, 4);
 
     $this->_addContact($firstName2, $lastName2, $externalId2);
@@ -97,7 +96,7 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase {
     $headers = array(
       'external_identifier' => 'External Identifier',
       'fee_amount' => 'Fee Amount',
-                          'financial_type'         => 'Financial Type',
+      'financial_type' => 'Financial Type',
       'contribution_status_id' => 'Contribution Status',
       'total_amount' => 'Total Amount',
     );
@@ -106,45 +105,44 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase {
       array(
         'external_identifier' => $externalId1,
         'fee_amount' => '200',
-                             'financial_type'         => 'Donation',
+        'financial_type' => 'Donation',
         'contribution_status_id' => 'Completed',
         'total_amount' => '200',
       ),
       array(
         'external_identifier' => $externalId2,
         'fee_amount' => '400',
-                             'financial_type'         => 'Donation',
+        'financial_type' => 'Donation',
         'contribution_status_id' => 'Completed',
         'total_amount' => '400',
       ),
     );
     $fieldMapper = array(
       'mapper[0][0]' => 'external_identifier',
-                              'mapper[2][0]' => 'financial_type',
+      'mapper[2][0]' => 'financial_type',
       'mapper[4][0]' => 'total_amount',
     );
     return array($headers, $rows, $fieldMapper);
   }
 
-  /*
-     *  Helper function to provide data for membership import for Individual.
-     */
   /**
+   * Helper function to provide data for membership import for Individual.
+   *
    * @return array
    */
-  function _memberIndividualCSVData() {
+  public function _memberIndividualCSVData() {
     $memTypeParams = $this->webtestAddMembershipType();
 
-    $firstName1  = substr(sha1(rand()), 0, 7);
-    $lastName1   = substr(sha1(rand()), 0, 7);
+    $firstName1 = substr(sha1(rand()), 0, 7);
+    $lastName1 = substr(sha1(rand()), 0, 7);
     $externalId1 = substr(sha1(rand()), 0, 4);
 
     $this->_addContact($firstName1, $lastName1, $externalId1);
     $startDate1 = date('Y-m-d');
     $year = date('Y') - 1;
 
-    $firstName2  = substr(sha1(rand()), 0, 7);
-    $lastName2   = substr(sha1(rand()), 0, 7);
+    $firstName2 = substr(sha1(rand()), 0, 7);
+    $lastName2 = substr(sha1(rand()), 0, 7);
     $externalId2 = substr(sha1(rand()), 0, 4);
 
     $this->_addContact($firstName2, $lastName2, $externalId2);
@@ -176,23 +174,22 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase {
     return array($headers, $rows, $fieldMapper);
   }
 
-  /*
-     *  Helper function to provide data for participant import for Individual.
-     */
   /**
+   * Helper function to provide data for participant import for Individual.
+   *
    * @return array
    */
-  function _participantIndividualCSVData() {
+  public function _participantIndividualCSVData() {
     $eventInfo = $this->_addNewEvent();
 
-    $firstName1  = substr(sha1(rand()), 0, 7);
-    $lastName1   = substr(sha1(rand()), 0, 7);
+    $firstName1 = substr(sha1(rand()), 0, 7);
+    $lastName1 = substr(sha1(rand()), 0, 7);
     $externalId1 = substr(sha1(rand()), 0, 4);
 
     $this->_addContact($firstName1, $lastName1, $externalId1);
 
-    $firstName2  = substr(sha1(rand()), 0, 7);
-    $lastName2   = substr(sha1(rand()), 0, 7);
+    $firstName2 = substr(sha1(rand()), 0, 7);
+    $lastName2 = substr(sha1(rand()), 0, 7);
     $externalId2 = substr(sha1(rand()), 0, 4);
 
     $this->_addContact($firstName2, $lastName2, $externalId2);
@@ -235,21 +232,17 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase {
     return array($headers, $rows, $fieldMapper);
   }
 
-  /*
-     * Helper function to add new contact
-     *
-     * @params $firstName, $lastName, $externalId
-     *
-     * @return int external id
-     */
   /**
-   * @param $firstName
-   * @param $lastName
-   * @param $externalId
+   * Helper function to add new contact
+   *
+   * @param string $firstName
+   * @param string $lastName
+   * @param int $externalId
    *
-   * @return mixed
+   * @return int
+   *   external id
    */
-  function _addContact($firstName, $lastName, $externalId) {
+  public function _addContact($firstName, $lastName, $externalId) {
     $this->openCiviPage('contact/add', 'reset=1&ct=Individual');
 
     //fill in first name
@@ -269,24 +262,19 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase {
     return $externalId;
   }
 
-  /*
-     * Helper function to add new event
-     *
-     * @params array $params parameters to create an event
-     *
-     * @return array $params event details of newly created event
-     */
   /**
+   * Helper function to add new event
+   *
    * @param array $params
    *
    * @return array
+   *   event details of newly created event
    */
-  function _addNewEvent($params = array(
-    )) {
+  public function _addNewEvent($params = array()) {
     if (empty($params)) {
 
-      // We need a payment processor
-      $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
+      // Use default payment processor
+      $processorName = 'Test Processor';
       $this->webtestAddPaymentProcessor($processorName);
 
       // create an event
@@ -332,7 +320,7 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase {
     $this->waitForElementPresent("_qf_Fee_upload-bottom");
     $this->click("CIVICRM_QFID_1_is_monetary");
     $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']");
-        $this->select( "financial_type_id", "value=4" );
+    $this->select("financial_type_id", "value=4");
 
     $counter = 1;
     foreach ($params['fee_level'] as $label => $amount) {
@@ -365,7 +353,7 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase {
     // verify event input on info page
     // start at Manage Events listing
     $this->openCiviPage('event/manage', 'reset=1');
-    $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input",$params['title']);
+    $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $params['title']);
     $this->click("_qf_SearchEvent_refresh");
     $this->waitForPageToLoad($this->getTimeoutMsec());
     $this->clickLink("link=" . $params['title'], NULL);
@@ -374,5 +362,5 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase {
 
     return $params;
   }
-}
 
+}