Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-08-12-10-27-52
[civicrm-core.git] / tests / phpunit / WebTest / Member / StandaloneAddTest.php
index 70f188a53fd7bfba5d5278996d49c67e3466fde7..8123794d5e08dbeafb0998e994c1210782755f11 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  +--------------------------------------------------------------------+
 */
 
-
 require_once 'CiviTest/CiviSeleniumTestCase.php';
+
+/**
+ * Class WebTest_Member_StandaloneAddTest
+ */
 class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
 
   protected function setUp() {
@@ -34,7 +37,6 @@ class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
 
   function testStandaloneMemberAdd() {
 
-    $this->open($this->sboxPath);
     $this->webtestLogin();
 
     // create contact
@@ -46,9 +48,7 @@ class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
     $membershipTypes = $this->webtestAddMembershipType();
 
     // now add membership
-    $this->open($this->sboxPath . "civicrm/member/add?reset=1&action=add&context=standalone");
-
-    $this->waitForElementPresent("_qf_Membership_upload");
+    $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
 
     // select contact
     $this->webtestFillAutocomplete($firstName);
@@ -71,26 +71,25 @@ class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
 
     // fill in Status Override?
     // fill in Record Membership Payment?
-
+    $this->click("send_receipt");
+    $this->assertTrue($this->isChecked("send_receipt"), 'Send Confirmation and Receipt checkbox should be checked.');
     $this->click("_qf_Membership_upload");
 
     //View Membership
     $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
     $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']");
     $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
+
     $expected = array(
-      2 => $membershipTypes['membership_type'],
-      3 => 'New',
-      4 => 'Membership StandaloneAddTest Webtest',
+      'Membership Type' => $membershipTypes['membership_type'],
+      'Status' => 'New',
+      'Source' => 'Membership StandaloneAddTest Webtest',
     );
-    foreach ($expected as $label => $value) {
-      $this->verifyText("xpath=id('MembershipView')/div[2]/div/table[1]/tbody/tr[$label]/td[2]", preg_quote($value));
-    }
+    $this->webtestVerifyTabularData($expected);
   }
 
   function testStandaloneMemberOverrideAdd() {
 
-    $this->open($this->sboxPath);
     $this->webtestLogin();
 
     // add contact
@@ -102,9 +101,7 @@ class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
     $membershipTypes = $this->webtestAddMembershipType();
 
     // add membership
-    $this->open($this->sboxPath . "civicrm/member/add?reset=1&action=add&context=standalone");
-
-    $this->waitForElementPresent("_qf_Membership_upload");
+    $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
 
     // select contact
     $this->webtestFillAutocomplete($firstName);
@@ -163,14 +160,30 @@ class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
     $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
 
     $expected = array(
-      2 => $membershipTypes['membership_type'],
-      3 => 'Grace',
-      4 => 'Membership StandaloneAddTest Webtest',
+      'Membership Type' => $membershipTypes['membership_type'],
+      'Status' => 'Grace',
+      'Source' => 'Membership StandaloneAddTest Webtest',
     );
-    foreach ($expected as $label => $value) {
-      $this->verifyText("xpath=id('MembershipView')/div[2]/div/table[1]/tbody/tr[$label]/td[2]", preg_quote($value));
-    }
+    $this->webtestVerifyTabularData($expected);
   }
-}
 
+  function testAjaxCustomGroupLoad() {
+    $this->webtestLogin();
+    $triggerElement = array('name' => 'membership_type_id_1', 'type' => 'select');
+    $customSets = array(
+      array('entity' => 'Membership', 'subEntity' => 'General', 'triggerElement' => $triggerElement),
+      array('entity' => 'Membership', 'subEntity' => 'Student', 'triggerElement' => $triggerElement)
+    );
+
+    $pageUrl = array('url' => 'member/add', 'args' => 'reset=1&action=add&context=standalone');
 
+    //case where we should fire certain
+    //ui actions which helps triggering possible
+    $test = $this;
+    $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl,
+      function() use ($test) {
+        $test->select('membership_type_id_0', 'value=1');
+      }
+    );
+  }
+}