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->type("email-5", $email);
112 $this->webtestAddCreditCardDetails();
113 $this->webtestAddBillingDetails($firstName, $middleName, $lastName);
115 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
116 $this->click("_qf_Confirm_next-bottom");
118 $this->waitForElementPresent("thankyou_footer");
119 $this->openCiviPage("contribute/campaign", "action=add&reset=1&pageId={$pageId}&component=contribute", "_qf_PCPAccount_next-bottom");
121 $cmsUserName = 'CmsUser' . substr(sha1(rand()), 0, 7);
122 $this->type("cms_name", $cmsUserName);
123 $this->click("checkavailability");
124 $this->type("first_name", $firstName);
125 $this->type("last_name", $lastName);
126 $this->type("email-Primary", $email);
127 if ($this->isElementPresent("cms_pass")) {
128 $pass = 'myBigPassword';
129 $this->type("cms_pass", $pass);
131 $this->type("cms_confirm_pass", $pass);
134 $this->clickLink("_qf_PCPAccount_next-bottom", "_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->clickLink("_qf_PCP_refresh", "_qf_PCP_refresh");
146 $id = explode('id=', $this->getAttribute("xpath=//div[@id='option11_wrapper']/table[@id='option11']/tbody/tr/td/a[text()='$pcpTitle']@href"));
147 $pcpId = trim($id[1]);
148 $pcpUrl = "civicrm/contribute/pcp/info?reset=1&id=$pcpId";
149 $this->clickLink("xpath=//td[@id=$pcpId]/span[1]/a[2]");
151 $this->webtestLogout();
153 // Set pcp contributor name
154 $donorFirstName = 'Donor' . substr(sha1(rand()), 0, 4);
155 $donorLastName = 'Person' . substr(sha1(rand()), 0, 7);
156 $middleName = 'Mid' . substr(sha1(rand()), 0, 7);
158 $this->open($this->sboxPath
. $pcpUrl);
160 $this->waitForPageToLoad($this->getTimeoutMsec());
161 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&pcpId=$id[1]", "_qf_Main_upload-bottom");
162 $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input");
163 $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount);
164 $this->type("email-5", $donorFirstName . "@example.com");
166 $this->webtestAddCreditCardDetails();
167 $this->webtestAddBillingDetails($donorFirstName, $middleName, $donorLastName);
168 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
169 $this->click("_qf_Confirm_next-bottom");
171 $this->waitForElementPresent("thankyou_footer");
173 //login to check contribution
174 $this->webtestLogin();
177 $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
178 $this->waitForElementPresent('contribution_pcp_made_through_id');
179 $this->select2('contribution_pcp_made_through_id', $lastName . ', ' . $firstName);
181 $this->clickLink("_qf_Search_refresh", "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[11]/span/a[1][text()='View']");
182 $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[11]/span/a[1][text()='View']");
183 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
185 // View Contribution Record and test for expected values
187 'From' => "{$donorFirstName} {$donorLastName}",
188 'Financial Type' => 'Donation',
189 'Total Amount' => $contributionAmount,
190 'Contribution Status' => 'Completed',
192 $this->webtestVerifyTabularData($expected);
194 //Check for SoftCredit
195 $softCreditor = "{$firstName} {$lastName}";
196 $this->verifyText("xpath=//div['PCPView']/div[2]/table[@class='crm-info-panel']/tbody/tr[2]/td[2]/a", preg_quote($softCreditor));
198 // Check PCP Summary Report
199 $this->openCiviPage('report/instance/16', 'reset=1');
200 $this->verifyText("PCP", preg_quote($pcpTitle));
201 $this->verifyText("PCP", preg_quote("{$lastName}, {$firstName}"));