Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Contribute_UpdateBatchPendingContributionTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Contribute_UpdateBatchPendingContributionTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
38 | function testBatchUpdatePendingContribution() { | |
6a488035 TO |
39 | $this->webtestLogin(); |
40 | $this->_testOfflineContribution(); | |
41 | $this->_testOfflineContribution(); | |
42 | $this->_testOfflineContribution(); | |
43 | ||
42daf119 | 44 | $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); |
6a488035 TO |
45 | |
46 | $this->type("sort_name", "Contributor"); | |
47 | $this->click('contribution_status_id_2'); | |
48 | $this->click("_qf_Search_refresh"); | |
49 | ||
50 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
51 | $this->click('radio_ts', 'ts_all'); | |
52 | ||
53 | $this->select('task', "label=Update Pending Contribution Status"); | |
54 | $this->click("_qf_Search_next_action"); | |
55 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
56 | $this->select('contribution_status_id', 'label=Completed'); | |
57 | $this->click('_qf_Status_next'); | |
58 | $this->waitForElementPresent("_qf_Result_done"); | |
59 | $this->click("_qf_Result_done"); | |
60 | ||
61 | $this->waitForElementPresent("contribution_date_low"); | |
62 | ||
63 | $this->type("sort_name", "Contributor"); | |
64 | $this->click('contribution_status_id_1'); | |
65 | $this->click("_qf_Search_refresh"); | |
66 | ||
67 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
f1690d4a | 68 | $this->click("xpath=//div[@id='contributionSearch']/table[@class='selector row-highlight']/tbody/tr[1]/td[11]/span/a[text()='View']"); |
69 | $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); | |
6a488035 TO |
70 | $expected = array( |
71 | 'Received Into' => "Deposit Bank Account", | |
72 | 'Contribution Status' => "Completed", | |
76e86fd8 CW |
73 | ); |
74 | ||
6a488035 TO |
75 | $this->webtestVerifyTabularData($expected); |
76 | } | |
77 | ||
78 | function testParticipationAdd() { | |
6a488035 TO |
79 | // Log in using webtestLogin() method |
80 | $this->webtestLogin(); | |
81 | ||
82 | // Adding contact with randomized first name (so we can then select that contact when creating event registration) | |
83 | // We're using Quick Add block on the main page for this. | |
84 | $firstName1 = substr(sha1(rand()), 0, 7); | |
85 | $this->webtestAddContact($firstName1, 'Anderson', TRUE); | |
86 | $sortName1 = "Anderson, $firstName1"; | |
87 | $this->_addParticipant($firstName1); | |
88 | ||
89 | $firstName2 = substr(sha1(rand()), 0, 7); | |
90 | $this->webtestAddContact($firstName2, 'Anderson', TRUE); | |
91 | $sortName2 = "Anderson, $firstName2"; | |
92 | $this->_addParticipant($firstName2); | |
93 | ||
94 | // Search the participants | |
42daf119 | 95 | $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh'); |
6a488035 TO |
96 | |
97 | $eventName = 'Rain'; | |
f1690d4a | 98 | $this->select2("event_id", $eventName); |
6a488035 TO |
99 | $this->click('_qf_Search_refresh'); |
100 | ||
42daf119 | 101 | $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); |
6a488035 TO |
102 | |
103 | $this->type("sort_name", "Anderson"); | |
104 | $this->click('contribution_status_id_2'); | |
105 | $this->click("_qf_Search_refresh"); | |
106 | ||
107 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
108 | $this->click('radio_ts', 'ts_all'); | |
109 | ||
110 | $this->select('task', "label=Update Pending Contribution Status"); | |
111 | $this->click("_qf_Search_next_action"); | |
112 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
113 | $this->select('contribution_status_id', 'label=Completed'); | |
114 | $this->click('_qf_Status_next'); | |
115 | $this->waitForElementPresent("_qf_Result_done"); | |
116 | $this->click("_qf_Result_done"); | |
117 | ||
118 | $this->waitForElementPresent("contribution_date_low"); | |
119 | ||
120 | $this->type("sort_name", "Anderson"); | |
121 | $this->click('contribution_status_id_1'); | |
122 | $this->click("_qf_Search_refresh"); | |
123 | ||
124 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
f1690d4a | 125 | $this->click("xpath=//div[@id='contributionSearch']/table[@class='selector row-highlight']/tbody/tr[1]/td[11]/span/a[text()='View']"); |
c51f8adb | 126 | $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); |
6a488035 TO |
127 | $expected = array( |
128 | 'Received Into' => "Deposit Bank Account", | |
129 | 'Contribution Status' => "Completed", | |
76e86fd8 CW |
130 | ); |
131 | ||
6a488035 TO |
132 | $this->webtestVerifyTabularData($expected); |
133 | } | |
134 | ||
4cbe18b8 EM |
135 | /** |
136 | * @param $firstName | |
137 | */ | |
6a488035 | 138 | function _addParticipant($firstName) { |
6a488035 | 139 | |
42daf119 | 140 | $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", '_qf_Participant_upload-bottom'); |
6a488035 | 141 | |
6a488035 TO |
142 | // Type contact last name in contact auto-complete, wait for dropdown and click first result |
143 | $this->webtestFillAutocomplete($firstName); | |
144 | ||
145 | // Select event. Based on label for now. | |
f1690d4a | 146 | $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament"); |
6a488035 TO |
147 | |
148 | // Select role | |
f1690d4a | 149 | $this->multiselect2('role_id', array('Volunteer')); |
6a488035 | 150 | |
6a488035 TO |
151 | // Select participant status |
152 | $this->select('status_id', 'value=1'); | |
153 | ||
154 | // Setting registration source | |
155 | $this->type('source', 'Event StandaloneAddTest Webtest'); | |
156 | ||
157 | // Since we're here, let's check of screen help is being displayed properly | |
158 | $this->assertTrue($this->isTextPresent('Source for this registration (if applicable).')); | |
159 | ||
160 | // Select an event fee | |
161 | $this->waitForElementPresent('priceset'); | |
162 | ||
f1690d4a | 163 | $this->click("xpath=//input[@class='crm-form-radio']"); |
6a488035 TO |
164 | |
165 | // Enter amount to be paid (note: this should default to selected fee level amount, s/b fixed during 3.2 cycle) | |
166 | $this->type('total_amount', '800'); | |
167 | ||
168 | $this->select('contribution_status_id', "label=Pending"); | |
169 | ||
170 | // Clicking save. | |
171 | $this->click('_qf_Participant_upload-bottom'); | |
172 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
173 | ||
174 | // Is status message correct? | |
f1690d4a | 175 | $this->waitForText("crm-notification-container", "Event registration for $firstName Anderson has been added"); |
6a488035 | 176 | |
f1690d4a | 177 | $this->waitForElementPresent("xpath=//form[@id='Search']//table//tbody/tr[1]/td[8]/span/a[text()='View']"); |
6a488035 | 178 | //click through to the participant view screen |
f1690d4a | 179 | $this->click("xpath=//form[@id='Search']//table//tbody/tr[1]/td[8]/span/a[text()='View']"); |
6a488035 TO |
180 | $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom'); |
181 | ||
182 | $this->webtestVerifyTabularData( | |
183 | array( | |
184 | 'Event' => 'Rain-forest Cup Youth Soccer Tournament', | |
185 | 'Participant Role' => 'Attendee', | |
186 | 'Status' => 'Registered', | |
187 | 'Event Source' => 'Event StandaloneAddTest Webtest', | |
f1690d4a | 188 | 'Fees' => '$ 800.00', |
6a488035 TO |
189 | ) |
190 | ); | |
191 | } | |
192 | ||
193 | function _testOfflineContribution() { | |
194 | $firstName = substr(sha1(rand()), 0, 7); | |
195 | $lastName = 'Contributor'; | |
196 | $email = $firstName . "@example.com"; | |
197 | ||
42daf119 | 198 | $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload"); |
6a488035 | 199 | |
6a488035 TO |
200 | // create new contact using dialog |
201 | $this->webtestNewDialogContact($firstName, "Contributor", $email); | |
202 | ||
203 | // select financial type | |
204 | $this->select( "financial_type_id", "value=1" ); | |
205 | ||
206 | //Contribution status | |
207 | $this->select("contribution_status_id", "label=Pending"); | |
208 | ||
209 | // total amount | |
210 | $this->type("total_amount", "100"); | |
211 | ||
212 | // Clicking save. | |
213 | $this->click("_qf_Contribution_upload"); | |
214 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
215 | ||
216 | // Is status message correct? | |
217 | $this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!"); | |
218 | ||
219 | // verify if Membership is created | |
f1690d4a | 220 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table[2]//tbody/tr[1]/td[8]/span/a[text()='View']"); |
6a488035 TO |
221 | |
222 | //click through to the Membership view screen | |
f1690d4a | 223 | $this->click("xpath=//div[@class='view-content']//table[2]/tbody/tr[1]/td[8]/span/a[text()='View']"); |
6a488035 TO |
224 | $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); |
225 | ||
226 | $expected = array( | |
227 | 'Financial Type' => 'Donation', | |
228 | 'Total Amount' => '100.00', | |
229 | 'Contribution Status' => 'Pending', | |
230 | ); | |
231 | foreach ($expected as $label => $value) { | |
232 | $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody//tr/td[1][text()='$label']/../td[2]", preg_quote($value)); | |
233 | } | |
234 | } | |
235 | } | |
236 |