3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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';
30 * Class WebTest_Contribute_PCPAddTest
32 class WebTest_Contribute_PCPAddTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testPCPAdd() {
39 // open browser, login
40 $this->webtestLogin();
42 // set pcp supporter name and email
43 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
44 $lastName = 'An' . substr(sha1(rand()), 0, 7);
45 $middleName = 'Mid' . substr(sha1(rand()), 0, 7);
46 $email = substr(sha1(rand()), 0, 7) . '@example.org';
48 $this->openCiviPage("admin/domain", "action=update&reset=1", '_qf_Domain_cancel-bottom');
49 $this->type('name', 'DefaultDomain');
50 $this->type('email_name', $firstName);
51 $this->type('email_address', $email);
53 $this->click('_qf_Domain_next_view-bottom');
54 $this->waitForPageToLoad($this->getTimeoutMsec());
55 $this->assertTrue($this->isTextPresent("Domain information for 'DefaultDomain' has been saved."),
56 "Status message didn't show up after saving!"
59 require_once 'ContributionPageAddTest.php';
61 // a random 7-char string and an even number to make this pass unique
62 $hash = substr(sha1(rand()), 0, 7);
63 $rand = $contributionAmount = 2 * rand(2, 50);
64 $pageTitle = 'PCP Contribution' . $hash;
65 $amountSection = TRUE;
71 $memPriceSetId = NULL;
74 $profilePostId = NULL;
78 $isAprovalNeeded = TRUE;
80 // create a new online contribution page with pcp enabled
81 // create contribution page with randomized title and default params
82 $pageId = $this->webtestAddContributionPage($hash,
85 array('Test Processor' => 'Dummy'),
104 $this->webtestLogout();
106 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", "_qf_Main_upload-bottom");
108 $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input");
109 $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount);
110 $this->typeKeys("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount);
111 $this->type("email-5", $email);
112 $this->click("xpath=//label[text()='Test Processor']");
113 $this->waitForAjaxContent();
115 $this->webtestAddCreditCardDetails();
116 $this->webtestAddBillingDetails($firstName, $middleName, $lastName);
118 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
119 $this->click("_qf_Confirm_next-bottom");
121 $this->waitForElementPresent("thankyou_footer");
122 $this->openCiviPage("contribute/campaign", "action=add&reset=1&pageId={$pageId}&component=contribute", "_qf_PCPAccount_next-bottom");
124 $cmsUserName = 'CmsUser' . substr(sha1(rand()), 0, 7);
125 $this->type("cms_name", $cmsUserName);
126 $this->click("checkavailability");
127 $this->type("first_name", $firstName);
128 $this->type("last_name", $lastName);
129 $this->type("email-Primary", $email);
130 if ($this->isElementPresent("cms_pass")) {
131 $pass = 'myBigPassword';
132 $this->type("cms_pass", $pass);
134 $this->type("cms_confirm_pass", $pass);
137 $this->clickLink("_qf_PCPAccount_next-bottom", "_qf_Campaign_upload-bottom");
139 $pcpTitle = 'PCPTitle' . substr(sha1(rand()), 0, 7);
140 $this->type("pcp_title", $pcpTitle);
141 $this->type("pcp_intro_text", "Welcome Text $hash");
142 $this->type("goal_amount", $contributionAmount);
143 $this->clickLink("_qf_Campaign_upload-bottom", '_qf_Main_upload-bottom');
145 $this->webtestLogin();
146 $this->openCiviPage("admin/pcp", "reset=1", "_qf_PCP_refresh");
147 $this->select('status_id', 'value=1');
148 $this->clickLink("_qf_PCP_refresh", "_qf_PCP_refresh");
149 $id = explode('id=', $this->getAttribute("xpath=//div[@id='option11_wrapper']/table[@id='option11']/tbody/tr/td/a[text()='$pcpTitle']@href"));
150 $pcpId = trim($id[1]);
151 $pcpUrl = "civicrm/contribute/pcp/info?reset=1&id=$pcpId";
152 $this->clickLink("xpath=//td[@id=$pcpId]/span[1]/a[2]");
154 $this->webtestLogout();
156 // Set pcp contributor name
157 $donorFirstName = 'Donor' . substr(sha1(rand()), 0, 4);
158 $donorLastName = 'Person' . substr(sha1(rand()), 0, 7);
159 $middleName = 'Mid' . substr(sha1(rand()), 0, 7);
161 $this->open($this->sboxPath
. $pcpUrl);
163 $this->waitForPageToLoad($this->getTimeoutMsec());
164 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&pcpId=$id[1]", "_qf_Main_upload-bottom");
165 $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input");
166 $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount);
167 $this->typeKeys("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount);
168 $this->type("email-5", $donorFirstName . "@example.com");
169 $this->click("xpath=//label[text()='Test Processor']");
170 $this->waitForAjaxContent();
172 $this->webtestAddCreditCardDetails();
173 $this->webtestAddBillingDetails($donorFirstName, $middleName, $donorLastName);
174 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
175 $this->click("_qf_Confirm_next-bottom");
177 $this->waitForElementPresent("thankyou_footer");
179 //login to check contribution
180 $this->webtestLogin();
183 $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
184 $this->waitForElementPresent('contribution_pcp_made_through_id');
185 $this->multiselect2('contribution_pcp_made_through_id', array($pcpTitle));
187 $this->clickLink("_qf_Search_refresh", "xpath=//table[@class='selector row-highlight']/tbody/tr[1]//td/span/a[1][text()='View']");
188 $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]//td/span/a[1][text()='View']");
189 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
191 // View Contribution Record and test for expected values
193 'From' => "{$donorFirstName} {$donorLastName}",
194 'Financial Type' => 'Donation',
195 'Total Amount' => $contributionAmount,
196 'Contribution Status' => 'Completed',
198 $this->webtestVerifyTabularData($expected);
200 //Check for SoftCredit
201 $softCreditor = "{$firstName} {$lastName}";
202 $this->verifyText("xpath=//div['PCPView']/div[2]/table[@class='crm-info-panel']/tbody/tr[2]/td[2]/a", preg_quote($softCreditor));
204 // Check PCP Summary Report
205 $this->openCiviPage('report/instance/17', 'reset=1');
206 $this->verifyText("PCP", preg_quote($pcpTitle));
207 $this->verifyText("PCP", preg_quote("{$lastName}, {$firstName}"));