phpcs - Fix error, "Expected 1 newline at end of file; XXX found".
[civicrm-core.git] / tests / phpunit / WebTest / Import / CustomDataTest.php
index 78282b0d99bde581e39dd99be7e424c88cde9f2f..95b6a608c00d6c58c3eb5d607b2443e19e1585e7 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -35,7 +35,7 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase {
     parent::setUp();
   }
 
-  function testCustomDataImport() {
+  public function testCustomDataImport() {
     $this->webtestLogin();
 
     $firstName1       = 'Ma_' . substr(sha1(rand()), 0, 7);
@@ -102,19 +102,18 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase {
     }
   }
 
-  /*
-     *  Helper function to provide data for custom data import.
-     */
   /**
+   * Helper function to provide data for custom data import.
+   *
    * @param $customGroupTitle
-   * @param $firstName1
-   * @param $firstName2
+   * @param string $firstName1
+   * @param string $firstName2
    * @param $id1
    * @param $id2
    *
    * @return array
    */
-  function _individualCustomCSVData($customGroupTitle, $firstName1, $firstName2, $id1, $id2) {
+  public function _individualCustomCSVData($customGroupTitle, $firstName1, $firstName2, $id1, $id2) {
     list($customDataParams, $customDataVerify) = $this->_addCustomData($customGroupTitle, $id1, $id2);
 
     $headers = array(
@@ -156,7 +155,7 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase {
    *
    * @return array
    */
-  function _addCustomData($customGroupTitle, $id1, $id2) {
+  public function _addCustomData($customGroupTitle, $id1, $id2) {
 
     $this->openCiviPage("admin/custom/group", "reset=1");
 
@@ -172,11 +171,11 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase {
     $this->click("extends[0]");
     $this->select("extends[0]", "value=Contact");
     $this->click("//option[@value='Contact']");
-    $this->click('_qf_Group_next-bottom');
-    $this->waitForElementPresent('_qf_Field_cancel-bottom');
+    $this->clickLink('_qf_Group_next-bottom');
 
     //Is custom group created?
     $this->assertTrue($this->isTextPresent("Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."));
+    $this->waitForElementPresent('_qf_Field_cancel-bottom');
     $url = explode('gid=', $this->getLocation());
     $gid = $url[1];
 
@@ -207,11 +206,12 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase {
     $this->click("is_searchable");
 
     // clicking save
-    $this->click('_qf_Field_next-bottom');
+    $this->click('_qf_Field_done-bottom');
     $this->waitForElementPresent('newCustomField');
 
-    $this->assertTrue($this->isTextPresent("Custom field '{$dateFieldLabel}' has been saved."));
+    $this->waitForText('crm-notification-container', "Custom field '{$dateFieldLabel}' has been saved.");
 
+    $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$dateFieldLabel']");
     $dateFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$dateFieldLabel']/../../td[8]/span/a@href"));
     $dateFieldId = $dateFieldId[1];
 
@@ -247,7 +247,7 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase {
     $this->click("is_searchable");
 
     //clicking save
-    $this->click("_qf_Field_next");
+    $this->click("_qf_Field_done");
     $this->waitForElementPresent('newCustomField');
 
     //Is custom field created
@@ -288,7 +288,7 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase {
     $this->click("is_searchable");
 
     // clicking save
-    $this->click('_qf_Field_next-bottom');
+    $this->click('_qf_Field_done-bottom');
     $this->waitForElementPresent('newCustomField');
     $this->waitForText("crm-notification-container", "Custom field '{$multiSelectLabel}' has been saved.");
     $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$multiSelectLabel']/parent::td/parent::tr/");
@@ -313,28 +313,30 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase {
     $this->click("is_searchable");
 
     // clicking save
-    $this->click('_qf_Field_next-bottom');
+    $this->click('_qf_Field_done-bottom');
     $this->waitForElementPresent('newCustomField');
 
     $this->waitForText("crm-notification-container", "Custom field '{$contactReferenceLabel}' has been saved.");
+    $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$contactReferenceLabel']/parent::td/parent::tr/");
     $contactReferenceFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$contactReferenceLabel']/parent::td/parent::tr/td[8]/span/a@href"));
     $contactReferenceFieldId = $contactReferenceFieldId[1];
 
     $customDataParams = array(
-      'headers' =>
-      array(
+      'headers' => array(
         "custom_{$dateFieldId}" => "$dateFieldLabel :: $customGroupTitle",
         "custom_{$radioFieldId}" => "$radioFieldLabel :: $customGroupTitle",
         "custom_{$multiSelectFieldId}" => "$multiSelectLabel :: $customGroupTitle",
         "custom_{$contactReferenceFieldId}" => "$contactReferenceLabel :: $customGroupTitle",
       ),
-      'rows' =>
-      array(0 => array("custom_{$dateFieldId}" => date('Y-m-d'),
+      'rows' => array(
+        0 => array(
+          "custom_{$dateFieldId}" => date('Y-m-d'),
           "custom_{$radioFieldId}" => '2',
           "custom_{$multiSelectFieldId}" => '3',
           "custom_{$contactReferenceFieldId}" => $id1,
         ),
-        1 => array("custom_{$dateFieldId}" => date('Y-m-d', mktime(0, 0, 0, 4, 5, date('Y'))),
+        1 => array(
+          "custom_{$dateFieldId}" => date('Y-m-d', mktime(0, 0, 0, 4, 5, date('Y'))),
           "custom_{$radioFieldId}" => '1',
           "custom_{$multiSelectFieldId}" => '2',
           "custom_{$contactReferenceFieldId}" => $id2,
@@ -351,4 +353,3 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase {
     return array($customDataParams, $customDataVerify);
   }
 }
-