Merge pull request #8042 from jitendrapurohit/CRM-18250
[civicrm-core.git] / tests / phpunit / WebTest / Contribute / OnBehalfOfOrganization.php
index 2a7b1d56d0580573d5edc348a39cb30b25b8665d..b991fabfa2f1c52fa2a65b31d0db53e3006fc4a1 100644 (file)
@@ -3,7 +3,7 @@
    +--------------------------------------------------------------------+
    | CiviCRM version 4.7                                                |
    +--------------------------------------------------------------------+
-   | Copyright CiviCRM LLC (c) 2004-2015                                |
+   | Copyright CiviCRM LLC (c) 2004-2016                                |
    +--------------------------------------------------------------------+
    | This file is a part of CiviCRM.                                    |
    |                                                                    |
@@ -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');
+  }
+
 }