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