Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Contribute_OnlineRecurContributionTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Contribute_OnlineRecurContributionTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testOnlineRecurContribution() { |
6a488035 TO |
39 | require_once 'ContributionPageAddTest.php'; |
40 | ||
41 | // a random 7-char string and an even number to make this pass unique | |
42daf119 CW |
42 | $hash = substr(sha1(rand()), 0, 7); |
43 | $rand = $contributionAmount = 2 * rand(2, 50); | |
44 | $pageTitle = 'Donate Online Recurring ' . $hash; | |
6a488035 TO |
45 | $processorType = 'AuthNet'; |
46 | $processorName = "Webtest AuthNet " . substr(sha1(rand()), 0, 7); | |
47 | $amountSection = TRUE; | |
42daf119 CW |
48 | $payLater = FALSE; |
49 | $onBehalf = FALSE; | |
50 | $pledges = FALSE; | |
51 | $recurring = TRUE; | |
52 | $memberships = FALSE; | |
6a488035 | 53 | $memPriceSetId = NULL; |
42daf119 CW |
54 | $friend = TRUE; |
55 | $profilePreId = NULL; | |
6a488035 | 56 | $profilePostId = NULL; |
42daf119 CW |
57 | $premiums = FALSE; |
58 | $widget = FALSE; | |
59 | $pcp = FALSE; | |
6a488035 TO |
60 | |
61 | // open browser, login | |
14d071ba | 62 | $this->webtestLogin('admin'); |
6a488035 TO |
63 | |
64 | // create a new online contribution page with recurring enabled (using a newly created AuthNet processor) | |
65 | // create contribution page with randomized title and default params | |
66 | $pageId = $this->webtestAddContributionPage($hash, | |
67 | $rand, | |
68 | $pageTitle, | |
69 | array($processorName => $processorType), | |
70 | $amountSection, | |
71 | $payLater, | |
72 | $onBehalf, | |
73 | $pledges, | |
74 | $recurring, | |
75 | $memberships, | |
76 | $memPriceSetId, | |
77 | $friend, | |
78 | $profilePreId, | |
79 | $profilePostId, | |
80 | $premiums, | |
81 | $widget, | |
82 | $pcp | |
83 | ); | |
84 | ||
85 | //now do the test online recurring contribution as an anonymous user. | |
42daf119 CW |
86 | $anonymous = TRUE; |
87 | $firstName = 'Jane' . substr(sha1(rand()), 0, 7); | |
88 | $middleName = 'Middle'; | |
89 | $lastName = 'Recuron_' . substr(sha1(rand()), 0, 7); | |
90 | $email = $firstName . '@example.com'; | |
6a488035 TO |
91 | $contactName = "$firstName $lastName"; |
92 | ||
93 | // logout | |
42daf119 | 94 | $this->webtestLogout(); |
6a488035 | 95 | |
071a6d2e | 96 | $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", "_qf_Main_upload-bottom"); |
6a488035 TO |
97 | |
98 | // helper AddContributionPage sets Minimum Other Amout = $rand / 2 so must contribute more than that | |
99 | $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input"); | |
100 | $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount); | |
101 | ||
102 | // recurring contribution - each month for 12 months | |
103 | $this->click("is_recur"); | |
104 | $this->type("frequency_interval", "1"); | |
105 | $this->type("installments", "12"); | |
106 | ||
107 | $this->type("email-5", $email); | |
108 | ||
109 | $this->webtestAddCreditCardDetails(); | |
110 | $this->webtestAddBillingDetails($firstName, $middleName, $lastName); | |
111 | $this->click("_qf_Main_upload-bottom"); | |
112 | ||
113 | // Confirmation page | |
114 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); | |
b4a57e40 | 115 | $text = 'I want to contribute this amount every month for 12 installments.'; |
6a488035 TO |
116 | $this->assertTrue($this->isTextPresent($text), 'Missing recurring contribution text (confirmation): ' . $text); |
117 | $text = $rand; | |
118 | $this->assertTrue($this->isTextPresent($contributionAmount), 'Missing contribution amount (confirmation): ' . $contributionAmount); | |
119 | $this->click("_qf_Confirm_next-bottom"); | |
120 | ||
121 | // Thank-you page | |
122 | $this->waitForElementPresent("thankyou_footer"); | |
123 | $this->assertTrue($this->isElementPresent('tell-a-friend'), 'Missing tell-a-friend div'); | |
687bced0 | 124 | $text = 'This recurring contribution will be automatically processed every month for a total 12 installments'; |
6a488035 TO |
125 | $this->assertTrue($this->isTextPresent($text), 'Missing recurring contribution text (thank-you): ' . $text); |
126 | $this->assertTrue($this->isTextPresent($contributionAmount), 'Missing contribution amount (thank-you): ' . $contributionAmount); | |
127 | ||
128 | // Log back in and verify that test contribution has been recorded | |
6a488035 | 129 | $this->webtestLogin(); |
42daf119 | 130 | $this->openCiviPage("contribute/search", "reset=1", "contribution_currency_type"); |
6a488035 TO |
131 | |
132 | $this->type("sort_name", "{$lastName}, {$firstName}"); | |
133 | $this->click("contribution_test"); | |
134 | $this->click("_qf_Search_refresh"); | |
135 | ||
a1c7d42f CW |
136 | $this->waitForElementPresent('css=#contributionSearch table tbody tr td span a.action-item:first-child'); |
137 | $this->click('css=#contributionSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
138 | $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); |
139 | ||
140 | // View Recurring Contribution Record | |
141 | $verifyData = array( | |
142 | 'From' => "$contactName", | |
92915c55 | 143 | 'Financial Type' => 'Donation (test)', |
6a488035 TO |
144 | 'Total Amount' => 'Installments: 12, Interval: 1 month(s)', |
145 | 'Contribution Status' => 'Pending : Incomplete Transaction', | |
4db803dd | 146 | 'Payment Method' => 'Credit Card', |
6a488035 TO |
147 | 'Online Contribution Page' => $pageTitle, |
148 | ); | |
149 | foreach ($verifyData as $label => $value) { | |
150 | $this->verifyText("xpath=//form[@id='ContributionView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
151 | preg_quote($value) | |
152 | ); | |
153 | } | |
154 | } | |
96025800 | 155 | |
6a488035 | 156 | } |