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 'WebTest/Import/ImportCiviSeleniumTestCase.php';
28 class WebTest_Import_ParticipantTest
extends ImportCiviSeleniumTestCase
{
30 protected function setUp() {
35 * Test participant import for Individuals.
37 function testParticipantImportIndividual() {
38 // Log in using webtestLogin() method
39 $this->webtestLogin();
41 // Get sample import data.
42 list($headers, $rows) = $this->_participantIndividualCSVData();
44 // Create and import csv from provided data and check imported data.
46 'mapper[0][0]' => 'email',
47 'mapper[1][0]' => 'event_id',
48 'mapper[2][0]' => 'participant_fee_level',
49 'mapper[4][0]' => 'participant_status_id',
52 $this->importCSVComponent('Event', $headers, $rows, 'Individual', 'Skip', $fieldMapper);
56 * Test participant import for Organizations.
58 function testParticipantImportOrganization() {
59 // Log in using webtestLogin() method
60 $this->webtestLogin();
62 // Get sample import data.
63 list($headers, $rows) = $this->_participantOrganizationCSVData();
65 // Create and import csv from provided data and check imported data.
67 'mapper[0][0]' => 'organization_name',
68 'mapper[1][0]' => 'event_id',
69 'mapper[2][0]' => 'participant_fee_level',
70 'mapper[4][0]' => 'participant_status_id',
73 $this->importCSVComponent('Event', $headers, $rows, 'Organization', 'Skip', $fieldMapper);
77 * Test participant import for Households.
79 function testParticipantImportHousehold() {
80 // Log in using webtestLogin() method
81 $this->webtestLogin();
83 // Get sample import data.
84 list($headers, $rows) = $this->_participantHouseholdCSVData();
86 // Create and import csv from provided data and check imported data.
88 'mapper[0][0]' => 'household_name',
89 'mapper[1][0]' => 'event_id',
90 'mapper[2][0]' => 'participant_fee_level',
91 'mapper[4][0]' => 'participant_status_id',
94 $this->importCSVComponent('Event', $headers, $rows, 'Household', 'Skip', $fieldMapper);
98 * Helper function to provide data for participant import for Individuals.
100 function _participantIndividualCSVData() {
101 $eventInfo = $this->_addNewEvent();
103 $firstName1 = substr(sha1(rand()), 0, 7);
104 $email1 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
105 $this->webtestAddContact($firstName1, 'Anderson', $email1);
107 $firstName2 = substr(sha1(rand()), 0, 7);
108 $email2 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
109 $this->webtestAddContact($firstName2, 'Anderson', $email2);
113 'event_id' => 'Event Id',
114 'fee_level' => 'Fee Level',
115 'role' => 'Participant Role',
116 'status' => 'Participant Status',
117 'register_date' => 'Register date',
123 'event_id' => $eventInfo['event_id'],
124 'fee_level' => 'Member',
127 'register_date' => '2011-03-30',
131 'event_id' => $eventInfo['event_id'],
132 'fee_level' => 'Non-Member',
135 'register_date' => '2011-03-30',
139 return array($headers, $rows);
143 * Helper function to provide data for participant import for Household.
145 function _participantHouseholdCSVData() {
146 $eventInfo = $this->_addNewEvent();
148 $household1 = substr(sha1(rand()), 0, 7) . ' home';
149 $this->webtestAddHousehold($household1, TRUE);
151 $household2 = substr(sha1(rand()), 0, 7) . ' home';
152 $this->webtestAddHousehold($household2, TRUE);
155 'household' => 'Household Name',
156 'event_id' => 'Event Id',
157 'fee_level' => 'Fee Level',
158 'role' => 'Participant Role',
159 'status' => 'Participant Status',
160 'register_date' => 'Register date',
165 'household' => $household1,
166 'event_id' => $eventInfo['event_id'],
167 'fee_level' => 'Member',
170 'register_date' => '2011-03-30',
173 'household' => $household2,
174 'event_id' => $eventInfo['event_id'],
175 'fee_level' => 'Non-Member',
178 'register_date' => '2011-03-30',
182 return array($headers, $rows);
186 * Helper function to provide data for participant import for Organization.
188 function _participantOrganizationCSVData() {
189 $eventInfo = $this->_addNewEvent();
191 $organization1 = substr(sha1(rand()), 0, 7) . ' org';
192 $this->webtestAddOrganization($organization1, TRUE);
194 $organization2 = substr(sha1(rand()), 0, 7) . ' org';
195 $this->webtestAddOrganization($organization2, TRUE);
198 'organization' => 'Organization Name',
199 'event_id' => 'Event Id',
200 'fee_level' => 'Fee Level',
201 'role' => 'Participant Role',
202 'status' => 'Participant Status',
203 'register_date' => 'Register date',
208 'organization' => $organization1,
209 'event_id' => $eventInfo['event_id'],
210 'fee_level' => 'Member',
213 'register_date' => '2011-03-30',
216 'organization' => $organization2,
217 'event_id' => $eventInfo['event_id'],
218 'fee_level' => 'Non-Member',
221 'register_date' => '2011-03-30',
225 return array($headers, $rows);
229 * Helper function to add new event
231 * @params array $params parameters to create an event
233 * @return array $params event details of newly created event
235 function _addNewEvent($params = array(
238 if (empty($params)) {
240 // We need a payment processor
241 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
242 $this->webtestAddPaymentProcessor($processorName);
245 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
247 'title' => $eventTitle,
249 'event_type_id' => 4,
250 'payment_processor' => $processorName,
251 'fee_level' => array(
252 'Member' => "250.00",
253 'Non-Member' => "325.00",
258 $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
260 $this->select("event_type_id", "value={$params['event_type_id']}");
262 // Attendee role s/b selected now.
263 $this->select("default_role_id", "value=1");
265 // Enter Event Title, Summary and Description
266 $this->type("title", $params['title']);
267 $this->type("summary", "This is a great conference. Sign up now!");
268 $this->fillRichTextField("description", "Here is a description for this event.", 'CKEditor');
270 // Choose Start and End dates.
271 // Using helper webtestFillDate function.
272 $this->webtestFillDateTime("start_date", "+1 week");
273 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
275 $this->type("max_participants", "50");
276 $this->click("is_map");
277 $this->click("_qf_EventInfo_upload-bottom");
279 // Wait for Location tab form to load
280 $this->waitForPageToLoad($this->getTimeoutMsec());
283 $this->click("link=Fees");
284 $this->waitForElementPresent("_qf_Fee_upload-bottom");
285 $this->click("CIVICRM_QFID_1_is_monetary");
287 // select newly created processor
288 $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]";
289 $this->assertElementContainsText('paymentProcessor', $processorName);
290 $this->check($xpath);
291 $this->select("financial_type_id", "value=4");
294 foreach ($params['fee_level'] as $label => $amount) {
295 $this->type("label_{$counter}", $label);
296 $this->type("value_{$counter}", $amount);
300 $this->click("_qf_Fee_upload-bottom");
301 $this->waitForPageToLoad($this->getTimeoutMsec());
303 // Go to Online Registration tab
304 $this->click("link=Online Registration");
305 $this->waitForElementPresent("_qf_Registration_upload-bottom");
307 $this->check("is_online_registration");
308 $this->assertChecked("is_online_registration");
310 $this->fillRichTextField("intro_text", "Fill in all the fields below and click Continue.");
312 // enable confirmation email
313 $this->click("CIVICRM_QFID_1_is_email_confirm");
314 $this->type("confirm_from_name", "Jane Doe");
315 $this->type("confirm_from_email", "jane.doe@example.org");
317 $this->click("_qf_Registration_upload-bottom");
318 $this->waitForPageToLoad($this->getTimeoutMsec());
319 $this->waitForTextPresent("'Registration' information has been saved.");
321 // verify event input on info page
322 // start at Manage Events listing
323 $this->openCiviPage('event/manage', 'reset=1');
324 $this->clickLink("link=" . $params['title']);
326 $params['event_id'] = $this->urlArg('id');;