Mass switch to openCiviPage method
[civicrm-core.git] / tests / phpunit / WebTest / Event / ChangeParticipantStatus.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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
27
28require_once 'CiviTest/CiviSeleniumTestCase.php';
29class WebTest_Event_ChangeParticipantStatus extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testParticipationAdd() {
6a488035
TO
36 // Log in using webtestLogin() method
37 $this->webtestLogin();
38
39 // Adding contact with randomized first name (so we can then select that contact when creating event registration)
40 // We're using Quick Add block on the main page for this.
41 $firstName1 = substr(sha1(rand()), 0, 7);
42 $this->webtestAddContact($firstName1, 'Anderson', TRUE);
43 $sortName1 = "Anderson, $firstName1";
44 $this->addParticipant($firstName1);
45
46 $firstName2 = substr(sha1(rand()), 0, 7);
47 $this->webtestAddContact($firstName2, 'Anderson', TRUE);
48 $sortName2 = "Anderson, $firstName2";
49 $this->addParticipant($firstName2);
50
51 // Search the participants
42daf119 52 $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh');
6a488035
TO
53
54 $eventName = 'Rain';
55 $this->click("event_name");
56 $this->type("event_name", $eventName);
57 $this->typeKeys("event_name", $eventName);
58 $this->waitForElementPresent("css=div.ac_results-inner li");
59 $this->click("css=div.ac_results-inner li");
60 $this->assertContains($eventName, $this->getValue("event_name"), "autocomplete expected $eventName but didn’t find it in " . $this->getValue("event_name"));
61 $this->click('_qf_Search_refresh');
62
63 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName1']");
64 $id1 = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName1']/../../td[1]/input@id");
65 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName1']/../../td[1]/");
66 $this->click($id1);
67
68 $id2 = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName2']/../../td[1]/input@id");
69 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName2']/../../td[1]/");
70 $this->click($id2);
71
72 // Change participant status for selected participants
73 $this->select('task', "label=Change Participant Status");
74 $this->click('Go');
75 $this->waitForElementPresent('_qf_ParticipantStatus_next');
76
77 $this->select('status_change', "label=Attended");
78 $this->click('_qf_ParticipantStatus_next');
79 $this->waitForElementPresent('Go');
80 $this->assertTrue($this->isTextPresent('The updates have been saved.'),
81 "Status message didn't show up after saving!"
82 );
83
84 // Verify the changed status
42daf119 85 $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh');
6a488035
TO
86 $this->type('sort_name', $firstName1);
87 $this->click('_qf_Search_refresh');
88 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName1']");
89 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName1']/../../td[11]/span/a[text()='View']");
90 $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
91 $this->webtestVerifyTabularData(array('Status' => 'Attended'));
92
42daf119 93 $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh');
6a488035
TO
94 $this->type('sort_name', $firstName2);
95 $this->click('_qf_Search_refresh');
96 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName2']");
97 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName2']/../../td[11]/span/a[text()='View']");
98 $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
99 $this->webtestVerifyTabularData(array('Status' => 'Attended'));
100 }
101
102 function addParticipant($firstName) {
42daf119 103 $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", '_qf_Participant_upload-bottom');
6a488035 104
6a488035
TO
105 // Type contact last name in contact auto-complete, wait for dropdown and click first result
106 $this->webtestFillAutocomplete($firstName);
107
108 // Select event. Based on label for now.
109 $this->select('event_id', "label=regexp:Rain-forest Cup Youth Soccer Tournament.");
110
111 // Select role
112 $this->click('role_id[2]');
113
114 // Choose Registration Date.
115 // Using helper webtestFillDate function.
116 $this->webtestFillDate('register_date', 'now');
117 $today = date('F jS, Y', strtotime('now'));
118
119 // Select participant status
120 $this->select('status_id', 'value=1');
121
122 // Setting registration source
123 $this->type('source', 'Event StandaloneAddTest Webtest');
124
125 // Since we're here, let's check of screen help is being displayed properly
126 $this->assertTrue($this->isTextPresent('Source for this registration (if applicable).'));
127
128 // Select an event fee
129 $this->waitForElementPresent('priceset');
130
131 $this->click("xpath=//input[@class='form-radio']");
132 // Select 'Record Payment'
133 $this->click('record_contribution');
134
135 // Enter amount to be paid (note: this should default to selected fee level amount, s/b fixed during 3.2 cycle)
136 $this->type('total_amount', '800');
137
138 // Select payment method = Check and enter chk number
139 $this->select('payment_instrument_id', 'value=4');
140 $this->waitForElementPresent('check_number');
141 $this->type('check_number', '1044');
142
143 // Clicking save.
144 $this->click('_qf_Participant_upload-bottom');
145 $this->waitForPageToLoad($this->getTimeoutMsec());
146
147 // Is status message correct?
148 $this->assertTrue($this->isTextPresent("Event registration for $firstName Anderson has been added"),
149 "Status message didn't show up after saving!"
150 );
151
152 $this->waitForElementPresent("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
153 //click through to the participant view screen
154 $this->click("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
155 $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
156
157 $this->webtestVerifyTabularData(
158 array(
159 'Event' => 'Rain-forest Cup Youth Soccer Tournament',
160 'Participant Role' => 'Attendee',
161 'Status' => 'Registered',
162 'Event Source' => 'Event StandaloneAddTest Webtest',
163 'Event Fees' => '$ 800.00',
164 )
165 );
166 }
167}
168