3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Contribute_PCPAddTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testPCPAdd() {
35 // open browser, login
36 $this->webtestLogin();
38 // set pcp supporter name and email
39 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
40 $lastName = 'An' . substr(sha1(rand()), 0, 7);
41 $middleName = 'Mid' . substr(sha1(rand()), 0, 7);
42 $email = substr(sha1(rand()), 0, 7) . '@example.org';
44 $this->openCiviPage("admin/domain", "action=update&reset=1", '_qf_Domain_cancel-bottom');
45 $this->type('name', 'DefaultDomain');
46 $this->type('email_name', $firstName);
47 $this->type('email_address', $email);
49 $this->click('_qf_Domain_next_view-bottom');
50 $this->waitForPageToLoad($this->getTimeoutMsec());
51 $this->assertTrue($this->isTextPresent("Domain information for 'DefaultDomain' has been saved."),
52 "Status message didn't show up after saving!"
55 require_once 'ContributionPageAddTest.php';
57 // a random 7-char string and an even number to make this pass unique
58 $hash = substr(sha1(rand()), 0, 7);
59 $rand = $contributionAmount = 2 * rand(2, 50);
60 $pageTitle = 'PCP Contribution' . $hash;
61 $processorType = 'Dummy';
62 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
63 $amountSection = TRUE;
69 $memPriceSetId = NULL;
72 $profilePostId = NULL;
76 $isAprovalNeeded = TRUE;
78 // create a new online contribution page with pcp enabled
79 // create contribution page with randomized title and default params
80 $pageId = $this->webtestAddContributionPage($hash,
83 array($processorName => $processorType),
102 $this->webtestLogout();
104 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", "_qf_Main_upload-bottom");
106 $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input");
107 $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount);
108 $this->type("email-5", $email);
110 $this->webtestAddCreditCardDetails();
111 $this->webtestAddBillingDetails($firstName, $middleName, $lastName);
113 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
114 $this->click("_qf_Confirm_next-bottom");
116 $this->waitForElementPresent("thankyou_footer");
117 $this->openCiviPage("contribute/campaign", "action=add&reset=1&pageId={$pageId}&component=contribute", "_qf_PCPAccount_next-bottom");
119 $cmsUserName = 'CmsUser' . substr(sha1(rand()), 0, 7);
120 $this->type("cms_name", $cmsUserName);
121 $this->click("checkavailability");
122 $this->type("first_name", $firstName);
123 $this->type("last_name", $lastName);
124 $this->type("email-Primary", $email);
125 if ($this->isElementPresent("cms_pass")) {
126 $pass = 'myBigPassword';
127 $this->type("cms_pass", $pass);
129 $this->type("cms_confirm_pass", $pass);
132 $this->click("_qf_PCPAccount_next-bottom");
134 $this->waitForElementPresent("_qf_Campaign_upload-bottom");
136 $pcpTitle = 'PCPTitle' . substr(sha1(rand()), 0, 7);
137 $this->type("pcp_title", $pcpTitle);
138 $this->type("pcp_intro_text", "Welcome Text $hash");
139 $this->type("goal_amount", $contributionAmount);
140 $this->clickLink("_qf_Campaign_upload-bottom", '_qf_Main_upload-bottom');
142 $this->webtestLogin();
143 $this->openCiviPage("admin/pcp", "reset=1", "_qf_PCP_refresh");
144 $this->select('status_id', 'value=1');
145 $this->click("_qf_PCP_refresh");
146 $this->waitForElementPresent("_qf_PCP_refresh");
147 $id = explode('id=', $this->getAttribute("xpath=//div[@id='option11_wrapper']/table[@id='option11']/tbody/tr/td/a[text()='$pcpTitle']@href"));
148 $pcpId = trim($id[1]);
149 $pcpUrl = "civicrm/contribute/pcp/info?reset=1&id=$pcpId";
150 $this->click("xpath=//td[@id=$pcpId]/span[1]/a[2]");
151 $this->waitForPageToLoad($this->getTimeoutMsec());
153 $this->webtestLogout();
155 // Set pcp contributor name
156 $donorFirstName = 'Donor' . substr(sha1(rand()), 0, 4);
157 $donorLastName = 'Person' . substr(sha1(rand()), 0, 7);
158 $middleName = 'Mid' . substr(sha1(rand()), 0, 7);
160 $this->open($this->sboxPath
. $pcpUrl);
162 $this->waitForPageToLoad($this->getTimeoutMsec());
163 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&pcpId=$id[1]", "_qf_Main_upload-bottom");
164 $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input");
165 $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount);
166 $this->type("email-5", $donorFirstName . "@example.com");
168 $this->webtestAddCreditCardDetails();
169 $this->webtestAddBillingDetails($donorFirstName, $middleName, $donorLastName);
170 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
171 $this->click("_qf_Confirm_next-bottom");
173 $this->waitForElementPresent("thankyou_footer");
175 //login to check contribution
176 $this->webtestLogin();
179 $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
181 $this->select('contribution_pcp_made_through_id', "label={$pcpTitle}");
183 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
184 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
186 // View Contribution Record and test for expected values
188 'From' => "{$donorFirstName} {$donorLastName}",
189 'Financial Type' => 'Donation',
190 'Total Amount' => $contributionAmount,
191 'Contribution Status' => 'Completed',
193 $this->webtestVerifyTabularData($expected);
195 //Check for SoftCredit
196 $softCreditor = "{$firstName} {$lastName}";
197 $this->verifyText("xpath=//table[@class='crm-info-panel crm-soft-credit-listing']/tbody/tr/td[1]", preg_quote($softCreditor), 'In line ' . __LINE__
);
199 // Check PCP Summary Report
200 $this->openCiviPage('report/instance/16', 'reset=1');
201 $this->verifyText("PCP", preg_quote($pcpTitle));
202 $this->verifyText("PCP", preg_quote("{$lastName}, {$firstName}"));