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