CRM-18152 Added webtest to support patch
authorEdsel <edsel.lopez@jmaconsulting.biz>
Fri, 4 Mar 2016 13:35:28 +0000 (19:05 +0530)
committerEdsel <edsel.lopez@jmaconsulting.biz>
Fri, 4 Mar 2016 13:35:28 +0000 (19:05 +0530)
----------------------------------------
* CRM-18152: On Behalf profile does not select org profile by default if contribution profiles are added prior to it
  https://issues.civicrm.org/jira/browse/CRM-18152

tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php

index 2a7b1d56d0580573d5edc348a39cb30b25b8665d..1e8e46ec9aadc821a1c84a2a6e6edddf57c85aed 100644 (file)
@@ -1342,4 +1342,40 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase {
     $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img"));
   }
 
+  public function testOnBehalfSetDefaults() {
+    $this->webtestLogin();
+    $hash = substr(sha1(rand()), 0, 7);
+    $pageTitle = 'Donate Online ' . $hash;
+    $rand = 2 * rand(2, 50);
+
+    // go to the New Contribution Page page
+    $this->openCiviPage('admin/contribute', 'action=add&reset=1');
+
+    // fill in step 1 (Title and Settings)
+    $this->type('title', $pageTitle);
+
+    //to select financial type
+    $this->select('financial_type_id', "label=Donation");
+    $this->clickLink('_qf_Settings_next');
+
+    $this->click('link=Profiles');
+    $this->waitForElementPresent('_qf_Custom_next-bottom');
+    $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', "value=1");
+    $this->click('_qf_Custom_next-bottom');
+    $this->waitForElementPresent('_qf_Custom_next-bottom');
+
+    $this->click('link=Title');
+    $this->waitForElementPresent('_qf_Settings_next');
+    $this->click('is_organization');
+    $this->clickLink('_qf_Settings_next');
+    $this->waitForElementPresent('_qf_Settings_next');
+    $this->click('is_organization');
+    $this->clickLink('_qf_Settings_next');
+    $this->waitForElementPresent('_qf_Settings_next');
+    $this->click('is_organization');
+    $this->waitForElementPresent("xpath=//*[@id='select2-chosen-2']");
+    $sel = $this->getText("xpath=//*[@id='select2-chosen-2']");
+    $this->assertEquals($sel, 'On Behalf Of Organization');
+  }
+
 }