fixes for WebTest_Contribute_AddBatchesTest::testBatchAddContribution
authorkurund <kurund@civicrm.org>
Mon, 12 Aug 2013 21:39:39 +0000 (03:09 +0530)
committerkurund <kurund@civicrm.org>
Mon, 12 Aug 2013 21:39:39 +0000 (03:09 +0530)
tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/Contribute/AddBatchesTest.php

index 6a78696c7c7f429fd78cbb0adb7fa04b945b709c..d49ce50b8ae43b3050942e622fac8da098850666 100644 (file)
@@ -496,14 +496,20 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
 
   /**
    */
-  function webtestNewDialogContact($fname = 'Anthony', $lname = 'Anderson', $email = 'anthony@anderson.biz', $type = 4, $selectId = 'profiles_1', $row = 1) {
+  function webtestNewDialogContact($fname = 'Anthony', $lname = 'Anderson', $email = 'anthony@anderson.biz',
+                                   $type = 4, $selectId = 'profiles_1', $row = 1, $prefix = '') {
     // 4 - Individual profile
     // 5 - Organization profile
     // 6 - Household profile
     $this->select($selectId, "value={$type}");
 
     // create new contact using dialog
-    $this->waitForElementPresent("css=div#contact-dialog-{$row}");
+    if (!$prefix) {
+      $this->waitForElementPresent("css=div#contact-dialog-{$row}");
+    }
+    else {
+      $this->waitForElementPresent("css=div#contact-dialog-{$prefix}_{$row}");
+    }
     $this->waitForElementPresent('_qf_Edit_next');
 
     switch ($type) {
index 43ee26ff6c425759e82e32a6ef8be19cf5c6da5a..d94f8aec6fcfa58e34094a76d59c5a7395678bf8 100644 (file)
@@ -90,7 +90,6 @@ class WebTest_Contribute_AddBatchesTest extends CiviSeleniumTestCase {
         'last_name' => 'An'.substr(sha1(rand()), 0, 7),
         'membership_type' => 'Default Organization',
         'amount' => 100,
-
         'financial_type' => 'Member Dues',
       );
       $this->_fillData($data[$i], $i, "Membership");
@@ -103,7 +102,8 @@ class WebTest_Contribute_AddBatchesTest extends CiviSeleniumTestCase {
 
   function _fillData($data, $row, $type) {
     $email = $data['first_name'] . '@example.com';
-    $this->webtestNewDialogContact($data['first_name'], $data['last_name'], $email, 4, "primary_profiles_{$row}", "primary_{$row}");
+    $this->webtestNewDialogContact($data['first_name'], $data['last_name'], $email, 4,
+      "primary_profiles_{$row}", $row, 'primary');
 
     if ($type == "Contribution") {
       $this->select("field_{$row}_financial_type", $data['financial_type']);
@@ -186,35 +186,4 @@ class WebTest_Contribute_AddBatchesTest extends CiviSeleniumTestCase {
       $this->_checkResult($value, $type);
     }
   }
-
-  function webtestNewDialogContact($fname = 'Anthony', $lname = 'Anderson', $email = 'anthony@anderson.biz', $type = 4, $row) {
-    // 4 - Individual profile
-    // 5 - Organization profile
-    // 6 - Household profile
-    $this->select("{$row}", "value={$type}");
-    // create new contact using dialog
-    //   $this->waitForElementPresent('#first_name');
-    $this->waitForElementPresent('_qf_Edit_next');
-
-    switch ($type) {
-      case 4:
-        $this->type('first_name', $fname);
-        $this->type('last_name', $lname);
-        break;
-
-      case 5:
-        $this->type('organization_name', $fname);
-        break;
-
-      case 6:
-        $this->type('household_name', $fname);
-        break;
-    }
-
-    $this->type('email-Primary', $email);
-    $this->click('_qf_Edit_next');
-
-    // Is new contact created?
-    $this->assertTrue($this->isTextPresent("{$lname}, {$fname} has been created."), "Status message didn't show up after saving!");
-  }
 }