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