3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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_UpdateBatchPendingContributionTest
32 class WebTest_Contribute_UpdateBatchPendingContributionTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testBatchUpdatePendingContribution() {
39 $this->webtestLogin();
40 $this->_testOfflineContribution();
41 $this->_testOfflineContribution();
42 $this->_testOfflineContribution();
44 $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
46 $this->type("sort_name", "Individual");
47 $this->multiselect2('contribution_status_id', array("Pending"));
48 $this->clickLink("_qf_Search_refresh");
50 $this->click('radio_ts', 'ts_all');
51 $this->waitForAjaxContent();
52 $this->select('task', "label=Update pending contribution status");
53 $this->waitForAjaxContent();
54 $this->select('contribution_status_id', 'label=Completed');
55 $this->waitForAjaxContent();
56 $this->click('_qf_Status_next');
57 $this->waitForElementPresent("_qf_Result_done");
58 $this->click("_qf_Result_done");
60 $this->waitForElementPresent("contribution_date_low");
62 $this->type("sort_name", "Individual");
63 $this->multiselect2('contribution_status_id', array("Completed"));
64 $this->click("_qf_Search_refresh");
66 $this->waitForPageToLoad($this->getTimeoutMsec());
67 $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']");
68 $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
70 'Received Into' => "Deposit Bank Account",
71 'Contribution Status' => "Completed",
74 $this->webtestVerifyTabularData($expected);
77 public function testParticipationAdd() {
78 // Log in using webtestLogin() method
79 $this->webtestLogin();
81 // Adding contact with randomized first name (so we can then select that contact when creating event registration)
82 // We're using Quick Add block on the main page for this.
83 $firstName1 = substr(sha1(rand()), 0, 7);
84 $this->webtestAddContact($firstName1, 'Anderson', TRUE);
85 $sortName1 = "Anderson, $firstName1";
86 $this->_addParticipant($firstName1);
88 $firstName2 = substr(sha1(rand()), 0, 7);
89 $this->webtestAddContact($firstName2, 'Anderson', TRUE);
90 $sortName2 = "Anderson, $firstName2";
91 $this->_addParticipant($firstName2);
93 // Search the participants
94 $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh');
97 $this->select2("event_id", $eventName);
98 $this->click('_qf_Search_refresh');
100 $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
102 $this->type("sort_name", "Anderson");
103 $this->multiselect2('contribution_status_id', array("Pending"));
104 $this->click("_qf_Search_refresh");
106 $this->waitForPageToLoad($this->getTimeoutMsec());
107 $this->click('radio_ts', 'ts_all');
109 $this->select('task', "label=Update pending contribution status");
110 $this->waitForElementPresent("_qf_Search_next_action");
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");
118 $this->waitForElementPresent("contribution_date_low");
120 $this->type("sort_name", "Anderson");
121 $this->multiselect2('contribution_status_id', array("Completed"));
122 $this->click("_qf_Search_refresh");
124 $this->waitForPageToLoad($this->getTimeoutMsec());
125 $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']");
126 $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
128 'Received Into' => "Deposit Bank Account",
129 'Contribution Status' => "Completed",
132 $this->webtestVerifyTabularData($expected);
136 * @param string $firstName
138 public function _addParticipant($firstName) {
140 $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", '_qf_Participant_upload-bottom');
142 // Type contact last name in contact auto-complete, wait for dropdown and click first result
143 $this->webtestFillAutocomplete($firstName);
145 // Select event. Based on label for now.
146 $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
149 $this->multiselect2('role_id', array('Volunteer'));
151 // Select participant status
152 $this->select('status_id', 'value=1');
154 // Setting registration source
155 $this->type('source', 'Event StandaloneAddTest Webtest');
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).'));
160 // Select an event fee
161 $this->waitForElementPresent('priceset');
163 $this->click("xpath=//input[@class='crm-form-radio']");
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');
168 $this->select('contribution_status_id', "label=Pending");
171 $this->click('_qf_Participant_upload-bottom');
172 $this->waitForPageToLoad($this->getTimeoutMsec());
174 // Is status message correct?
175 $this->waitForText("crm-notification-container", "Event registration for $firstName Anderson has been added");
177 $this->waitForElementPresent("xpath=//form[@class='CRM_Event_Form_Search crm-search-form']/table//tbody/tr[1]/td[8]/span/a[text()='View']");
178 //click through to the participant view screen
179 $this->click("xpath=//form[@class='CRM_Event_Form_Search crm-search-form']/table//tbody/tr[1]/td[8]/span/a[text()='View']");
180 $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
182 $this->webtestVerifyTabularData(
184 'Event' => 'Rain-forest Cup Youth Soccer Tournament',
185 'Participant Role' => 'Attendee',
186 'Status' => 'Registered',
187 'Event Source' => 'Event StandaloneAddTest Webtest',
188 'Fees' => '$ 800.00',
193 public function _testOfflineContribution() {
194 $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload");
196 // create new contact using dialog
197 $this->createDialogContact();
199 // select financial type
200 $this->select("financial_type_id", "value=1");
202 //Contribution status
203 $this->select("contribution_status_id", "label=Pending");
206 $this->type("total_amount", "100");
209 $this->click("_qf_Contribution_upload");
210 $this->waitForPageToLoad($this->getTimeoutMsec());
212 // Is status message correct?
213 $this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!");
215 // verify if Membership is created
216 $this->waitForElementPresent("xpath=//div[@class='view-content']//table[2]//tbody/tr[1]/td[8]/span/a[text()='View']");
218 //click through to the Membership view screen
219 $this->click("xpath=//div[@class='view-content']//table[2]/tbody/tr[1]/td[8]/span/a[text()='View']");
220 $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
223 'Financial Type' => 'Donation',
224 'Total Amount' => '100.00',
225 'Contribution Status' => 'Pending',
227 foreach ($expected as $label => $value) {
228 $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody//tr/td[1][text()='$label']/../td[2]", preg_quote($value));